client.h 23 KB

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