client.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef CLIENT_H
  17. #define CLIENT_H
  18. #include "../common/EQStream.h"
  19. #include <list>
  20. #include "../common/timer.h"
  21. #include "Items/Items.h"
  22. #include "zoneserver.h"
  23. #include "Player.h"
  24. #include "Quests.h"
  25. using namespace std;
  26. #define CLIENT_TIMEOUT 60000
  27. struct TransportDestination;
  28. struct ConversationOption;
  29. struct VoiceOverStruct;
  30. #define MAIL_SEND_RESULT_SUCCESS 0
  31. #define MAIL_SEND_RESULT_UNKNOWN_PLAYER 1
  32. #define MAIL_SEND_RESULT_CANNOT_SEND_TO_PLAYER 2
  33. #define MAIL_SEND_RESULT_GIFT_WRONG_SERVER 3 /* Cannot send gifts across worlds */
  34. #define MAIL_SEND_RESULT_CANNOT_SEND_TO_SELF 4
  35. #define MAIL_SEND_RESULT_MAILBOX_FULL 5
  36. #define MAIL_SEND_RESULT_NOT_ENOUGH_COIN 6
  37. #define MAIL_SEND_RESULT_ITEM_IN_BAG 7 /* Cannot send non-empty bags as gifts */
  38. #define MAIL_SEND_RESULT_NOT_IN_GUILD 8
  39. #define MAIL_SEND_RESULT_GUILD_ACCESS_DENIED 9
  40. #define MAIL_SEND_RESULT_GIFTS_TO_GUILD 10 /* Cannot send gifts to entire guild */
  41. #define MAIL_SEND_RESULT_EMPTY_TO_LIST 11 /* Empty recipient list */
  42. #define MAIL_SEND_RESULT_TRIAL_PLAYERS 12 /* Cannot send mail to trial players */
  43. #define MAIL_SEND_RESULT_MAIL_WRONG_SERVER 13 /* Cannot send mail across worlds */
  44. #define MAIL_SEND_RESULT_UNKNOWN_ERROR 14
  45. #define MAIL_TYPE_REGULAR 0
  46. #define MAIL_TYPE_SPAM 1
  47. #define MAIL_TYPE_GM 2
  48. struct QueuedQuest{
  49. int32 quest_id;
  50. int32 step;
  51. bool display_quest_helper;
  52. };
  53. struct BuyBackItem{
  54. int32 item_id;
  55. int32 unique_id;
  56. int16 quantity;
  57. int32 price;
  58. bool save_needed;
  59. };
  60. struct MacroData{
  61. string name;
  62. string text;
  63. int16 icon;
  64. };
  65. struct Mail {
  66. int32 mail_id;
  67. int32 player_to_id;
  68. string player_from;
  69. string subject;
  70. string mail_body;
  71. int8 already_read;
  72. int8 mail_type;
  73. int32 coin_copper;
  74. int32 coin_silver;
  75. int32 coin_gold;
  76. int32 coin_plat;
  77. int16 stack;
  78. int32 postage_cost;
  79. int32 attachment_cost;
  80. int32 char_item_id;
  81. int32 time_sent;
  82. int32 expire_time;
  83. int8 save_needed;
  84. };
  85. struct MailWindow {
  86. int32 coin_copper;
  87. int32 coin_silver;
  88. int32 coin_gold;
  89. int32 coin_plat;
  90. Item* item;
  91. int32 char_item_id;
  92. int32 stack;
  93. };
  94. struct PendingGuildInvite {
  95. Guild* guild;
  96. Player* invited_by;
  97. };
  98. struct PendingResurrection {
  99. Spawn* caster;
  100. Timer* expire_timer;
  101. string spell_name;
  102. string heal_name;
  103. bool active;
  104. float hp_perc;
  105. float mp_perc;
  106. float range;
  107. int8 crit_mod;
  108. bool no_calcs;
  109. int32 subspell;
  110. bool crit;
  111. bool should_delete;
  112. int32 spell_visual;
  113. };
  114. #define PAPERDOLL_TYPE_FULL 0
  115. #define PAPERDOLL_TYPE_HEAD 1
  116. struct IncomingPaperdollImage {
  117. uchar* image_bytes;
  118. int32 current_size_bytes;
  119. int8 image_num_packets;
  120. int8 last_received_packet_index;
  121. int8 image_type;
  122. };
  123. struct WaypointInfo {
  124. int32 id;
  125. int8 type;
  126. };
  127. struct QuestRewardData {
  128. int32 quest_id;
  129. bool is_temporary;
  130. std::string description;
  131. bool is_collection;
  132. bool has_displayed;
  133. int64 tmp_coin;
  134. int32 tmp_status;
  135. bool db_saved;
  136. int32 db_index;
  137. };
  138. class Client {
  139. public:
  140. Client(EQStream* ieqs);
  141. ~Client();
  142. void RemoveClientFromZone();
  143. bool Process(bool zone_process = false);
  144. void Disconnect(bool send_disconnect = true);
  145. void SetConnected(bool val){ connected = val; }
  146. bool IsConnected(){ return connected; }
  147. bool IsReadyForSpawns(){ return ready_for_spawns; }
  148. bool IsReadyForUpdates() { return ready_for_updates; }
  149. bool IsZoning(){ return client_zoning; }
  150. void SetReadyForUpdates();
  151. void SetReadyForSpawns(bool val);
  152. void QueuePacket(EQ2Packet* app, bool attemptedCombine=false);
  153. void SendLoginInfo();
  154. int8 GetMessageChannelColor(int8 channel_type);
  155. void HandleTellMessage(Client* from, const char* message, const char* to, int32 current_language_id);
  156. void SimpleMessage(int8 color, const char* message);
  157. void Message(int8 type, const char* message, ...);
  158. void SendSpellUpdate(Spell* spell, bool add_silently = false, bool add_to_hotbar = true);
  159. void Zone(ZoneServer* new_zone, bool set_coords = true, bool is_spell = false);
  160. void Zone(const char* new_zone, bool set_coords = true, bool is_spell = false);
  161. void Zone(int32 instanceid, bool set_coords = true, bool byInstanceID=false, bool is_spell = false);
  162. void SendZoneInfo();
  163. void SendZoneSpawns();
  164. void HandleVerbRequest(EQApplicationPacket* app);
  165. void SendCharInfo();
  166. void SendLoginDeniedBadVersion();
  167. void SendCharPOVGhost();
  168. void SendPlayerDeathWindow();
  169. float DistanceFrom(Client* client);
  170. void SendDefaultGroupOptions();
  171. bool HandleLootItem(Spawn* entity, int32 item_id);
  172. bool HandleLootItem(Spawn* entity, Item* item);
  173. void HandleLoot(EQApplicationPacket* app);
  174. void HandleSkillInfoRequest(EQApplicationPacket* app);
  175. void HandleExamineInfoRequest(EQApplicationPacket* app);
  176. void HandleQuickbarUpdateRequest(EQApplicationPacket* app);
  177. void SendPopupMessage(int8 unknown, const char* text, const char* type, float size, int8 red, int8 green, int8 blue);
  178. void PopulateSkillMap();
  179. void ChangeLevel(int16 old_level, int16 new_level);
  180. void ChangeTSLevel(int16 old_level, int16 new_level);
  181. bool Summon(const char* search_name);
  182. std::string IdentifyInstanceLockout(int32 zoneID, bool displayClient = true);
  183. ZoneServer* IdentifyInstance(int32 zoneID);
  184. bool TryZoneInstance(int32 zoneID, bool zone_coords_valid=false);
  185. bool GotoSpawn(const char* search_name, bool forceTarget=false);
  186. void DisplayDeadWindow();
  187. void HandlePlayerRevive(int32 point_id);
  188. void Bank(Spawn* banker, bool cancel = false);
  189. void BankWithdrawal(int64 amount);
  190. void BankDeposit(int64 amount);
  191. Spawn* GetBanker();
  192. void SetBanker(Spawn* in_banker);
  193. bool AddItem(int32 item_id, int16 quantity = 0, AddItemType type = AddItemType::NOT_SET);
  194. bool AddItem(Item* item, bool* item_deleted = 0, AddItemType type = AddItemType::NOT_SET);
  195. bool AddItemToBank(int32 item_id, int16 quantity = 0);
  196. bool AddItemToBank(Item* item);
  197. bool RemoveItem(Item *item, int16 quantity, bool force_override_no_delete = false);
  198. void ProcessTeleport(Spawn* spawn, vector<TransportDestination*>* destinations, int32 transport_id = 0, bool is_spell = false);
  199. void ProcessTeleportLocation(EQApplicationPacket* app);
  200. void UpdateCharacterInstances();
  201. void SetLastSavedTimeStamp(int32 unixts) { last_saved_timestamp = unixts; }
  202. int32 GetLastSavedTimeStamp() { return last_saved_timestamp; }
  203. bool CheckZoneAccess(const char* zoneName);
  204. ZoneServer* GetCurrentZone();
  205. void SetCurrentZoneByInstanceID(int32 id, int32 zoneid);
  206. //void SetCurrentZoneByInstanceID(instanceid, zoneid);
  207. void SetCurrentZone(int32 id);
  208. void SetCurrentZone(ZoneServer* zone) {
  209. current_zone = zone;
  210. player->SetZone(zone, GetVersion());
  211. }
  212. void SetZoningDestination(ZoneServer* zone) {
  213. zoning_destination = zone;
  214. }
  215. ZoneServer* GetZoningDestination() { return zoning_destination; }
  216. Player* GetPlayer(){ return player; }
  217. EQStream* getConnection(){ return eqs; }
  218. inline int32 GetIP() { return ip; }
  219. inline int16 GetPort() { return port; }
  220. inline int32 WaitingForBootup() { return pwaitingforbootup; }
  221. inline int32 GetCharacterID() { return character_id; }
  222. inline int32 GetAccountID() { return account_id; }
  223. inline const char* GetAccountName() { return account_name; }
  224. inline sint16 GetAdminStatus() { return admin_status; }
  225. inline int16 GetVersion() { return version; }
  226. void SetNameCRC(int32 val){ name_crc = val; }
  227. int32 GetNameCRC(){ return name_crc; }
  228. void SetVersion(int16 new_version){ version = new_version; }
  229. void SetAccountID(int32 in_accountid) { account_id = in_accountid; }
  230. void SetCharacterID(int32 in_characterid) { character_id = in_characterid; }
  231. void SetAdminStatus(sint16 in_status) { admin_status = in_status; }
  232. void DetermineCharacterUpdates ( );
  233. void UpdateTimeStampFlag ( int8 flagType )
  234. {
  235. if(! (timestamp_flag & flagType ) )
  236. timestamp_flag |= flagType;
  237. }
  238. int8 GetTimeStampFlag ( ) { return timestamp_flag; }
  239. bool UpdateQuickbarNeeded();
  240. void Save();
  241. bool remove_from_list;
  242. void CloseLoot(int32 spawn_id);
  243. void SendPendingLoot(int32 total_coins, Spawn* entity);
  244. void Loot(int32 total_coins, vector<Item*>* items, Spawn* entity);
  245. void Loot(Spawn* entity, bool attemptDisarm=true);
  246. void OpenChest(Spawn* entity, bool attemptDisarm=true);
  247. void CastGroupOrSelf(Entity* source, uint32 spellID, uint32 spellTier=1, float restrictiveRadius=0.0f);
  248. void CheckPlayerQuestsKillUpdate(Spawn* spawn);
  249. void CheckPlayerQuestsChatUpdate(Spawn* spawn);
  250. void CheckPlayerQuestsItemUpdate(Item* item);
  251. void CheckPlayerQuestsSpellUpdate(Spell* spell);
  252. void CheckPlayerQuestsLocationUpdate();
  253. void AddPendingQuest(Quest* quest, bool forced = false);
  254. void AcceptQuest(int32 id);
  255. Quest* GetPendingQuest(int32 id);
  256. void RemovePendingQuest(Quest* quest);
  257. void SetPlayerQuest(Quest* quest, map<int32, int32>* progress);
  258. void AddPlayerQuest(Quest* quest, bool call_accepted = true, bool send_packets = true);
  259. void RemovePlayerQuest(int32 id, bool send_update = true, bool delete_quest = true);
  260. void SendQuestJournal(bool all_quests = false, Client* client = 0, bool updated = true);
  261. void SendQuestUpdate(Quest* quest);
  262. void SendQuestFailure(Quest* quest);
  263. void SendQuestUpdateStep(Quest* quest, int32 step, bool display_quest_helper = true);
  264. void SendQuestUpdateStepImmediately(Quest* quest, int32 step, bool display_quest_helper = true);
  265. void DisplayQuestRewards(Quest* quest, int64 coin, vector<Item*>* rewards=0, vector<Item*>* selectable_rewards=0, map<int32, sint32>* factions=0, const char* header="Quest Reward!", int32 status_points=0, const char* text=0, bool was_displayed = false);
  266. void DisplayQuestComplete(Quest* quest, bool tempReward = false, std::string customDescription = string(""), bool was_displayed = false);
  267. void DisplayRandomizeFeatures(int32 features);
  268. void AcceptQuestReward(Quest* quest, int32 item_id);
  269. Quest* GetPendingQuestAcceptance(int32 item_id);
  270. Quest* GetActiveQuest(int32 quest_id);
  271. void DisplayConversation(int32 conversation_id, int32 spawn_id, vector<ConversationOption>* conversations, const char* text, const char* mp3, int32 key1, int32 key2, int8 language = 0, int8 can_close = 1);
  272. void DisplayConversation(Item* item, vector<ConversationOption>* conversations, const char* text, int8 type, const char* mp3 = 0, int32 key1 = 0, int32 key2 = 0, int8 language = 0, int8 can_close = 1);
  273. void DisplayConversation(Spawn* src, int8 type, vector<ConversationOption>* conversations, const char* text, const char* mp3 = 0, int32 key1 = 0, int32 key2 = 0, int8 language = 0, int8 can_close = 1);
  274. void CloseDialog(int32 conversation_id);
  275. int32 GetConversationID(Spawn* spawn, Item* item);
  276. void CombineSpawns(float radius, Spawn* spawn);
  277. void AddCombineSpawn(Spawn* spawn);
  278. void RemoveCombineSpawn(Spawn* spawn);
  279. void SaveCombineSpawns(const char* name = 0);
  280. Spawn* GetCombineSpawn();
  281. bool ShouldTarget();
  282. void TargetSpawn(Spawn* spawn);
  283. void ReloadQuests();
  284. int32 GetCurrentQuestID(){ return current_quest_id; }
  285. void SetLuaDebugClient(bool val);
  286. void SetMerchantTransaction(Spawn* spawn);
  287. Spawn* GetMerchantTransaction();
  288. void SetMailTransaction(Spawn* spawn);
  289. Spawn* GetMailTransaction();
  290. void PlaySound(const char* name);
  291. void SendBuyMerchantList(bool sell = false);
  292. void SendSellMerchantList(bool sell = false);
  293. void SendBuyBackList(bool sell = false);
  294. void SendRepairList();
  295. void ShowLottoWindow();
  296. void PlayLotto(int32 price, int32 ticket_item_id);
  297. void SendGuildCreateWindow();
  298. float CalculateBuyMultiplier(int32 merchant_id);
  299. float CalculateSellMultiplier(int32 merchant_id);
  300. void BuyItem(int32 item_id, int16 quantity);
  301. void SellItem(int32 item_id, int16 quantity, int32 unique_id = 0);
  302. void BuyBack(int32 item_id, int16 quantity);
  303. void RepairItem(int32 item_id);
  304. void RepairAllItems();
  305. void AddBuyBack(int32 unique_id, int32 item_id, int16 quantity, int32 price, bool save_needed = true);
  306. deque<BuyBackItem*>* GetBuyBacks();
  307. vector<Item*>* GetRepairableItems();
  308. vector<Item*>* GetItemsByEffectType(ItemEffectType type, ItemEffectType secondary_effect = NO_EFFECT_TYPE);
  309. void SendMailList();
  310. void DisplayMailMessage(int32 mail_id);
  311. void HandleSentMail(EQApplicationPacket* app);
  312. void DeleteMail(int32 mail_id, bool from_database = false);
  313. bool AddMailItem(Item* item);
  314. bool AddMailCoin(int32 copper, int32 silver = 0, int32 gold = 0, int32 plat = 0);
  315. bool RemoveMailCoin(int32 copper, int32 silver = 0, int32 gold = 0, int32 plat = 0);
  316. void TakeMailAttachments(int32 mail_id);
  317. void ResetSendMail(bool cancel = true, bool needslock = true);
  318. bool GateAllowed();
  319. bool BindAllowed();
  320. bool Bind();
  321. bool Gate(bool is_spell = false);
  322. void SendChatRelationship(int8 type, const char* name);
  323. void SendFriendList();
  324. void SendIgnoreList();
  325. void SendNewSpells(int8 class_id);
  326. string GetCoinMessage(int32 total_coins);
  327. void SetItemSearch(vector<Item*>* items);
  328. vector<Item*>* GetSearchItems();
  329. void SearchStore(int32 page);
  330. void SetPlayer(Player* new_player);
  331. void AddPendingQuestAcceptReward(Quest* quest);
  332. void AddPendingQuestReward(Quest* quest, bool update=true, bool is_temporary = false, std::string description = std::string(""));
  333. bool HasQuestRewardQueued(int32 quest_id, bool is_temporary, bool is_collection);
  334. void QueueQuestReward(int32 quest_id, bool is_temporary, bool is_collection, bool has_displayed, int64 tmp_coin, int32 tmp_status, std::string description, bool db_saved=false, int32 index=0);
  335. void RemoveQueuedQuestReward();
  336. void AddPendingQuestUpdate(int32 quest_id, int32 step_id, int32 progress = 0xFFFFFFFF);
  337. void ProcessQuestUpdates();
  338. void AddWaypoint(const char* waypoint_name, int8 waypoint_category, int32 spawn_id);
  339. void BeginWaypoint(const char* waypoint_name, float x, float y, float z);
  340. void InspectPlayer(Player* player_to_inspect);
  341. void SetPendingGuildInvite(Guild* guild, Player* invited_by = 0);
  342. PendingGuildInvite* GetPendingGuildInvite() {return &pending_guild_invite;}
  343. void ShowClaimWindow();
  344. void ShowGuildSearchWindow();
  345. void CheckQuestQueue();
  346. void ShowDressingRoom(Item *item, sint32 crc);
  347. void SendCollectionList();
  348. bool SendCollectionsForItem(Item *item);
  349. void HandleCollectionAddItem(int32 collection_id, Item *item);
  350. void DisplayCollectionComplete(Collection *collection);
  351. void HandInCollections();
  352. void AcceptCollectionRewards(Collection *collection, int32 selectable_item_id = 0);
  353. void SendRecipeList();
  354. void SendTitleUpdate();
  355. void SendUpdateTitles(sint32 prefix, sint32 suffix);
  356. void SendLanguagesUpdate(int32 id);
  357. void SendAchievementsList();
  358. void SendAchievementUpdate(bool first_login = false);
  359. ///<summary>Send the pet options window to the client</summary>
  360. ///<param name="type">Type of pet, 1 = combat 0 = non combat</param>
  361. void SendPetOptionsWindow(const char* pet_name, int8 type = 1);
  362. void SendBiography();
  363. bool IsCrafting();
  364. void SetRecipeListSent(bool val) {m_recipeListSent = val; }
  365. bool GetRecipeListSent() { return m_recipeListSent; }
  366. void ShowRecipeBook();
  367. PendingResurrection* GetCurrentRez();
  368. void SendResurrectionWindow();
  369. void AcceptResurrection();
  370. Mutex m_resurrect;
  371. Mutex* GetResurrectMutex();
  372. void SetPendingLastName(string last_name);
  373. void RemovePendingLastName();
  374. string* GetPendingLastName();
  375. void SendLastNameConfirmation();
  376. void SetInitialSpawnsSent(bool val) { initial_spawns_sent = val; }
  377. bool GetInitialSpawnsSent() { return initial_spawns_sent; }
  378. void SendQuestJournalUpdate(Quest* quest, bool updated=true);
  379. void AddQuestTimer(int32 quest_id);
  380. void RemoveQuestTimer(int32 quest_id);
  381. void SetPendingFlightPath(int32 val) { pending_flight_path = val; }
  382. int32 GetPendingFlightPath() { return pending_flight_path; }
  383. void EndAutoMount();
  384. bool GetOnAutoMount() { return on_auto_mount; }
  385. bool IsCurrentTransmuteID(int32 trans_id);
  386. void SetTransmuteID(int32 trans_id);
  387. int32 GetTransmuteID();
  388. enum ServerSpawnPlacementMode { DEFAULT, OPEN_HEADING, CLOSE_HEADING };
  389. void SetSpawnPlacementMode(ServerSpawnPlacementMode mode) { spawnPlacementMode = mode; }
  390. ServerSpawnPlacementMode GetSpawnPlacementMode() { return spawnPlacementMode; }
  391. bool HandleNewLogin(int32 account_id, int32 access_code);
  392. void SendSpawnChanges(set<Spawn*>& spawns);
  393. void MakeSpawnChangePacket(map<int32, SpawnData> info_changes, map<int32, SpawnData> pos_changes, map<int32, SpawnData> vis_changes, int32 info_size, int32 pos_size, int32 vis_size);
  394. bool IsZonedIn() { return connected_to_zone; }
  395. void SendHailCommand(Spawn* target);
  396. void SendDefaultCommand(Spawn* spawn, const char* command, float distance);
  397. void SetTempPlacementSpawn(Spawn* tmp);
  398. Spawn* GetTempPlacementSpawn() { return tempPlacementSpawn; }
  399. void SetPlacementUniqueItemID(int32 id) { placement_unique_item_id = id; }
  400. int32 GetPlacementUniqueItemID() { return placement_unique_item_id; }
  401. void SetHasOwnerOrEditAccess(bool val) { hasOwnerOrEditAccess = val; }
  402. bool HasOwnerOrEditAccess() { return hasOwnerOrEditAccess; }
  403. bool HandleHouseEntityCommands(Spawn* spawn, int32 spawnid, string command);
  404. // find an appropriate spawn to use for the house object, save spawn location/entry data to DB
  405. bool PopulateHouseSpawn(PacketStruct* place_object);
  406. // finalize the spawn-in of the object in world, remove the item from player inventory, set the spawned in object item id (for future pickup)
  407. bool PopulateHouseSpawnFinalize();
  408. void SendMoveObjectMode(Spawn* spawn, uint8 placementMode, float unknown2_3=0.0f);
  409. void SendFlightAutoMount(int32 path_id, int16 mount_id = 0, int8 mount_red_color = 0xFF, int8 mount_green_color = 0xFF, int8 mount_blue_color=0xFF);
  410. void SendShowBook(Spawn* sender, string title, int8 language, int8 num_pages, ...);
  411. void SendShowBook(Spawn* sender, string title, int8 language, vector<Item::BookPage*> pages);
  412. void SetTemporaryTransportID(int32 id) { temporary_transport_id = id; }
  413. int32 GetTemporaryTransportID() { return temporary_transport_id; }
  414. void SetRejoinGroupID(int32 id) { rejoin_group_id = id; }
  415. void TempRemoveGroup();
  416. void ReplaceGroupClient(Client* new_client);
  417. void SendWaypoints();
  418. void AddWaypoint(string name, int8 type);
  419. void RemoveWaypoint(string name) {
  420. if (waypoints.count(name) > 0){
  421. waypoints.erase(name);
  422. }
  423. }
  424. void SelectWaypoint(int32 id);
  425. void ClearWaypoint();
  426. bool ShowPathToTarget(float x, float y, float z, float y_offset);
  427. bool ShowPathToTarget(Spawn* spawn);
  428. void SetRegionDebug(bool val) { regionDebugMessaging = val; }
  429. static void CreateMail(int32 charID, std::string fromName, std::string subjectName, std::string mailBody,
  430. int8 mailType, int32 copper, int32 silver, int32 gold, int32 platinum, int32 item_id, int16 stack_size, int32 time_sent, int32 expire_time);
  431. void CreateAndUpdateMail(std::string fromName, std::string subjectName, std::string mailBody,
  432. int8 mailType, int32 copper, int32 silver, int32 gold, int32 platinum, int32 item_id, int16 stack_size, int32 time_sent, int32 expire_time);
  433. void SendEquipOrInvUpdateBySlot(int8 slot);
  434. void SetReloadingZone(bool val) { client_reloading_zone = val; }
  435. bool IsReloadingZone() { return client_reloading_zone; }
  436. void QueueStateCommand(int32 spawn_player_id, int32 state);
  437. void ProcessStateCommands();
  438. void PurgeItem(Item* item);
  439. void ConsumeFoodDrink(Item* item, int32 slot);
  440. void AwardCoins(int64 total_coins, std::string reason = string(""));
  441. void TriggerSpellSave();
  442. void ClearSentItemDetails() {
  443. MItemDetails.writelock(__FUNCTION__, __LINE__);
  444. sent_item_details.clear();
  445. MItemDetails.releasewritelock(__FUNCTION__, __LINE__);
  446. }
  447. bool IsPlayerLoadingComplete() { return player_loading_complete; }
  448. int32 GetRejoinGroupID() { return rejoin_group_id; }
  449. void ClearSentSpellList() {
  450. MSpellDetails.writelock(__FUNCTION__, __LINE__);
  451. sent_spell_details.clear();
  452. MSpellDetails.releasewritelock(__FUNCTION__, __LINE__);
  453. }
  454. void UpdateSentSpellList();
  455. bool CountSentSpell(int32 id, int32 tier) {
  456. bool res = false;
  457. MSpellDetails.readlock(__FUNCTION__, __LINE__);
  458. std::map<int32, int32>::iterator itr = sent_spell_details.find(id);
  459. if(itr != sent_spell_details.end() && itr->second == tier)
  460. res = true;
  461. MSpellDetails.releasereadlock(__FUNCTION__, __LINE__);
  462. return res;
  463. }
  464. void SetSentSpell(int32 id, int32 tier) {
  465. MSpellDetails.writelock(__FUNCTION__, __LINE__);
  466. sent_spell_details[id] = tier;
  467. MSpellDetails.releasewritelock(__FUNCTION__, __LINE__);
  468. }
  469. void DisableSave() { disable_save = true; }
  470. bool IsSaveDisabled() { return disable_save; }
  471. void ResetZoningCoords() {
  472. zoning_x = 0;
  473. zoning_y = 0;
  474. zoning_z = 0;
  475. zoning_h = 0;
  476. }
  477. void SetZoningCoords(float x, float y, float z, float h) {
  478. zoning_x = x;
  479. zoning_y = y;
  480. zoning_z = z;
  481. zoning_h = h;
  482. }
  483. bool UseItem(Item* item, Spawn* target = nullptr);
  484. void SendPlayFlavor(Spawn* spawn, int8 language, VoiceOverStruct* non_garble, VoiceOverStruct* garble, bool success = false, bool garble_success = false);
  485. void SaveQuestRewardData(bool force_refresh = false);
  486. void UpdateCharacterRewardData(QuestRewardData* data);
  487. void SetQuestUpdateState(bool val) { quest_updates = val; }
  488. void AddRecipeToPlayer(Recipe* recipe, PacketStruct* packet, int16* i);
  489. private:
  490. void SavePlayerImages();
  491. void SkillChanged(Skill* skill, int16 previous_value, int16 new_value);
  492. void GiveQuestReward(Quest* quest, bool has_displayed = false);
  493. void SetStepComplete(int32 quest_id, int32 step);
  494. void AddStepProgress(int32 quest_id, int32 step, int32 progress);
  495. map<int32, map<int32, int32> > quest_pending_updates;
  496. vector<QueuedQuest*> quest_queue;
  497. vector<QuestRewardData*> quest_pending_reward;
  498. volatile bool quest_updates;
  499. Mutex MQuestPendingUpdates;
  500. Mutex MQuestQueue;
  501. Mutex MDeletePlayer;
  502. vector<Item*>* search_items;
  503. int32 waypoint_id = 0;
  504. map<string, WaypointInfo> waypoints;
  505. Spawn* transport_spawn;
  506. Mutex MBuyBack;
  507. deque<BuyBackItem*> buy_back_items;
  508. Spawn* merchant_transaction;
  509. Spawn* mail_transaction;
  510. Mutex MPendingQuestAccept;
  511. vector<int32> pending_quest_accept;
  512. bool lua_debug;
  513. bool should_target;
  514. Spawn* combine_spawn;
  515. int8 num_active_failures;
  516. int32 next_conversation_id;
  517. map<int32, int32> conversation_spawns;
  518. map<int32, Item*> conversation_items;
  519. Mutex MConversation;
  520. map<int32, map<int8, string> > conversation_map;
  521. int32 current_quest_id;
  522. Spawn* banker;
  523. map<int32, int32> sent_spell_details;
  524. map<int32, bool> sent_item_details;
  525. Player* player;
  526. int16 version;
  527. int8 timestamp_flag;
  528. int32 ip;
  529. int16 port;
  530. int32 account_id;
  531. int32 character_id;
  532. sint16 admin_status; // -2 Banned, -1 Suspended, 0 User, etc.
  533. char account_name[64];
  534. char zone_name[64];
  535. int32 zoneID;
  536. int32 instanceID;
  537. Timer* autobootup_timeout;
  538. int32 pwaitingforbootup;
  539. int32 last_update_time;
  540. int32 last_saved_timestamp;
  541. Timer* CLE_keepalive_timer;
  542. Timer* connect;
  543. Timer* camp_timer;
  544. bool connected;
  545. bool ready_for_spawns;
  546. bool ready_for_updates;
  547. bool seencharsel;
  548. bool connected_to_zone;
  549. bool client_zoning;
  550. int32 zoning_id;
  551. int32 zoning_instance_id;
  552. ZoneServer* zoning_destination;
  553. float zoning_x;
  554. float zoning_y;
  555. float zoning_z;
  556. float zoning_h;
  557. bool firstlogin;
  558. bool new_client_login;
  559. Timer pos_update;
  560. Timer quest_pos_timer;
  561. Timer lua_debug_timer;
  562. Timer temp_placement_timer;
  563. Timer spawn_removal_timer;
  564. bool player_pos_changed;
  565. bool HandlePacket(EQApplicationPacket *app);
  566. EQStream* eqs;
  567. bool quickbar_changed;
  568. ZoneServer* current_zone;
  569. int32 name_crc;
  570. MailWindow mail_window;
  571. std::mutex MMailWindowMutex;
  572. PendingGuildInvite pending_guild_invite;
  573. PendingResurrection current_rez;
  574. string* pending_last_name;
  575. IncomingPaperdollImage incoming_paperdoll;
  576. int32 transmuteID;
  577. bool m_recipeListSent;
  578. bool initial_spawns_sent;
  579. bool should_load_spells;
  580. // int32 = quest id
  581. vector<int32> quest_timers;
  582. Mutex MQuestTimers;
  583. int32 pending_flight_path;
  584. ServerSpawnPlacementMode spawnPlacementMode;
  585. bool on_auto_mount;
  586. bool EntityCommandPrecheck(Spawn* spawn, const char* command);
  587. bool delayedLogin;
  588. int32 delayedAccountID;
  589. int32 delayedAccessKey;
  590. Timer delayTimer;
  591. Spawn* tempPlacementSpawn;
  592. int32 placement_unique_item_id;
  593. bool hasOwnerOrEditAccess;
  594. bool hasSentTempPlacementSpawn;
  595. int32 temporary_transport_id;
  596. int32 rejoin_group_id;
  597. int32 lastRegionRemapTime;
  598. bool regionDebugMessaging;
  599. bool client_reloading_zone;
  600. map<int32, int32> queued_state_commands;
  601. Mutex MQueueStateCmds;
  602. Timer save_spell_state_timer; // will be the 're-trigger' to delay
  603. int32 save_spell_state_time_bucket; // bucket as we collect over time when timer is reset by new spell effects being casted
  604. std::mutex MSaveSpellStateMutex;
  605. bool player_loading_complete;
  606. Mutex MItemDetails;
  607. Mutex MSpellDetails;
  608. bool disable_save;
  609. vector< string > devices;
  610. };
  611. class ClientList {
  612. public:
  613. ClientList();
  614. ~ClientList();
  615. bool ContainsStream(EQStream* eqs);
  616. void Add(Client* client);
  617. Client* Get(int32 ip, int16 port);
  618. Client* FindByAccountID(int32 account_id);
  619. Client* FindByName(char* charname);
  620. void Remove(Client* client, bool delete_data = false);
  621. void RemoveConnection(EQStream* eqs);
  622. void Process();
  623. int32 Count();
  624. void ReloadQuests();
  625. void CheckPlayersInvisStatus(Client* owner);
  626. void RemovePlayerFromInvisHistory(int32 spawnID);
  627. private:
  628. Mutex MClients;
  629. list<Client*> client_list;
  630. };
  631. #endif