2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2013-01-08 19:21:54 +01:00
|
|
|
* Copyright (c) 2010-2013 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#ifndef PROTOCOLGAME_H
|
|
|
|
#define PROTOCOLGAME_H
|
|
|
|
|
|
|
|
#include "declarations.h"
|
2012-07-14 03:10:24 +02:00
|
|
|
#include "protocolcodes.h"
|
2011-08-15 16:11:24 +02:00
|
|
|
#include <framework/net/protocol.h>
|
2012-07-14 03:10:24 +02:00
|
|
|
#include "creature.h"
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
class ProtocolGame : public Protocol
|
|
|
|
{
|
|
|
|
public:
|
2013-01-28 23:52:03 +01:00
|
|
|
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName);
|
2012-07-20 07:45:11 +02:00
|
|
|
void send(const OutputMessagePtr& outputMessage);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-07-20 07:45:11 +02:00
|
|
|
void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
|
2013-01-17 21:24:41 +01:00
|
|
|
void sendLoginPacket(uint challengeTimestamp, uint8 challengeRandom);
|
2013-01-03 23:42:02 +01:00
|
|
|
void sendEnterGame();
|
2011-08-15 16:11:24 +02:00
|
|
|
void sendLogout();
|
2012-05-12 13:55:22 +02:00
|
|
|
void sendPing();
|
|
|
|
void sendPingBack();
|
2012-03-23 15:48:00 +01:00
|
|
|
void sendAutoWalk(const std::vector<Otc::Direction>& path);
|
2011-08-15 16:11:24 +02:00
|
|
|
void sendWalkNorth();
|
|
|
|
void sendWalkEast();
|
|
|
|
void sendWalkSouth();
|
|
|
|
void sendWalkWest();
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendStop();
|
2011-08-29 07:54:28 +02:00
|
|
|
void sendWalkNorthEast();
|
|
|
|
void sendWalkSouthEast();
|
|
|
|
void sendWalkSouthWest();
|
|
|
|
void sendWalkNorthWest();
|
2011-08-17 06:45:55 +02:00
|
|
|
void sendTurnNorth();
|
|
|
|
void sendTurnEast();
|
|
|
|
void sendTurnSouth();
|
|
|
|
void sendTurnWest();
|
2012-05-12 13:55:22 +02:00
|
|
|
void sendEquipItem(int itemId, int countOrSubType);
|
2012-02-09 04:45:19 +01:00
|
|
|
void sendMove(const Position& fromPos, int itemId, int stackpos, const Position& toPos, int count);
|
|
|
|
void sendInspectNpcTrade(int itemId, int count);
|
2012-04-28 02:44:55 +02:00
|
|
|
void sendBuyItem(int itemId, int subType, int amount, bool ignoreCapacity, bool buyWithBackpack);
|
|
|
|
void sendSellItem(int itemId, int subType, int amount, bool ignoreEquipped);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendCloseNpcTrade();
|
2012-01-12 20:20:18 +01:00
|
|
|
void sendRequestTrade(const Position& pos, int thingId, int stackpos, uint playerId);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendInspectTrade(bool counterOffer, int index);
|
2012-01-02 23:23:54 +01:00
|
|
|
void sendAcceptTrade();
|
|
|
|
void sendRejectTrade();
|
2011-11-10 07:53:16 +01:00
|
|
|
void sendUseItem(const Position& position, int itemId, int stackpos, int index);
|
2013-01-20 17:09:14 +01:00
|
|
|
void sendUseItemWith(const Position& fromPos, int itemId, int fromStackPos, const Position& toPos, int toThingId, int toStackPos);
|
2012-01-17 23:28:55 +01:00
|
|
|
void sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId);
|
2012-01-03 14:13:54 +01:00
|
|
|
void sendRotateItem(const Position& pos, int thingId, int stackpos);
|
|
|
|
void sendCloseContainer(int containerId);
|
|
|
|
void sendUpContainer(int containerId);
|
2012-02-09 04:45:19 +01:00
|
|
|
void sendEditText(uint id, const std::string& text);
|
2012-05-01 02:53:02 +02:00
|
|
|
void sendEditList(uint id, int doorId, const std::string& text);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendLook(const Position& position, int thingId, int stackpos);
|
2012-08-29 17:09:05 +02:00
|
|
|
void sendLookCreature(uint creatureId);
|
2012-07-26 11:12:20 +02:00
|
|
|
void sendTalk(Otc::MessageMode mode, int channelId, const std::string& receiver, const std::string& message);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendRequestChannels();
|
2012-01-03 14:13:54 +01:00
|
|
|
void sendJoinChannel(int channelId);
|
|
|
|
void sendLeaveChannel(int channelId);
|
2012-02-02 23:29:44 +01:00
|
|
|
void sendOpenPrivateChannel(const std::string& receiver);
|
2013-01-27 10:44:15 +01:00
|
|
|
void sendOpenRuleViolation(const std::string& reporter);
|
|
|
|
void sendCloseRuleViolation(const std::string& reporter);
|
|
|
|
void sendCancelRuleViolation();
|
2012-01-03 14:13:54 +01:00
|
|
|
void sendCloseNpcChannel();
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight);
|
2012-07-26 08:10:28 +02:00
|
|
|
void sendAttack(uint creatureId, uint seq);
|
|
|
|
void sendFollow(uint creatureId, uint seq);
|
2012-01-12 20:20:18 +01:00
|
|
|
void sendInviteToParty(uint creatureId);
|
|
|
|
void sendJoinParty(uint creatureId);
|
|
|
|
void sendRevokeInvitation(uint creatureId);
|
|
|
|
void sendPassLeadership(uint creatureId);
|
2012-01-03 14:13:54 +01:00
|
|
|
void sendLeaveParty();
|
2012-07-26 08:10:28 +02:00
|
|
|
void sendShareExperience(bool active);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendOpenOwnChannel();
|
|
|
|
void sendInviteToOwnChannel(const std::string& name);
|
|
|
|
void sendExcludeFromOwnChannel(const std::string& name);
|
|
|
|
void sendCancelAttackAndFollow();
|
2012-12-29 18:41:14 +01:00
|
|
|
void sendRefreshContainer(int containerId);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendRequestOutfit();
|
|
|
|
void sendChangeOutfit(const Outfit& outfit);
|
2012-07-15 13:49:28 +02:00
|
|
|
void sendMountStatus(bool mount);
|
2011-09-03 00:52:40 +02:00
|
|
|
void sendAddVip(const std::string& name);
|
2012-01-12 20:20:18 +01:00
|
|
|
void sendRemoveVip(uint playerId);
|
2012-05-01 00:24:50 +02:00
|
|
|
void sendBugReport(const std::string& comment);
|
2012-12-29 18:41:14 +01:00
|
|
|
void sendRuleViolation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment);
|
2012-05-01 00:24:50 +02:00
|
|
|
void sendDebugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendRequestQuestLog();
|
2012-02-09 04:45:19 +01:00
|
|
|
void sendRequestQuestLine(int questId);
|
2012-05-12 13:55:22 +02:00
|
|
|
void sendNewNewRuleViolation(int reason, int action, const std::string& characterName, const std::string& comment, const std::string& translation);
|
2012-07-30 17:08:21 +02:00
|
|
|
void sendRequestItemInfo(int itemId, int subType, int index);
|
2012-11-27 14:48:48 +01:00
|
|
|
void sendAnswerModalDialog(int dialog, int button, int choice);
|
2013-01-21 22:36:53 +01:00
|
|
|
|
|
|
|
// otclient only
|
2013-01-09 20:29:58 +01:00
|
|
|
void sendChangeMapAwareRange(int xrange, int yrange);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-07-20 07:45:11 +02:00
|
|
|
protected:
|
|
|
|
void onConnect();
|
|
|
|
void onRecv(const InputMessagePtr& inputMessage);
|
|
|
|
void onError(const boost::system::error_code& error);
|
|
|
|
|
|
|
|
friend class Game;
|
|
|
|
|
2012-05-14 23:36:54 +02:00
|
|
|
public:
|
|
|
|
void addPosition(const OutputMessagePtr& msg, const Position& position);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-05-14 23:36:54 +02:00
|
|
|
private:
|
|
|
|
void parseMessage(const InputMessagePtr& msg);
|
2012-12-26 14:56:06 +01:00
|
|
|
void parsePendingGame(const InputMessagePtr& msg);
|
|
|
|
void parseEnterGame(const InputMessagePtr& msg);
|
2013-01-17 21:24:41 +01:00
|
|
|
void parseLogin(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
void parseGMActions(const InputMessagePtr& msg);
|
2013-01-09 20:29:58 +01:00
|
|
|
void parseUpdateNeeded(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
void parseLoginError(const InputMessagePtr& msg);
|
|
|
|
void parseLoginAdvice(const InputMessagePtr& msg);
|
|
|
|
void parseLoginWait(const InputMessagePtr& msg);
|
|
|
|
void parsePing(const InputMessagePtr& msg);
|
|
|
|
void parsePingBack(const InputMessagePtr& msg);
|
2013-01-17 21:24:41 +01:00
|
|
|
void parseChallenge(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
void parseDeath(const InputMessagePtr& msg);
|
|
|
|
void parseMapDescription(const InputMessagePtr& msg);
|
|
|
|
void parseMapMoveNorth(const InputMessagePtr& msg);
|
|
|
|
void parseMapMoveEast(const InputMessagePtr& msg);
|
|
|
|
void parseMapMoveSouth(const InputMessagePtr& msg);
|
|
|
|
void parseMapMoveWest(const InputMessagePtr& msg);
|
|
|
|
void parseUpdateTile(const InputMessagePtr& msg);
|
|
|
|
void parseTileAddThing(const InputMessagePtr& msg);
|
|
|
|
void parseTileTransformThing(const InputMessagePtr& msg);
|
|
|
|
void parseTileRemoveThing(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureMove(const InputMessagePtr& msg);
|
|
|
|
void parseOpenContainer(const InputMessagePtr& msg);
|
|
|
|
void parseCloseContainer(const InputMessagePtr& msg);
|
|
|
|
void parseContainerAddItem(const InputMessagePtr& msg);
|
|
|
|
void parseContainerUpdateItem(const InputMessagePtr& msg);
|
|
|
|
void parseContainerRemoveItem(const InputMessagePtr& msg);
|
|
|
|
void parseAddInventoryItem(const InputMessagePtr& msg);
|
|
|
|
void parseRemoveInventoryItem(const InputMessagePtr& msg);
|
|
|
|
void parseOpenNpcTrade(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerGoods(const InputMessagePtr& msg);
|
|
|
|
void parseCloseNpcTrade(const InputMessagePtr&);
|
|
|
|
void parseWorldLight(const InputMessagePtr& msg);
|
|
|
|
void parseMagicEffect(const InputMessagePtr& msg);
|
|
|
|
void parseAnimatedText(const InputMessagePtr& msg);
|
|
|
|
void parseDistanceMissile(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureMark(const InputMessagePtr& msg);
|
|
|
|
void parseTrappers(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureHealth(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureLight(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureOutfit(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureSpeed(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureSkulls(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureShields(const InputMessagePtr& msg);
|
|
|
|
void parseCreatureUnpass(const InputMessagePtr& msg);
|
|
|
|
void parseEditText(const InputMessagePtr& msg);
|
|
|
|
void parseEditList(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerInfo(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerStats(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerSkills(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerState(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerCancelAttack(const InputMessagePtr& msg);
|
2012-07-26 08:10:28 +02:00
|
|
|
void parseSpellCooldown(const InputMessagePtr& msg);
|
|
|
|
void parseSpellGroupCooldown(const InputMessagePtr& msg);
|
|
|
|
void parseMultiUseCooldown(const InputMessagePtr& msg);
|
2012-07-26 11:12:20 +02:00
|
|
|
void parseTalk(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
void parseChannelList(const InputMessagePtr& msg);
|
|
|
|
void parseOpenChannel(const InputMessagePtr& msg);
|
|
|
|
void parseOpenPrivateChannel(const InputMessagePtr& msg);
|
|
|
|
void parseOpenOwnPrivateChannel(const InputMessagePtr& msg);
|
|
|
|
void parseCloseChannel(const InputMessagePtr& msg);
|
|
|
|
void parseRuleViolationChannel(const InputMessagePtr& msg);
|
|
|
|
void parseRuleViolationRemove(const InputMessagePtr& msg);
|
|
|
|
void parseRuleViolationCancel(const InputMessagePtr& msg);
|
|
|
|
void parseRuleViolationLock(const InputMessagePtr& msg);
|
|
|
|
void parseOwnTrade(const InputMessagePtr& msg);
|
|
|
|
void parseCounterTrade(const InputMessagePtr& msg);
|
|
|
|
void parseCloseTrade(const InputMessagePtr&);
|
|
|
|
void parseTextMessage(const InputMessagePtr& msg);
|
|
|
|
void parseCancelWalk(const InputMessagePtr& msg);
|
|
|
|
void parseWalkWait(const InputMessagePtr& msg);
|
|
|
|
void parseFloorChangeUp(const InputMessagePtr& msg);
|
|
|
|
void parseFloorChangeDown(const InputMessagePtr& msg);
|
|
|
|
void parseOpenOutfitWindow(const InputMessagePtr& msg);
|
|
|
|
void parseVipAdd(const InputMessagePtr& msg);
|
2012-12-26 14:56:06 +01:00
|
|
|
void parseVipState(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
void parseVipLogout(const InputMessagePtr& msg);
|
|
|
|
void parseTutorialHint(const InputMessagePtr& msg);
|
|
|
|
void parseAutomapFlag(const InputMessagePtr& msg);
|
|
|
|
void parseQuestLog(const InputMessagePtr& msg);
|
|
|
|
void parseQuestLine(const InputMessagePtr& msg);
|
|
|
|
void parseChannelEvent(const InputMessagePtr& msg);
|
|
|
|
void parseItemInfo(const InputMessagePtr& msg);
|
|
|
|
void parsePlayerInventory(const InputMessagePtr& msg);
|
2012-07-26 08:10:28 +02:00
|
|
|
void parseShowModalDialog(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
void parseExtendedOpcode(const InputMessagePtr& msg);
|
2013-01-09 20:29:58 +01:00
|
|
|
void parseChangeMapAwareRange(const InputMessagePtr& msg);
|
2011-08-15 23:02:52 +02:00
|
|
|
|
2012-05-14 23:36:54 +02:00
|
|
|
public:
|
|
|
|
void setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height);
|
|
|
|
int setFloorDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height, int offset, int skip);
|
2012-07-26 08:10:28 +02:00
|
|
|
int setTileDescription(const InputMessagePtr& msg, Position position);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-05-14 23:36:54 +02:00
|
|
|
Outfit getOutfit(const InputMessagePtr& msg);
|
|
|
|
ThingPtr getThing(const InputMessagePtr& msg);
|
2012-07-26 08:10:28 +02:00
|
|
|
ThingPtr getMappedThing(const InputMessagePtr& msg);
|
2012-05-14 23:36:54 +02:00
|
|
|
CreaturePtr getCreature(const InputMessagePtr& msg, int type = 0);
|
2013-01-09 20:29:58 +01:00
|
|
|
StaticTextPtr getStaticText(const InputMessagePtr& msg, int type = 0);
|
2012-05-14 23:36:54 +02:00
|
|
|
ItemPtr getItem(const InputMessagePtr& msg, int id = 0);
|
|
|
|
Position getPosition(const InputMessagePtr& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
private:
|
2012-07-29 12:32:44 +02:00
|
|
|
stdext::boolean<false> m_enableSendExtendedOpcode;
|
|
|
|
stdext::boolean<false> m_gameInitialized;
|
2012-08-03 07:05:09 +02:00
|
|
|
stdext::boolean<false> m_mapKnown;
|
2012-07-31 19:23:52 +02:00
|
|
|
stdext::boolean<true> m_firstRecv;
|
2011-08-15 23:02:52 +02:00
|
|
|
std::string m_accountName;
|
|
|
|
std::string m_accountPassword;
|
|
|
|
std::string m_characterName;
|
|
|
|
LocalPlayerPtr m_localPlayer;
|
2011-08-15 16:11:24 +02:00
|
|
|
};
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#endif
|