client.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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. class Client {
  128. public:
  129. Client(EQStream* ieqs);
  130. ~Client();
  131. void RemoveClientFromZone();
  132. bool Process(bool zone_process = false);
  133. void Disconnect(bool send_disconnect = true);
  134. void SetConnected(bool val){ connected = val; }
  135. bool IsConnected(){ return connected; }
  136. bool IsReadyForSpawns(){ return ready_for_spawns; }
  137. bool IsReadyForUpdates() { return ready_for_updates; }
  138. bool IsZoning(){ return client_zoning; }
  139. void SetReadyForUpdates();
  140. void SetReadyForSpawns(bool val);
  141. void QueuePacket(EQ2Packet* app, bool attemptedCombine=false);
  142. void SendLoginInfo();
  143. int8 GetMessageChannelColor(int8 channel_type);
  144. void HandleTellMessage(Client* from, const char* message, const char* to, int32 current_language_id);
  145. void SimpleMessage(int8 color, const char* message);
  146. void Message(int8 type, const char* message, ...);
  147. void SendSpellUpdate(Spell* spell, bool add_silently = false, bool add_to_hotbar = true);
  148. void Zone(ZoneServer* new_zone, bool set_coords = true, bool is_spell = false);
  149. void Zone(const char* new_zone, bool set_coords = true, bool is_spell = false);
  150. void Zone(int32 instanceid, bool set_coords = true, bool byInstanceID=false, bool is_spell = 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, AddItemType type = AddItemType::NOT_SET);
  183. bool AddItem(Item* item, bool* item_deleted = 0, AddItemType type = AddItemType::NOT_SET);
  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, bool is_spell = false);
  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. void SetZoningDestination(ZoneServer* zone) {
  202. zoning_destination = zone;
  203. }
  204. ZoneServer* GetZoningDestination() { return zoning_destination; }
  205. Player* GetPlayer(){ return player; }
  206. EQStream* getConnection(){ return eqs; }
  207. inline int32 GetIP() { return ip; }
  208. inline int16 GetPort() { return port; }
  209. inline int32 WaitingForBootup() { return pwaitingforbootup; }
  210. inline int32 GetCharacterID() { return character_id; }
  211. inline int32 GetAccountID() { return account_id; }
  212. inline const char* GetAccountName() { return account_name; }
  213. inline sint16 GetAdminStatus() { return admin_status; }
  214. inline int16 GetVersion() { return version; }
  215. void SetNameCRC(int32 val){ name_crc = val; }
  216. int32 GetNameCRC(){ return name_crc; }
  217. void SetVersion(int16 new_version){ version = new_version; }
  218. void SetAccountID(int32 in_accountid) { account_id = in_accountid; }
  219. void SetCharacterID(int32 in_characterid) { character_id = in_characterid; }
  220. void SetAdminStatus(sint16 in_status) { admin_status = in_status; }
  221. void DetermineCharacterUpdates ( );
  222. void UpdateTimeStampFlag ( int8 flagType )
  223. {
  224. if(! (timestamp_flag & flagType ) )
  225. timestamp_flag |= flagType;
  226. }
  227. int8 GetTimeStampFlag ( ) { return timestamp_flag; }
  228. bool UpdateQuickbarNeeded();
  229. void Save();
  230. bool remove_from_list;
  231. void CloseLoot(int32 spawn_id);
  232. void SendPendingLoot(int32 total_coins, Spawn* entity);
  233. void Loot(int32 total_coins, vector<Item*>* items, Spawn* entity);
  234. void Loot(Spawn* entity, bool attemptDisarm=true);
  235. void OpenChest(Spawn* entity, bool attemptDisarm=true);
  236. void CastGroupOrSelf(Entity* source, uint32 spellID, uint32 spellTier=1, float restrictiveRadius=0.0f);
  237. void CheckPlayerQuestsKillUpdate(Spawn* spawn);
  238. void CheckPlayerQuestsChatUpdate(Spawn* spawn);
  239. void CheckPlayerQuestsItemUpdate(Item* item);
  240. void CheckPlayerQuestsSpellUpdate(Spell* spell);
  241. void CheckPlayerQuestsLocationUpdate();
  242. void AddPendingQuest(Quest* quest, bool forced = false);
  243. void AcceptQuest(int32 id);
  244. Quest* GetPendingQuest(int32 id);
  245. void RemovePendingQuest(Quest* quest);
  246. void SetPlayerQuest(Quest* quest, map<int32, int32>* progress);
  247. void AddPlayerQuest(Quest* quest, bool call_accepted = true, bool send_packets = true);
  248. void RemovePlayerQuest(int32 id, bool send_update = true, bool delete_quest = true);
  249. void SendQuestJournal(bool all_quests = false, Client* client = 0, bool updated = true);
  250. void SendQuestUpdate(Quest* quest);
  251. void SendQuestFailure(Quest* quest);
  252. void SendQuestUpdateStep(Quest* quest, int32 step, bool display_quest_helper = true);
  253. void SendQuestUpdateStepImmediately(Quest* quest, int32 step, bool display_quest_helper = true);
  254. 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);
  255. void DisplayQuestComplete(Quest* quest, bool tempReward = false, std::string customDescription = string(""));
  256. void DisplayRandomizeFeatures(int32 features);
  257. void AcceptQuestReward(Quest* quest, int32 item_id);
  258. Quest* GetPendingQuestAcceptance(int32 item_id);
  259. Quest* GetActiveQuest(int32 quest_id);
  260. 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);
  261. 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);
  262. 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);
  263. void CloseDialog(int32 conversation_id);
  264. int32 GetConversationID(Spawn* spawn, Item* item);
  265. void CombineSpawns(float radius, Spawn* spawn);
  266. void AddCombineSpawn(Spawn* spawn);
  267. void RemoveCombineSpawn(Spawn* spawn);
  268. void SaveCombineSpawns(const char* name = 0);
  269. Spawn* GetCombineSpawn();
  270. bool ShouldTarget();
  271. void TargetSpawn(Spawn* spawn);
  272. void ReloadQuests();
  273. int32 GetCurrentQuestID(){ return current_quest_id; }
  274. void SetLuaDebugClient(bool val);
  275. void SetMerchantTransaction(Spawn* spawn);
  276. Spawn* GetMerchantTransaction();
  277. void SetMailTransaction(Spawn* spawn);
  278. Spawn* GetMailTransaction();
  279. void PlaySound(const char* name);
  280. void SendBuyMerchantList(bool sell = false);
  281. void SendSellMerchantList(bool sell = false);
  282. void SendBuyBackList(bool sell = false);
  283. void SendRepairList();
  284. void ShowLottoWindow();
  285. void PlayLotto(int32 price, int32 ticket_item_id);
  286. void SendGuildCreateWindow();
  287. float CalculateBuyMultiplier(int32 merchant_id);
  288. float CalculateSellMultiplier(int32 merchant_id);
  289. void BuyItem(int32 item_id, int16 quantity);
  290. void SellItem(int32 item_id, int16 quantity, int32 unique_id = 0);
  291. void BuyBack(int32 item_id, int16 quantity);
  292. void RepairItem(int32 item_id);
  293. void RepairAllItems();
  294. void AddBuyBack(int32 unique_id, int32 item_id, int16 quantity, int32 price, bool save_needed = true);
  295. deque<BuyBackItem*>* GetBuyBacks();
  296. vector<Item*>* GetRepairableItems();
  297. vector<Item*>* GetItemsByEffectType(ItemEffectType type, ItemEffectType secondary_effect = NO_EFFECT_TYPE);
  298. void SendMailList();
  299. void DisplayMailMessage(int32 mail_id);
  300. void HandleSentMail(EQApplicationPacket* app);
  301. void DeleteMail(int32 mail_id, bool from_database = false);
  302. bool AddMailItem(Item* item);
  303. bool AddMailCoin(int32 copper, int32 silver = 0, int32 gold = 0, int32 plat = 0);
  304. bool RemoveMailCoin(int32 copper, int32 silver = 0, int32 gold = 0, int32 plat = 0);
  305. void TakeMailAttachments(int32 mail_id);
  306. void ResetSendMail(bool cancel = true, bool needslock = true);
  307. bool GateAllowed();
  308. bool BindAllowed();
  309. bool Bind();
  310. bool Gate(bool is_spell = false);
  311. void SendChatRelationship(int8 type, const char* name);
  312. void SendFriendList();
  313. void SendIgnoreList();
  314. void SendNewSpells(int8 class_id);
  315. string GetCoinMessage(int32 total_coins);
  316. void SetItemSearch(vector<Item*>* items);
  317. vector<Item*>* GetSearchItems();
  318. void SearchStore(int32 page);
  319. void SetPlayer(Player* new_player);
  320. void AddPendingQuestAcceptReward(Quest* quest);
  321. void AddPendingQuestReward(Quest* quest, bool update=true);
  322. void AddPendingQuestUpdate(int32 quest_id, int32 step_id, int32 progress = 0xFFFFFFFF);
  323. void ProcessQuestUpdates();
  324. void AddWaypoint(const char* waypoint_name, int8 waypoint_category, int32 spawn_id);
  325. void BeginWaypoint(const char* waypoint_name, float x, float y, float z);
  326. void InspectPlayer(Player* player_to_inspect);
  327. void SetPendingGuildInvite(Guild* guild, Player* invited_by = 0);
  328. PendingGuildInvite* GetPendingGuildInvite() {return &pending_guild_invite;}
  329. void ShowClaimWindow();
  330. void ShowGuildSearchWindow();
  331. void CheckQuestQueue();
  332. void ShowDressingRoom(Item *item, sint32 crc);
  333. void SendCollectionList();
  334. bool SendCollectionsForItem(Item *item);
  335. void HandleCollectionAddItem(int32 collection_id, Item *item);
  336. void DisplayCollectionComplete(Collection *collection);
  337. void HandInCollections();
  338. void AcceptCollectionRewards(Collection *collection, int32 selectable_item_id = 0);
  339. void SendRecipeList();
  340. void SendTitleUpdate();
  341. void SendUpdateTitles(sint32 prefix, sint32 suffix);
  342. void SendLanguagesUpdate(int32 id);
  343. void SendAchievementsList();
  344. void SendAchievementUpdate(bool first_login = false);
  345. ///<summary>Send the pet options window to the client</summary>
  346. ///<param name="type">Type of pet, 1 = combat 0 = non combat</param>
  347. void SendPetOptionsWindow(const char* pet_name, int8 type = 1);
  348. void SendBiography();
  349. bool IsCrafting();
  350. void SetRecipeListSent(bool val) {m_recipeListSent = val; }
  351. bool GetRecipeListSent() { return m_recipeListSent; }
  352. void ShowRecipeBook();
  353. PendingResurrection* GetCurrentRez();
  354. void SendResurrectionWindow();
  355. void AcceptResurrection();
  356. Mutex m_resurrect;
  357. Mutex* GetResurrectMutex();
  358. void SetPendingLastName(string last_name);
  359. void RemovePendingLastName();
  360. string* GetPendingLastName();
  361. void SendLastNameConfirmation();
  362. void SetInitialSpawnsSent(bool val) { initial_spawns_sent = val; }
  363. bool GetInitialSpawnsSent() { return initial_spawns_sent; }
  364. void SendQuestJournalUpdate(Quest* quest, bool updated=true);
  365. void AddQuestTimer(int32 quest_id);
  366. void RemoveQuestTimer(int32 quest_id);
  367. void SetPendingFlightPath(int32 val) { pending_flight_path = val; }
  368. int32 GetPendingFlightPath() { return pending_flight_path; }
  369. void EndAutoMount();
  370. bool GetOnAutoMount() { return on_auto_mount; }
  371. bool IsCurrentTransmuteID(int32 trans_id);
  372. void SetTransmuteID(int32 trans_id);
  373. int32 GetTransmuteID();
  374. enum ServerSpawnPlacementMode { DEFAULT, OPEN_HEADING, CLOSE_HEADING };
  375. void SetSpawnPlacementMode(ServerSpawnPlacementMode mode) { spawnPlacementMode = mode; }
  376. ServerSpawnPlacementMode GetSpawnPlacementMode() { return spawnPlacementMode; }
  377. bool HandleNewLogin(int32 account_id, int32 access_code);
  378. void SendSpawnChanges(set<Spawn*>& spawns);
  379. 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);
  380. bool IsZonedIn() { return connected_to_zone; }
  381. void SendHailCommand(Spawn* target);
  382. void SendDefaultCommand(Spawn* spawn, const char* command, float distance);
  383. void SetTempPlacementSpawn(Spawn* tmp);
  384. Spawn* GetTempPlacementSpawn() { return tempPlacementSpawn; }
  385. void SetPlacementUniqueItemID(int32 id) { placement_unique_item_id = id; }
  386. int32 GetPlacementUniqueItemID() { return placement_unique_item_id; }
  387. void SetHasOwnerOrEditAccess(bool val) { hasOwnerOrEditAccess = val; }
  388. bool HasOwnerOrEditAccess() { return hasOwnerOrEditAccess; }
  389. bool HandleHouseEntityCommands(Spawn* spawn, int32 spawnid, string command);
  390. // find an appropriate spawn to use for the house object, save spawn location/entry data to DB
  391. bool PopulateHouseSpawn(PacketStruct* place_object);
  392. // 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)
  393. bool PopulateHouseSpawnFinalize();
  394. void SendMoveObjectMode(Spawn* spawn, uint8 placementMode, float unknown2_3=0.0f);
  395. void SendFlightAutoMount(int32 path_id, int16 mount_id = 0, int8 mount_red_color = 0xFF, int8 mount_green_color = 0xFF, int8 mount_blue_color=0xFF);
  396. void SendShowBook(Spawn* sender, string title, int8 language, int8 num_pages, ...);
  397. void SendShowBook(Spawn* sender, string title, int8 language, vector<Item::BookPage*> pages);
  398. void SetTemporaryTransportID(int32 id) { temporary_transport_id = id; }
  399. int32 GetTemporaryTransportID() { return temporary_transport_id; }
  400. void SetRejoinGroupID(int32 id) { rejoin_group_id = id; }
  401. void TempRemoveGroup();
  402. void ReplaceGroupClient(Client* new_client);
  403. void SendWaypoints();
  404. void AddWaypoint(string name, int8 type);
  405. void RemoveWaypoint(string name) {
  406. if (waypoints.count(name) > 0){
  407. waypoints.erase(name);
  408. }
  409. }
  410. void SelectWaypoint(int32 id);
  411. void ClearWaypoint();
  412. bool ShowPathToTarget(float x, float y, float z, float y_offset);
  413. bool ShowPathToTarget(Spawn* spawn);
  414. void SetRegionDebug(bool val) { regionDebugMessaging = val; }
  415. static void CreateMail(int32 charID, std::string fromName, std::string subjectName, std::string mailBody,
  416. int8 mailType, int32 copper, int32 silver, int32 gold, int32 platinum, int32 item_id, int16 stack_size, int32 time_sent, int32 expire_time);
  417. void CreateAndUpdateMail(std::string fromName, std::string subjectName, std::string mailBody,
  418. int8 mailType, int32 copper, int32 silver, int32 gold, int32 platinum, int32 item_id, int16 stack_size, int32 time_sent, int32 expire_time);
  419. void SendEquipOrInvUpdateBySlot(int8 slot);
  420. void SetReloadingZone(bool val) { client_reloading_zone = val; }
  421. bool IsReloadingZone() { return client_reloading_zone; }
  422. void QueueStateCommand(int32 spawn_player_id, int32 state);
  423. void ProcessStateCommands();
  424. void PurgeItem(Item* item);
  425. void ConsumeFoodDrink(Item* item, int32 slot);
  426. void AwardCoins(int64 total_coins, std::string reason = string(""));
  427. void TriggerSpellSave();
  428. void ClearSentItemDetails() {
  429. MItemDetails.writelock(__FUNCTION__, __LINE__);
  430. sent_item_details.clear();
  431. MItemDetails.releasewritelock(__FUNCTION__, __LINE__);
  432. }
  433. bool IsPlayerLoadingComplete() { return player_loading_complete; }
  434. int32 GetRejoinGroupID() { return rejoin_group_id; }
  435. void ClearSentSpellList() {
  436. MSpellDetails.writelock(__FUNCTION__, __LINE__);
  437. sent_spell_details.clear();
  438. MSpellDetails.releasewritelock(__FUNCTION__, __LINE__);
  439. }
  440. void UpdateSentSpellList();
  441. bool CountSentSpell(int32 id, int32 tier) {
  442. bool res = false;
  443. MSpellDetails.readlock(__FUNCTION__, __LINE__);
  444. std::map<int32, int32>::iterator itr = sent_spell_details.find(id);
  445. if(itr != sent_spell_details.end() && itr->second == tier)
  446. res = true;
  447. MSpellDetails.releasereadlock(__FUNCTION__, __LINE__);
  448. return res;
  449. }
  450. void SetSentSpell(int32 id, int32 tier) {
  451. MSpellDetails.writelock(__FUNCTION__, __LINE__);
  452. sent_spell_details[id] = tier;
  453. MSpellDetails.releasewritelock(__FUNCTION__, __LINE__);
  454. }
  455. void DisableSave() { disable_save = true; }
  456. bool IsSaveDisabled() { return disable_save; }
  457. void ResetZoningCoords() {
  458. zoning_x = 0;
  459. zoning_y = 0;
  460. zoning_z = 0;
  461. zoning_h = 0;
  462. }
  463. void SetZoningCoords(float x, float y, float z, float h) {
  464. zoning_x = x;
  465. zoning_y = y;
  466. zoning_z = z;
  467. zoning_h = h;
  468. }
  469. bool UseItem(Item* item, Spawn* target = nullptr);
  470. void SendPlayFlavor(Spawn* spawn, int8 language, VoiceOverStruct* non_garble, VoiceOverStruct* garble, bool success = false, bool garble_success = false);
  471. private:
  472. void SavePlayerImages();
  473. void SkillChanged(Skill* skill, int16 previous_value, int16 new_value);
  474. void GiveQuestReward(Quest* quest);
  475. void SetStepComplete(int32 quest_id, int32 step);
  476. void AddStepProgress(int32 quest_id, int32 step, int32 progress);
  477. map<int32, map<int32, int32> > quest_pending_updates;
  478. vector<QueuedQuest*> quest_queue;
  479. vector<int32> quest_pending_reward;
  480. volatile bool quest_updates;
  481. Mutex MQuestPendingUpdates;
  482. Mutex MQuestQueue;
  483. Mutex MDeletePlayer;
  484. vector<Item*>* search_items;
  485. int32 waypoint_id = 0;
  486. map<string, WaypointInfo> waypoints;
  487. Spawn* transport_spawn;
  488. Mutex MBuyBack;
  489. deque<BuyBackItem*> buy_back_items;
  490. Spawn* merchant_transaction;
  491. Spawn* mail_transaction;
  492. Mutex MPendingQuestAccept;
  493. vector<int32> pending_quest_accept;
  494. bool lua_debug;
  495. bool should_target;
  496. Spawn* combine_spawn;
  497. int8 num_active_failures;
  498. int32 next_conversation_id;
  499. map<int32, int32> conversation_spawns;
  500. map<int32, Item*> conversation_items;
  501. Mutex MConversation;
  502. map<int32, map<int8, string> > conversation_map;
  503. int32 current_quest_id;
  504. Spawn* banker;
  505. map<int32, int32> sent_spell_details;
  506. map<int32, bool> sent_item_details;
  507. Player* player;
  508. int16 version;
  509. int8 timestamp_flag;
  510. int32 ip;
  511. int16 port;
  512. int32 account_id;
  513. int32 character_id;
  514. sint16 admin_status; // -2 Banned, -1 Suspended, 0 User, etc.
  515. char account_name[64];
  516. char zone_name[64];
  517. int32 zoneID;
  518. int32 instanceID;
  519. Timer* autobootup_timeout;
  520. int32 pwaitingforbootup;
  521. int32 last_update_time;
  522. int32 last_saved_timestamp;
  523. Timer* CLE_keepalive_timer;
  524. Timer* connect;
  525. Timer* camp_timer;
  526. bool connected;
  527. bool ready_for_spawns;
  528. bool ready_for_updates;
  529. bool seencharsel;
  530. bool connected_to_zone;
  531. bool client_zoning;
  532. int32 zoning_id;
  533. int32 zoning_instance_id;
  534. ZoneServer* zoning_destination;
  535. float zoning_x;
  536. float zoning_y;
  537. float zoning_z;
  538. float zoning_h;
  539. bool firstlogin;
  540. bool new_client_login;
  541. Timer pos_update;
  542. Timer quest_pos_timer;
  543. Timer lua_debug_timer;
  544. Timer temp_placement_timer;
  545. Timer spawn_removal_timer;
  546. bool player_pos_changed;
  547. bool HandlePacket(EQApplicationPacket *app);
  548. EQStream* eqs;
  549. bool quickbar_changed;
  550. ZoneServer* current_zone;
  551. int32 name_crc;
  552. MailWindow mail_window;
  553. std::mutex MMailWindowMutex;
  554. PendingGuildInvite pending_guild_invite;
  555. PendingResurrection current_rez;
  556. string* pending_last_name;
  557. IncomingPaperdollImage incoming_paperdoll;
  558. int32 transmuteID;
  559. bool m_recipeListSent;
  560. bool initial_spawns_sent;
  561. bool should_load_spells;
  562. // int32 = quest id
  563. vector<int32> quest_timers;
  564. Mutex MQuestTimers;
  565. int32 pending_flight_path;
  566. ServerSpawnPlacementMode spawnPlacementMode;
  567. bool on_auto_mount;
  568. bool EntityCommandPrecheck(Spawn* spawn, const char* command);
  569. bool delayedLogin;
  570. int32 delayedAccountID;
  571. int32 delayedAccessKey;
  572. Timer delayTimer;
  573. Spawn* tempPlacementSpawn;
  574. int32 placement_unique_item_id;
  575. bool hasOwnerOrEditAccess;
  576. bool hasSentTempPlacementSpawn;
  577. int32 temporary_transport_id;
  578. int32 rejoin_group_id;
  579. int32 lastRegionRemapTime;
  580. bool regionDebugMessaging;
  581. bool client_reloading_zone;
  582. map<int32, int32> queued_state_commands;
  583. Mutex MQueueStateCmds;
  584. Timer save_spell_state_timer; // will be the 're-trigger' to delay
  585. int32 save_spell_state_time_bucket; // bucket as we collect over time when timer is reset by new spell effects being casted
  586. std::mutex MSaveSpellStateMutex;
  587. bool player_loading_complete;
  588. Mutex MItemDetails;
  589. Mutex MSpellDetails;
  590. bool disable_save;
  591. };
  592. class ClientList {
  593. public:
  594. ClientList();
  595. ~ClientList();
  596. bool ContainsStream(EQStream* eqs);
  597. void Add(Client* client);
  598. Client* Get(int32 ip, int16 port);
  599. Client* FindByAccountID(int32 account_id);
  600. Client* FindByName(char* charname);
  601. void Remove(Client* client, bool delete_data = false);
  602. void RemoveConnection(EQStream* eqs);
  603. void Process();
  604. int32 Count();
  605. void ReloadQuests();
  606. void CheckPlayersInvisStatus(Client* owner);
  607. void RemovePlayerFromInvisHistory(int32 spawnID);
  608. private:
  609. Mutex MClients;
  610. list<Client*> client_list;
  611. };
  612. #endif