Fixed possible crash
[getmangos.git] / src / game / World.h
blobd8800e2c3137cc3f7a30a8e2abd47f3767aa709d
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /// \addtogroup world The World
20 /// @{
21 /// \file
23 #ifndef __WORLD_H
24 #define __WORLD_H
26 #include "Common.h"
27 #include "Timer.h"
28 #include "Policies/Singleton.h"
29 #include "SharedDefines.h"
31 #include <map>
32 #include <set>
33 #include <list>
35 class Object;
36 class WorldPacket;
37 class WorldSession;
38 class Player;
39 class Weather;
40 struct ScriptAction;
41 struct ScriptInfo;
42 class SqlResultQueue;
43 class QueryResult;
44 class WorldSocket;
46 enum ShutdownMask
48 SHUTDOWN_MASK_RESTART = 1,
49 SHUTDOWN_MASK_IDLE = 2,
52 enum ShutdownExitCode
54 SHUTDOWN_EXIT_CODE = 0,
55 ERROR_EXIT_CODE = 1,
56 RESTART_EXIT_CODE = 2,
59 /// Timers for different object refresh rates
60 enum WorldTimers
62 WUPDATE_OBJECTS = 0,
63 WUPDATE_SESSIONS = 1,
64 WUPDATE_AUCTIONS = 2,
65 WUPDATE_WEATHERS = 3,
66 WUPDATE_UPTIME = 4,
67 WUPDATE_CORPSES = 5,
68 WUPDATE_EVENTS = 6,
69 WUPDATE_COUNT = 7
72 /// Configuration elements
73 enum WorldConfigs
75 CONFIG_COMPRESSION = 0,
76 CONFIG_GRID_UNLOAD,
77 CONFIG_INTERVAL_SAVE,
78 CONFIG_INTERVAL_GRIDCLEAN,
79 CONFIG_INTERVAL_MAPUPDATE,
80 CONFIG_INTERVAL_CHANGEWEATHER,
81 CONFIG_PORT_WORLD,
82 CONFIG_SOCKET_SELECTTIME,
83 CONFIG_GROUP_XP_DISTANCE,
84 CONFIG_SIGHT_MONSTER,
85 CONFIG_SIGHT_GUARDER,
86 CONFIG_GAME_TYPE,
87 CONFIG_REALM_ZONE,
88 CONFIG_ALLOW_TWO_SIDE_ACCOUNTS,
89 CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT,
90 CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL,
91 CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP,
92 CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD,
93 CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION,
94 CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL,
95 CONFIG_ALLOW_TWO_SIDE_WHO_LIST,
96 CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND,
97 CONFIG_STRICT_PLAYER_NAMES,
98 CONFIG_STRICT_CHARTER_NAMES,
99 CONFIG_STRICT_PET_NAMES,
100 CONFIG_CHARACTERS_CREATING_DISABLED,
101 CONFIG_CHARACTERS_PER_ACCOUNT,
102 CONFIG_CHARACTERS_PER_REALM,
103 CONFIG_SKIP_CINEMATICS,
104 CONFIG_MAX_PLAYER_LEVEL,
105 CONFIG_START_PLAYER_LEVEL,
106 CONFIG_START_PLAYER_MONEY,
107 CONFIG_MAX_HONOR_POINTS,
108 CONFIG_START_HONOR_POINTS,
109 CONFIG_MAX_ARENA_POINTS,
110 CONFIG_START_ARENA_POINTS,
111 CONFIG_INSTANCE_IGNORE_LEVEL,
112 CONFIG_INSTANCE_IGNORE_RAID,
113 CONFIG_BATTLEGROUND_CAST_DESERTER,
114 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE,
115 CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY,
116 CONFIG_INSTANCE_RESET_TIME_HOUR,
117 CONFIG_INSTANCE_UNLOAD_DELAY,
118 CONFIG_CAST_UNSTUCK,
119 CONFIG_MAX_PRIMARY_TRADE_SKILL,
120 CONFIG_MIN_PETITION_SIGNS,
121 CONFIG_GM_LOGIN_STATE,
122 CONFIG_GM_ACCEPT_TICKETS,
123 CONFIG_GM_CHAT,
124 CONFIG_GM_WISPERING_TO,
125 CONFIG_GM_IN_GM_LIST,
126 CONFIG_GM_IN_WHO_LIST,
127 CONFIG_GM_LOG_TRADE,
128 CONFIG_START_GM_LEVEL,
129 CONFIG_GROUP_VISIBILITY,
130 CONFIG_MAIL_DELIVERY_DELAY,
131 CONFIG_UPTIME_UPDATE,
132 CONFIG_SKILL_CHANCE_ORANGE,
133 CONFIG_SKILL_CHANCE_YELLOW,
134 CONFIG_SKILL_CHANCE_GREEN,
135 CONFIG_SKILL_CHANCE_GREY,
136 CONFIG_SKILL_CHANCE_MINING_STEPS,
137 CONFIG_SKILL_CHANCE_SKINNING_STEPS,
138 CONFIG_SKILL_PROSPECTING,
139 CONFIG_SKILL_GAIN_CRAFTING,
140 CONFIG_SKILL_GAIN_DEFENSE,
141 CONFIG_SKILL_GAIN_GATHERING,
142 CONFIG_SKILL_GAIN_WEAPON,
143 CONFIG_MAX_OVERSPEED_PINGS,
144 CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY,
145 CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL,
146 CONFIG_WEATHER,
147 CONFIG_EXPANSION,
148 CONFIG_CHATFLOOD_MESSAGE_COUNT,
149 CONFIG_CHATFLOOD_MESSAGE_DELAY,
150 CONFIG_CHATFLOOD_MUTE_TIME,
151 CONFIG_EVENT_ANNOUNCE,
152 CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS,
153 CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY,
154 CONFIG_WORLD_BOSS_LEVEL_DIFF,
155 CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF,
156 CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF,
157 CONFIG_DETECT_POS_COLLISION,
158 CONFIG_RESTRICTED_LFG_CHANNEL,
159 CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL,
160 CONFIG_TALENTS_INSPECTING,
161 CONFIG_CHAT_FAKE_MESSAGE_PREVENTING,
162 CONFIG_CORPSE_DECAY_NORMAL,
163 CONFIG_CORPSE_DECAY_RARE,
164 CONFIG_CORPSE_DECAY_ELITE,
165 CONFIG_CORPSE_DECAY_RAREELITE,
166 CONFIG_CORPSE_DECAY_WORLDBOSS,
167 CONFIG_ADDON_CHANNEL,
168 CONFIG_DEATH_SICKNESS_LEVEL,
169 CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP,
170 CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE,
171 CONFIG_THREAT_RADIUS,
172 CONFIG_INSTANT_LOGOUT,
173 CONFIG_DISABLE_BREATHING,
174 CONFIG_ALL_TAXI_PATHS,
175 CONFIG_DECLINED_NAMES_USED,
176 CONFIG_LISTEN_RANGE_SAY,
177 CONFIG_LISTEN_RANGE_TEXTEMOTE,
178 CONFIG_LISTEN_RANGE_YELL,
179 CONFIG_SKILL_MILLING,
180 CONFIG_VALUE_COUNT
183 /// Server rates
184 enum Rates
186 RATE_HEALTH=0,
187 RATE_POWER_MANA,
188 RATE_POWER_RAGE_INCOME,
189 RATE_POWER_RAGE_LOSS,
190 RATE_POWER_RUNICPOWER_INCOME,
191 RATE_POWER_RUNICPOWER_LOSS,
192 RATE_POWER_FOCUS,
193 RATE_SKILL_DISCOVERY,
194 RATE_DROP_ITEM_POOR,
195 RATE_DROP_ITEM_NORMAL,
196 RATE_DROP_ITEM_UNCOMMON,
197 RATE_DROP_ITEM_RARE,
198 RATE_DROP_ITEM_EPIC,
199 RATE_DROP_ITEM_LEGENDARY,
200 RATE_DROP_ITEM_ARTIFACT,
201 RATE_DROP_ITEM_REFERENCED,
202 RATE_DROP_MONEY,
203 RATE_XP_KILL,
204 RATE_XP_QUEST,
205 RATE_XP_EXPLORE,
206 RATE_XP_PAST_70,
207 RATE_REPUTATION_GAIN,
208 RATE_CREATURE_NORMAL_HP,
209 RATE_CREATURE_ELITE_ELITE_HP,
210 RATE_CREATURE_ELITE_RAREELITE_HP,
211 RATE_CREATURE_ELITE_WORLDBOSS_HP,
212 RATE_CREATURE_ELITE_RARE_HP,
213 RATE_CREATURE_NORMAL_DAMAGE,
214 RATE_CREATURE_ELITE_ELITE_DAMAGE,
215 RATE_CREATURE_ELITE_RAREELITE_DAMAGE,
216 RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE,
217 RATE_CREATURE_ELITE_RARE_DAMAGE,
218 RATE_CREATURE_NORMAL_SPELLDAMAGE,
219 RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE,
220 RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE,
221 RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE,
222 RATE_CREATURE_ELITE_RARE_SPELLDAMAGE,
223 RATE_CREATURE_AGGRO,
224 RATE_REST_INGAME,
225 RATE_REST_OFFLINE_IN_TAVERN_OR_CITY,
226 RATE_REST_OFFLINE_IN_WILDERNESS,
227 RATE_DAMAGE_FALL,
228 RATE_AUCTION_TIME,
229 RATE_AUCTION_DEPOSIT,
230 RATE_AUCTION_CUT,
231 RATE_HONOR,
232 RATE_MINING_AMOUNT,
233 RATE_MINING_NEXT,
234 RATE_TALENT,
235 RATE_CORPSE_DECAY_LOOTED,
236 RATE_INSTANCE_RESET_TIME,
237 RATE_TARGET_POS_RECALCULATION_RANGE,
238 RATE_DURABILITY_LOSS_DAMAGE,
239 RATE_DURABILITY_LOSS_PARRY,
240 RATE_DURABILITY_LOSS_ABSORB,
241 RATE_DURABILITY_LOSS_BLOCK,
242 MAX_RATES
245 /// Type of server
246 enum RealmType
248 REALM_TYPE_NORMAL = 0,
249 REALM_TYPE_PVP = 1,
250 REALM_TYPE_NORMAL2 = 4,
251 REALM_TYPE_RP = 6,
252 REALM_TYPE_RPPVP = 8,
253 REALM_TYPE_FFA_PVP = 16 // custom, free for all pvp mode like arena PvP in all zones except rest activated places and sanctuaries
254 // replaced by REALM_PVP in realm list
257 enum RealmZone
259 REALM_ZONE_UNKNOWN = 0, // any language
260 REALM_ZONE_DEVELOPMENT = 1, // any language
261 REALM_ZONE_UNITED_STATES = 2, // extended-Latin
262 REALM_ZONE_OCEANIC = 3, // extended-Latin
263 REALM_ZONE_LATIN_AMERICA = 4, // extended-Latin
264 REALM_ZONE_TOURNAMENT_5 = 5, // basic-Latin at create, any at login
265 REALM_ZONE_KOREA = 6, // East-Asian
266 REALM_ZONE_TOURNAMENT_7 = 7, // basic-Latin at create, any at login
267 REALM_ZONE_ENGLISH = 8, // extended-Latin
268 REALM_ZONE_GERMAN = 9, // extended-Latin
269 REALM_ZONE_FRENCH = 10, // extended-Latin
270 REALM_ZONE_SPANISH = 11, // extended-Latin
271 REALM_ZONE_RUSSIAN = 12, // Cyrillic
272 REALM_ZONE_TOURNAMENT_13 = 13, // basic-Latin at create, any at login
273 REALM_ZONE_TAIWAN = 14, // East-Asian
274 REALM_ZONE_TOURNAMENT_15 = 15, // basic-Latin at create, any at login
275 REALM_ZONE_CHINA = 16, // East-Asian
276 REALM_ZONE_CN1 = 17, // basic-Latin at create, any at login
277 REALM_ZONE_CN2 = 18, // basic-Latin at create, any at login
278 REALM_ZONE_CN3 = 19, // basic-Latin at create, any at login
279 REALM_ZONE_CN4 = 20, // basic-Latin at create, any at login
280 REALM_ZONE_CN5 = 21, // basic-Latin at create, any at login
281 REALM_ZONE_CN6 = 22, // basic-Latin at create, any at login
282 REALM_ZONE_CN7 = 23, // basic-Latin at create, any at login
283 REALM_ZONE_CN8 = 24, // basic-Latin at create, any at login
284 REALM_ZONE_TOURNAMENT_25 = 25, // basic-Latin at create, any at login
285 REALM_ZONE_TEST_SERVER = 26, // any language
286 REALM_ZONE_TOURNAMENT_27 = 27, // basic-Latin at create, any at login
287 REALM_ZONE_QA_SERVER = 28, // any language
288 REALM_ZONE_CN9 = 29 // basic-Latin at create, any at login
291 // DB scripting commands
292 #define SCRIPT_COMMAND_TALK 0 // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text)
293 #define SCRIPT_COMMAND_EMOTE 1 // source = unit, datalong = anim_id
294 #define SCRIPT_COMMAND_FIELD_SET 2 // source = any, datalong = field_id, datalog2 = value
295 #define SCRIPT_COMMAND_MOVE_TO 3 // source = Creature, datalog2 = time, x/y/z
296 #define SCRIPT_COMMAND_FLAG_SET 4 // source = any, datalong = field_id, datalog2 = bitmask
297 #define SCRIPT_COMMAND_FLAG_REMOVE 5 // source = any, datalong = field_id, datalog2 = bitmask
298 #define SCRIPT_COMMAND_TELEPORT_TO 6 // source or target with Player, datalong = map_id, x/y/z
299 #define SCRIPT_COMMAND_QUEST_EXPLORED 7 // one from source or target must be Player, another GO/Creature, datalong=quest_id, datalong2=distance or 0
300 #define SCRIPT_COMMAND_RESPAWN_GAMEOBJECT 9 // source = any (summoner), datalong=db_guid, datalong2=despawn_delay
301 #define SCRIPT_COMMAND_TEMP_SUMMON_CREATURE 10 // source = any (summoner), datalong=creature entry, datalong2=despawn_delay
302 #define SCRIPT_COMMAND_OPEN_DOOR 11 // source = unit, datalong=db_guid, datalong2=reset_delay
303 #define SCRIPT_COMMAND_CLOSE_DOOR 12 // source = unit, datalong=db_guid, datalong2=reset_delay
304 #define SCRIPT_COMMAND_ACTIVATE_OBJECT 13 // source = unit, target=GO
305 #define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
306 #define SCRIPT_COMMAND_CAST_SPELL 15 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
308 /// Storage class for commands issued for delayed execution
309 struct CliCommandHolder
311 typedef void Print(const char*);
313 char *m_command;
314 Print* m_print;
316 CliCommandHolder(const char *command, Print* zprint)
317 : m_print(zprint)
319 size_t len = strlen(command)+1;
320 m_command = new char[len];
321 memcpy(m_command, command, len);
324 ~CliCommandHolder() { delete[] m_command; }
327 /// The World
328 class World
330 public:
331 static volatile uint32 m_worldLoopCounter;
333 World();
334 ~World();
336 WorldSession* FindSession(uint32 id) const;
337 void AddSession(WorldSession *s);
338 bool RemoveSession(uint32 id);
339 /// Get the number of current active sessions
340 void UpdateMaxSessionCounters();
341 uint32 GetActiveAndQueuedSessionCount() const { return m_sessions.size(); }
342 uint32 GetActiveSessionCount() const { return m_sessions.size() - m_QueuedPlayer.size(); }
343 uint32 GetQueuedSessionCount() const { return m_QueuedPlayer.size(); }
344 /// Get the maximum number of parallel sessions on the server since last reboot
345 uint32 GetMaxQueuedSessionCount() const { return m_maxQueuedSessionCount; }
346 uint32 GetMaxActiveSessionCount() const { return m_maxActiveSessionCount; }
347 Player* FindPlayerInZone(uint32 zone);
349 Weather* FindWeather(uint32 id) const;
350 Weather* AddWeather(uint32 zone_id);
351 void RemoveWeather(uint32 zone_id);
353 /// Get the active session server limit (or security level limitations)
354 uint32 GetPlayerAmountLimit() const { return m_playerLimit >= 0 ? m_playerLimit : 0; }
355 AccountTypes GetPlayerSecurityLimit() const { return m_playerLimit <= 0 ? AccountTypes(-m_playerLimit) : SEC_PLAYER; }
357 /// Set the active session server limit (or security level limitation)
358 void SetPlayerLimit(int32 limit, bool needUpdate = false);
360 //player Queue
361 typedef std::list<WorldSession*> Queue;
362 void AddQueuedPlayer(WorldSession*);
363 bool RemoveQueuedPlayer(WorldSession* session);
364 int32 GetQueuePos(WorldSession*);
365 uint32 GetQueueSize() const { return m_QueuedPlayer.size(); }
367 /// \todo Actions on m_allowMovement still to be implemented
368 /// Is movement allowed?
369 bool getAllowMovement() const { return m_allowMovement; }
370 /// Allow/Disallow object movements
371 void SetAllowMovement(bool allow) { m_allowMovement = allow; }
373 /// Set a new Message of the Day
374 void SetMotd(std::string motd) { m_motd = motd; }
375 /// Get the current Message of the Day
376 const char* GetMotd() const { return m_motd.c_str(); }
378 uint32 GetDefaultDbcLocale() const { return m_defaultDbcLocale; }
380 /// Get the path where data (dbc, maps) are stored on disk
381 std::string GetDataPath() const { return m_dataPath; }
383 /// When server started?
384 time_t const& GetStartTime() const { return m_startTime; }
385 /// What time is it?
386 time_t const& GetGameTime() const { return m_gameTime; }
387 /// Uptime (in secs)
388 uint32 GetUptime() const { return uint32(m_gameTime - m_startTime); }
390 /// Get the maximum skill level a player can reach
391 uint16 GetConfigMaxSkillValue() const
393 uint32 lvl = getConfig(CONFIG_MAX_PLAYER_LEVEL);
394 return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl*5;
397 void SetInitialWorldSettings();
398 void LoadConfigSettings(bool reload = false);
400 void SendWorldText(int32 string_id, ...);
401 void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0, uint32 team = 0);
402 void SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self = 0, uint32 team = 0);
403 void SendZoneText(uint32 zone, const char *text, WorldSession *self = 0, uint32 team = 0);
404 void SendServerMessage(uint32 type, const char *text = "", Player* player = NULL);
406 /// Are we in the middle of a shutdown?
407 bool IsShutdowning() const { return m_ShutdownTimer > 0; }
408 void ShutdownServ(uint32 time, uint32 options, uint8 exitcode);
409 void ShutdownCancel();
410 void ShutdownMsg(bool show = false, Player* player = NULL);
411 static uint8 GetExitCode() { return m_ExitCode; }
412 static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; }
413 static bool IsStopped() { return m_stopEvent; }
415 void Update(time_t diff);
417 void UpdateSessions( time_t diff );
418 /// Set a server rate (see #Rates)
419 void setRate(Rates rate,float value) { rate_values[rate]=value; }
420 /// Get a server rate (see #Rates)
421 float getRate(Rates rate) const { return rate_values[rate]; }
423 /// Set a server configuration element (see #WorldConfigs)
424 void setConfig(uint32 index,uint32 value)
426 if(index<CONFIG_VALUE_COUNT)
427 m_configs[index]=value;
430 /// Get a server configuration element (see #WorldConfigs)
431 uint32 getConfig(uint32 index) const
433 if(index<CONFIG_VALUE_COUNT)
434 return m_configs[index];
435 else
436 return 0;
439 /// Are we on a "Player versus Player" server?
440 bool IsPvPRealm() { return (getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP || getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP); }
441 bool IsFFAPvPRealm() { return getConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP; }
443 bool KickPlayer(std::string playerName);
444 void KickAll();
445 void KickAllLess(AccountTypes sec);
446 BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author);
447 bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
449 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
450 void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
451 bool IsScriptScheduled() const { return !m_scriptSchedule.empty(); }
453 // for max speed access
454 static float GetMaxVisibleDistanceForCreature() { return m_MaxVisibleDistanceForCreature; }
455 static float GetMaxVisibleDistanceForPlayer() { return m_MaxVisibleDistanceForPlayer; }
456 static float GetMaxVisibleDistanceForObject() { return m_MaxVisibleDistanceForObject; }
457 static float GetMaxVisibleDistanceInFlight() { return m_MaxVisibleDistanceInFlight; }
458 static float GetVisibleUnitGreyDistance() { return m_VisibleUnitGreyDistance; }
459 static float GetVisibleObjectGreyDistance() { return m_VisibleObjectGreyDistance; }
461 void ProcessCliCommands();
462 void QueueCliCommand( CliCommandHolder::Print* zprintf, char const* input ) { cliCmdQueue.add(new CliCommandHolder(input, zprintf)); }
464 void UpdateResultQueue();
465 void InitResultQueue();
467 void UpdateRealmCharCount(uint32 accid);
469 LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; }
471 //used World DB version
472 void LoadDBVersion();
473 char const* GetDBVersion() { return m_DBVersion.c_str(); }
475 //used Script version
476 void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; }
477 char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); }
479 protected:
480 void _UpdateGameTime();
481 void ScriptsProcess();
482 // callback for UpdateRealmCharacters
483 void _UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId);
485 void InitDailyQuestResetTime();
486 void ResetDailyQuests();
487 private:
488 static volatile bool m_stopEvent;
489 static uint8 m_ExitCode;
490 uint32 m_ShutdownTimer;
491 uint32 m_ShutdownMask;
493 time_t m_startTime;
494 time_t m_gameTime;
495 IntervalTimer m_timers[WUPDATE_COUNT];
496 uint32 mail_timer;
497 uint32 mail_timer_expires;
499 typedef UNORDERED_MAP<uint32, Weather*> WeatherMap;
500 WeatherMap m_weathers;
501 typedef UNORDERED_MAP<uint32, WorldSession*> SessionMap;
502 SessionMap m_sessions;
503 uint32 m_maxActiveSessionCount;
504 uint32 m_maxQueuedSessionCount;
506 std::multimap<time_t, ScriptAction> m_scriptSchedule;
508 float rate_values[MAX_RATES];
509 uint32 m_configs[CONFIG_VALUE_COUNT];
510 int32 m_playerLimit;
511 LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales
512 uint32 m_availableDbcLocaleMask; // by loaded DBC
513 void DetectDBCLang();
514 bool m_allowMovement;
515 std::string m_motd;
516 std::string m_dataPath;
518 // for max speed access
519 static float m_MaxVisibleDistanceForCreature;
520 static float m_MaxVisibleDistanceForPlayer;
521 static float m_MaxVisibleDistanceForObject;
522 static float m_MaxVisibleDistanceInFlight;
523 static float m_VisibleUnitGreyDistance;
524 static float m_VisibleObjectGreyDistance;
526 // CLI command holder to be thread safe
527 ZThread::LockedQueue<CliCommandHolder*, ZThread::FastMutex> cliCmdQueue;
528 SqlResultQueue *m_resultQueue;
530 // next daily quests reset time
531 time_t m_NextDailyQuestReset;
533 //Player Queue
534 Queue m_QueuedPlayer;
536 //sessions that are added async
537 void AddSession_(WorldSession* s);
538 ZThread::LockedQueue<WorldSession*, ZThread::FastMutex> addSessQueue;
540 //used versions
541 std::string m_DBVersion;
542 std::string m_ScriptsVersion;
545 extern uint32 realmID;
547 #define sWorld MaNGOS::Singleton<World>::Instance()
548 #endif
549 /// @}