World.h 24 KB

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