World.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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 EQ2_WORLD_H
  17. #define EQ2_WORLD_H
  18. #include <string>
  19. #include <vector>
  20. #include <map>
  21. #include <list>
  22. #include <mutex>
  23. #include <shared_mutex>
  24. #include <atomic>
  25. #include "SpawnLists.h"
  26. #include "zoneserver.h"
  27. #include "NPC.h"
  28. #include "Widget.h"
  29. #include "Object.h"
  30. #include "GroundSpawn.h"
  31. #include "Sign.h"
  32. #include "Variables.h"
  33. #include "MutexList.h"
  34. #include "PlayerGroups.h"
  35. #include "../common/Web/WebServer.h"
  36. #include "./Zone/region_map.h"
  37. #include "./Zone/map.h"
  38. using namespace std;
  39. struct MerchantInfo{
  40. vector<int32> inventory_ids;
  41. /*int32 faction_id;
  42. sint32 faction_min;
  43. sint32 faction_max;
  44. float low_buy_multiplier;
  45. float high_buy_multiplier;
  46. float low_sell_multiplier;
  47. float high_sell_multiplier;*/
  48. };
  49. struct MerchantItemInfo{
  50. int32 item_id;
  51. int16 quantity;
  52. int32 price_item_id;
  53. int32 price_item2_id;
  54. int16 price_item_qty;
  55. int16 price_item2_qty;
  56. int32 price_status;
  57. int64 price_coins;
  58. int32 price_stationcash;
  59. };
  60. struct LootTable{
  61. string name;
  62. int32 mincoin;
  63. int32 maxcoin;
  64. int16 maxlootitems;
  65. float lootdrop_probability;
  66. float coin_probability;
  67. };
  68. struct LootDrop{
  69. int32 item_id;
  70. int16 item_charges;
  71. bool equip_item;
  72. float probability;
  73. int32 no_drop_quest_completed_id;
  74. };
  75. struct GroundSpawnEntry {
  76. int16 min_skill_level;
  77. int16 min_adventure_level;
  78. int8 bonus_table;
  79. float harvest1;
  80. float harvest3;
  81. float harvest5;
  82. float harvest_imbue;
  83. float harvest_rare;
  84. float harvest10;
  85. int32 harvest_coin;
  86. };
  87. struct GroundSpawnEntryItem {
  88. int32 item_id;
  89. int8 is_rare;
  90. int32 grid_id;
  91. };
  92. struct TransportDestination{
  93. int32 unique_id;
  94. int8 type;
  95. string display_name;
  96. string message;
  97. int32 destination_zone_id;
  98. float destination_x;
  99. float destination_y;
  100. float destination_z;
  101. float destination_heading;
  102. int32 cost;
  103. int8 min_level;
  104. int8 max_level;
  105. int32 req_quest;
  106. int16 req_quest_step;
  107. int32 req_quest_complete;
  108. int32 map_x;
  109. int32 map_y;
  110. int32 faction_id;
  111. int32 faction_value;
  112. int32 expansion_flag;
  113. int32 holiday_flag;
  114. int32 min_client_version;
  115. int32 max_client_version;
  116. int32 flight_path_id;
  117. int16 mount_id;
  118. int8 mount_red_color;
  119. int8 mount_green_color;
  120. int8 mount_blue_color;
  121. };
  122. struct LocationTransportDestination{
  123. int32 unique_id;
  124. string message;
  125. int32 destination_zone_id;
  126. float destination_x;
  127. float destination_y;
  128. float destination_z;
  129. float destination_heading;
  130. float trigger_x;
  131. float trigger_y;
  132. float trigger_z;
  133. float trigger_radius;
  134. int32 cost;
  135. int32 faction_id;
  136. int32 faction_value;
  137. };
  138. struct LottoPlayer {
  139. int32 end_time;
  140. int8 num_matches;
  141. bool set;
  142. };
  143. struct HouseZone {
  144. int32 id;
  145. string name;
  146. int64 cost_coin;
  147. int32 cost_status;
  148. int64 upkeep_coin;
  149. int32 upkeep_status;
  150. int8 vault_slots;
  151. int8 alignment;
  152. int8 guild_level;
  153. int32 zone_id;
  154. int32 exit_zone_id;
  155. float exit_x;
  156. float exit_y;
  157. float exit_z;
  158. float exit_heading;
  159. };
  160. struct Deposit {
  161. int32 timestamp;
  162. int64 amount;
  163. int64 last_amount;
  164. int32 status;
  165. int32 last_status;
  166. string name;
  167. };
  168. struct HouseHistory {
  169. HouseHistory()
  170. {
  171. timestamp = 0;
  172. amount = 0;
  173. name = string("");
  174. reason = string("");
  175. status = 0;
  176. pos_flag = 0;
  177. }
  178. HouseHistory(int32 in_timestamp, int64 in_amount, string in_name, string in_reason, int32 in_status, int8 in_pos_flag)
  179. {
  180. timestamp = in_timestamp;
  181. amount = in_amount;
  182. name = in_name;
  183. reason = in_reason;
  184. status = in_status;
  185. pos_flag = in_pos_flag;
  186. }
  187. int32 timestamp;
  188. int64 amount;
  189. string name;
  190. string reason;
  191. int32 status;
  192. int8 pos_flag;
  193. };
  194. struct PlayerHouse {
  195. int32 house_id;
  196. int64 unique_id;
  197. int32 instance_id;
  198. int32 upkeep_due;
  199. int64 escrow_coins;
  200. int32 escrow_status;
  201. string player_name;
  202. list<Deposit> deposits;
  203. map<string, Deposit> depositsMap;
  204. list<HouseHistory> history;
  205. };
  206. // Constants for STATs counters
  207. // Server Utilization
  208. #define STAT_SERVER_OS_TYPE 1 // what OS this server is running on
  209. #define STAT_SERVER_CPU_TYPE 2 // cpu type/speed (ie., Intel P4 3.0GHz)
  210. #define STAT_SERVER_CPU_CURRENT 3 // current CPU usage by EQ2World.exe process
  211. #define STAT_SERVER_CPU_PEAK 4 // highest CPU usage by EQ2World.exe this session
  212. #define STAT_SERVER_PHYSICAL_RAM_TOTAL 5 // total RAM in server
  213. #define STAT_SERVER_PHYSICAL_RAM_CURRENT 6 // current RAM usage by EQ2World.exe
  214. #define STAT_SERVER_PHYSICAL_RAM_PEAK 7 // highest RAM usage by EQ2World.exe this session
  215. #define STAT_SERVER_VIRTUAL_RAM_TOTAL 8 // total vRAM in server
  216. #define STAT_SERVER_VIRTUAL_RAM_CURRENT 9 // current vRAM usage by EQ2World.exe
  217. #define STAT_SERVER_VIRTUAL_RAM_PEAK 10 // highest vRAM usage by EQ2World.exe this session
  218. #define STAT_SERVER_DISK_USAGE 11 // size of /eq2emulator folder and contents
  219. #define STAT_SERVER_THREAD_COUNT 12 // thread count of EQ2World.exe process
  220. #define STAT_SERVER_AVG_LATENCY 13 // network latency between world and loginserver
  221. // Server Stats
  222. #define STAT_SERVER_CREATED 100 // unix_timestamp of date server first came online
  223. #define STAT_SERVER_START_TIME 101 // unix_timestamp of date/time server booted up
  224. #define STAT_SERVER_ACCEPTED_CONNECTION 102 // successful connections since server startup
  225. #define STAT_SERVER_MOST_CONNECTIONS 103 // most players online in history of server
  226. #define STAT_SERVER_NUM_ACCOUNTS 104 // total number of unique accounts
  227. #define STAT_SERVER_NUM_CHARACTERS 105 // total number of player characters
  228. #define STAT_SERVER_AVG_CHAR_LEVEL 106 // average level of player characters
  229. #define STAT_SERVER_NUM_ACTIVE_ZONES 107 // number of currently running/loaded zones
  230. #define STAT_SERVER_NUM_ACTIVE_INSTANCES 108 // number of active zones that are "instances"
  231. // Player PvE counters
  232. #define STAT_PLAYER_TOTAL_NPC_KILLS 1000 // total NPC kills by player
  233. #define STAT_PLAYER_TOTAL_DEATHS 1001 // total non-PvP deaths of player
  234. #define STAT_PLAYER_KVD_RATIO 1002 // kill-versus-death ratio of player
  235. #define STAT_PLAYER_HIGHEST_MELEE_HIT 1003 // players highest melee hit to date
  236. #define STAT_PLAYER_HIGHEST_MAGIC_HIT 1004 // players highest magic hit to date
  237. #define STAT_PLAYER_HIGHEST_HO_HIT 1005 // players highest heroic opportunity hit
  238. #define STAT_PLAYER_TOTAL_STATUS 1006 // player total status
  239. #define STAT_PLAYER_TOTAL_WEALTH 1007 // player total wealth
  240. #define STAT_PLAYER_QUESTS_COMPLETED 1008 // total quests completed
  241. #define STAT_PLAYER_RECIPES_KNOWN 1009 // total recipes player knows
  242. #define STAT_PLAYER_TOTAL_CRAFTED_ITEMS 1010 // total items crafted by player
  243. #define STAT_PLAYER_ITEMS_DISCOVERED 1011 // total items discovered by player
  244. #define STAT_PLAYER_RARES_HARVESTED 1012 // total rare harvests by player
  245. #define STAT_PLAYER_ITEMS_HARVESTED 1013 // total rare harvests by player
  246. #define STAT_PLAYER_MASTER_ABILITIES 1014 // total master abilities player has
  247. #define STAT_PLAYER_HIGHEST_FALLING_HIT 1015 // player's highest damage amount taken from falling
  248. // Player PvP counters
  249. #define STAT_PLAYER_TOTAL_PVP_KILLS 1100 // total PVP kills by player
  250. #define STAT_PLAYER_PVP_KILL_STREAK 1101 // longest PVP kill streak of player
  251. #define STAT_PLAYER_TOTAL_PVP_DEATHS 1102 // total PVP deaths of player
  252. #define STAT_PLAYER_PVP_DEATH_STREAK 1103 // longest PVP death streak of player
  253. #define STAT_PLAYER_PVP_KVD_RATIO 1104 // PVP kill-versus-death ratio of player
  254. #define STAT_PLAYER_TOTAL_ARENA_KILLS 1105 // total Arena kills of player
  255. // MOST stats for players
  256. #define STAT_PLAYER_MOST_NPC_KILLS 1200 // IPvP: Player with most NPC kills
  257. #define STAT_PLAYER_MOST_NPC_DEATHS 1201 // IPvP: Player with most non-PVP deaths
  258. #define STAT_PLAYER_MOST_PVP_KILLS 1202 // IPvP: Player with most PvP kills
  259. #define STAT_PLAYER_MOST_PVP_DEATHS 1203 // IPvP: Player with most PvP deaths
  260. #define STAT_PLAYER_MOST_ARENA_KILLS 1204 // IPvP: Player with most Arena kills
  261. #define STAT_PLAYER_MOST_STATUS 1205 // IPvP: Player with most Status
  262. #define STAT_PLAYER_MOST_WEALTH 1206 // IPvP: Player with most Wealth
  263. // HIGHEST stats for players
  264. #define STAT_PLAYER_HIGHEST_NPC_KVD_RATIO 1300 // IPvP: Player with highest NPC kill-versus-death ratio
  265. #define STAT_PLAYER_HIGHEST_PVP_KILL_STREAK 1301 // IPvP: Player with longest PvP kill streak
  266. #define STAT_PLAYER_HIGHEST_PVP_DEATH_STREAK 1302 // IPvP: Player with longest PvP death streak
  267. #define STAT_PLAYER_HIGHEST_PVP_KVD_RATIO 1303 // IPvP: Player with highest PvP kill-versus-death ratio
  268. #define STAT_PLAYER_HIGHEST_HP 1304 // IPvP: Player with highest HP on server
  269. #define STAT_PLAYER_HIGHEST_POWER 1305 // IPvP: Player with highest Power on server
  270. #define STAT_PLAYER_HIGHEST_RESISTS 1306 // IPvP: Player with highest Resists on server
  271. struct Statistic {
  272. int32 stat_id;
  273. sint32 stat_value;
  274. int32 stat_date;
  275. bool save_needed;
  276. };
  277. // Player EVENT defines
  278. // Some EVENTs are single occurrance (S), while others are cummulative throughout the life of the player (C)
  279. #define PLAYER_EVENT_NEW_ADV_LEVEL 2000 // (C) player achieves a new adventure level
  280. #define PLAYER_EVENT_NEW_TS_LEVEL 2001 // (C) player achieves a new tradeskill level
  281. #define PLAYER_EVENT_NEW_AA 2002 // (C) player earns AA pt
  282. #define PLAYER_EVENT_NEW_ACHIEVEMENT 2003 // (C) player new achievement
  283. #define PLAYER_EVENT_LAST_DEATH 2004 // (S) player was last killed
  284. #define PLAYER_EVENT_LAST_KILL 2005 // (S) player last killed spawn_id
  285. #define PLAYER_EVENT_DISCOVER_POI 2006 // (C) player discovers location_id
  286. // These maybe should be World stat events, since it is about 1 player discovering a new item?
  287. #define PLAYER_EVENT_DISCOVER_ITEM 2007 // (C) player discovers item_id
  288. #define PLAYER_EVENT_DISCOVER_RECIPE 2008 // (C) player discovers recipe_id
  289. struct PlayerHistory {
  290. int32 history_zone;
  291. int32 history_id;
  292. sint32 history_value;
  293. int32 history_date;
  294. bool save_needed;
  295. };
  296. struct GlobalLoot {
  297. int8 minLevel;
  298. int8 maxLevel;
  299. int32 table_id;
  300. int32 loot_tier;
  301. };
  302. #define TRANSPORT_TYPE_LOCATION 0
  303. #define TRANSPORT_TYPE_ZONE 1
  304. #define TRANSPORT_TYPE_GENERIC 2
  305. #define TRANSPORT_TYPE_FLIGHT 3
  306. // structs MUST start with class_id and race_id, in that order as int8's
  307. struct StartingStructHeader
  308. {
  309. int8 class_id;
  310. int8 race_id;
  311. };
  312. struct StartingSkill
  313. {
  314. StartingStructHeader header;
  315. int32 skill_id;
  316. int16 current_val;
  317. int16 max_val;
  318. int32 progress; // what is this for..?
  319. };
  320. struct StartingSpell
  321. {
  322. StartingStructHeader header;
  323. int32 spell_id;
  324. int8 tier;
  325. int32 knowledge_slot;
  326. };
  327. #define MAX_VOICEOVER_TYPE 2
  328. struct VoiceOverStruct{
  329. string mp3_string;
  330. string text_string;
  331. string emote_string;
  332. int32 key1;
  333. int32 key2;
  334. bool is_garbled;
  335. int8 garble_link_id;
  336. };
  337. class ZoneList {
  338. public:
  339. ZoneList();
  340. ~ZoneList();
  341. void Add(ZoneServer* zone);
  342. void Remove(ZoneServer* zone);
  343. ZoneServer* Get(int32 id, bool loadZone = true, bool skip_existing_zones = false, bool increment_zone = true);
  344. ZoneServer* Get(const char* zone_name, bool loadZone=true, bool skip_existing_zones = false, bool increment_zone = true);
  345. ZoneServer* GetByInstanceID(int32 id, int32 zone_id=0, bool skip_existing_zones = false, bool increment_zone = true);
  346. /// <summary>Get the instance for the given zone id with the lowest population</summary>
  347. /// <param name='zone_id'>The id of the zone to look up</param>
  348. /// <returns>ZoneServer* of an active zone with the given id</returns>
  349. ZoneServer* GetByLowestPopulation(int32 zone_id);
  350. int32 GetZonesPlayersCount();
  351. void AddClientToMap(string name, Client* client){
  352. name = ToLower(name);
  353. MClientList.lock();
  354. client_map[name] = client;
  355. MClientList.unlock();
  356. }
  357. void CheckFriendList(Client* client);
  358. void CheckFriendZoned(Client* client);
  359. // move to Chat/Chat.h?
  360. bool HandleGlobalChatMessage(Client* from, char* to, int16 channel, const char* message, const char* channel_name = 0, int32 current_language_id = 0);
  361. void HandleGlobalBroadcast(const char* message);
  362. void HandleGlobalAnnouncement(const char* message);
  363. //
  364. int32 Count();
  365. Client* GetClientByCharName(string name){
  366. name = ToLower(name);
  367. Client* ret = 0;
  368. MClientList.lock();
  369. if(client_map.count(name) > 0)
  370. ret = client_map[name];
  371. MClientList.unlock();
  372. return ret;
  373. }
  374. Client* GetClientByCharID(int32 id) {
  375. Client* ret = 0;
  376. MClientList.lock();
  377. map<string, Client*>::iterator itr;
  378. for (itr = client_map.begin(); itr != client_map.end(); itr++) {
  379. if (itr->second->GetCharacterID() == id) {
  380. ret = itr->second;
  381. break;
  382. }
  383. }
  384. MClientList.unlock();
  385. return ret;
  386. }
  387. Client* GetClientByEQStream(EQStream* eqs) {
  388. Client* ret = 0;
  389. if (eqs) {
  390. MClientList.lock();
  391. map<string, Client*>::iterator itr;
  392. for (itr = client_map.begin(); itr != client_map.end(); itr++) {
  393. if (itr->second->getConnection() == eqs) {
  394. ret = itr->second;
  395. break;
  396. }
  397. }
  398. MClientList.unlock();
  399. }
  400. return ret;
  401. }
  402. void UpdateVitality(float amount);
  403. void RemoveClientFromMap(string name, Client* client){
  404. name = ToLower(name);
  405. MClientList.lock();
  406. if(client_map.count(name) > 0 && client_map[name] == client)
  407. client_map.erase(name);
  408. MClientList.unlock();
  409. }
  410. bool ClientConnected(int32 account_id);
  411. void RemoveClientZoneReference(ZoneServer* zone);
  412. void ReloadClientQuests();
  413. bool DepopFinished();
  414. void Depop();
  415. void Repop();
  416. void DeleteSpellProcess();
  417. void LoadSpellProcess();
  418. void ProcessWhoQuery(const char* query, Client* client);
  419. void ProcessWhoQuery(vector<string>* queries, ZoneServer* zone, vector<Entity*>* players, bool isGM);
  420. void SendZoneList(Client* client);
  421. void WritePlayerStatistics();
  422. void ShutDownZones();
  423. void ReloadMail();
  424. void ReloadSpawns();
  425. void WatchdogHeartbeat();
  426. void SendTimeUpdate();
  427. void PopulateClientList(http::response<http::string_body>& res);
  428. private:
  429. Mutex MClientList;
  430. Mutex MZoneList;
  431. map<ZoneServer*, int32> removed_zoneservers;
  432. map<string,Client*> client_map;
  433. list<ZoneServer*> zlist;
  434. };
  435. class World {
  436. public:
  437. World();
  438. ~World();
  439. int8 GetClassID(const char* name);
  440. void Process();
  441. void init(std::string web_ipaddr, int16 web_port, std::string cert_file, std::string key_file, std::string key_password, std::string hardcode_user, std::string hardcode_password);
  442. PacketStruct* GetWorldTime(int16 version);
  443. void WorldTimeTick();
  444. float GetXPRate();
  445. float GetTSXPRate();
  446. void LoadVitalityInformation();
  447. void UpdateVitality();
  448. WorldTime* GetWorldTimeStruct(){
  449. return &world_time;
  450. }
  451. ulong GetCurrentThreadID();
  452. int64 GetThreadUsageCPUTime();
  453. // These 2 functions are never used. What was their purpose? Should they be removed?
  454. void AddNPCAppearance(int32 id, AppearanceData* appearance){ npc_appearance_list[id] = appearance; }
  455. AppearanceData* GetNPCAppearance(int32 id) { return npc_appearance_list[id]; }
  456. void ReloadGuilds();
  457. bool ReportBug(string data, char* player_name, int32 account_id, const char* spawn_name, int32 spawn_id, int32 zone_id);
  458. void AddSpawnScript(int32 id, const char* name);
  459. void AddSpawnEntryScript(int32 id, const char* name);
  460. void AddSpawnLocationScript(int32 id, const char* name);
  461. void AddZoneScript(int32 id, const char* name);
  462. const char* GetSpawnScript(int32 id);
  463. const char* GetSpawnEntryScript(int32 id);
  464. const char* GetSpawnLocationScript(int32 id);
  465. const char* GetZoneScript(int32 id);
  466. void ResetSpawnScripts();
  467. void ResetZoneScripts();
  468. int16 GetMerchantItemQuantity(int32 merchant_id, int32 item_id);
  469. void DecreaseMerchantQuantity(int32 merchant_id, int32 item_id, int16 amount);
  470. int32 GetInventoryID(int32 merchant_id, int32 item_id);
  471. void AddMerchantItem(int32 inventory_id, MerchantItemInfo ItemInfo);
  472. void RemoveMerchantItem(int32 inventory_id, int32 item_id);
  473. vector<MerchantItemInfo>* GetMerchantList(int32 merchant_id);
  474. vector<MerchantItemInfo>* GetMerchantItemList(int32 merchant_id, int8 merchant_type, Player* player);
  475. MerchantInfo* GetMerchantInfo(int32 merchant_id);
  476. map<int32, MerchantInfo*>* GetMerchantInfo();
  477. void AddMerchantInfo(int32 merchant_id, MerchantInfo* multiplier);
  478. void DeleteMerchantsInfo();
  479. void DeleteMerchantItems();
  480. void DeleteSpawns();
  481. vector<Variable*>* GetClientVariables();
  482. void WritePlayerStatistics();
  483. void WriteServerStatistics();
  484. void AddServerStatistic(int32 stat_id, sint32 stat_value, int32 stat_date);
  485. void UpdateServerStatistic(int32 stat_id, sint32 stat_value, bool overwrite = false);
  486. sint32 GetServerStatisticValue(int32 stat_id);
  487. void RemoveServerStatistics();
  488. //PlayerGroup* AddGroup(Client* leader);
  489. //void AddGroupMember(PlayerGroup* group, Client* member);
  490. //void RemoveGroupMember(Client* member, bool immediate = false);
  491. //void DisbandGroup(PlayerGroup* group, bool lock = true);
  492. void SendGroupQuests(PlayerGroup* group, Client* client);
  493. //void UpdateGroupBuffs();
  494. //void RemoveGroupBuffs(PlayerGroup *group, Client *client);
  495. //void SetPendingGroup(char* name, char* leader);
  496. //void GroupMessage(PlayerGroup* group, const char* message, ...);
  497. //void SimpleGroupMessage(PlayerGroup* group, const char* message);
  498. //void GroupChatMessage(PlayerGroup* group, Spawn* from, const char* message);
  499. //const char* GetPendingGroup(string name);
  500. //void GroupReadLock();
  501. //void GroupReadUnLock();
  502. //void CheckRemoveGroupedPlayer();
  503. //void SendGroupUpdate(PlayerGroup* group, Client* exclude = 0);
  504. bool RejoinGroup(Client* client, int32 group_id);
  505. //bool MakeLeader(Client* leader, string new_leader);
  506. void AddBonuses(Item* item, ItemStatsValues* values, int16 type, sint32 value, Entity* entity);
  507. void CreateGuild(const char* guild_name, Client* leader = 0, int32 group_id = 0);
  508. void SaveGuilds();
  509. void PickRandomLottoDigits(int32* digits);
  510. void AddLottoPlayer(int32 character_id, int32 end_time);
  511. void RemoveLottoPlayer(int32 character_id);
  512. void SetLottoPlayerNumMatches(int32 character_id, int8 num_matches);
  513. void CheckLottoPlayers();
  514. void PopulateTOVStatMap();
  515. int32 LoadItemBlueStats();
  516. sint16 GetItemStatAOMValue(sint16 subtype);
  517. sint16 GetItemStatTOVValue(sint16 subtype);
  518. sint16 GetItemStatDOVValue(sint16 subtype);
  519. sint16 GetItemStatCOEValue(sint16 subtype);
  520. sint16 GetItemStatKAValue(sint16 subtype);
  521. sint16 GetItemStatTESTValue(sint16 subtype);
  522. int8 TranslateSlotSubTypeToClient(Client* client, int8 stat_type, sint16 sub_type);
  523. vector<string> biography;
  524. volatile bool items_loaded;
  525. volatile bool spells_loaded;
  526. volatile bool achievments_loaded;
  527. std::atomic<bool> world_loaded;
  528. std::atomic<int64> world_uptime;
  529. void AddHouseZone(int32 id, string name, int64 cost_coins, int32 cost_status, int64 upkeep_coins, int32 upkeep_status, int8 vault_slots, int8 alignment, int8 guild_level, int32 zone_id, int32 exit_zone_id, float exit_x, float exit_y, float exit_z, float exit_heading);
  530. HouseZone* GetHouseZone(int32 id);
  531. void AddPlayerHouse(int32 char_id, int32 house_id, int64 unique_id, int32 instance_id, int32 upkeep_due, int64 escrow_coins, int32 escrow_status, string player_name);
  532. PlayerHouse* GetPlayerHouseByHouseID(int32 char_id, int32 house_id);
  533. PlayerHouse* GetPlayerHouseByUniqueID(int64 unique_id);
  534. PlayerHouse* GetPlayerHouseByInstanceID(int32 instance_id);
  535. vector<PlayerHouse*> GetAllPlayerHouses(int32 char_id);
  536. vector<PlayerHouse*> GetAllPlayerHousesByHouseID(int32 house_id);
  537. PlayerHouse* GetPlayerHouse(Client* client, int32 spawn_id, int64 unique_house_id, HouseZone** set_house_zone);
  538. void ReloadHouseData(PlayerHouse* ph);
  539. PlayerGroupManager* GetGroupManager() { return &m_playerGroupManager; }
  540. bool CheckTempBugCRC(char* msg);
  541. void SyncCharacterAbilities(Client* client);
  542. void LoadStartingLists();
  543. void PurgeStartingLists();
  544. multimap<int8, multimap<int8, StartingSkill>*> starting_skills;
  545. multimap<int8, multimap<int8, StartingSpell>*> starting_spells;
  546. Mutex MStartingLists;
  547. void SetReloadingSubsystem(string subsystem);
  548. void RemoveReloadingSubSystem(string subsystem);
  549. bool IsReloadingSubsystems();
  550. int32 GetSuppressedWarningTime() {
  551. return suppressed_warning;
  552. }
  553. void SetSuppressedWarning() { suppressed_warning = Timer::GetCurrentTime2(); }
  554. map<string, int32> GetOldestReloadingSubsystem();
  555. void LoadRegionMaps(std::string zoneFile);
  556. RegionMap* GetRegionMap(std::string zoneFile, int32 client_version);
  557. void LoadMaps(std::string zoneFile);
  558. void RemoveMaps(std::string zoneFile);
  559. Map* GetMap(std::string zoneFile, int32 client_version);
  560. void SendTimeUpdate();
  561. // just in case we roll over a time as to not send bad times to clients (days before hours, hours before minutes as examples)
  562. Mutex MWorldTime;
  563. void LoadVoiceOvers();
  564. void PurgeVoiceOvers();
  565. typedef std::multimap<int16, VoiceOverStruct>::iterator VOMapIterator;
  566. bool FindVoiceOver(int8 type, int32 id, int16 index, VoiceOverStruct* struct_ = nullptr, bool* find_garbled = nullptr, VoiceOverStruct* garble_struct_ = nullptr);
  567. void AddVoiceOver(int8 type, int32 id, int16 index, VoiceOverStruct* struct_);
  568. void CopyVoiceOver(VoiceOverStruct* struct1, VoiceOverStruct* struct2);
  569. /* NPC Spells */
  570. void AddNPCSpell(int32 list_id, int32 spell_id, int8 tier, bool spawn_cast, bool aggro_cast, sint8 req_hp_ratio);
  571. vector<NPCSpell*>* GetNPCSpells(int32 primary_list, int32 secondary_list);
  572. void PurgeNPCSpells();
  573. static void Web_worldhandle_status(const http::request<http::string_body>& req, http::response<http::string_body>& res);
  574. static void Web_worldhandle_clients(const http::request<http::string_body>& req, http::response<http::string_body>& res);
  575. static void Web_worldhandle_setadminstatus(const http::request<http::string_body>& req, http::response<http::string_body>& res);
  576. Mutex MVoiceOvers;
  577. static sint64 newValue;
  578. private:
  579. multimap<int32, multimap<int16, VoiceOverStruct>*> voiceover_map[3];
  580. int32 suppressed_warning = 0;
  581. map<string, int32> reloading_subsystems;
  582. //void RemovePlayerFromGroup(PlayerGroup* group, GroupMemberInfo* info, bool erase = true);
  583. //void DeleteGroupMember(GroupMemberInfo* info);
  584. Mutex MReloadingSubsystems;
  585. Mutex MMerchantList;
  586. Mutex MSpawnScripts;
  587. Mutex MZoneScripts;
  588. //Mutex MGroups;
  589. mutable std::shared_mutex MNPCSpells;
  590. map<int32, MerchantInfo*> merchant_info;
  591. map<int32, vector<MerchantItemInfo> > merchant_inventory_items;
  592. int32 vitality_frequency;
  593. float vitality_amount;
  594. float xp_rate;
  595. float ts_xp_rate; // JA
  596. WorldTime world_time;
  597. map<int32,AppearanceData*> npc_appearance_list;
  598. map<int32, string> spawn_scripts;
  599. map<int32, string> spawnentry_scripts;
  600. map<int32, string> spawnlocation_scripts;
  601. map<int32, string> zone_scripts;
  602. //vector<PlayerGroup*> player_groups;
  603. //map<GroupMemberInfo*, int32> group_removal_pending;
  604. //map<string, string> pending_groups;
  605. map<int32, Statistic*> server_statistics;
  606. MutexMap<int32, LottoPlayer*> lotto_players;
  607. int32 last_checked_time;
  608. Timer save_time_timer;
  609. Timer time_tick_timer;
  610. Timer vitality_timer;
  611. Timer player_stats_timer;
  612. Timer server_stats_timer;
  613. //Timer remove_grouped_player;
  614. Timer guilds_timer;
  615. Timer lotto_players_timer;
  616. Timer group_buff_updates;
  617. Timer watchdog_timer;
  618. map<int32, HouseZone*> m_houseZones;
  619. // Map <house id, map<char id, player house>>
  620. map<int32, map<int32, PlayerHouse*> > m_playerHouses;
  621. Mutex MHouseZones;
  622. Mutex MPlayerHouses;
  623. map<int16,int16> tov_itemstat_conversion;
  624. map<int16,int16> dov_itemstat_conversion;
  625. map<int16,int16> coe_itemstat_conversion;
  626. map<int16,int16> ka_itemstat_conversion;
  627. PlayerGroupManager m_playerGroupManager;
  628. Mutex MBugReport;
  629. map<sint32, bool> bug_report_crc;
  630. std::map<std::string, RegionMapRange*> region_maps;
  631. std::map<std::string, MapRange*> maps;
  632. Mutex MWorldMaps;
  633. Mutex MWorldRegionMaps;
  634. map<int32, map<int32, NPCSpell*> > npc_spell_list;
  635. WebServer* world_webserver;
  636. };
  637. #endif