2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2012-01-02 17:58:37 +01:00
|
|
|
* Copyright (c) 2010-2012 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"
|
2011-08-29 16:14:21 +02:00
|
|
|
#include <otclient/core/declarations.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
#include <framework/net/protocol.h>
|
2011-08-29 16:14:21 +02:00
|
|
|
#include <otclient/core/creature.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
class ProtocolGame : public Protocol
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProtocolGame();
|
|
|
|
|
|
|
|
public:
|
2011-08-26 20:00:22 +02:00
|
|
|
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
void onConnect();
|
|
|
|
void onRecv(InputMessage& inputMessage);
|
2011-08-16 02:30:31 +02:00
|
|
|
void onError(const boost::system::error_code& error);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
void sendLogout();
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendPingResponse();
|
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-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);
|
|
|
|
void sendBuyItem(int itemId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack);
|
|
|
|
void sendSellItem(int itemId, int count, 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);
|
2012-02-08 22:23:15 +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-02-08 22:23:15 +01:00
|
|
|
void sendEditList(int listId, uint id, const std::string& text);
|
|
|
|
void sendLook(const Position& position, int thingId, int stackpos);
|
2012-02-03 01:25:18 +01:00
|
|
|
void sendTalk(Otc::SpeakType speakType, 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);
|
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-01-12 20:20:18 +01:00
|
|
|
void sendAttack(uint creatureId);
|
|
|
|
void sendFollow(uint creatureId);
|
|
|
|
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();
|
|
|
|
void sendShareExperience(bool active, int unknown);
|
2012-02-08 22:23:15 +01:00
|
|
|
void sendOpenOwnChannel();
|
|
|
|
void sendInviteToOwnChannel(const std::string& name);
|
|
|
|
void sendExcludeFromOwnChannel(const std::string& name);
|
|
|
|
void sendCancelAttackAndFollow();
|
|
|
|
void sendRefreshContainer();
|
|
|
|
void sendRequestOutfit();
|
|
|
|
void sendChangeOutfit(const Outfit& outfit);
|
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-02-08 22:23:15 +01:00
|
|
|
void sendRequestQuestLog();
|
2012-02-09 04:45:19 +01:00
|
|
|
void sendRequestQuestLine(int questId);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
private:
|
2012-01-12 20:20:18 +01:00
|
|
|
void sendLoginPacket(uint timestamp, uint8 unknown);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
|
|
|
// Parse Messages
|
|
|
|
void parseMessage(InputMessage& msg);
|
|
|
|
|
2012-02-08 00:54:33 +01:00
|
|
|
void parseInitGame(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseGMActions(InputMessage& msg);
|
2011-11-11 21:26:10 +01:00
|
|
|
void parseLoginError(InputMessage& msg);
|
2012-02-08 22:23:15 +01:00
|
|
|
void parseLoginAdvice(InputMessage& msg);
|
|
|
|
void parseLoginWait(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parsePing(InputMessage&);
|
2011-09-02 02:28:24 +02:00
|
|
|
void parseDeath(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseMapDescription(InputMessage& msg);
|
2012-02-08 22:23:15 +01:00
|
|
|
void parseMapMoveNorth(InputMessage& msg);
|
|
|
|
void parseMapMoveEast(InputMessage& msg);
|
|
|
|
void parseMapMoveSouth(InputMessage& msg);
|
|
|
|
void parseMapMoveWest(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseUpdateTile(InputMessage& msg);
|
|
|
|
void parseTileAddThing(InputMessage& msg);
|
|
|
|
void parseTileTransformThing(InputMessage& msg);
|
|
|
|
void parseTileRemoveThing(InputMessage& msg);
|
|
|
|
void parseCreatureMove(InputMessage& msg);
|
|
|
|
void parseOpenContainer(InputMessage& msg);
|
|
|
|
void parseCloseContainer(InputMessage& msg);
|
|
|
|
void parseContainerAddItem(InputMessage& msg);
|
|
|
|
void parseContainerUpdateItem(InputMessage& msg);
|
|
|
|
void parseContainerRemoveItem(InputMessage& msg);
|
|
|
|
void parseAddInventoryItem(InputMessage& msg);
|
|
|
|
void parseRemoveInventoryItem(InputMessage& msg);
|
2012-02-09 04:45:19 +01:00
|
|
|
void parseOpenNpcTrade(InputMessage& msg);
|
|
|
|
void parsePlayerGoods(InputMessage& msg);
|
|
|
|
void parseCloseNpcTrade(InputMessage&);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseWorldLight(InputMessage& msg);
|
|
|
|
void parseMagicEffect(InputMessage& msg);
|
|
|
|
void parseAnimatedText(InputMessage& msg);
|
2011-11-12 07:24:32 +01:00
|
|
|
void parseDistanceMissile(InputMessage& msg);
|
2012-02-09 04:45:19 +01:00
|
|
|
void parseCreatureMark(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseCreatureHealth(InputMessage& msg);
|
|
|
|
void parseCreatureLight(InputMessage& msg);
|
|
|
|
void parseCreatureOutfit(InputMessage& msg);
|
|
|
|
void parseCreatureSpeed(InputMessage& msg);
|
|
|
|
void parseCreatureSkulls(InputMessage& msg);
|
|
|
|
void parseCreatureShields(InputMessage& msg);
|
|
|
|
void parseCreatureTurn(InputMessage& msg);
|
2012-02-09 04:45:19 +01:00
|
|
|
void parseEditText(InputMessage& msg);
|
|
|
|
void parseEditList(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parsePlayerStats(InputMessage& msg);
|
|
|
|
void parsePlayerSkills(InputMessage& msg);
|
2012-02-09 04:45:19 +01:00
|
|
|
void parsePlayerState(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parsePlayerCancelAttack(InputMessage& msg);
|
|
|
|
void parseCreatureSpeak(InputMessage& msg);
|
|
|
|
void parseChannelList(InputMessage& msg);
|
|
|
|
void parseOpenChannel(InputMessage& msg);
|
2012-02-02 23:29:44 +01:00
|
|
|
void parseOpenPrivateChannel(InputMessage& msg);
|
2012-02-08 22:23:15 +01:00
|
|
|
void parseOpenOwnPrivateChannel(InputMessage& msg);
|
2012-02-02 23:29:44 +01:00
|
|
|
void parseCloseChannel(InputMessage& msg);
|
2012-02-09 04:45:19 +01:00
|
|
|
void parseOpenTrade(InputMessage& msg);
|
|
|
|
void parseCloseTrade(InputMessage&);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseTextMessage(InputMessage& msg);
|
|
|
|
void parseCancelWalk(InputMessage& msg);
|
|
|
|
void parseFloorChangeUp(InputMessage& msg);
|
|
|
|
void parseFloorChangeDown(InputMessage& msg);
|
2012-02-09 04:45:19 +01:00
|
|
|
void parseOpenOutfitWindow(InputMessage& msg);
|
2012-02-08 22:23:15 +01:00
|
|
|
void parseVipAdd(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
void parseVipLogin(InputMessage& msg);
|
|
|
|
void parseVipLogout(InputMessage& msg);
|
2012-02-08 22:23:15 +01:00
|
|
|
void parseTutorialHint(InputMessage& msg);
|
|
|
|
void parseAutomapFlag(InputMessage& msg);
|
|
|
|
void parseQuestLog(InputMessage& msg);
|
|
|
|
void parseQuestLine(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2012-01-12 20:20:18 +01:00
|
|
|
void setMapDescription(InputMessage& msg, int x, int y, int z, int width, int height);
|
|
|
|
void setFloorDescription(InputMessage& msg, int x, int y, int z, int width, int height, int offset, int* skipTiles);
|
2011-08-15 16:11:24 +02:00
|
|
|
void setTileDescription(InputMessage& msg, Position position);
|
2011-08-15 23:02:52 +02:00
|
|
|
|
|
|
|
Outfit internalGetOutfit(InputMessage& msg);
|
2011-08-15 16:11:24 +02:00
|
|
|
ThingPtr internalGetThing(InputMessage& msg);
|
2012-01-12 20:20:18 +01:00
|
|
|
ItemPtr internalGetItem(InputMessage& msg, int id = 0);
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-11-10 07:53:16 +01:00
|
|
|
void addPosition(OutputMessage& msg, const Position& position);
|
2011-08-15 16:11:24 +02:00
|
|
|
Position parsePosition(InputMessage& msg);
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
private:
|
2011-08-16 02:30:31 +02:00
|
|
|
bool m_waitingLoginPacket;
|
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
|