zoneserver.h 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  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. // 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...
  233. class ZoneServer {
  234. public:
  235. ZoneServer(const char* file, bool incoming_client=false);
  236. ~ZoneServer();
  237. void IncrementIncomingClients();
  238. void DecrementIncomingClients();
  239. void Init();
  240. bool Process();
  241. bool SpawnProcess();
  242. ZoneInfoSlideStruct* GenerateSlideStruct(float unknown1a, float unknown1b, int32 unknown2a, int32 unknown2b, int32 unknown3, int32 unknown4, const char* slide, const char* voiceover, int32 key1, int32 key2);
  243. void AddZoneInfoSlideStructTransitionInfo(ZoneInfoSlideStruct* info, int32 x, int32 y, float zoom, float transition_time);
  244. vector<ZoneInfoSlideStruct*>* GenerateTutorialSlides();
  245. void LoadRevivePoints(vector<RevivePoint*>* revive_points);
  246. vector<RevivePoint*>* GetRevivePoints(Client* client);
  247. RevivePoint* GetRevivePoint(int32 id);
  248. void AddClient(Client* client);
  249. void SimpleMessage(int8 type, const char* message, Spawn* from, float distance, bool send_to_sender = true);
  250. 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);
  251. 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);
  252. void HandleBroadcast(const char* message);
  253. void HandleAnnouncement(const char* message);
  254. int16 SetSpawnTargetable(Spawn* spawn, float distance);
  255. int16 SetSpawnTargetable(int32 spawn_id);
  256. void ApplySetSpawnCommand(Client* client, Spawn* target, int8 type, const char* value);
  257. void SetSpawnCommand(Spawn* spawn, int8 type, char* value, Client* client = 0);
  258. void SetSpawnCommand(int32 spawn_id, int8 type, char* value, Client* client = 0);
  259. void AddLoot(NPC* npc, Spawn* killer = nullptr);
  260. NPC* AddNPCSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  261. Object* AddObjectSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  262. GroundSpawn* AddGroundSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  263. Widget* AddWidgetSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  264. Sign* AddSignSpawn(SpawnLocation* spawnlocation, SpawnEntry* spawnentry);
  265. void AddSpawn(Spawn* spawn);
  266. void RemoveDeadEnemyList(Spawn* spawn);
  267. void RemoveDeadSpawn(Spawn* spawn);
  268. void AddSpawnGroupLocation(int32 group_id, int32 location_id, int32 spawn_location_id);
  269. void AddSpawnGroupAssociation(int32 group_id1, int32 group_id2);
  270. void AddSpawnGroupChance(int32 group_id, float percent);
  271. 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);
  272. void ProcessSpawnLocations();
  273. void SendQuestUpdates(Client* client, Spawn* spawn = 0);
  274. EQ2Packet* GetZoneInfoPacket(Client* client);
  275. Spawn* FindSpawn(Player* searcher, const char* name);
  276. 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);
  277. void SendSpawnVisualState(Spawn* spawn, int16 type);
  278. void SendSpellFailedPacket(Client* client, int16 error);
  279. void SendInterruptPacket(Spawn* interrupted, LuaSpell* spell, bool fizzle=false);
  280. void HandleEmote(Client* originator, string name);
  281. Client* GetClientBySpawn(Spawn* spawn);
  282. Spawn* GetSpawnByDatabaseID(int32 id);
  283. Spawn* GetSpawnByID(int32 id, bool spawnListLocked=false);
  284. void PlaySoundFile(Client* client, const char* name, float origin_x, float origin_y, float origin_z);
  285. void SendZoneSpawns(Client* client);
  286. void StartZoneInitialSpawnThread(Client* client);
  287. void SendSpawnChanges();
  288. void SendSpawnChanges(Spawn* spawn);
  289. void SendSpawnChanges(Spawn* spawn, Client* client, bool override_changes = false, bool override_vis_changes = false);
  290. void SendSpawnChangesByDBID(int32 spawn_id, Client* client, bool override_changes = false, bool override_vis_changes = false);
  291. void SendPlayerPositionChanges(Player* player);
  292. void UpdateVitality(float amount);
  293. vector<Entity*> GetPlayers();
  294. void KillSpawn(bool spawnListLocked, Spawn* dead, Spawn* killer, bool send_packet = true, int8 damage_type = 0, int16 kill_blow_type = 0);
  295. void SendDamagePacket(Spawn* attacker, Spawn* victim, int8 type1, int8 type2, int8 damage_type, int16 damage, const char* spell_name);
  296. void SendHealPacket(Spawn* caster, Spawn* target, int16 type, int32 heal_amt, const char* spell_name);
  297. void SendCastSpellPacket(LuaSpell* spell, Entity* caster);
  298. void SendCastSpellPacket(int32 spell_visual, Spawn* target, Spawn* caster = 0);
  299. void SendCastEntityCommandPacket(EntityCommand* entity_command, int32 spawn_id, int32 target_id);
  300. void TriggerCharSheetTimer();
  301. /// <summary>Sends the game time packet to all connected clients</summary>
  302. void SendTimeUpdateToAllClients();
  303. void AddWidgetTimer(Spawn* widget, float time);
  304. bool HasWidgetTimer(Spawn* widget);
  305. void Despawn(Spawn* spawn, int32 timer);
  306. void RepopSpawns(Client* client, Spawn* spawn);
  307. bool AddCloseSpawnsToSpawnGroup(Spawn* spawn, float radius);
  308. void Depop(bool respawns = false, bool repop = false);
  309. Spawn* GetSpawnGroup(int32 id);
  310. void AddEnemyList(NPC* npc);
  311. void ReloadClientQuests();
  312. void SendAllSpawnsForLevelChange(Client* client);
  313. void SendAllSpawnsForSeeInvisChange(Client* client);
  314. void SendAllSpawnsForVisChange(Client* client, bool limitToEntities=true);
  315. void AddLocationGrid(LocationGrid* grid);
  316. void RemoveLocationGrids();
  317. void DeleteTransporters();
  318. void CheckTransporters(Client* client);
  319. void WritePlayerStatistics();
  320. bool SendRadiusSpawnInfo(Client* client, float radius);
  321. void FindSpawn(Client* client, char* regSearchStr);
  322. volatile bool spawnthread_active;
  323. volatile bool combatthread_active;
  324. volatile int8 initial_spawn_threads_active;
  325. volatile bool client_thread_active;
  326. void AddChangedSpawn(Spawn* spawn);
  327. void AddDamagedSpawn(Spawn* spawn);
  328. void AddDrowningVictim(Player* player);
  329. void RemoveDrowningVictim(Player* player);
  330. Client* GetDrowningVictim(Player* player);
  331. void DeleteSpellProcess();
  332. void LoadSpellProcess();
  333. void LockAllSpells(Player* player);
  334. void UnlockAllSpells(Player* player);
  335. void RemoveSpellTimersFromSpawn(Spawn* spawn, bool remove_all, bool delete_recast = true, bool call_expire_function = true, bool lock_spell_process = false);
  336. void Interrupted(Entity* caster, Spawn* interruptor, int16 error_code, bool cancel = false, bool from_movement = false);
  337. Spell* GetSpell(Entity* caster);
  338. 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);
  339. void ProcessEntityCommand(EntityCommand* entity_command, Entity* caster, Spawn* target, bool lock = true);
  340. void AddPlayerTracking(Player* player);
  341. void RemovePlayerTracking(Player* player, int8 mode);
  342. void SendUpdateTitles(Client *client, Title *suffix = 0, Title *prefix = 0);
  343. void SendUpdateTitles(Spawn *spawn, Title *suffix = 0, Title *prefix = 0);
  344. void RemoveTargetFromSpell(LuaSpell* spell, Spawn* target, bool remove_caster = false);
  345. /// <summary>Set the rain levl in the zone</summary>
  346. /// <param name='val'>Level of rain in the zone 0.0 - 1.1 (rain starts at 0.76)</param>
  347. void SetRain(float val);
  348. /// <summary>Sets the wind direction</summary>
  349. /// <param name='val'>Direction in degrees to set the wind</param>
  350. void SetWind(float val);
  351. /// <summary>Handles zone-wide weather changes</summary>
  352. void ProcessWeather();
  353. Spawn* GetClosestTransportSpawn(float x, float y, float z);
  354. Spawn* GetTransportByRailID(sint64 rail_id);
  355. void ResurrectSpawn(Spawn* spawn, Client* client);
  356. void HidePrivateSpawn(Spawn* spawn);
  357. Client* GetClientByName(char* name);
  358. Client* GetClientByCharID(int32 charid);
  359. /// <summary>Gets spawns for a true AoE spell</summary>
  360. vector<Spawn*> GetAttackableSpawnsByDistance(Spawn* spawn, float distance);
  361. void StartZoneSpawnsForLevelThread(Client* client);
  362. void SendDispellPacket(Entity* caster, Spawn* target, string dispell_name, string spell_name, int8 dispell_type);
  363. void SetupInstance(int32 createdInstanceID=0);
  364. void SendUpdateDefaultCommand(Spawn* spawn, const char* command, float distance, Spawn* toplayer = NULL);
  365. map<int32, int32>* GetSpawnLocationsByGroup(int32 group_id);
  366. IPathfinder* pathing;
  367. MobMovementManager* movementMgr;
  368. /****************************************************
  369. Following functions are only used for LUA commands
  370. ****************************************************/
  371. int32 GetClosestLocation(Spawn* spawn);
  372. Spawn* GetClosestSpawn(Spawn* spawn, int32 spawn_id);
  373. SpawnLocation* GetSpawnLocation(int32 id);
  374. void PlayFlavor(Client* client, Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language);
  375. void PlayVoice(Client* client, Spawn* spawn, const char* mp3, int32 key1, int32 key2);
  376. void PlayFlavor(Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language);
  377. void PlayVoice(Spawn* spawn, const char* mp3, int32 key1, int32 key2);
  378. void SendThreatPacket(Spawn* caster, Spawn* target, int32 threat_amt, const char* spell_name);
  379. void KillSpawnByDistance(Spawn* spawn, float max_distance, bool include_players = false, bool send_packet = false);
  380. void SpawnSetByDistance(Spawn* spawn, float max_distance, string field, string value);
  381. void AddSpawnScriptTimer(SpawnScriptTimer* timer);
  382. Spawn* GetSpawnByLocationID(int32 location_id);
  383. void AddMovementNPC(Spawn* spawn);
  384. void AddPlayerProximity(Spawn* spawn, float distance, string in_range_function, string leaving_range_function);
  385. void AddLocationProximity(float x, float y, float z, float max_variation, string in_range_function, string leaving_range_function);
  386. void PlayAnimation(Spawn* spawn, int32 visual_state, Spawn* spawn2 = 0, int8 type = 1);
  387. void AddTransportSpawn(Spawn* spawn);
  388. vector<Spawn*> GetSpawnsByID(int32 id);
  389. vector<Spawn*> GetSpawnsByRailID(sint64 rail_id);
  390. void RemovePlayerPassenger(int32 char_id);
  391. bool IsDusk() { return isDusk; } // never used, probably meant for lua though
  392. /****************************************************
  393. Following functions are all contained in the header
  394. ****************************************************/
  395. inline const char* GetZoneName() { return zone_name; }
  396. void SetZoneName(char* new_zone) {
  397. if( strlen(new_zone) >= sizeof zone_name )
  398. return;
  399. strcpy(zone_name, new_zone);
  400. }
  401. inline const char* GetZoneFile() { return zone_file; }
  402. void SetZoneFile(char* zone) {
  403. if (strlen(zone) >= sizeof zone_file)
  404. return;
  405. strcpy(zone_file, zone);
  406. }
  407. inline const char* GetZoneSkyFile() { return zonesky_file; }
  408. void SetZoneSkyFile(char* zone) {
  409. if (strlen(zone) >= sizeof zonesky_file)
  410. return;
  411. strcpy(zonesky_file, zone);
  412. }
  413. inline const char* GetZoneDescription() { return zone_description; }
  414. void SetZoneDescription(char* desc) {
  415. if( strlen(desc) >= sizeof zone_description )
  416. return;
  417. strcpy(zone_description, desc);
  418. }
  419. void SetUnderWorld(float under){ underworld = under; }
  420. inline int32 GetZoneID() { return zoneID; }
  421. void SetZoneID(int32 new_id){ zoneID = new_id; }
  422. inline bool IsCityZone() { return cityzone; }
  423. inline bool AlwaysLoaded() { return always_loaded; }
  424. void SetCityZone(bool val) { cityzone = val; }
  425. void SetAlwaysLoaded(bool val) { always_loaded = val; }
  426. inline int32& NumPlayers() { return pNumPlayers; }
  427. void SetMinimumStatus(sint16 minStatus) { minimumStatus = minStatus; }
  428. sint16 GetMinimumStatus() { return minimumStatus; }
  429. void SetMinimumLevel(int16 minLevel) { minimumLevel = minLevel; }
  430. void SetMaximumLevel(int16 maxLevel) { maximumLevel = maxLevel; }
  431. void SetMinimumVersion(int16 minVersion) { minimumVersion = minVersion; }
  432. int16 GetMinimumLevel() { return minimumLevel; }
  433. int16 GetMaximumLevel() { return maximumLevel; }
  434. int16 GetMinimumVersion() { return minimumVersion; }
  435. inline bool GetZoneLockState() { return locked; } // JA: /zone lock|unlock
  436. void SetZoneLockState(bool lock_state) { locked = lock_state; } // JA: /zone lock|unlock
  437. int32 GetInstanceID() { return instanceID; }
  438. bool IsInstanceZone() { return isInstance; }
  439. void SetShutdownTimer(int val){
  440. shutdownTimer.SetTimer(val*1000);
  441. }
  442. void AddSpawnLocation(int32 id, SpawnLocation* spawnlocation) {
  443. MSpawnLocationList.writelock(__FUNCTION__, __LINE__);
  444. if (spawn_location_list.count(id) > 0)
  445. safe_delete(spawn_location_list[id]);
  446. spawn_location_list[id] = spawnlocation;
  447. MSpawnLocationList.releasewritelock(__FUNCTION__, __LINE__);
  448. }
  449. void SetInstanceType(int16 type) { InstanceType = (Instance_Type)type; if(type>0)isInstance=true; else isInstance=false; }
  450. Instance_Type GetInstanceType() { return InstanceType; }
  451. float GetSafeX(){ return safe_x; }
  452. float GetSafeY(){ return safe_y; }
  453. float GetSafeZ(){ return safe_z; }
  454. float GetSafeHeading() { return safe_heading; }
  455. void SetSafeX(float val){ safe_x = val; }
  456. void SetSafeY(float val){ safe_y = val; }
  457. void SetSafeZ(float val){ safe_z = val; }
  458. void SetSafeHeading(float val) { safe_heading = val; }
  459. float GetXPModifier() { return xp_mod; }
  460. void SetXPModifier(float val) { xp_mod = val; }
  461. void SetZoneMOTD(string z_motd) { zone_motd = z_motd; }
  462. string GetZoneMOTD() { return zone_motd; }
  463. bool isZoneShuttingDown ( ) { return zoneShuttingDown; }
  464. void Shutdown(){ zoneShuttingDown = true; }
  465. int32 GetClientCount(){ return clients.size(); }
  466. int32 GetDefaultLockoutTime() { return def_lockout_time; }
  467. int32 GetDefaultReenterTime() { return def_reenter_time; }
  468. int32 GetDefaultResetTime() { return def_reset_time; }
  469. int8 GetForceGroupZoneOption() { return group_zone_option; }
  470. void SetDefaultLockoutTime(int32 val) { def_lockout_time = val; }
  471. void SetDefaultReenterTime(int32 val) { def_reenter_time = val; }
  472. void SetDefaultResetTime(int32 val) { def_reset_time = val; }
  473. void SetForceGroupZoneOption(int8 val) { group_zone_option = val; }
  474. SpellProcess* GetSpellProcess() {return spellProcess;}
  475. bool FinishedDepop(){ return finished_depop; }
  476. /// <summary>Returns the Tradeskill Manager for this zone</summary>
  477. TradeskillMgr* GetTradeskillMgr() { return tradeskillMgr; }
  478. // had to add these to access weather from Commands
  479. bool isWeatherEnabled() { return weather_enabled; }
  480. void SetWeatherEnabled(bool val) { weather_enabled = val; }
  481. bool isWeatherAllowed() { return weather_allowed; }
  482. void SetWeatherAllowed(bool val) { weather_allowed = val; }
  483. int8 GetWeatherType() { return weather_type; }
  484. void SetWeatherType(int8 val) { weather_type = val; }
  485. int32 GetWeatherFrequency() { return weather_frequency; }
  486. void SetWeatherFrequency(int32 val) { weather_frequency = val; }
  487. float GetWeatherMinSeverity() { return weather_min_severity; }
  488. void SetWeatherMinSeverity(float val) { weather_min_severity = val; }
  489. float GetWeatherMaxSeverity() { return weather_max_severity; }
  490. void SetWeatherMaxSeverity(float val) { weather_max_severity = val; }
  491. float GetWeatherChangeAmount() { return weather_change_amount; }
  492. void SetWeatherChangeAmount(float val) { weather_change_amount = val; }
  493. float GetWeatherDynamicOffset() { return weather_dynamic_offset; }
  494. void SetWeatherDynamicOffset(float val) { weather_dynamic_offset = val; }
  495. int8 GetWeatherChance() { return weather_change_chance; }
  496. void SetWeatherChance(int8 val) { weather_change_chance = val; }
  497. float GetCurrentWeather() { return weather_current_severity; }
  498. void SetCurrentWeather(float val) { weather_current_severity = val; }
  499. int8 GetWeatherPattern() { return weather_pattern; }
  500. void SetWeatherPattern(int8 val) { weather_pattern = val; }
  501. void SetWeatherLastChangedTime(int32 val) { weather_last_changed_time = val; }
  502. int32 GetExpansionFlag() { return expansion_flag; }
  503. void SetExpansionFlag(int32 val) { expansion_flag = val; }
  504. int32 GetHolidayFlag() { return holiday_flag; }
  505. void SetHolidayFlag(int32 val) { holiday_flag = val; }
  506. int32 GetCanBind() { return can_bind; }
  507. void SetCanBind(int32 val) { can_bind = val; }
  508. bool GetCanGate() { return can_gate; }
  509. void SetCanGate(int32 val) { can_gate = val; }
  510. void RemoveClientImmediately(Client* client);
  511. void ClearHate(Entity* entity);
  512. /****************************************************
  513. Following functions are pending deletion, left in for
  514. now just to make sure one won't be of future use.
  515. ****************************************************/
  516. //void RemoveFromRangeMap(Client* client); // never used?
  517. //void AddSpawnAssociatedGroup(vector<int32>* ret, int32 group_id); // never used, not even any code for it
  518. //inline const char* GetCAddress() { return clientaddress; } // never used?
  519. //inline int16 GetCPort() { return clientport; } // never used?
  520. //inline bool IsBootingUp() { return BootingUp; } // never used?
  521. //int32 GetShutdownTimer() {return shutdownTimer.GetTimerTime();} // never used
  522. //float GetUnderWorld(){ return underworld; } // function never used but variable is
  523. // Following were private
  524. //char clientaddress[250]; // never used
  525. //int16 clientport; // never used
  526. //bool BootingUp; // never used
  527. //bool authenticated; // never used?
  528. //int16 next_index; // never used
  529. void AddFlightPath(int32 id, FlightPathInfo* info);
  530. void AddFlightPathLocation(int32 id, FlightPathLocation* location);
  531. void DeleteFlightPaths();
  532. void SendFlightPathsPackets(Client* client);
  533. int32 GetFlightPathIndex(int32 id);
  534. float GetFlightPathSpeed(int32 id);
  535. void SendSpawn(Spawn* spawn, Client* client); // moved from private to public for bots
  536. void ProcessSpawnConditional(int8 condition);
  537. void SetSpawnStructs(Client* client);
  538. void AddSpawnProximities(Spawn* spawn);
  539. void RemoveSpawnProximities(Spawn* spawn);
  540. void SetSpawnScript(SpawnEntry* entry, Spawn* spawn);
  541. bool IsLoading() {
  542. return LoadingData;
  543. }
  544. vector<HouseItem> GetHouseItems(Client* client);
  545. Spawn* GetSpawnFromUniqueItemID(int32 unique_id);
  546. void SendHouseItems(Client* client);
  547. MutexMap<int32, int32> house_object_database_lookup; // 1st int32 = model type, 2nd int32 = spawn id
  548. int32 GetWatchdogTime() { return watchdogTimestamp; }
  549. void SetWatchdogTime(int32 time) { watchdogTimestamp = time; }
  550. void CancelThreads();
  551. void AddPendingSpawnRemove(int32 id);
  552. void ProcessSpawnRemovals();
  553. bool SendRemoveSpawn(Client* client, Spawn* spawn, PacketStruct* packet = 0, bool delete_spawn = false);
  554. void AddSpawnToGroup(Spawn* spawn, int32 group_id);
  555. void QueueStateCommandToClients(int32 spawn_id, int32 state);
  556. void QueueDefaultCommand(int32 spawn_id, std::string command, float distance);
  557. void ProcessQueuedStateCommands();
  558. void UpdateClientSpawnMap(Player* player, Client* client);
  559. void RemoveClientsFromZone(ZoneServer* zone);
  560. void WorldTimeUpdateTrigger() { sync_game_time_timer.Trigger(); }
  561. void StopSpawnScriptTimer(Spawn* spawn, std::string functionName);
  562. Client* RemoveZoneServerFromClient(ZoneServer* zone);
  563. private:
  564. #ifndef WIN32
  565. pthread_t ZoneThread;
  566. pthread_t SpawnThread;
  567. #endif
  568. /* Private Functions */
  569. void AddTransporter(LocationTransportDestination* loc);
  570. void CheckDeadSpawnRemoval();
  571. void DeleteData(bool boot_clients = true);
  572. void DeleteFactionLists();
  573. void ProcessDepop(bool respawns_allowed = false, bool repop = false);
  574. /*
  575. Following functions were public but never used outside the zone server so moved them to private
  576. */
  577. void ClientProcess(); // never used outside zone server
  578. void RemoveClient(Client* client); // never used outside zone server
  579. void DeterminePosition(SpawnLocation* spawnlocation, Spawn* spawn); // never used outside zone server
  580. void AddDeadSpawn(Spawn* spawn, int32 timer = 0xFFFFFFFF); // never used outside zone server
  581. int32 CalculateSpawnGroup(SpawnLocation* spawnlocation, bool respawn = false); // never used outside zone server
  582. float GetSpawnGroupChance(int32 group_id); // never used outside zone server
  583. vector<int32>* GetAssociatedLocations(set<int32>* groups); // never used outside zone server
  584. set<int32>* GetAssociatedGroups(int32 group_id); // never used outside zone server
  585. list<int32>* GetSpawnGroupsByLocation(int32 location_id); // never used outside zone server
  586. void ProcessSpawnLocation(int32 location_id, bool respawn = false); // never used outside zone server
  587. Spawn* ProcessSpawnLocation(SpawnLocation* spawnlocation, bool respawn = false); // never used outside zone server
  588. 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
  589. void SendCharSheetChanges(); // never used outside zone server
  590. void SendCharSheetChanges(Client* client); // never used outside zone server
  591. void SaveClients(); // never used outside zone server
  592. void CheckSendSpawnToClient(); // never used outside zone server
  593. void CheckSendSpawnToClient(Client* client, bool initial_login = false); // never used outside zone server
  594. void CheckRemoveSpawnFromClient(Spawn* spawn); // never used outside zone server
  595. void SaveClient(Client* client); // never used outside zone server
  596. void ProcessFaction(Spawn* spawn, Client* client); // never used outside zone server
  597. void RegenUpdate(); // never used outside zone server
  598. void SendCalculatedXP(Player* player, Spawn* victim); // never used outside zone server, might not be used at all any more
  599. void SendTimeUpdate(Client* client); // never used outside zone server
  600. void CheckWidgetTimers(); // never used outside zone server
  601. void CheckRespawns(); // never used outside zone server
  602. void CheckSpawnExpireTimers(); // never used outside zone server
  603. void AddSpawnExpireTimer(Spawn* spawn, int32 expire_time, int32 expire_offset = 0); // never used outside zone server
  604. void CheckSpawnRange(Client* client, Spawn* spawn, bool initial_login = false); // never used outside zone server
  605. void CheckSpawnRange(Spawn* spawn); // never used outside zone server
  606. void DeleteSpawnScriptTimers(Spawn* spawn, bool all = false); // never used outside zone server
  607. void DeleteSpawnScriptTimers(); // never used outside zone server
  608. void CheckSpawnScriptTimers(); // never used outside zone server
  609. bool PrepareSpawnID(Player* player, Spawn* spawn); // never used outside zone server
  610. void RemoveMovementNPC(Spawn* spawn); // never used outside zone server
  611. bool CheckNPCAttacks(NPC* npc, Spawn* victim, Client* client = 0); // never used outside zone server
  612. bool AggroVictim(NPC* npc, Spawn* victim, Client* client = 0); // never used outside zone server
  613. bool CheckEnemyList(NPC* npc); // never used outside zone server
  614. void RemovePlayerProximity(Spawn* spawn, bool all = false); // never used outside zone server
  615. void RemovePlayerProximity(Client* client); // never used outside zone server
  616. void CheckPlayerProximity(Spawn* spawn, Client* client); // never used outside zone server
  617. void RemoveLocationProximities(); // never used outside zone server
  618. void CheckLocationProximity(); // never used outside zone server
  619. void CheckLocationGrids(); // never used outside zone server
  620. void RemoveSpawnSupportFunctions(Spawn* spawn, bool lock_spell_process = false); // never used outside zone server
  621. void ReloadTransporters(); // never used outside zone server
  622. void DeleteSpawns(bool delete_all); // never used outside zone server
  623. void AddPendingDelete(Spawn* spawn); // never used outside zone server
  624. void RemovePendingDelete(Spawn* spawn); // never used outside zone server
  625. void ClearDeadSpawns(); // never used outside zone server
  626. void RemoveChangedSpawn(Spawn* spawn); // never used outside zone server
  627. void ProcessDrowning(); // never used outside zone server
  628. void RemoveDamagedSpawn(Spawn* spawn); // never used outside zone server
  629. void ProcessTracking(); // never used outside zone server
  630. void ProcessTracking(Client* client); // never used outside zone server
  631. void SendEpicMobDeathToGuild(Player* killer, Spawn* victim); // never used outside zone server
  632. void ProcessAggroChecks(Spawn* spawn); // never used outside zone server
  633. /// <summary>Checks to see if it is time to remove a spawn and removes it</summary>
  634. /// <param name='force_delete_all'>Forces all spawns scheduled to be removed regardless of time</param>
  635. bool CombatProcess(Spawn* spawn); // never used outside zone server
  636. void InitWeather(); // never used outside zone server
  637. ///<summary>Dismiss all pets in the zone, useful when the spell process needs to be reloaded</summary>
  638. void DismissAllPets(); // never used outside zone server
  639. /* Mutex Lists */
  640. MutexList<int32> changed_spawns; // int32 = spawn id
  641. vector<Client*> clients;
  642. MutexList<Client*> connected_clients; // probably remove this list so we are not maintaining 2 client lists
  643. MutexList<int32> damaged_spawns; // int32 = spawn id
  644. MutexList<LocationProximity*> location_proximities;
  645. MutexList<LocationGrid*> location_grids;
  646. MutexList<int32> remove_movement_spawns; // int32 = spawn id
  647. set<SpawnScriptTimer*> spawn_script_timers;
  648. Mutex MSpawnScriptTimers;
  649. set<SpawnScriptTimer*> remove_spawn_script_timers_list;
  650. Mutex MRemoveSpawnScriptTimersList;
  651. list<LocationTransportDestination*> transporter_locations;
  652. /* Mutex Maps */
  653. MutexMap<Spawn*, Client*> client_spawn_map; // ok
  654. MutexMap<Client*, int32> drowning_victims;
  655. MutexMap<int32, int32> movement_spawns; // 1st int32 = spawn id
  656. MutexMap<int32, PlayerProximity*> player_proximities; // 1st int32 = spawn id
  657. MutexMap<int32, Player*> players_tracking;
  658. MutexMap<int32, int32> quick_database_id_lookup; // 1st int32 = database id, 2nd int32 = spawn id
  659. MutexMap<int32, int32> respawn_timers;
  660. map<Spawn*, int32> spawn_delete_list;
  661. MutexMap<int32, int32> spawn_expire_timers; // 1st int32 = spawn id
  662. map<int32, set<int32>* > spawn_group_associations;
  663. map<int32, float> spawn_group_chances;
  664. map<int32, map<int32, int32>* > spawn_group_locations;
  665. MutexMap<int32, MutexList<int32> > spawn_group_map; // MutexList<int32> is a list of spawn id's
  666. map<int32, list<int32>* > spawn_location_groups;
  667. map<int32, SpawnLocation*> spawn_location_list;
  668. MutexMap<Client*, MutexMap<int32, float >* > spawn_range_map; // int32 in the MutexMap<int32, float>* = spawn id, float = distance
  669. Mutex MWidgetTimers;
  670. map<int32, int32> widget_timers; // 1st int32 = spawn id
  671. /* Mutexs */
  672. Mutex m_enemy_faction_list;
  673. Mutex m_npc_faction_list;
  674. Mutex m_reverse_enemy_faction_list;
  675. Mutex MDeadSpawns;
  676. CriticalSection* MMasterZoneLock; //This needs to be a recursive lock to fix a possible /reload spells crash with multiple zones loaded - Foof
  677. Mutex MMasterSpawnLock;
  678. Mutex MPendingSpawnListAdd;
  679. Mutex MSpawnList;
  680. Mutex MTransportSpawns;
  681. Mutex MSpawnGroupAssociation;
  682. Mutex MSpawnGroupLocations;
  683. Mutex MSpawnLocationGroups;
  684. Mutex MSpawnGroupChances;
  685. Mutex MTransportLocations;
  686. Mutex MSpawnLocationList;
  687. Mutex MSpawnDeleteList;
  688. Mutex MClientList;
  689. Mutex MIncomingClients;
  690. /* Maps */
  691. map<int32, int32> dead_spawns;
  692. map<int32, vector<int32>* > enemy_faction_list;
  693. map<int32, vector<int32>* > npc_faction_list;
  694. map<int32, vector<int32>* > reverse_enemy_faction_list;
  695. map<int32, Spawn*> spawn_list;
  696. map<int32, FlightPathInfo*> m_flightPaths;
  697. map<int32, vector<FlightPathLocation*> > m_flightPathRoutes;
  698. /* Lists */
  699. list<Spawn*> pending_spawn_list_add;
  700. /* Vectors */
  701. vector<RevivePoint*>* revive_points;
  702. vector<int32> transport_spawns;
  703. /* Classes */
  704. SpellProcess* spellProcess;
  705. TradeskillMgr* tradeskillMgr;
  706. /* Timers */
  707. Timer aggro_timer;
  708. Timer charsheet_changes;
  709. Timer client_save;
  710. Timer location_prox_timer;
  711. Timer location_grid_timer;
  712. Timer movement_timer;
  713. Timer regenTimer;
  714. Timer respawn_timer;
  715. Timer shutdownTimer;
  716. Timer spawn_check_add;
  717. Timer spawn_check_remove;
  718. Timer spawn_expire_timer;
  719. Timer spawn_range;
  720. Timer spawn_update;
  721. Timer sync_game_time_timer;
  722. Timer tracking_timer;
  723. Timer weatherTimer;
  724. Timer widget_timer;
  725. Timer queue_updates;
  726. Timer shutdownDelayTimer;
  727. /* Enums */
  728. Instance_Type InstanceType;
  729. /* Variables */
  730. volatile bool finished_depop;
  731. volatile bool depop_zone;
  732. volatile bool repop_zone;
  733. volatile bool respawns_allowed;
  734. volatile bool LoadingData;
  735. bool reloading_spellprocess;
  736. bool zoneShuttingDown;
  737. bool cityzone;
  738. bool always_loaded;
  739. bool isInstance;
  740. int32 pNumPlayers;
  741. sint16 minimumStatus;
  742. int16 minimumLevel;
  743. int16 maximumLevel;
  744. int16 minimumVersion;
  745. char zone_name[64];
  746. char zonesky_file[64];
  747. char zone_file[64];
  748. char zone_description[255];
  749. float underworld;
  750. float safe_x;
  751. float safe_y;
  752. float safe_z;
  753. float safe_heading;
  754. float xp_mod;
  755. volatile int32 zoneID;
  756. bool locked; // JA: implementing /zone lock|unlock commands
  757. int32 instanceID;
  758. string zone_motd;
  759. int32 def_reenter_time;
  760. int32 def_reset_time;
  761. int32 def_lockout_time;
  762. int8 group_zone_option;
  763. float rain;
  764. bool isDusk;
  765. int dusk_hour;
  766. int dawn_hour;
  767. int dusk_minute;
  768. int dawn_minute;
  769. int32 spawn_delete_timer;
  770. int32 expansion_flag;
  771. int32 holiday_flag;
  772. //devn00b:test
  773. int can_bind;
  774. bool can_gate;
  775. map<int16, PacketStruct*> versioned_pos_structs;
  776. map<int16, PacketStruct*> versioned_info_structs;
  777. map<int16, PacketStruct*> versioned_vis_structs;
  778. /* Weather Stuff */
  779. bool weather_enabled; // false = disabled, true = enabled
  780. int8 weather_type; // 0 = normal, 1 = dynamic, 2 = random, 3 = chaotic
  781. int32 weather_frequency; // how often weather changes
  782. float weather_min_severity; // minimum weather severity in a zone
  783. float weather_max_severity; // maximum weather severity in a zone
  784. float weather_change_amount; // how much does the weather change each interval (normal weather conditions)
  785. float weather_dynamic_offset; // max amount the weather change each interval (dynamic weather conditions)
  786. int8 weather_change_chance; // percentage chance the weather will change
  787. int8 weather_pattern; // 0 = decreasing severity, 1 = increasing severity, 2 = random severity
  788. int32 weather_last_changed_time; // last time weather changed (used with weather_frequency)
  789. float weather_current_severity; // current weather conditions in a zone
  790. bool weather_allowed; // from zones.weather_allowed field in database
  791. bool weather_signaled; // whether or not we told the client "it begins to rain"
  792. bool reloading;
  793. map<int32, vector<EntityCommand*>* > entity_command_list;
  794. map<int32, map<int32, int8> > npc_spell_list;
  795. map<int32, map<int32, int16> > npc_skill_list;
  796. map<int32, vector<int32> > npc_equipment_list;
  797. map<int32, NPC*> npc_list;
  798. map<int32,Object*> object_list;
  799. map<int32,Sign*> sign_list;
  800. map<int32,Widget*> widget_list;
  801. map<int32, vector<GroundSpawnEntry*> > groundspawn_entries;
  802. map<int32, vector<GroundSpawnEntryItem*> > groundspawn_items;
  803. Mutex MGroundSpawnItems;
  804. map<int32,GroundSpawn*> groundspawn_list;
  805. map<int32,LootTable*> loot_tables;
  806. map<int32, vector<LootDrop*> > loot_drops;
  807. map<int32, vector<int32> > spawn_loot_list;
  808. vector<GlobalLoot*> level_loot_list;
  809. map<int16, vector<GlobalLoot*> > racial_loot_list;
  810. map<int32, vector<GlobalLoot*> > zone_loot_list;
  811. map<int32, vector<TransportDestination*> > transporters;
  812. map<int32, MutexList<LocationTransportDestination*>* > location_transporters;
  813. Mutex MTransporters;
  814. Mutex MTransportMaps;
  815. // Map <transport if, map name>
  816. map<int32, string> m_transportMaps;
  817. int32 watchdogTimestamp;
  818. std::map<int32, bool> m_pendingSpawnRemove;
  819. Mutex MPendingSpawnRemoval;
  820. std::map<int32, int32> lua_queued_state_commands;
  821. std::map<int32, std::map<std::string, float>> lua_spawn_update_command;
  822. std::mutex MLuaQueueStateCmd;
  823. public:
  824. Spawn* GetSpawn(int32 id);
  825. /* Entity Commands */
  826. map<int32, vector<EntityCommand*>*>* GetEntityCommandListAll() {return &entity_command_list;}
  827. vector<EntityCommand*>* GetEntityCommandList(int32 id);
  828. void SetEntityCommandList(int32 id, EntityCommand* command);
  829. void ClearEntityCommands();
  830. EntityCommand* GetEntityCommand(int32 id, string name);
  831. /* NPC's */
  832. void AddNPC(int32 id, NPC* npc);
  833. NPC* GetNPC(int32 id, bool override_loading = false) {
  834. if((!reloading || override_loading) && npc_list.count(id) > 0)
  835. return npc_list[id];
  836. else
  837. return 0;
  838. }
  839. NPC* GetNewNPC(int32 id) {
  840. if(!reloading && npc_list.count(id) > 0)
  841. return new NPC(npc_list[id]);
  842. else
  843. return 0;
  844. }
  845. /* NPC Spells */
  846. void AddNPCSpell(int32 list_id, int32 spell_id, int8 tier);
  847. vector<Spell*>* GetNPCSpells(int32 primary_list, int32 secondary_list);
  848. /* NPC Skills */
  849. void AddNPCSkill(int32 list_id, int32 skill_id, int16 value);
  850. map<string, Skill*>* GetNPCSkills(int32 primary_list, int32 secondary_list);
  851. /* NPC Equipment */
  852. void AddNPCEquipment(int32 list_id, int32 item_id);
  853. void SetNPCEquipment(NPC* npc);
  854. /* Objects */
  855. void AddObject(int32 id, Object* object){ object_list[id] = object; }
  856. Object* GetObject(int32 id, bool override_loading = false) {
  857. if((!reloading || override_loading) && object_list.count(id) > 0)
  858. return object_list[id];
  859. else
  860. return 0;
  861. }
  862. Object* GetNewObject(int32 id) {
  863. if(!reloading && object_list.count(id) > 0)
  864. return object_list[id]->Copy();
  865. else
  866. return 0;
  867. }
  868. /* Signs */
  869. void AddSign(int32 id, Sign* sign){ sign_list[id] = sign; }
  870. Sign* GetSign(int32 id, bool override_loading = false) {
  871. if((!reloading || override_loading) && sign_list.count(id) > 0)
  872. return sign_list[id];
  873. else
  874. return 0;
  875. }
  876. Sign* GetNewSign(int32 id) {
  877. if(!reloading && sign_list.count(id) > 0)
  878. return sign_list[id]->Copy();
  879. else
  880. return 0;
  881. }
  882. /* Widgets */
  883. void AddWidget(int32 id, Widget* widget);
  884. Widget* GetWidget(int32 id, bool override_loading = false);
  885. Widget* GetNewWidget(int32 id);
  886. /* Groundspawns */
  887. // JA: groundspawn revamp
  888. 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);
  889. void AddGroundSpawnItem(int32 groundspawn_id, int32 item_id, int8 is_rare, int32 grid_id);
  890. vector<GroundSpawnEntry*>* GetGroundSpawnEntries(int32 id);
  891. vector<GroundSpawnEntryItem*>* GetGroundSpawnEntryItems(int32 id);
  892. void LoadGroundSpawnEntries();
  893. void LoadGroundSpawnItems();
  894. //
  895. void DeleteGroundSpawnItems();
  896. void AddGroundSpawn(int32 id, GroundSpawn* spawn);
  897. GroundSpawn* GetGroundSpawn(int32 id, bool override_loading = false);
  898. GroundSpawn* GetNewGroundSpawn(int32 id);
  899. /* Pet names */
  900. vector<string> pet_names;
  901. /* Loot */
  902. void AddLootTable(int32 id, LootTable* table);
  903. void AddLootDrop(int32 id, LootDrop* drop);
  904. void AddSpawnLootList(int32 spawn_id, int32 id);
  905. void ClearSpawnLootList(int32 spawn_id);
  906. void AddLevelLootList(GlobalLoot* loot);
  907. void AddRacialLootList(int16 racial_id, GlobalLoot* loot);
  908. void AddZoneLootList(int32 zone, GlobalLoot* loot);
  909. void ClearLootTables();
  910. vector<int32> GetSpawnLootList(int32 spawn_id, int32 zone_id, int8 spawn_level, int16 racial_id, Spawn* spawn = 0);
  911. vector<LootDrop*>* GetLootDrops(int32 table_id);
  912. LootTable* GetLootTable(int32 table_id);
  913. /* Transporters */
  914. 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);
  915. 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,
  916. 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,
  917. int32 max_client_version, int32 flight_path_id, int16 mount_id, int8 mount_red_color, int8 mount_green_color, int8 mount_blue_color);
  918. void GetTransporters(vector<TransportDestination*>* returnList, Client* client, int32 transport_id);
  919. MutexList<LocationTransportDestination*>* GetLocationTransporters(int32 zone_id);
  920. void DeleteGlobalTransporters();
  921. ///<summary></summary>
  922. ///<param name='id'>The transport id</param>
  923. ///<param name='name'>Name of the map</param>
  924. void AddTransportMap(int32 id, string name);
  925. ///<summary>Checks to see if the transport has a map</summary>
  926. ///<param name='id'>The transport id we want to check</param>
  927. ///<returns>True if the transport id has a map</returns>
  928. bool TransportHasMap(int32 id);
  929. ///<summary>Gets the map name for the given transport id</summary>
  930. ///<param name='id'>The transport id that we want a map for</param>
  931. ///<returns>Map name</returns>
  932. string GetTransportMap(int32 id);
  933. ///<summary>Clears the list of transporter maps</summary>
  934. void DeleteTransporterMaps();
  935. void DeleteGlobalSpawns();
  936. void ReloadSpawns();
  937. void SendStateCommand(Spawn* spawn, int32 state);
  938. int32 lifetime_client_count;
  939. int32 incoming_clients;
  940. };
  941. #endif