9
3

zoneserver.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  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 ZONESERVER_H
  17. #define ZONESERVER_H
  18. #include "../common/linked_list.h"
  19. #include "../common/timer.h"
  20. #include "../common/queue.h"
  21. #include "../common/servertalk.h"
  22. #include "../common/TCPConnection.h"
  23. #include "WorldTCPConnection.h"
  24. #include "../common/Mutex.h"
  25. #include "../common/DataBuffer.h"
  26. #include "net.h"
  27. #include "Player.h"
  28. #include "Combat.h"
  29. #include <list>
  30. #include <map>
  31. #include <set>
  32. #include "MutexList.h"
  33. #include "MutexMap.h"
  34. #include "MutexVector.h"
  35. #include "NPC.h"
  36. #include "Widget.h"
  37. #include "Object.h"
  38. #include "GroundSpawn.h"
  39. #include "Sign.h"
  40. #include "Zone/map.h"
  41. #include "Zone/pathfinder_interface.h"
  42. #include "Zone/mob_movement_manager.h"
  43. #include "Zone/region_map.h"
  44. extern NetConnection net; // needs to be here or compile errors in commands.cpp
  45. class SpellProcess;
  46. class TradeskillMgr;
  47. class Bot;
  48. #define EXPANSION_UNKNOWN 1
  49. #define EXPANSION_UNKNOWN2 64
  50. #define EXPANSION_UNKNOWN3 128
  51. #define EXPANSION_UNKNOWN4 256
  52. #define EXPANSION_UNKNOWN5 512
  53. #define EXPANSION_DOF 1024
  54. #define EXPANSION_KOS 2048
  55. #define EXPANSION_EOF 4096
  56. #define EXPANSION_ROK 8192
  57. #define EXPANSION_TSO 16384
  58. #define EXPANSION_DOV 65536 // This enables DoV and CoE AA tree's lower values disable both trees
  59. // Can't verify these 3 values
  60. // 32768 - SF
  61. // 131072 - AoD
  62. #define SPAWN_SCRIPT_SPAWN 0
  63. #define SPAWN_SCRIPT_RESPAWN 1
  64. #define SPAWN_SCRIPT_ATTACKED 2
  65. #define SPAWN_SCRIPT_TARGETED 3
  66. #define SPAWN_SCRIPT_HAILED 4
  67. #define SPAWN_SCRIPT_DEATH 5
  68. #define SPAWN_SCRIPT_KILLED 6
  69. #define SPAWN_SCRIPT_AGGRO 7
  70. #define SPAWN_SCRIPT_HEALTHCHANGED 8
  71. #define SPAWN_SCRIPT_RANDOMCHAT 9
  72. #define SPAWN_SCRIPT_CONVERSATION 10
  73. #define SPAWN_SCRIPT_TIMER 11
  74. #define SPAWN_SCRIPT_CUSTOM 12
  75. #define SPAWN_SCRIPT_HAILED_BUSY 13
  76. #define SPAWN_SCRIPT_CASTED_ON 14
  77. #define SPAWN_SCRIPT_AUTO_ATTACK_TICK 15
  78. #define SPAWN_SCRIPT_COMBAT_RESET 16
  79. #define SPAWN_SCRIPT_GROUP_DEAD 17
  80. #define SPAWN_SCRIPT_HEAR_SAY 18
  81. #define SPAWN_SCRIPT_PRESPAWN 19
  82. #define SPAWN_SCRIPT_USEDOOR 20
  83. #define SPAWN_SCRIPT_BOARD 21
  84. #define SPAWN_SCRIPT_DEBOARD 22
  85. #define SPAWN_CONDITIONAL_NONE 0
  86. #define SPAWN_CONDITIONAL_DAY 1
  87. #define SPAWN_CONDITIONAL_NIGHT 2
  88. #define SPAWN_CONDITIONAL_NOT_RAINING 4
  89. #define SPAWN_CONDITIONAL_RAINING 8
  90. #define MAX_REVIVEPOINT_DISTANCE 1000
  91. /* JA: TODO Turn into R_World Rules */
  92. #define SEND_SPAWN_DISTANCE 250 /* when spawns appear visually to the client */
  93. #define HEAR_SPAWN_DISTANCE 30 /* max distance a client can be from a spawn to 'hear' it */
  94. #define MAX_CHASE_DISTANCE 80
  95. #define REMOVE_SPAWN_DISTANCE 300 // increased distance between send/remove is ideal, this makes sure there is no overlap if a 'fast' client (AKA GM warp speed)
  96. #define TRACKING_STOP 0
  97. #define TRACKING_START 1
  98. #define TRACKING_UPDATE 2
  99. #define TRACKING_CLOSE_WINDOW 3
  100. #define TRACKING_TYPE_ENTITIES 1
  101. #define TRACKING_TYPE_HARVESTABLES 2
  102. #define TRACKING_SPAWN_TYPE_PC 0
  103. #define TRACKING_SPAWN_TYPE_NPC 1
  104. #define WAYPOINT_CATEGORY_GROUP 0
  105. #define WAYPOINT_CATEGORY_QUESTS 1
  106. #define WAYPOINT_CATEGORY_PEOPLE 2
  107. #define WAYPOINT_CATEGORY_PLACES 3
  108. #define WAYPOINT_CATEGORY_USER 4
  109. #define WAYPOINT_CATEGORY_DIRECTIONS 5
  110. #define WAYPOINT_CATEGORY_TRACKING 6
  111. #define WAYPOINT_CATEGORY_HOUSES 7
  112. #define WAYPOINT_CATEGORY_MAP 8
  113. struct PlayerProximity{
  114. float distance;
  115. string in_range_lua_function;
  116. string leaving_range_lua_function;
  117. map<Client*, bool> clients_in_proximity;
  118. };
  119. struct LocationProximity {
  120. float x;
  121. float y;
  122. float z;
  123. float max_variation;
  124. string in_range_lua_function;
  125. string leaving_range_lua_function;
  126. map<Client*, bool> clients_in_proximity;
  127. };
  128. struct LocationGrid {
  129. int32 id;
  130. int32 grid_id;
  131. string name;
  132. bool include_y;
  133. bool discovery;
  134. MutexList<Location*> locations;
  135. MutexMap<Player*, bool> players;
  136. };
  137. struct TrackedSpawn {
  138. Spawn* spawn;
  139. float distance;
  140. };
  141. struct HouseItem {
  142. int32 spawn_id;
  143. int32 item_id;
  144. int32 unique_id;
  145. Item* item;
  146. };
  147. class Widget;
  148. class Client;
  149. class Sign;
  150. class Object;
  151. class GroundSpawn;
  152. struct GroundSpawnEntry;
  153. struct GroundSpawnEntryItem;
  154. struct LootTable;
  155. struct LootDrop;
  156. struct GlobalLoot;
  157. struct TransportDestination;
  158. struct LocationTransportDestination;
  159. #ifdef WIN32
  160. void ZoneLoop(void *tmp);
  161. void SpawnLoop(void *tmp);
  162. void SendInitialSpawns(void *tmp);
  163. void SendLevelChangedSpawns(void*tmp);
  164. #else
  165. void *ZoneLoop(void *tmp);
  166. void *SpawnLoop(void *tmp);
  167. void *SendInitialSpawns(void *tmp);
  168. void *SendLevelChangedSpawns(void *tmp);
  169. #endif
  170. using namespace std;
  171. struct RevivePoint{
  172. int32 id;
  173. int32 zone_id; //usually this zone, but not always
  174. string location_name;
  175. float x;
  176. float y;
  177. float z;
  178. float heading;
  179. };
  180. struct SpawnScriptTimer {
  181. int32 timer;
  182. int32 spawn;
  183. int32 player;
  184. string function;
  185. int32 current_count;
  186. int32 max_count;
  187. };
  188. enum Instance_Type {
  189. NONE,
  190. GROUP_LOCKOUT_INSTANCE,
  191. GROUP_PERSIST_INSTANCE,
  192. RAID_LOCKOUT_INSTANCE,
  193. RAID_PERSIST_INSTANCE,
  194. SOLO_LOCKOUT_INSTANCE,
  195. SOLO_PERSIST_INSTANCE,
  196. TRADESKILL_INSTANCE, // allows anyone to enter, server searches for the first instance that is available
  197. PUBLIC_INSTANCE, // same as tradeskill, except dead spawns are tracked
  198. PERSONAL_HOUSE_INSTANCE,
  199. GUILD_HOUSE_INSTANCE,
  200. QUEST_INSTANCE
  201. };
  202. struct FlightPathInfo {
  203. float speed;
  204. bool flying;
  205. bool dismount;
  206. };
  207. struct FlightPathLocation {
  208. float X;
  209. float Y;
  210. float Z;
  211. };
  212. struct ZoneInfoSlideStructInfo {
  213. float unknown1[2];
  214. int32 unknown2[2];
  215. int32 unknown3;
  216. int32 unknown4;
  217. char slide[128];
  218. char voiceover[128];
  219. int32 key1;
  220. int32 key2;
  221. };
  222. struct ZoneInfoSlideStructTransitionInfo {
  223. int32 transition_x;
  224. int32 transition_y;
  225. float transition_zoom;
  226. float transition_time;
  227. };
  228. struct ZoneInfoSlideStruct {
  229. ZoneInfoSlideStructInfo* info;
  230. vector<ZoneInfoSlideStructTransitionInfo*> slide_transition_info;
  231. };
  232. enum SUBSPAWN_TYPES {
  233. COLLECTOR = 0,
  234. HOUSE_ITEM_SPAWN = 1,
  235. MAX_SUBSPAWN_TYPE = 20
  236. };
  237. // need to attempt to clean this up and add xml comments, remove unused code, find a logical way to sort the functions maybe by get/set/process/add etc...
  238. class ZoneServer {
  239. public:
  240. ZoneServer(const char* file, bool incoming_client=false);
  241. ~ZoneServer();
  242. void IncrementIncomingClients();
  243. void DecrementIncomingClients();
  244. void Init();
  245. bool Process();
  246. bool SpawnProcess();
  247. ZoneInfoSlideStruct* GenerateSlideStruct(float unknown1a, float unknown1b, int32 unknown2a, int32 unknown2b, int32 unknown3, int32 unknown4, const char* slide, const char* voiceover, int32 key1, int32 key2);
  248. void AddZoneInfoSlideStructTransitionInfo(ZoneInfoSlideStruct* info, int32 x, int32 y, float zoom, float transition_time);
  249. vector<ZoneInfoSlideStruct*>* GenerateTutorialSlides();
  250. void LoadRevivePoints(vector<RevivePoint*>* revive_points);
  251. vector<RevivePoint*>* GetRevivePoints(Client* client);
  252. RevivePoint* GetRevivePoint(int32 id);
  253. void AddClient(Client* client);
  254. void SimpleMessage(int8 type, const char* message, Spawn* from, float distance, bool send_to_sender = true);
  255. void HandleChatMessage(Spawn* from, const char* to, int16 channel, const char* message, float distance = 0, const char* channel_name = 0, bool show_bubble = true, int32 language = 0);
  256. void HandleChatMessage(Client* client, Spawn* from, const char* to, int16 channel, const char* message, float distance = 0, const char* channel_name = 0, bool show_bubble = true, int32 language = 0);
  257. void HandleBroadcast(const char* message);
  258. void HandleAnnouncement(const char* message);
  259. int16 SetSpawnTargetable(Spawn* spawn, float distance);
  260. int16 SetSpawnTargetable(int32 spawn_id);
  261. void ApplySetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value);
  262. void SetSpawnCommand(Spawn* spawn, int8 type, char* value, Client* client = 0);
  263. void SetSpawnCommand(int32 spawn_id, int8 type, char* value, Client* client = 0);
  264. void AddLoot(NPC* npc, Spawn* killer = nullptr);
  265. NPC* AddNPCSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  266. Object* AddObjectSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  267. GroundSpawn* AddGroundSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  268. Widget* AddWidgetSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  269. Sign* AddSignSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  270. void AddSpawn(Spawn* spawn);
  271. void RemoveDeadEnemyList(Spawn* spawn);
  272. void RemoveDeadSpawn(Spawn* spawn);
  273. void AddSpawnGroupLocation(int32 group_id, int32 location_id, int32 spawn_location_id);
  274. void AddSpawnGroupAssociation(int32 group_id1, int32 group_id2);
  275. void AddSpawnGroupChance(int32 group_id, float percent);
  276. void RemoveSpawn(Spawn* spawn, bool delete_spawn = true, bool respawn = true, bool lock = true, bool erase_from_spawn_list = true, bool lock_spell_process = false);
  277. void ProcessSpawnLocations();
  278. void SendQuestUpdates(Client* client, Spawn* spawn = 0);
  279. EQ2Packet* GetZoneInfoPacket(Client* client);
  280. Spawn* FindSpawn(Player* searcher, const char* name);
  281. bool CallSpawnScript(Spawn* npc, int8 type, Spawn* spawn = 0, const char* message = 0, bool is_door_open = false, sint32 input_value = 0, sint32* return_value = 0);
  282. void SendSpawnVisualState(Spawn* spawn, int16 type);
  283. void SendSpellFailedPacket(Client* client, int16 error);
  284. void SendInterruptPacket(Spawn* interrupted, LuaSpell* spell, bool fizzle=false);
  285. void HandleEmote(Client* originator, string name);
  286. Client* GetClientBySpawn(Spawn* spawn);
  287. Spawn* GetSpawnByDatabaseID(int32 id);
  288. Spawn* GetSpawnByID(int32 id, bool spawnListLocked=false);
  289. void PlaySoundFile(Client* client, const char* name, float origin_x, float origin_y, float origin_z);
  290. void SendZoneSpawns(Client* client);
  291. void StartZoneInitialSpawnThread(Client* client);
  292. void SendSpawnChanges();
  293. void SendSpawnChanges(Spawn* spawn);
  294. void SendSpawnChanges(Spawn* spawn, Client* client, bool override_changes = false, bool override_vis_changes = false);
  295. void SendSpawnChangesByDBID(int32 spawn_id, Client* client, bool override_changes = false, bool override_vis_changes = false);
  296. void SendPlayerPositionChanges(Player* player);
  297. void UpdateVitality(float amount);
  298. vector<Entity*> GetPlayers();
  299. void KillSpawn(bool spawnListLocked, Spawn* dead, Spawn* killer, bool send_packet = true, int8 type = 0, int8 damage_type = 0, int16 kill_blow_type = 0);
  300. void SendDamagePacket(Spawn* attacker, Spawn* victim, int8 type1, int8 type2, int8 damage_type, int16 damage, const char* spell_name);
  301. void SendHealPacket(Spawn* caster, Spawn* target, int16 type, int32 heal_amt, const char* spell_name);
  302. void SendCastSpellPacket(LuaSpell* spell, Entity* caster);
  303. void SendCastSpellPacket(int32 spell_visual, Spawn* target, Spawn* caster = 0);
  304. void SendCastEntityCommandPacket(EntityCommand* entity_command, int32 spawn_id, int32 target_id);
  305. void TriggerCharSheetTimer();
  306. /// <summary>Sends the game time packet to all connected clients</summary>
  307. void SendTimeUpdateToAllClients();
  308. void AddWidgetTimer(Spawn* widget, float time);
  309. bool HasWidgetTimer(Spawn* widget);
  310. void Despawn(Spawn* spawn, int32 timer);
  311. void RepopSpawns(Client* client, Spawn* spawn);
  312. bool AddCloseSpawnsToSpawnGroup(Spawn* spawn, float radius);
  313. void Depop(bool respawns = false, bool repop = false);
  314. Spawn* GetSpawnGroup(int32 id);
  315. void AddEnemyList(NPC* npc);
  316. void ReloadClientQuests();
  317. void SendAllSpawnsForLevelChange(Client* client);
  318. void SendAllSpawnsForSeeInvisChange(Client* client);
  319. void SendAllSpawnsForVisChange(Client* client, bool limitToEntities=true);
  320. void AddLocationGrid(LocationGrid* grid);
  321. void RemoveLocationGrids();
  322. void DeleteTransporters();
  323. void CheckTransporters(Client* client);
  324. void WritePlayerStatistics();
  325. bool SendRadiusSpawnInfo(Client* client, float radius);
  326. void FindSpawn(Client* client, char* regSearchStr);
  327. volatile bool spawnthread_active;
  328. volatile bool combatthread_active;
  329. volatile int8 initial_spawn_threads_active;
  330. volatile bool client_thread_active;
  331. void AddChangedSpawn(Spawn* spawn);
  332. void AddDamagedSpawn(Spawn* spawn);
  333. void AddDrowningVictim(Player* player);
  334. void RemoveDrowningVictim(Player* player);
  335. Client* GetDrowningVictim(Player* player);
  336. void DeleteSpellProcess();
  337. void LoadSpellProcess();
  338. void LockAllSpells(Player* player);
  339. void UnlockAllSpells(Player* player);
  340. void RemoveSpellTimersFromSpawn(Spawn* spawn, bool remove_all, bool delete_recast = true, bool call_expire_function = true, bool lock_spell_process = false);
  341. void Interrupted(Entity* caster, Spawn* interruptor, int16 error_code, bool cancel = false, bool from_movement = false);
  342. Spell* GetSpell(Entity* caster);
  343. void ProcessSpell(Spell* spell, Entity* caster, Spawn* target = 0, bool lock = true, bool harvest_spell = false, LuaSpell* customSpell = 0, int16 custom_cast_time = 0, bool in_heroic_opp = false);
  344. void ProcessEntityCommand(EntityCommand* entity_command, Entity* caster, Spawn* target, bool lock = true);
  345. void AddPlayerTracking(Player* player);
  346. void RemovePlayerTracking(Player* player, int8 mode);
  347. void SendUpdateTitles(Client *client, Title *suffix = 0, Title *prefix = 0);
  348. void SendUpdateTitles(Spawn *spawn, Title *suffix = 0, Title *prefix = 0);
  349. void RemoveTargetFromSpell(LuaSpell* spell, Spawn* target, bool remove_caster = false);
  350. /// <summary>Set the rain levl in the zone</summary>
  351. /// <param name='val'>Level of rain in the zone 0.0 - 1.1 (rain starts at 0.76)</param>
  352. void SetRain(float val);
  353. /// <summary>Sets the wind direction</summary>
  354. /// <param name='val'>Direction in degrees to set the wind</param>
  355. void SetWind(float val);
  356. /// <summary>Handles zone-wide weather changes</summary>
  357. void ProcessWeather();
  358. Spawn* GetClosestTransportSpawn(float x, float y, float z);
  359. Spawn* GetTransportByRailID(sint64 rail_id);
  360. void ResurrectSpawn(Spawn* spawn, Client* client);
  361. void HidePrivateSpawn(Spawn* spawn);
  362. Client* GetClientByName(char* name);
  363. Client* GetClientByCharID(int32 charid);
  364. /// <summary>Gets spawns for a true AoE spell</summary>
  365. vector<Spawn*> GetAttackableSpawnsByDistance(Spawn* spawn, float distance);
  366. void StartZoneSpawnsForLevelThread(Client* client);
  367. void SendDispellPacket(Entity* caster, Spawn* target, string dispell_name, string spell_name, int8 dispell_type);
  368. void SetupInstance(int32 createdInstanceID=0);
  369. void SendUpdateDefaultCommand(Spawn* spawn, const char* command, float distance, Spawn* toplayer = NULL);
  370. map<int32, int32>* GetSpawnLocationsByGroup(int32 group_id);
  371. IPathfinder* pathing;
  372. MobMovementManager* movementMgr;
  373. /****************************************************
  374. Following functions are only used for LUA commands
  375. ****************************************************/
  376. int32 GetClosestLocation(Spawn* spawn);
  377. Spawn* GetClosestSpawn(Spawn* spawn, int32 spawn_id);
  378. SpawnLocation* GetSpawnLocation(int32 id);
  379. void PlayFlavor(Client* client, Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language);
  380. void PlayVoice(Client* client, Spawn* spawn, const char* mp3, int32 key1, int32 key2);
  381. void PlayFlavor(Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language);
  382. void PlayFlavorID(Spawn* spawn, int8 type, int32 id, int16 index, int8 language);
  383. void PlayVoice(Spawn* spawn, const char* mp3, int32 key1, int32 key2);
  384. void SendThreatPacket(Spawn* caster, Spawn* target, int32 threat_amt, const char* spell_name);
  385. void KillSpawnByDistance(Spawn* spawn, float max_distance, bool include_players = false, bool send_packet = false);
  386. void SpawnSetByDistance(Spawn* spawn, float max_distance, string field, string value);
  387. void AddSpawnScriptTimer(SpawnScriptTimer* timer);
  388. Spawn* GetSpawnByLocationID(int32 location_id);
  389. void AddMovementNPC(Spawn* spawn);
  390. void AddPlayerProximity(Spawn* spawn, float distance, string in_range_function, string leaving_range_function);
  391. void AddLocationProximity(float x, float y, float z, float max_variation, string in_range_function, string leaving_range_function);
  392. void PlayAnimation(Spawn* spawn, int32 visual_state, Spawn* spawn2 = 0, int8 type = 1);
  393. void AddTransportSpawn(Spawn* spawn);
  394. vector<Spawn*> GetSpawnsByID(int32 id);
  395. vector<Spawn*> GetSpawnsByRailID(sint64 rail_id);
  396. void RemovePlayerPassenger(int32 char_id);
  397. bool IsDusk() { return isDusk; } // never used, probably meant for lua though
  398. /****************************************************
  399. Following functions are all contained in the header
  400. ****************************************************/
  401. inline const char* GetZoneName() { return zone_name; }
  402. void SetZoneName(char* new_zone) {
  403. if( strlen(new_zone) >= sizeof zone_name )
  404. return;
  405. strcpy(zone_name, new_zone);
  406. }
  407. inline const char* GetZoneFile() { return zone_file; }
  408. void SetZoneFile(char* zone) {
  409. if (strlen(zone) >= sizeof zone_file)
  410. return;
  411. strcpy(zone_file, zone);
  412. }
  413. inline const char* GetZoneSkyFile() { return zonesky_file; }
  414. void SetZoneSkyFile(char* zone) {
  415. if (strlen(zone) >= sizeof zonesky_file)
  416. return;
  417. strcpy(zonesky_file, zone);
  418. }
  419. inline const char* GetZoneDescription() { return zone_description; }
  420. void SetZoneDescription(char* desc) {
  421. if( strlen(desc) >= sizeof zone_description )
  422. return;
  423. strcpy(zone_description, desc);
  424. }
  425. void SetUnderWorld(float under){ underworld = under; }
  426. inline int32 GetZoneID() { return zoneID; }
  427. void SetZoneID(int32 new_id){ zoneID = new_id; }
  428. inline bool IsCityZone() { return cityzone; }
  429. inline bool AlwaysLoaded() { return always_loaded; }
  430. void SetCityZone(bool val) { cityzone = val; }
  431. void SetAlwaysLoaded(bool val) { always_loaded = val; }
  432. inline int32& NumPlayers() { return pNumPlayers; }
  433. void SetMinimumStatus(sint16 minStatus) { minimumStatus = minStatus; }
  434. sint16 GetMinimumStatus() { return minimumStatus; }
  435. void SetMinimumLevel(int16 minLevel) { minimumLevel = minLevel; }
  436. void SetMaximumLevel(int16 maxLevel) { maximumLevel = maxLevel; }
  437. void SetMinimumVersion(int16 minVersion) { minimumVersion = minVersion; }
  438. int16 GetMinimumLevel() { return minimumLevel; }
  439. int16 GetMaximumLevel() { return maximumLevel; }
  440. int16 GetMinimumVersion() { return minimumVersion; }
  441. inline bool GetZoneLockState() { return locked; } // JA: /zone lock|unlock
  442. void SetZoneLockState(bool lock_state) { locked = lock_state; } // JA: /zone lock|unlock
  443. int32 GetInstanceID() { return instanceID; }
  444. bool IsInstanceZone() { return isInstance; }
  445. void SetShutdownTimer(int val){
  446. shutdownTimer.SetTimer(val*1000);
  447. }
  448. void AddSpawnLocation(int32 id, SpawnLocation* spawnlocation) {
  449. MSpawnLocationList.writelock(__FUNCTION__, __LINE__);
  450. if (spawn_location_list.count(id) > 0)
  451. safe_delete(spawn_location_list[id]);
  452. spawn_location_list[id] = spawnlocation;
  453. MSpawnLocationList.releasewritelock(__FUNCTION__, __LINE__);
  454. }
  455. void SetInstanceType(int16 type) { InstanceType = (Instance_Type)type; if(type>0)isInstance=true; else isInstance=false; }
  456. Instance_Type GetInstanceType() { return InstanceType; }
  457. float GetSafeX(){ return safe_x; }
  458. float GetSafeY(){ return safe_y; }
  459. float GetSafeZ(){ return safe_z; }
  460. float GetSafeHeading() { return safe_heading; }
  461. void SetSafeX(float val){ safe_x = val; }
  462. void SetSafeY(float val){ safe_y = val; }
  463. void SetSafeZ(float val){ safe_z = val; }
  464. void SetSafeHeading(float val) { safe_heading = val; }
  465. float GetXPModifier() { return xp_mod; }
  466. void SetXPModifier(float val) { xp_mod = val; }
  467. void SetZoneMOTD(string z_motd) { zone_motd = z_motd; }
  468. string GetZoneMOTD() { return zone_motd; }
  469. bool isZoneShuttingDown ( ) { return zoneShuttingDown; }
  470. void Shutdown(){ zoneShuttingDown = true; }
  471. int32 GetClientCount(){ return clients.size(); }
  472. int32 GetDefaultLockoutTime() { return def_lockout_time; }
  473. int32 GetDefaultReenterTime() { return def_reenter_time; }
  474. int32 GetDefaultResetTime() { return def_reset_time; }
  475. int8 GetForceGroupZoneOption() { return group_zone_option; }
  476. void SetDefaultLockoutTime(int32 val) { def_lockout_time = val; }
  477. void SetDefaultReenterTime(int32 val) { def_reenter_time = val; }
  478. void SetDefaultResetTime(int32 val) { def_reset_time = val; }
  479. void SetForceGroupZoneOption(int8 val) { group_zone_option = val; }
  480. SpellProcess* GetSpellProcess() {return spellProcess;}
  481. bool FinishedDepop(){ return finished_depop; }
  482. /// <summary>Returns the Tradeskill Manager for this zone</summary>
  483. TradeskillMgr* GetTradeskillMgr() { return tradeskillMgr; }
  484. // had to add these to access weather from Commands
  485. bool isWeatherEnabled() { return weather_enabled; }
  486. void SetWeatherEnabled(bool val) { weather_enabled = val; }
  487. bool isWeatherAllowed() { return weather_allowed; }
  488. void SetWeatherAllowed(bool val) { weather_allowed = val; }
  489. int8 GetWeatherType() { return weather_type; }
  490. void SetWeatherType(int8 val) { weather_type = val; }
  491. int32 GetWeatherFrequency() { return weather_frequency; }
  492. void SetWeatherFrequency(int32 val) { weather_frequency = val; }
  493. float GetWeatherMinSeverity() { return weather_min_severity; }
  494. void SetWeatherMinSeverity(float val) { weather_min_severity = val; }
  495. float GetWeatherMaxSeverity() { return weather_max_severity; }
  496. void SetWeatherMaxSeverity(float val) { weather_max_severity = val; }
  497. float GetWeatherChangeAmount() { return weather_change_amount; }
  498. void SetWeatherChangeAmount(float val) { weather_change_amount = val; }
  499. float GetWeatherDynamicOffset() { return weather_dynamic_offset; }
  500. void SetWeatherDynamicOffset(float val) { weather_dynamic_offset = val; }
  501. int8 GetWeatherChance() { return weather_change_chance; }
  502. void SetWeatherChance(int8 val) { weather_change_chance = val; }
  503. float GetCurrentWeather() { return weather_current_severity; }
  504. void SetCurrentWeather(float val) { weather_current_severity = val; }
  505. int8 GetWeatherPattern() { return weather_pattern; }
  506. void SetWeatherPattern(int8 val) { weather_pattern = val; }
  507. void SetWeatherLastChangedTime(int32 val) { weather_last_changed_time = val; }
  508. int32 GetExpansionFlag() { return expansion_flag; }
  509. void SetExpansionFlag(int32 val) { expansion_flag = val; }
  510. int32 GetHolidayFlag() { return holiday_flag; }
  511. void SetHolidayFlag(int32 val) { holiday_flag = val; }
  512. int32 GetCanBind() { return can_bind; }
  513. void SetCanBind(int32 val) { can_bind = val; }
  514. bool GetCanGate() { return can_gate; }
  515. void SetCanGate(int32 val) { can_gate = val; }
  516. void RemoveClientImmediately(Client* client);
  517. void ClearHate(Entity* entity);
  518. /****************************************************
  519. Following functions are pending deletion, left in for
  520. now just to make sure one won't be of future use.
  521. ****************************************************/
  522. //void RemoveFromRangeMap(Client* client); // never used?
  523. //void AddSpawnAssociatedGroup(vector<int32>* ret, int32 group_id); // never used, not even any code for it
  524. //inline const char* GetCAddress() { return clientaddress; } // never used?
  525. //inline int16 GetCPort() { return clientport; } // never used?
  526. //inline bool IsBootingUp() { return BootingUp; } // never used?
  527. //int32 GetShutdownTimer() {return shutdownTimer.GetTimerTime();} // never used
  528. //float GetUnderWorld(){ return underworld; } // function never used but variable is
  529. // Following were private
  530. //char clientaddress[250]; // never used
  531. //int16 clientport; // never used
  532. //bool BootingUp; // never used
  533. //bool authenticated; // never used?
  534. //int16 next_index; // never used
  535. void AddFlightPath(int32 id, FlightPathInfo* info);
  536. void AddFlightPathLocation(int32 id, FlightPathLocation* location);
  537. void DeleteFlightPaths();
  538. void SendFlightPathsPackets(Client* client);
  539. int32 GetFlightPathIndex(int32 id);
  540. float GetFlightPathSpeed(int32 id);
  541. void SendSpawn(Spawn* spawn, Client* client); // moved from private to public for bots
  542. void ProcessSpawnConditional(int8 condition);
  543. void SetSpawnStructs(Client* client);
  544. void AddSpawnProximities(Spawn* spawn);
  545. void RemoveSpawnProximities(Spawn* spawn);
  546. void SetSpawnScript(SpawnEntry* entry, Spawn* spawn);
  547. bool IsLoading() {
  548. return LoadingData;
  549. }
  550. vector<HouseItem> GetHouseItems(Client* client);
  551. Spawn* GetSpawnFromUniqueItemID(int32 unique_id);
  552. void SendHouseItems(Client* client);
  553. MutexMap<int32, int32> house_object_database_lookup; // 1st int32 = model type, 2nd int32 = spawn id
  554. int32 GetWatchdogTime() { return watchdogTimestamp; }
  555. void SetWatchdogTime(int32 time) { watchdogTimestamp = time; }
  556. void CancelThreads();
  557. void AddPendingSpawnRemove(int32 id);
  558. void ProcessSpawnRemovals();
  559. bool SendRemoveSpawn(Client* client, Spawn* spawn, PacketStruct* packet = 0, bool delete_spawn = false);
  560. void AddSpawnToGroup(Spawn* spawn, int32 group_id);
  561. void QueueStateCommandToClients(int32 spawn_id, int32 state);
  562. void QueueDefaultCommand(int32 spawn_id, std::string command, float distance);
  563. void ProcessQueuedStateCommands();
  564. void UpdateClientSpawnMap(Player* player, Client* client);
  565. void RemoveClientsFromZone(ZoneServer* zone);
  566. void WorldTimeUpdateTrigger() { sync_game_time_timer.Trigger(); }
  567. void StopSpawnScriptTimer(Spawn* spawn, std::string functionName);
  568. Client* RemoveZoneServerFromClient(ZoneServer* zone);
  569. void SendSubSpawnUpdates(SUBSPAWN_TYPES subtype);
  570. bool HouseItemSpawnExists(int32 item_id);
  571. private:
  572. #ifndef WIN32
  573. pthread_t ZoneThread;
  574. pthread_t SpawnThread;
  575. #endif
  576. /* Private Functions */
  577. void AddTransporter(LocationTransportDestination* loc);
  578. void CheckDeadSpawnRemoval();
  579. void DeleteData(bool boot_clients = true);
  580. void DeleteFactionLists();
  581. void ProcessDepop(bool respawns_allowed = false, bool repop = false);
  582. /*
  583. Following functions were public but never used outside the zone server so moved them to private
  584. */
  585. void ClientProcess(); // never used outside zone server
  586. void RemoveClient(Client* client); // never used outside zone server
  587. void DeterminePosition(SpawnLocation* spawnlocation, Spawn* spawn); // never used outside zone server
  588. void AddDeadSpawn(Spawn* spawn, int32 timer = 0xFFFFFFFF); // never used outside zone server
  589. int32 CalculateSpawnGroup(SpawnLocation* spawnlocation, bool respawn = false); // never used outside zone server
  590. float GetSpawnGroupChance(int32 group_id); // never used outside zone server
  591. vector<int32>* GetAssociatedLocations(set<int32>* groups); // never used outside zone server
  592. set<int32>* GetAssociatedGroups(int32 group_id); // never used outside zone server
  593. list<int32>* GetSpawnGroupsByLocation(int32 location_id); // never used outside zone server
  594. void ProcessSpawnLocation(int32 location_id, bool respawn = false); // never used outside zone server
  595. Spawn* ProcessSpawnLocation(SpawnLocation* spawnlocation, bool respawn = false); // never used outside zone server
  596. Spawn* ProcessInstanceSpawnLocation(SpawnLocation* spawnlocation, map<int32,int32>* instNPCs, map<int32,int32>* instGroundSpawns, map<int32,int32>* instObjSpawns, map<int32,int32>* instWidgetSpawns, map<int32,int32>* instSignSpawns, bool respawn = false); // never used outside zone server
  597. void SendCharSheetChanges(); // never used outside zone server
  598. void SendCharSheetChanges(Client* client); // never used outside zone server
  599. void SaveClients(); // never used outside zone server
  600. void CheckSendSpawnToClient(); // never used outside zone server
  601. void CheckSendSpawnToClient(Client* client, bool initial_login = false); // never used outside zone server
  602. void CheckRemoveSpawnFromClient(Spawn* spawn); // never used outside zone server
  603. void SaveClient(Client* client); // never used outside zone server
  604. void ProcessFaction(Spawn* spawn, Client* client); // never used outside zone server
  605. void RegenUpdate(); // never used outside zone server
  606. void SendCalculatedXP(Player* player, Spawn* victim); // never used outside zone server, might not be used at all any more
  607. void SendTimeUpdate(Client* client); // never used outside zone server
  608. void CheckWidgetTimers(); // never used outside zone server
  609. void CheckRespawns(); // never used outside zone server
  610. void CheckSpawnExpireTimers(); // never used outside zone server
  611. void AddSpawnExpireTimer(Spawn* spawn, int32 expire_time, int32 expire_offset = 0); // never used outside zone server
  612. void CheckSpawnRange(Client* client, Spawn* spawn, bool initial_login = false); // never used outside zone server
  613. void CheckSpawnRange(Spawn* spawn); // never used outside zone server
  614. void DeleteSpawnScriptTimers(Spawn* spawn, bool all = false); // never used outside zone server
  615. void DeleteSpawnScriptTimers(); // never used outside zone server
  616. void CheckSpawnScriptTimers(); // never used outside zone server
  617. bool PrepareSpawnID(Player* player, Spawn* spawn); // never used outside zone server
  618. void RemoveMovementNPC(Spawn* spawn); // never used outside zone server
  619. bool CheckNPCAttacks(NPC* npc, Spawn* victim, Client* client = 0); // never used outside zone server
  620. bool AggroVictim(NPC* npc, Spawn* victim, Client* client = 0); // never used outside zone server
  621. bool CheckEnemyList(NPC* npc); // never used outside zone server
  622. void RemovePlayerProximity(Spawn* spawn, bool all = false); // never used outside zone server
  623. void RemovePlayerProximity(Client* client); // never used outside zone server
  624. void CheckPlayerProximity(Spawn* spawn, Client* client); // never used outside zone server
  625. void RemoveLocationProximities(); // never used outside zone server
  626. void CheckLocationProximity(); // never used outside zone server
  627. void CheckLocationGrids(); // never used outside zone server
  628. void RemoveSpawnSupportFunctions(Spawn* spawn, bool lock_spell_process = false); // never used outside zone server
  629. void ReloadTransporters(); // never used outside zone server
  630. void DeleteSpawns(bool delete_all); // never used outside zone server
  631. void AddPendingDelete(Spawn* spawn); // never used outside zone server
  632. void RemovePendingDelete(Spawn* spawn); // never used outside zone server
  633. void ClearDeadSpawns(); // never used outside zone server
  634. void RemoveChangedSpawn(Spawn* spawn); // never used outside zone server
  635. void ProcessDrowning(); // never used outside zone server
  636. void RemoveDamagedSpawn(Spawn* spawn); // never used outside zone server
  637. void ProcessTracking(); // never used outside zone server
  638. void ProcessTracking(Client* client); // never used outside zone server
  639. void SendEpicMobDeathToGuild(Player* killer, Spawn* victim); // never used outside zone server
  640. void ProcessAggroChecks(Spawn* spawn); // never used outside zone server
  641. /// <summary>Checks to see if it is time to remove a spawn and removes it</summary>
  642. /// <param name='force_delete_all'>Forces all spawns scheduled to be removed regardless of time</param>
  643. bool CombatProcess(Spawn* spawn); // never used outside zone server
  644. void InitWeather(); // never used outside zone server
  645. ///<summary>Dismiss all pets in the zone, useful when the spell process needs to be reloaded</summary>
  646. void DismissAllPets(); // never used outside zone server
  647. /* Mutex Lists */
  648. MutexList<int32> changed_spawns; // int32 = spawn id
  649. vector<Client*> clients;
  650. MutexList<Client*> connected_clients; // probably remove this list so we are not maintaining 2 client lists
  651. MutexList<int32> damaged_spawns; // int32 = spawn id
  652. MutexList<LocationProximity*> location_proximities;
  653. MutexList<LocationGrid*> location_grids;
  654. MutexList<int32> remove_movement_spawns; // int32 = spawn id
  655. set<SpawnScriptTimer*> spawn_script_timers;
  656. Mutex MSpawnScriptTimers;
  657. set<SpawnScriptTimer*> remove_spawn_script_timers_list;
  658. Mutex MRemoveSpawnScriptTimersList;
  659. list<LocationTransportDestination*> transporter_locations;
  660. /* Mutex Maps */
  661. MutexMap<Spawn*, Client*> client_spawn_map; // ok
  662. MutexMap<Client*, int32> drowning_victims;
  663. MutexMap<int32, int32> movement_spawns; // 1st int32 = spawn id
  664. MutexMap<int32, PlayerProximity*> player_proximities; // 1st int32 = spawn id
  665. MutexMap<int32, Player*> players_tracking;
  666. MutexMap<int32, int32> quick_database_id_lookup; // 1st int32 = database id, 2nd int32 = spawn id
  667. MutexMap<int32, int32> respawn_timers;
  668. map<Spawn*, int32> spawn_delete_list;
  669. MutexMap<int32, int32> spawn_expire_timers; // 1st int32 = spawn id
  670. map<int32, set<int32>* > spawn_group_associations;
  671. map<int32, float> spawn_group_chances;
  672. map<int32, map<int32, int32>* > spawn_group_locations;
  673. MutexMap<int32, MutexList<int32> > spawn_group_map; // MutexList<int32> is a list of spawn id's
  674. map<int32, list<int32>* > spawn_location_groups;
  675. map<int32, SpawnLocation*> spawn_location_list;
  676. MutexMap<Client*, MutexMap<int32, float >* > spawn_range_map; // int32 in the MutexMap<int32, float>* = spawn id, float = distance
  677. Mutex MWidgetTimers;
  678. map<int32, int32> widget_timers; // 1st int32 = spawn id
  679. /* Mutexs */
  680. Mutex m_enemy_faction_list;
  681. Mutex m_npc_faction_list;
  682. Mutex m_reverse_enemy_faction_list;
  683. Mutex MDeadSpawns;
  684. CriticalSection* MMasterZoneLock; //This needs to be a recursive lock to fix a possible /reload spells crash with multiple zones loaded - Foof
  685. Mutex MMasterSpawnLock;
  686. Mutex MPendingSpawnListAdd;
  687. Mutex MSpawnList;
  688. Mutex MTransportSpawns;
  689. Mutex MSpawnGroupAssociation;
  690. Mutex MSpawnGroupLocations;
  691. Mutex MSpawnLocationGroups;
  692. Mutex MSpawnGroupChances;
  693. Mutex MTransportLocations;
  694. Mutex MSpawnLocationList;
  695. Mutex MSpawnDeleteList;
  696. Mutex MClientList;
  697. Mutex MIncomingClients;
  698. /* Maps */
  699. map<int32, int32> dead_spawns;
  700. map<int32, vector<int32>* > enemy_faction_list;
  701. map<int32, vector<int32>* > npc_faction_list;
  702. map<int32, vector<int32>* > reverse_enemy_faction_list;
  703. map<int32, Spawn*> spawn_list;
  704. map<int32, FlightPathInfo*> m_flightPaths;
  705. map<int32, vector<FlightPathLocation*> > m_flightPathRoutes;
  706. /* Lists */
  707. list<Spawn*> pending_spawn_list_add;
  708. /* Specialized Lists to update specific scenarios */
  709. std::map<int32, Spawn*> subspawn_list[SUBSPAWN_TYPES::MAX_SUBSPAWN_TYPE];
  710. std::map<int32, int32> housing_spawn_map;
  711. /* Vectors */
  712. vector<RevivePoint*>* revive_points;
  713. vector<int32> transport_spawns;
  714. /* Classes */
  715. SpellProcess* spellProcess;
  716. TradeskillMgr* tradeskillMgr;
  717. /* Timers */
  718. Timer aggro_timer;
  719. Timer charsheet_changes;
  720. Timer client_save;
  721. Timer location_prox_timer;
  722. Timer location_grid_timer;
  723. Timer movement_timer;
  724. Timer regenTimer;
  725. Timer respawn_timer;
  726. Timer shutdownTimer;
  727. Timer spawn_check_add;
  728. Timer spawn_check_remove;
  729. Timer spawn_expire_timer;
  730. Timer spawn_range;
  731. Timer spawn_update;
  732. Timer sync_game_time_timer;
  733. Timer tracking_timer;
  734. Timer weatherTimer;
  735. Timer widget_timer;
  736. Timer queue_updates;
  737. Timer shutdownDelayTimer;
  738. /* Enums */
  739. Instance_Type InstanceType;
  740. /* Variables */
  741. volatile bool finished_depop;
  742. volatile bool depop_zone;
  743. volatile bool repop_zone;
  744. volatile bool respawns_allowed;
  745. volatile bool LoadingData;
  746. bool reloading_spellprocess;
  747. bool zoneShuttingDown;
  748. bool cityzone;
  749. bool always_loaded;
  750. bool isInstance;
  751. int32 pNumPlayers;
  752. sint16 minimumStatus;
  753. int16 minimumLevel;
  754. int16 maximumLevel;
  755. int16 minimumVersion;
  756. char zone_name[64];
  757. char zonesky_file[64];
  758. char zone_file[64];
  759. char zone_description[255];
  760. float underworld;
  761. float safe_x;
  762. float safe_y;
  763. float safe_z;
  764. float safe_heading;
  765. float xp_mod;
  766. volatile int32 zoneID;
  767. bool locked; // JA: implementing /zone lock|unlock commands
  768. int32 instanceID;
  769. string zone_motd;
  770. int32 def_reenter_time;
  771. int32 def_reset_time;
  772. int32 def_lockout_time;
  773. int8 group_zone_option;
  774. float rain;
  775. bool isDusk;
  776. int dusk_hour;
  777. int dawn_hour;
  778. int dusk_minute;
  779. int dawn_minute;
  780. int32 spawn_delete_timer;
  781. int32 expansion_flag;
  782. int32 holiday_flag;
  783. //devn00b:test
  784. int can_bind;
  785. bool can_gate;
  786. map<int16, PacketStruct*> versioned_pos_structs;
  787. map<int16, PacketStruct*> versioned_info_structs;
  788. map<int16, PacketStruct*> versioned_vis_structs;
  789. /* Weather Stuff */
  790. bool weather_enabled; // false = disabled, true = enabled
  791. int8 weather_type; // 0 = normal, 1 = dynamic, 2 = random, 3 = chaotic
  792. int32 weather_frequency; // how often weather changes
  793. float weather_min_severity; // minimum weather severity in a zone
  794. float weather_max_severity; // maximum weather severity in a zone
  795. float weather_change_amount; // how much does the weather change each interval (normal weather conditions)
  796. float weather_dynamic_offset; // max amount the weather change each interval (dynamic weather conditions)
  797. int8 weather_change_chance; // percentage chance the weather will change
  798. int8 weather_pattern; // 0 = decreasing severity, 1 = increasing severity, 2 = random severity
  799. int32 weather_last_changed_time; // last time weather changed (used with weather_frequency)
  800. float weather_current_severity; // current weather conditions in a zone
  801. bool weather_allowed; // from zones.weather_allowed field in database
  802. bool weather_signaled; // whether or not we told the client "it begins to rain"
  803. bool reloading;
  804. map<int32, vector<EntityCommand*>* > entity_command_list;
  805. map<int32, map<int32, int8> > npc_spell_list;
  806. map<int32, map<int32, int16> > npc_skill_list;
  807. map<int32, vector<int32> > npc_equipment_list;
  808. map<int32, NPC*> npc_list;
  809. map<int32,Object*> object_list;
  810. map<int32,Sign*> sign_list;
  811. map<int32,Widget*> widget_list;
  812. map<int32, vector<GroundSpawnEntry*> > groundspawn_entries;
  813. map<int32, vector<GroundSpawnEntryItem*> > groundspawn_items;
  814. Mutex MGroundSpawnItems;
  815. map<int32,GroundSpawn*> groundspawn_list;
  816. map<int32,LootTable*> loot_tables;
  817. map<int32, vector<LootDrop*> > loot_drops;
  818. map<int32, vector<int32> > spawn_loot_list;
  819. vector<GlobalLoot*> level_loot_list;
  820. map<int16, vector<GlobalLoot*> > racial_loot_list;
  821. map<int32, vector<GlobalLoot*> > zone_loot_list;
  822. map<int32, vector<TransportDestination*> > transporters;
  823. map<int32, MutexList<LocationTransportDestination*>* > location_transporters;
  824. Mutex MTransporters;
  825. Mutex MTransportMaps;
  826. // Map <transport if, map name>
  827. map<int32, string> m_transportMaps;
  828. int32 watchdogTimestamp;
  829. std::map<int32, bool> m_pendingSpawnRemove;
  830. Mutex MPendingSpawnRemoval;
  831. std::map<int32, int32> lua_queued_state_commands;
  832. std::map<int32, std::map<std::string, float>> lua_spawn_update_command;
  833. std::mutex MLuaQueueStateCmd;
  834. public:
  835. Spawn* GetSpawn(int32 id);
  836. /* Entity Commands */
  837. map<int32, vector<EntityCommand*>*>* GetEntityCommandListAll() {return &entity_command_list;}
  838. vector<EntityCommand*>* GetEntityCommandList(int32 id);
  839. void SetEntityCommandList(int32 id, EntityCommand* command);
  840. void ClearEntityCommands();
  841. EntityCommand* GetEntityCommand(int32 id, string name);
  842. /* NPC's */
  843. void AddNPC(int32 id, NPC* npc);
  844. NPC* GetNPC(int32 id, bool override_loading = false) {
  845. if((!reloading || override_loading) && npc_list.count(id) > 0)
  846. return npc_list[id];
  847. else
  848. return 0;
  849. }
  850. NPC* GetNewNPC(int32 id) {
  851. if(!reloading && npc_list.count(id) > 0)
  852. return new NPC(npc_list[id]);
  853. else
  854. return 0;
  855. }
  856. /* NPC Spells */
  857. void AddNPCSpell(int32 list_id, int32 spell_id, int8 tier);
  858. vector<Spell*>* GetNPCSpells(int32 primary_list, int32 secondary_list);
  859. /* NPC Skills */
  860. void AddNPCSkill(int32 list_id, int32 skill_id, int16 value);
  861. map<string, Skill*>* GetNPCSkills(int32 primary_list, int32 secondary_list);
  862. /* NPC Equipment */
  863. void AddNPCEquipment(int32 list_id, int32 item_id);
  864. void SetNPCEquipment(NPC* npc);
  865. /* Objects */
  866. void AddObject(int32 id, Object* object){ object_list[id] = object; }
  867. Object* GetObject(int32 id, bool override_loading = false) {
  868. if((!reloading || override_loading) && object_list.count(id) > 0)
  869. return object_list[id];
  870. else
  871. return 0;
  872. }
  873. Object* GetNewObject(int32 id) {
  874. if(!reloading && object_list.count(id) > 0)
  875. return object_list[id]->Copy();
  876. else
  877. return 0;
  878. }
  879. /* Signs */
  880. void AddSign(int32 id, Sign* sign){ sign_list[id] = sign; }
  881. Sign* GetSign(int32 id, bool override_loading = false) {
  882. if((!reloading || override_loading) && sign_list.count(id) > 0)
  883. return sign_list[id];
  884. else
  885. return 0;
  886. }
  887. Sign* GetNewSign(int32 id) {
  888. if(!reloading && sign_list.count(id) > 0)
  889. return sign_list[id]->Copy();
  890. else
  891. return 0;
  892. }
  893. /* Widgets */
  894. void AddWidget(int32 id, Widget* widget);
  895. Widget* GetWidget(int32 id, bool override_loading = false);
  896. Widget* GetNewWidget(int32 id);
  897. /* Groundspawns */
  898. // JA: groundspawn revamp
  899. void AddGroundSpawnEntry(int32 groundspawn_id, int16 min_skill_level, int16 min_adventure_level, int8 bonus_table, float harvest1, float harvest3, float harvest5, float harvest_imbue, float harvest_rare, float harvest10, int32 harvest_coin);
  900. void AddGroundSpawnItem(int32 groundspawn_id, int32 item_id, int8 is_rare, int32 grid_id);
  901. vector<GroundSpawnEntry*>* GetGroundSpawnEntries(int32 id);
  902. vector<GroundSpawnEntryItem*>* GetGroundSpawnEntryItems(int32 id);
  903. void LoadGroundSpawnEntries();
  904. void LoadGroundSpawnItems();
  905. //
  906. void DeleteGroundSpawnItems();
  907. void AddGroundSpawn(int32 id, GroundSpawn* spawn);
  908. GroundSpawn* GetGroundSpawn(int32 id, bool override_loading = false);
  909. GroundSpawn* GetNewGroundSpawn(int32 id);
  910. /* Pet names */
  911. vector<string> pet_names;
  912. /* Loot */
  913. void AddLootTable(int32 id, LootTable* table);
  914. void AddLootDrop(int32 id, LootDrop* drop);
  915. void AddSpawnLootList(int32 spawn_id, int32 id);
  916. void ClearSpawnLootList(int32 spawn_id);
  917. void AddLevelLootList(GlobalLoot* loot);
  918. void AddRacialLootList(int16 racial_id, GlobalLoot* loot);
  919. void AddZoneLootList(int32 zone, GlobalLoot* loot);
  920. void ClearLootTables();
  921. vector<int32> GetSpawnLootList(int32 spawn_id, int32 zone_id, int8 spawn_level, int16 racial_id, Spawn* spawn = 0);
  922. vector<LootDrop*>* GetLootDrops(int32 table_id);
  923. LootTable* GetLootTable(int32 table_id);
  924. /* Transporters */
  925. void AddLocationTransporter(int32 zone_id, string message, float trigger_x, float trigger_y, float trigger_z, float trigger_radius, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading, int32 cost, int32 unique_id);
  926. void AddTransporter(int32 transport_id, int8 type, string name, string message, int32 destination_zone_id, float destination_x, float destination_y, float destination_z, float destination_heading,
  927. int32 cost, int32 unique_id, int8 min_level, int8 max_level, int32 quest_req, int16 quest_step_req, int32 quest_complete, int32 map_x, int32 map_y, int32 expansion_flag, int32 holiday_flag, int32 min_client_version,
  928. int32 max_client_version, int32 flight_path_id, int16 mount_id, int8 mount_red_color, int8 mount_green_color, int8 mount_blue_color);
  929. void GetTransporters(vector<TransportDestination*>* returnList, Client* client, int32 transport_id);
  930. MutexList<LocationTransportDestination*>* GetLocationTransporters(int32 zone_id);
  931. void DeleteGlobalTransporters();
  932. ///<summary></summary>
  933. ///<param name='id'>The transport id</param>
  934. ///<param name='name'>Name of the map</param>
  935. void AddTransportMap(int32 id, string name);
  936. ///<summary>Checks to see if the transport has a map</summary>
  937. ///<param name='id'>The transport id we want to check</param>
  938. ///<returns>True if the transport id has a map</returns>
  939. bool TransportHasMap(int32 id);
  940. ///<summary>Gets the map name for the given transport id</summary>
  941. ///<param name='id'>The transport id that we want a map for</param>
  942. ///<returns>Map name</returns>
  943. string GetTransportMap(int32 id);
  944. ///<summary>Clears the list of transporter maps</summary>
  945. void DeleteTransporterMaps();
  946. void DeleteGlobalSpawns();
  947. void ReloadSpawns();
  948. void SendStateCommand(Spawn* spawn, int32 state);
  949. int32 lifetime_client_count;
  950. int32 incoming_clients;
  951. };
  952. #endif