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 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Copyright (c) 2010-2017 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 "protocolcodes.h"
  26. #include <framework/net/protocol.h>
  27. #include "creature.h"
  28. class ProtocolGame : public Protocol
  29. {
  30. public:
  31. void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
  32. void send(const OutputMessagePtr& outputMessage);
  33. void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
  34. void sendLoginPacket(uint challengeTimestamp, uint8 challengeRandom);
  35. void sendEnterGame();
  36. void sendLogout();
  37. void sendPing();
  38. void sendPingBack();
  39. void sendAutoWalk(const std::vector<Otc::Direction>& path);
  40. void sendWalkNorth();
  41. void sendWalkEast();
  42. void sendWalkSouth();
  43. void sendWalkWest();
  44. void sendStop();
  45. void sendWalkNorthEast();
  46. void sendWalkSouthEast();
  47. void sendWalkSouthWest();
  48. void sendWalkNorthWest();
  49. void sendTurnNorth();
  50. void sendTurnEast();
  51. void sendTurnSouth();
  52. void sendTurnWest();
  53. void sendEquipItem(int itemId, int countOrSubType);
  54. void sendMove(const Position& fromPos, int itemId, int stackpos, const Position& toPos, int count);
  55. void sendInspectNpcTrade(int itemId, int count);
  56. void sendBuyItem(int itemId, int subType, int amount, bool ignoreCapacity, bool buyWithBackpack);
  57. void sendSellItem(int itemId, int subType, int amount, bool ignoreEquipped);
  58. void sendCloseNpcTrade();
  59. void sendRequestTrade(const Position& pos, int thingId, int stackpos, uint playerId);
  60. void sendInspectTrade(bool counterOffer, int index);
  61. void sendAcceptTrade();
  62. void sendRejectTrade();
  63. void sendUseItem(const Position& position, int itemId, int stackpos, int index);
  64. void sendUseItemWith(const Position& fromPos, int itemId, int fromStackPos, const Position& toPos, int toThingId, int toStackPos);
  65. void sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId);
  66. void sendRotateItem(const Position& pos, int thingId, int stackpos);
  67. void sendCloseContainer(int containerId);
  68. void sendUpContainer(int containerId);
  69. void sendEditText(uint id, const std::string& text);
  70. void sendEditList(uint id, int doorId, const std::string& text);
  71. void sendLook(const Position& position, int thingId, int stackpos);
  72. void sendLookCreature(uint creatureId);
  73. void sendTalk(Otc::MessageMode mode, int channelId, const std::string& receiver, const std::string& message);
  74. void sendRequestChannels();
  75. void sendJoinChannel(int channelId);
  76. void sendLeaveChannel(int channelId);
  77. void sendOpenPrivateChannel(const std::string& receiver);
  78. void sendOpenRuleViolation(const std::string& reporter);
  79. void sendCloseRuleViolation(const std::string& reporter);
  80. void sendCancelRuleViolation();
  81. void sendCloseNpcChannel();
  82. void sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight, Otc::PVPModes pvpMode);
  83. void sendAttack(uint creatureId, uint seq);
  84. void sendFollow(uint creatureId, uint seq);
  85. void sendInviteToParty(uint creatureId);
  86. void sendJoinParty(uint creatureId);
  87. void sendRevokeInvitation(uint creatureId);
  88. void sendPassLeadership(uint creatureId);
  89. void sendLeaveParty();
  90. void sendShareExperience(bool active);
  91. void sendOpenOwnChannel();
  92. void sendInviteToOwnChannel(const std::string& name);
  93. void sendExcludeFromOwnChannel(const std::string& name);
  94. void sendCancelAttackAndFollow();
  95. void sendRefreshContainer(int containerId);
  96. void sendRequestOutfit();
  97. void sendChangeOutfit(const Outfit& outfit);
  98. void sendMountStatus(bool mount);
  99. void sendAddVip(const std::string& name);
  100. void sendRemoveVip(uint playerId);
  101. void sendEditVip(uint playerId, const std::string& description, int iconId, bool notifyLogin);
  102. void sendBugReport(const std::string& comment);
  103. void sendRuleViolation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment);
  104. void sendDebugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d);
  105. void sendRequestQuestLog();
  106. void sendRequestQuestLine(int questId);
  107. void sendNewNewRuleViolation(int reason, int action, const std::string& characterName, const std::string& comment, const std::string& translation);
  108. void sendRequestItemInfo(int itemId, int subType, int index);
  109. void sendAnswerModalDialog(uint32 dialog, int button, int choice);
  110. void sendBrowseField(const Position& position);
  111. void sendSeekInContainer(int cid, int index);
  112. void sendBuyStoreOffer(int offerId, int productType, const std::string& name);
  113. void sendRequestTransactionHistory(int page, int entriesPerPage);
  114. void sendRequestStoreOffers(const std::string& categoryName, int serviceType);
  115. void sendOpenStore(int serviceType, const std::string &category);
  116. void sendTransferCoins(const std::string& recipient, int amount);
  117. void sendOpenTransactionHistory(int entiresPerPage);
  118. // otclient only
  119. void sendChangeMapAwareRange(int xrange, int yrange);
  120. protected:
  121. void onConnect();
  122. void onRecv(const InputMessagePtr& inputMessage);
  123. void onError(const boost::system::error_code& error);
  124. friend class Game;
  125. public:
  126. void addPosition(const OutputMessagePtr& msg, const Position& position);
  127. private:
  128. void parseStoreButtonIndicators(const InputMessagePtr& msg);
  129. void parseSetStoreDeepLink(const InputMessagePtr& msg);
  130. void parseStore(const InputMessagePtr& msg);
  131. void parseStoreError(const InputMessagePtr& msg);
  132. void parseStoreTransactionHistory(const InputMessagePtr& msg);
  133. void parseStoreOffers(const InputMessagePtr& msg);
  134. void parseCompleteStorePurchase(const InputMessagePtr& msg);
  135. void parseRequestPurchaseData(const InputMessagePtr& msg);
  136. void parseCoinBalance(const InputMessagePtr& msg);
  137. void parseCoinBalanceUpdating(const InputMessagePtr& msg);
  138. void parseBlessings(const InputMessagePtr& msg);
  139. void parseUnjustifiedStats(const InputMessagePtr& msg);
  140. void parsePvpSituations(const InputMessagePtr& msg);
  141. void parsePreset(const InputMessagePtr& msg);
  142. void parseCreatureType(const InputMessagePtr& msg);
  143. void parsePlayerHelpers(const InputMessagePtr& msg);
  144. void parseMessage(const InputMessagePtr& msg);
  145. void parsePendingGame(const InputMessagePtr& msg);
  146. void parseEnterGame(const InputMessagePtr& msg);
  147. void parseLogin(const InputMessagePtr& msg);
  148. void parseGMActions(const InputMessagePtr& msg);
  149. void parseUpdateNeeded(const InputMessagePtr& msg);
  150. void parseLoginError(const InputMessagePtr& msg);
  151. void parseLoginAdvice(const InputMessagePtr& msg);
  152. void parseLoginWait(const InputMessagePtr& msg);
  153. void parseLoginToken(const InputMessagePtr& msg);
  154. void parsePing(const InputMessagePtr& msg);
  155. void parsePingBack(const InputMessagePtr& msg);
  156. void parseChallenge(const InputMessagePtr& msg);
  157. void parseDeath(const InputMessagePtr& msg);
  158. void parseMapDescription(const InputMessagePtr& msg);
  159. void parseMapMoveNorth(const InputMessagePtr& msg);
  160. void parseMapMoveEast(const InputMessagePtr& msg);
  161. void parseMapMoveSouth(const InputMessagePtr& msg);
  162. void parseMapMoveWest(const InputMessagePtr& msg);
  163. void parseUpdateTile(const InputMessagePtr& msg);
  164. void parseTileAddThing(const InputMessagePtr& msg);
  165. void parseTileTransformThing(const InputMessagePtr& msg);
  166. void parseTileRemoveThing(const InputMessagePtr& msg);
  167. void parseCreatureMove(const InputMessagePtr& msg);
  168. void parseOpenContainer(const InputMessagePtr& msg);
  169. void parseCloseContainer(const InputMessagePtr& msg);
  170. void parseContainerAddItem(const InputMessagePtr& msg);
  171. void parseContainerUpdateItem(const InputMessagePtr& msg);
  172. void parseContainerRemoveItem(const InputMessagePtr& msg);
  173. void parseAddInventoryItem(const InputMessagePtr& msg);
  174. void parseRemoveInventoryItem(const InputMessagePtr& msg);
  175. void parseOpenNpcTrade(const InputMessagePtr& msg);
  176. void parsePlayerGoods(const InputMessagePtr& msg);
  177. void parseCloseNpcTrade(const InputMessagePtr&);
  178. void parseWorldLight(const InputMessagePtr& msg);
  179. void parseMagicEffect(const InputMessagePtr& msg);
  180. void parseAnimatedText(const InputMessagePtr& msg);
  181. void parseDistanceMissile(const InputMessagePtr& msg);
  182. void parseCreatureMark(const InputMessagePtr& msg);
  183. void parseTrappers(const InputMessagePtr& msg);
  184. void parseCreatureHealth(const InputMessagePtr& msg);
  185. void parseCreatureLight(const InputMessagePtr& msg);
  186. void parseCreatureOutfit(const InputMessagePtr& msg);
  187. void parseCreatureSpeed(const InputMessagePtr& msg);
  188. void parseCreatureSkulls(const InputMessagePtr& msg);
  189. void parseCreatureShields(const InputMessagePtr& msg);
  190. void parseCreatureUnpass(const InputMessagePtr& msg);
  191. void parseEditText(const InputMessagePtr& msg);
  192. void parseEditList(const InputMessagePtr& msg);
  193. void parsePremiumTrigger(const InputMessagePtr& msg);
  194. void parsePlayerInfo(const InputMessagePtr& msg);
  195. void parsePlayerStats(const InputMessagePtr& msg);
  196. void parsePlayerSkills(const InputMessagePtr& msg);
  197. void parsePlayerState(const InputMessagePtr& msg);
  198. void parsePlayerCancelAttack(const InputMessagePtr& msg);
  199. void parsePlayerModes(const InputMessagePtr& msg);
  200. void parseSpellCooldown(const InputMessagePtr& msg);
  201. void parseSpellGroupCooldown(const InputMessagePtr& msg);
  202. void parseMultiUseCooldown(const InputMessagePtr& msg);
  203. void parseTalk(const InputMessagePtr& msg);
  204. void parseChannelList(const InputMessagePtr& msg);
  205. void parseOpenChannel(const InputMessagePtr& msg);
  206. void parseOpenPrivateChannel(const InputMessagePtr& msg);
  207. void parseOpenOwnPrivateChannel(const InputMessagePtr& msg);
  208. void parseCloseChannel(const InputMessagePtr& msg);
  209. void parseRuleViolationChannel(const InputMessagePtr& msg);
  210. void parseRuleViolationRemove(const InputMessagePtr& msg);
  211. void parseRuleViolationCancel(const InputMessagePtr& msg);
  212. void parseRuleViolationLock(const InputMessagePtr& msg);
  213. void parseOwnTrade(const InputMessagePtr& msg);
  214. void parseCounterTrade(const InputMessagePtr& msg);
  215. void parseCloseTrade(const InputMessagePtr&);
  216. void parseTextMessage(const InputMessagePtr& msg);
  217. void parseCancelWalk(const InputMessagePtr& msg);
  218. void parseWalkWait(const InputMessagePtr& msg);
  219. void parseFloorChangeUp(const InputMessagePtr& msg);
  220. void parseFloorChangeDown(const InputMessagePtr& msg);
  221. void parseOpenOutfitWindow(const InputMessagePtr& msg);
  222. void parseVipAdd(const InputMessagePtr& msg);
  223. void parseVipState(const InputMessagePtr& msg);
  224. void parseVipLogout(const InputMessagePtr& msg);
  225. void parseTutorialHint(const InputMessagePtr& msg);
  226. void parseAutomapFlag(const InputMessagePtr& msg);
  227. void parseQuestLog(const InputMessagePtr& msg);
  228. void parseQuestLine(const InputMessagePtr& msg);
  229. void parseChannelEvent(const InputMessagePtr& msg);
  230. void parseItemInfo(const InputMessagePtr& msg);
  231. void parsePlayerInventory(const InputMessagePtr& msg);
  232. void parseModalDialog(const InputMessagePtr& msg);
  233. void parseExtendedOpcode(const InputMessagePtr& msg);
  234. void parseChangeMapAwareRange(const InputMessagePtr& msg);
  235. void parseCreaturesMark(const InputMessagePtr& msg);
  236. public:
  237. void setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height);
  238. int setFloorDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height, int offset, int skip);
  239. int setTileDescription(const InputMessagePtr& msg, Position position);
  240. Outfit getOutfit(const InputMessagePtr& msg);
  241. ThingPtr getThing(const InputMessagePtr& msg);
  242. ThingPtr getMappedThing(const InputMessagePtr& msg);
  243. CreaturePtr getCreature(const InputMessagePtr& msg, int type = 0);
  244. StaticTextPtr getStaticText(const InputMessagePtr& msg, int type = 0);
  245. ItemPtr getItem(const InputMessagePtr& msg, int id = 0);
  246. Position getPosition(const InputMessagePtr& msg);
  247. private:
  248. stdext::boolean<false> m_enableSendExtendedOpcode;
  249. stdext::boolean<false> m_gameInitialized;
  250. stdext::boolean<false> m_mapKnown;
  251. stdext::boolean<true> m_firstRecv;
  252. std::string m_accountName;
  253. std::string m_accountPassword;
  254. std::string m_authenticatorToken;
  255. std::string m_sessionKey;
  256. std::string m_characterName;
  257. LocalPlayerPtr m_localPlayer;
  258. };
  259. #endif