No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

protocolgame.h 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. #ifndef PROTOCOLGAME_H
  23. #define PROTOCOLGAME_H
  24. #include "declarations.h"
  25. #include <otclient/core/declarations.h>
  26. #include <framework/net/protocol.h>
  27. #include <otclient/core/creature.h>
  28. class ProtocolGame : public Protocol
  29. {
  30. public:
  31. ProtocolGame();
  32. public:
  33. void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName);
  34. void onConnect();
  35. void onRecv(InputMessage& inputMessage);
  36. void onError(const boost::system::error_code& error);
  37. void sendLogout();
  38. void sendPing();
  39. void sendWalkNorth();
  40. void sendWalkEast();
  41. void sendWalkSouth();
  42. void sendWalkWest();
  43. void sendStopAutowalk();
  44. void sendWalkNorthEast();
  45. void sendWalkSouthEast();
  46. void sendWalkSouthWest();
  47. void sendWalkNorthWest();
  48. void sendTurnNorth();
  49. void sendTurnEast();
  50. void sendTurnSouth();
  51. void sendTurnWest();
  52. void sendThrow(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count);
  53. void sendLookInShop(int thingId, int count);
  54. void sendPlayerPurchase(int thingId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack);
  55. void sendPlayerSale(int thingId, int count, int amount, bool ignoreEquipped);
  56. void sendCloseShop();
  57. void sendRequestTrade(const Position& pos, int thingId, int stackpos, uint playerId);
  58. void sendLookInTrade(bool counterOffer, int index);
  59. void sendAcceptTrade();
  60. void sendRejectTrade();
  61. void sendUseItem(const Position& position, int itemId, int stackpos, int index);
  62. void sendUseItemEx(const Position& fromPos, int itemId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos);
  63. void sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId);
  64. void sendRotateItem(const Position& pos, int thingId, int stackpos);
  65. void sendCloseContainer(int containerId);
  66. void sendUpContainer(int containerId);
  67. void sendTextWindow(uint windowTextId, const std::string& text);
  68. void sendHouseWindow(int doorId, uint id, const std::string& text);
  69. void sendLookAt(const Position& position, int thingId, int stackpos);
  70. void sendTalk(Otc::SpeakType speakType, int channelId, const std::string& receiver, const std::string& message);
  71. void sendGetChannels();
  72. void sendJoinChannel(int channelId);
  73. void sendLeaveChannel(int channelId);
  74. void sendOpenPrivateChannel(const std::string& receiver);
  75. void sendCloseNpcChannel();
  76. void sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight);
  77. void sendAttack(uint creatureId);
  78. void sendFollow(uint creatureId);
  79. void sendInviteToParty(uint creatureId);
  80. void sendJoinParty(uint creatureId);
  81. void sendRevokeInvitation(uint creatureId);
  82. void sendPassLeadership(uint creatureId);
  83. void sendLeaveParty();
  84. void sendShareExperience(bool active, int unknown);
  85. void sendOpenChannel(int channelId);
  86. void sendInviteToChannel(const std::string& name);
  87. void sendExcludeFromChannel(const std::string& name);
  88. void sendCancel();
  89. void sendUpdateContainer();
  90. void sendGetOutfit();
  91. void sendSetOutfit(const Outfit& outfit);
  92. void sendAddVip(const std::string& name);
  93. void sendRemoveVip(uint playerId);
  94. void sendGetQuestLog();
  95. void sendGetQuestLine(int questId);
  96. private:
  97. void sendLoginPacket(uint timestamp, uint8 unknown);
  98. // Parse Messages
  99. void parseMessage(InputMessage& msg);
  100. void parseInitGame(InputMessage& msg);
  101. void parseGMActions(InputMessage& msg);
  102. void parseLoginError(InputMessage& msg);
  103. void parseFYIMessage(InputMessage& msg);
  104. void parseWaitList(InputMessage& msg);
  105. void parsePing(InputMessage&);
  106. void parseDeath(InputMessage& msg);
  107. void parseCanReportBugs(InputMessage& msg);
  108. void parseMapDescription(InputMessage& msg);
  109. void parseMoveNorth(InputMessage& msg);
  110. void parseMoveEast(InputMessage& msg);
  111. void parseMoveSouth(InputMessage& msg);
  112. void parseMoveWest(InputMessage& msg);
  113. void parseUpdateTile(InputMessage& msg);
  114. void parseTileAddThing(InputMessage& msg);
  115. void parseTileTransformThing(InputMessage& msg);
  116. void parseTileRemoveThing(InputMessage& msg);
  117. void parseCreatureMove(InputMessage& msg);
  118. void parseOpenContainer(InputMessage& msg);
  119. void parseCloseContainer(InputMessage& msg);
  120. void parseContainerAddItem(InputMessage& msg);
  121. void parseContainerUpdateItem(InputMessage& msg);
  122. void parseContainerRemoveItem(InputMessage& msg);
  123. void parseAddInventoryItem(InputMessage& msg);
  124. void parseRemoveInventoryItem(InputMessage& msg);
  125. void parseOpenShopWindow(InputMessage& msg);
  126. void parsePlayerCash(InputMessage& msg);
  127. void parseCloseShopWindow(InputMessage&);
  128. void parseWorldLight(InputMessage& msg);
  129. void parseMagicEffect(InputMessage& msg);
  130. void parseAnimatedText(InputMessage& msg);
  131. void parseDistanceMissile(InputMessage& msg);
  132. void parseCreatureSquare(InputMessage& msg);
  133. void parseCreatureHealth(InputMessage& msg);
  134. void parseCreatureLight(InputMessage& msg);
  135. void parseCreatureOutfit(InputMessage& msg);
  136. void parseCreatureSpeed(InputMessage& msg);
  137. void parseCreatureSkulls(InputMessage& msg);
  138. void parseCreatureShields(InputMessage& msg);
  139. void parseCreatureTurn(InputMessage& msg);
  140. void parseItemTextWindow(InputMessage& msg);
  141. void parseHouseTextWindow(InputMessage& msg);
  142. void parsePlayerStats(InputMessage& msg);
  143. void parsePlayerSkills(InputMessage& msg);
  144. void parsePlayerIcons(InputMessage& msg);
  145. void parsePlayerCancelAttack(InputMessage& msg);
  146. void parseCreatureSpeak(InputMessage& msg);
  147. void parseChannelList(InputMessage& msg);
  148. void parseOpenChannel(InputMessage& msg);
  149. void parseOpenPrivateChannel(InputMessage& msg);
  150. void parseCreateOwnPrivateChannel(InputMessage& msg);
  151. void parseCloseChannel(InputMessage& msg);
  152. void parseSafeTradeRequest(InputMessage& msg);
  153. void parseSafeTradeClose(InputMessage&);
  154. void parseTextMessage(InputMessage& msg);
  155. void parseCancelWalk(InputMessage& msg);
  156. void parseFloorChangeUp(InputMessage& msg);
  157. void parseFloorChangeDown(InputMessage& msg);
  158. void parseOutfitWindow(InputMessage& msg);
  159. void parseVipState(InputMessage& msg);
  160. void parseVipLogin(InputMessage& msg);
  161. void parseVipLogout(InputMessage& msg);
  162. void parseShowTutorial(InputMessage& msg);
  163. void parseAddMarker(InputMessage& msg);
  164. void parseQuestList(InputMessage& msg);
  165. void parseQuestPartList(InputMessage& msg);
  166. void setMapDescription(InputMessage& msg, int x, int y, int z, int width, int height);
  167. void setFloorDescription(InputMessage& msg, int x, int y, int z, int width, int height, int offset, int* skipTiles);
  168. void setTileDescription(InputMessage& msg, Position position);
  169. Outfit internalGetOutfit(InputMessage& msg);
  170. ThingPtr internalGetThing(InputMessage& msg);
  171. ItemPtr internalGetItem(InputMessage& msg, int id = 0);
  172. void addPosition(OutputMessage& msg, const Position& position);
  173. Position parsePosition(InputMessage& msg);
  174. private:
  175. bool m_waitingLoginPacket;
  176. std::string m_accountName;
  177. std::string m_accountPassword;
  178. std::string m_characterName;
  179. LocalPlayerPtr m_localPlayer;
  180. };
  181. #endif