zoneserver.h 42 KB

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