AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
World Class Reference

The World. More...

#include "World.h"

Inheritance diagram for World:
IWorld

Public Member Functions

 World ()
 World constructor.
 
 ~World () override
 World destructor.
 
bool IsClosed () const override
 Deny clients?
 
void SetClosed (bool val) override
 Close world.
 
AccountTypes GetPlayerSecurityLimit () const override
 Security level limitations.
 
void SetPlayerSecurityLimit (AccountTypes sec) override
 
void LoadDBAllowedSecurityLevel () override
 
bool getAllowMovement () const override
 
void SetAllowMovement (bool allow) override
 Allow/Disallow object movements.
 
LocaleConstant GetDefaultDbcLocale () const override
 
std::string const & GetDataPath () const override
 Get the path where data (dbc, maps) are stored on disk.
 
Seconds GetNextDailyQuestsResetTime () const override
 Next daily quests and random bg reset time.
 
Seconds GetNextWeeklyQuestsResetTime () const override
 
Seconds GetNextRandomBGResetTime () const override
 
uint16 GetConfigMaxSkillValue () const override
 Get the maximum skill level a player can reach.
 
void SetInitialWorldSettings () override
 Initialize the World.
 
void LoadConfigSettings (bool reload=false) override
 Initialize config values.
 
bool IsShuttingDown () const override
 Are we in the middle of a shutdown?
 
uint32 GetShutDownTimeLeft () const override
 
void ShutdownServ (uint32 time, uint32 options, uint8 exitcode, std::string const &reason=std::string()) override
 Shutdown the server.
 
void ShutdownCancel () override
 Cancel a planned server shutdown.
 
void ShutdownMsg (bool show=false, Player *player=nullptr, std::string const &reason=std::string()) override
 Displays a shutdown message at specific intervals or immediately if required.
 
void Update (uint32 diff) override
 Update the World !
 
void setRate (ServerConfigs index, float value) override
 
float getRate (ServerConfigs index) const override
 
void setBoolConfig (ServerConfigs index, bool value) override
 
bool getBoolConfig (ServerConfigs index) const override
 
void setFloatConfig (ServerConfigs index, float value) override
 
float getFloatConfig (ServerConfigs index) const override
 
void setIntConfig (ServerConfigs index, uint32 value) override
 
uint32 getIntConfig (ServerConfigs index) const override
 
void setStringConfig (ServerConfigs index, std::string const &value) override
 
std::string_view getStringConfig (ServerConfigs index) const override
 
bool IsPvPRealm () const override
 Are we on a "Player versus Player" server?
 
bool IsFFAPvPRealm () const override
 
uint32 GetNextWhoListUpdateDelaySecs () override
 
void ProcessCliCommands () override
 
void QueueCliCommand (CliCommandHolder *commandHolder) override
 
void ForceGameEventUpdate () override
 
void UpdateRealmCharCount (uint32 accid) override
 
LocaleConstant GetAvailableDbcLocale (LocaleConstant locale) const override
 
void LoadDBVersion () override
 
char const * GetDBVersion () const override
 
void UpdateAreaDependentAuras () override
 
uint32 GetCleaningFlags () const override
 
void SetCleaningFlags (uint32 flags) override
 
void ResetEventSeasonalQuests (uint16 event_id) override
 
std::string const & GetRealmName () const override
 
void SetRealmName (std::string name) override
 
- Public Member Functions inherited from IWorld
virtual ~IWorld ()=default
 

Static Public Member Functions

static Worldinstance ()
 
static uint8 GetExitCode ()
 
static void StopNow (uint8 exitcode)
 
static bool IsStopped ()
 
static float GetMaxVisibleDistanceOnContinents ()
 
static float GetMaxVisibleDistanceInInstances ()
 
static float GetMaxVisibleDistanceInBGArenas ()
 

Static Public Attributes

static uint32 m_worldLoopCounter = 0
 

Protected Member Functions

void _UpdateGameTime ()
 Update the game time.
 
void _UpdateRealmCharCount (PreparedQueryResult resultCharCount, uint32 accountId)
 
void InitDailyQuestResetTime ()
 
void InitWeeklyQuestResetTime ()
 
void InitMonthlyQuestResetTime ()
 
void InitRandomBGResetTime ()
 
void InitCalendarOldEventsDeletionTime ()
 
void InitGuildResetTime ()
 
void ResetDailyQuests ()
 
void ResetWeeklyQuests ()
 
void ResetMonthlyQuests ()
 
void ResetRandomBG ()
 
void CalendarDeleteOldEvents ()
 
void ResetGuildCap ()
 

Private Member Functions

void DetectDBCLang ()
 
void ProcessQueryCallbacks ()
 
void FinalizePlayerWorldSession (WorldSession *session)
 Executed when a World Session is being finalized. Be it from a normal login or via queue popping.
 

Private Attributes

WorldConfig _worldConfig
 
uint32 _shutdownTimer
 
uint32 _shutdownMask
 
std::string _shutdownReason
 
uint32 _cleaningFlags
 
bool _isClosed
 
IntervalTimer _timers [WUPDATE_COUNT]
 
Seconds _mail_expire_check_timer
 
AccountTypes _allowedSecurityLevel
 
LocaleConstant _defaultDbcLocale
 
uint32 _availableDbcLocaleMask
 
bool _allowMovement
 
std::string _dataPath
 
std::string _realmName
 
LockedQueue< CliCommandHolder * > _cliCmdQueue
 
Seconds _nextDailyQuestReset
 
Seconds _nextWeeklyQuestReset
 
Seconds _nextMonthlyQuestReset
 
Seconds _nextRandomBGReset
 
Seconds _nextCalendarOldEventsDeletionTime
 
Seconds _nextGuildReset
 
std::string _dbVersion
 
uint32 _dbClientCacheVersion
 
QueryCallbackProcessor _queryProcessor
 

Static Private Attributes

static std::atomic_long _stopEvent = false
 
static uint8 _exitCode = SHUTDOWN_EXIT_CODE
 
static float _maxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE
 
static float _maxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE
 
static float _maxVisibleDistanceInBGArenas = DEFAULT_VISIBILITY_BGARENAS
 

Detailed Description

The World.

Constructor & Destructor Documentation

◆ World()

World::World ( )

World constructor.

115{
117 _allowMovement = true;
118 _shutdownMask = 0;
119 _shutdownTimer = 0;
125 _nextGuildReset = 0s;
128 _isClosed = false;
129 _cleaningFlags = 0;
131}
@ LOCALE_enUS
Definition Common.h:118
@ SEC_PLAYER
Definition Common.h:57
Seconds _nextGuildReset
Definition World.h:299
uint32 _shutdownMask
Definition World.h:266
uint32 _cleaningFlags
Definition World.h:269
LocaleConstant _defaultDbcLocale
Definition World.h:277
Seconds _nextDailyQuestReset
Definition World.h:294
bool _isClosed
Definition World.h:271
uint32 _dbClientCacheVersion
Definition World.h:303
Seconds _nextMonthlyQuestReset
Definition World.h:296
Seconds _nextCalendarOldEventsDeletionTime
Definition World.h:298
Seconds _nextWeeklyQuestReset
Definition World.h:295
uint32 _shutdownTimer
Definition World.h:265
Seconds _nextRandomBGReset
Definition World.h:297
bool _allowMovement
Definition World.h:280
AccountTypes _allowedSecurityLevel
Definition World.h:276
Seconds _mail_expire_check_timer
Definition World.h:274

References _allowedSecurityLevel, _allowMovement, _cleaningFlags, _dbClientCacheVersion, _defaultDbcLocale, _isClosed, _mail_expire_check_timer, _nextCalendarOldEventsDeletionTime, _nextDailyQuestReset, _nextGuildReset, _nextMonthlyQuestReset, _nextRandomBGReset, _nextWeeklyQuestReset, _shutdownMask, _shutdownTimer, LOCALE_enUS, and SEC_PLAYER.

◆ ~World()

World::~World ( )
override

World destructor.

135{
136 CliCommandHolder* command = nullptr;
137 while (_cliCmdQueue.next(command))
138 delete command;
139
142}
bool next(T &result)
Gets the next item in the queue and removes it.
Definition LockedQueue.h:77
static void clear()
Definition MMapFactory.cpp:48
static void clear()
Definition VMapFactory.cpp:39
LockedQueue< CliCommandHolder * > _cliCmdQueue
Definition World.h:291
Storage class for commands issued for delayed execution.
Definition IWorld.h:35

References _cliCmdQueue, MMAP::MMapFactory::clear(), VMAP::VMapFactory::clear(), and LockedQueue< T, StorageType >::next().

Member Function Documentation

◆ _UpdateGameTime()

void World::_UpdateGameTime ( )
protected

Update the game time.

  • update the time
  • if there is a shutdown timer
  • ... and it is overdue, stop the world (set m_stopEvent)
  • ... else decrease it and if necessary display a shutdown countdown to the users
1432{
1434 Seconds lastGameTime = GameTime::GetGameTime();
1436
1437 Seconds elapsed = GameTime::GetGameTime() - lastGameTime;
1438
1440 if (!IsStopped() && _shutdownTimer > 0 && elapsed > 0s)
1441 {
1443 if (_shutdownTimer <= elapsed.count())
1444 {
1445 if (!(_shutdownMask & SHUTDOWN_MASK_IDLE) || sWorldSessionMgr->GetActiveAndQueuedSessionCount() == 0)
1446 _stopEvent = true; // exist code already set
1447 else
1448 _shutdownTimer = 1; // minimum timer value to wait idle state
1449 }
1451 else
1452 {
1453 _shutdownTimer -= elapsed.count();
1454
1455 ShutdownMsg();
1456 }
1457 }
1458}
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
#define sWorldSessionMgr
Definition WorldSessionMgr.h:110
void ShutdownMsg(bool show=false, Player *player=nullptr, std::string const &reason=std::string()) override
Displays a shutdown message at specific intervals or immediately if required.
Definition World.cpp:1503
static std::atomic_long _stopEvent
Definition World.h:263
static bool IsStopped()
Definition World.h:190
@ SHUTDOWN_MASK_IDLE
Definition World.h:48
void UpdateGameTimers()
Update all timers.
Definition GameTime.cpp:63
Seconds GetGameTime()
Definition GameTime.cpp:38

References _shutdownMask, _shutdownTimer, _stopEvent, GameTime::GetGameTime(), IsStopped(), SHUTDOWN_MASK_IDLE, ShutdownMsg(), sWorldSessionMgr, and GameTime::UpdateGameTimers().

Referenced by Update().

◆ _UpdateRealmCharCount()

void World::_UpdateRealmCharCount ( PreparedQueryResult  resultCharCount,
uint32  accountId 
)
protected
1579{
1580 uint8 charCount{0};
1581 if (resultCharCount)
1582 {
1583 Field* fields = resultCharCount->Fetch();
1584 charCount = uint8(fields[1].Get<uint64>());
1585 }
1586
1587 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
1588
1590 stmt->SetData(0, charCount);
1591 stmt->SetData(1, accountId);
1592 stmt->SetData(2, realm.Id.Realm);
1593 trans->Append(stmt);
1594
1595 LoginDatabase.CommitTransaction(trans);
1596}
SQLTransaction< LoginDatabaseConnection > LoginDatabaseTransaction
Definition DatabaseEnvFwd.h:70
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition DatabaseEnv.cpp:22
std::uint8_t uint8
Definition Define.h:109
@ LOGIN_REP_REALM_CHARACTERS
Definition LoginDatabase.h:63
Class used to access individual fields of database query result.
Definition Field.h:98
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
AC_GAME_API Realm realm
Definition World.cpp:111
uint32 Realm
Definition Realm.h:43
RealmHandle Id
Definition Realm.h:69

References Realm::Id, LOGIN_REP_REALM_CHARACTERS, LoginDatabase, realm, RealmHandle::Realm, and PreparedStatementBase::SetData().

Referenced by UpdateRealmCharCount().

◆ CalendarDeleteOldEvents()

void World::CalendarDeleteOldEvents ( )
protected
1762{
1763 LOG_INFO("server.worldserver", "Calendar deletion of old events.");
1764
1767 sCalendarMgr->DeleteOldEvents();
1768}
#define sCalendarMgr
Definition CalendarMgr.h:344
#define LOG_INFO(filterType__,...)
Definition Log.h:166
@ CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR
Definition WorldConfig.h:307
@ WORLD_STATE_CUSTOM_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME
Definition WorldStateDefines.h:613
#define sWorldState
Definition WorldState.h:377
uint32 getIntConfig(ServerConfigs index) const override
Definition World.cpp:1362
AC_COMMON_API time_t GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour)
Definition Timer.cpp:302

References _nextCalendarOldEventsDeletionTime, CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR, getIntConfig(), Acore::Time::GetNextTimeWithDayAndHour(), LOG_INFO, sCalendarMgr, sWorldState, and WORLD_STATE_CUSTOM_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME.

Referenced by Update().

◆ DetectDBCLang()

void World::DetectDBCLang ( )
private
1047{
1048 uint8 m_lang_confid = sConfigMgr->GetOption<int32>("DBC.Locale", 255);
1049
1050 if (m_lang_confid != 255 && m_lang_confid >= TOTAL_LOCALES)
1051 {
1052 LOG_ERROR("server.loading", "Incorrect DBC.Locale! Must be >= 0 and < {} (set to 0)", TOTAL_LOCALES);
1053 m_lang_confid = LOCALE_enUS;
1054 }
1055
1056 ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1);
1057 std::string availableLocalsStr;
1058
1059 uint8 default_locale = TOTAL_LOCALES;
1060 for (uint8 i = default_locale - 1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8
1061 {
1062 if (race->name[i][0] != '\0') // check by race names
1063 {
1064 default_locale = i;
1065 _availableDbcLocaleMask |= (1 << i);
1066 availableLocalsStr += localeNames[i];
1067 availableLocalsStr += " ";
1068 }
1069 }
1070
1071 if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES &&
1072 (_availableDbcLocaleMask & (1 << m_lang_confid)))
1073 {
1074 default_locale = m_lang_confid;
1075 }
1076
1077 if (default_locale >= TOTAL_LOCALES)
1078 {
1079 LOG_ERROR("server.loading", "Unable to determine your DBC Locale! (corrupt DBC?)");
1080 exit(1);
1081 }
1082
1083 _defaultDbcLocale = LocaleConstant(default_locale);
1084
1085 LOG_INFO("server.loading", "Using {} DBC Locale As Default. All Available DBC locales: {}", localeNames[GetDefaultDbcLocale()], availableLocalsStr.empty() ? "<none>" : availableLocalsStr);
1086 LOG_INFO("server.loading", " ");
1087}
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:117
@ TOTAL_LOCALES
Definition Common.h:128
#define sConfigMgr
Definition Config.h:74
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
std::int32_t int32
Definition Define.h:103
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
uint32 _availableDbcLocaleMask
Definition World.h:278
LocaleConstant GetDefaultDbcLocale() const override
Definition World.h:162
Definition DBCStructure.h:679
char const * name[16]
Definition DBCStructure.h:691

References _availableDbcLocaleMask, _defaultDbcLocale, GetDefaultDbcLocale(), LOCALE_enUS, localeNames, LOG_ERROR, LOG_INFO, ChrRacesEntry::name, sChrRacesStore, sConfigMgr, and TOTAL_LOCALES.

Referenced by SetInitialWorldSettings().

◆ FinalizePlayerWorldSession()

void World::FinalizePlayerWorldSession ( WorldSession session)
inlineprivate

Executed when a World Session is being finalized. Be it from a normal login or via queue popping.

Parameters
sessionThe World Session that we are finalizing.

◆ ForceGameEventUpdate()

void World::ForceGameEventUpdate ( )
overridevirtual

Implements IWorld.

1378{
1379 _timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed
1380 uint32 nextGameEvent = sGameEventMgr->Update();
1381 _timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
1383}
std::uint32_t uint32
Definition Define.h:107
#define sGameEventMgr
Definition GameEventMgr.h:201
IntervalTimer _timers[WUPDATE_COUNT]
Definition World.h:273
@ WUPDATE_EVENTS
Definition World.h:63
void SetInterval(time_t interval)
Definition Timer.h:179
void Reset()
Definition Timer.h:166

References _timers, IntervalTimer::Reset(), IntervalTimer::SetInterval(), sGameEventMgr, and WUPDATE_EVENTS.

◆ getAllowMovement()

bool World::getAllowMovement ( ) const
inlineoverridevirtual
Todo:
Actions on m_allowMovement still to be implemented Is movement allowed?

Implements IWorld.

158{ return _allowMovement; }

References _allowMovement.

◆ GetAvailableDbcLocale()

LocaleConstant World::GetAvailableDbcLocale ( LocaleConstant  locale) const
inlineoverridevirtual

Implements IWorld.

228{ if (_availableDbcLocaleMask & (1 << locale)) return locale; else return _defaultDbcLocale; }

References _availableDbcLocaleMask, and _defaultDbcLocale.

◆ getBoolConfig()

bool World::getBoolConfig ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1343{
1344 return _worldConfig.GetConfigValue<bool>(index);
1345}
T GetConfigValue(ConfigEnum const config) const
Definition ConfigValueCache.h:97
WorldConfig _worldConfig
Definition World.h:261

References _worldConfig, and ConfigValueCache< ConfigEnum >::GetConfigValue().

Referenced by LoadConfigSettings(), SetInitialWorldSettings(), and Update().

◆ GetCleaningFlags()

uint32 World::GetCleaningFlags ( ) const
inlineoverridevirtual

Implements IWorld.

236{ return _cleaningFlags; }

References _cleaningFlags.

◆ GetConfigMaxSkillValue()

uint16 World::GetConfigMaxSkillValue ( ) const
inlineoverridevirtual

Get the maximum skill level a player can reach.

Implements IWorld.

174 {
176 return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl * 5;
177 }
std::uint16_t uint16
Definition Define.h:108
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:187

References CONFIG_MAX_PLAYER_LEVEL, and getIntConfig().

◆ GetDataPath()

std::string const & World::GetDataPath ( ) const
inlineoverridevirtual

Get the path where data (dbc, maps) are stored on disk.

Implements IWorld.

165{ return _dataPath; }
std::string _dataPath
Definition World.h:281

References _dataPath.

◆ GetDBVersion()

char const * World::GetDBVersion ( ) const
inlineoverridevirtual

Implements IWorld.

232{ return _dbVersion.c_str(); }
std::string _dbVersion
Definition World.h:302

References _dbVersion.

◆ GetDefaultDbcLocale()

LocaleConstant World::GetDefaultDbcLocale ( ) const
inlineoverridevirtual

Implements IWorld.

162{ return _defaultDbcLocale; }

References _defaultDbcLocale.

Referenced by DetectDBCLang(), and SetInitialWorldSettings().

◆ GetExitCode()

static uint8 World::GetExitCode ( )
inlinestatic
188{ return _exitCode; }
static uint8 _exitCode
Definition World.h:264

References _exitCode.

Referenced by main().

◆ getFloatConfig()

float World::getFloatConfig ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1353{
1354 return _worldConfig.GetConfigValue<float>(index);
1355}

References _worldConfig, and ConfigValueCache< ConfigEnum >::GetConfigValue().

Referenced by getRate().

◆ getIntConfig()

◆ GetMaxVisibleDistanceInBGArenas()

static float World::GetMaxVisibleDistanceInBGArenas ( )
inlinestatic
static float _maxVisibleDistanceInBGArenas
Definition World.h:286

References _maxVisibleDistanceInBGArenas.

Referenced by Battleground::_ProcessJoin(), and BattlegroundMap::InitVisibilityDistance().

◆ GetMaxVisibleDistanceInInstances()

static float World::GetMaxVisibleDistanceInInstances ( )
inlinestatic
static float _maxVisibleDistanceInInstances
Definition World.h:285

References _maxVisibleDistanceInInstances.

Referenced by InstanceMap::InitVisibilityDistance().

◆ GetMaxVisibleDistanceOnContinents()

static float World::GetMaxVisibleDistanceOnContinents ( )
inlinestatic
static float _maxVisibleDistanceOnContinents
Definition World.h:284

References _maxVisibleDistanceOnContinents.

Referenced by Map::InitVisibilityDistance().

◆ GetNextDailyQuestsResetTime()

Seconds World::GetNextDailyQuestsResetTime ( ) const
inlineoverridevirtual

Next daily quests and random bg reset time.

Implements IWorld.

168{ return _nextDailyQuestReset; }

References _nextDailyQuestReset.

◆ GetNextRandomBGResetTime()

Seconds World::GetNextRandomBGResetTime ( ) const
inlineoverridevirtual

Implements IWorld.

170{ return _nextRandomBGReset; }

References _nextRandomBGReset.

◆ GetNextWeeklyQuestsResetTime()

Seconds World::GetNextWeeklyQuestsResetTime ( ) const
inlineoverridevirtual

Implements IWorld.

169{ return _nextWeeklyQuestReset; }

References _nextWeeklyQuestReset.

◆ GetNextWhoListUpdateDelaySecs()

uint32 World::GetNextWhoListUpdateDelaySecs ( )
overridevirtual

Implements IWorld.

1824{
1825 if (_timers[WUPDATE_5_SECS].Passed())
1826 return 1;
1827
1829 t = std::min(t, (uint32)_timers[WUPDATE_5_SECS].GetInterval());
1830
1831 return uint32(std::ceil(t / 1000.0f));
1832}
@ WUPDATE_5_SECS
Definition World.h:68
time_t GetCurrent() const
Definition Timer.h:189
time_t GetInterval() const
Definition Timer.h:184

References _timers, IntervalTimer::GetCurrent(), IntervalTimer::GetInterval(), and WUPDATE_5_SECS.

◆ GetPlayerSecurityLimit()

AccountTypes World::GetPlayerSecurityLimit ( ) const
inlineoverridevirtual

Security level limitations.

Implements IWorld.

152{ return _allowedSecurityLevel; }

References _allowedSecurityLevel.

◆ getRate()

float World::getRate ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1333{
1334 return getFloatConfig(index);
1335}
float getFloatConfig(ServerConfigs index) const override
Definition World.cpp:1352

References getFloatConfig().

Referenced by LoadConfigSettings().

◆ GetRealmName()

std::string const & World::GetRealmName ( ) const
inlineoverridevirtual

Implements IWorld.

240{ return _realmName; } // pussywizard
std::string _realmName
Definition World.h:288

References _realmName.

◆ GetShutDownTimeLeft()

uint32 World::GetShutDownTimeLeft ( ) const
inlineoverridevirtual

Implements IWorld.

184{ return _shutdownTimer; }

References _shutdownTimer.

◆ getStringConfig()

std::string_view World::getStringConfig ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1373{
1374 return _worldConfig.GetConfigValue(index);
1375}

References _worldConfig, and ConfigValueCache< ConfigEnum >::GetConfigValue().

◆ InitCalendarOldEventsDeletionTime()

void World::InitCalendarOldEventsDeletionTime ( )
protected
1643{
1645 Seconds nextDeletionTime = currentDeletionTime > 0s ? currentDeletionTime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR)));
1646
1647 if (currentDeletionTime == 0s)
1648 {
1649 sWorldState->setWorldState(WORLD_STATE_CUSTOM_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME, nextDeletionTime.count());
1650 }
1651}

References CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR, getIntConfig(), Acore::Time::GetNextTimeWithDayAndHour(), sWorldState, and WORLD_STATE_CUSTOM_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME.

Referenced by SetInitialWorldSettings().

◆ InitDailyQuestResetTime()

void World::InitDailyQuestResetTime ( )
protected
1610{
1613
1614 if (wstime == 0s)
1615 {
1617 }
1618}
@ WORLD_STATE_CUSTOM_DAILY_QUEST_RESET_TIME
Definition WorldStateDefines.h:610

References _nextDailyQuestReset, Acore::Time::GetNextTimeWithDayAndHour(), sWorldState, and WORLD_STATE_CUSTOM_DAILY_QUEST_RESET_TIME.

Referenced by SetInitialWorldSettings().

◆ InitGuildResetTime()

void World::InitGuildResetTime ( )
protected
1654{
1656 _nextGuildReset = wstime > 0s ? wstime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, 6));
1657
1658 if (wstime == 0s)
1659 {
1661 }
1662}
@ WORLD_STATE_CUSTOM_GUILD_DAILY_RESET_TIME
Definition WorldStateDefines.h:611

References _nextGuildReset, Acore::Time::GetNextTimeWithDayAndHour(), sWorldState, and WORLD_STATE_CUSTOM_GUILD_DAILY_RESET_TIME.

Referenced by SetInitialWorldSettings().

◆ InitMonthlyQuestResetTime()

void World::InitMonthlyQuestResetTime ( )
protected
1621{
1624
1625 if (wstime == 0s)
1626 {
1628 }
1629}
@ WORLD_STATE_CUSTOM_MONTHLY_QUEST_RESET_TIME
Definition WorldStateDefines.h:612

References _nextMonthlyQuestReset, Acore::Time::GetNextTimeWithDayAndHour(), sWorldState, and WORLD_STATE_CUSTOM_MONTHLY_QUEST_RESET_TIME.

Referenced by SetInitialWorldSettings().

◆ InitRandomBGResetTime()

void World::InitRandomBGResetTime ( )
protected
1632{
1634 _nextRandomBGReset = wstime > 0s ? wstime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, 6));
1635
1636 if (wstime == 0s)
1637 {
1639 }
1640}
@ WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME
Definition WorldStateDefines.h:608

References _nextRandomBGReset, Acore::Time::GetNextTimeWithDayAndHour(), sWorldState, and WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME.

Referenced by SetInitialWorldSettings().

◆ InitWeeklyQuestResetTime()

void World::InitWeeklyQuestResetTime ( )
protected
1599{
1602
1603 if (wstime == 0s)
1604 {
1606 }
1607}
@ WORLD_STATE_CUSTOM_WEEKLY_QUEST_RESET_TIME
Definition WorldStateDefines.h:607

References _nextWeeklyQuestReset, Acore::Time::GetNextTimeWithDayAndHour(), sWorldState, and WORLD_STATE_CUSTOM_WEEKLY_QUEST_RESET_TIME.

Referenced by SetInitialWorldSettings().

◆ instance()

static World * World::instance ( )
static

◆ IsClosed()

bool World::IsClosed ( ) const
overridevirtual

Deny clients?

Implements IWorld.

151{
152 return _isClosed;
153}

References _isClosed.

◆ IsFFAPvPRealm()

bool World::IsFFAPvPRealm ( ) const
overridevirtual

Implements IWorld.

1819{
1821}
@ REALM_TYPE_FFA_PVP
Definition Realm.h:62
@ CONFIG_GAME_TYPE
Definition WorldConfig.h:169

References CONFIG_GAME_TYPE, getIntConfig(), and REALM_TYPE_FFA_PVP.

Referenced by SetInitialWorldSettings().

◆ IsPvPRealm()

bool World::IsPvPRealm ( ) const
overridevirtual

Are we on a "Player versus Player" server?

Implements IWorld.

1814{
1816}
@ REALM_TYPE_RPPVP
Definition Realm.h:58
@ REALM_TYPE_PVP
Definition Realm.h:55

References CONFIG_GAME_TYPE, getIntConfig(), REALM_TYPE_FFA_PVP, REALM_TYPE_PVP, and REALM_TYPE_RPPVP.

◆ IsShuttingDown()

bool World::IsShuttingDown ( ) const
inlineoverridevirtual

Are we in the middle of a shutdown?

Implements IWorld.

183{ return _shutdownTimer > 0; }

References _shutdownTimer.

◆ IsStopped()

static bool World::IsStopped ( )
inlinestatic

◆ LoadConfigSettings()

void World::LoadConfigSettings ( bool  reload = false)
overridevirtual

Initialize config values.

  • Read the player limit and the Message of the day from the config file
  • Read the "Data" directory from the config file

Implements IWorld.

165{
166 if (reload)
167 {
168 if (!sConfigMgr->Reload())
169 {
170 LOG_ERROR("server.loading", "World settings reload fail: can't read settings.");
171 return;
172 }
173
174 sLog->LoadFromConfig();
175 sMetric->LoadFromConfigs();
176 }
177
178 // Set realm id and enable db logging
179 sLog->SetRealmId(realm.Id.Realm);
180
181 sScriptMgr->OnBeforeConfigLoad(reload);
182
183 // load update time related configs
185
187 if (!reload)
188 sWorldSessionMgr->SetPlayerAmountLimit(sConfigMgr->GetOption<int32>("PlayerLimit", 1000));
189
190 _worldConfig.Initialize(reload);
191
192 for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
194
195 for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
197
198 if (reload)
199 {
200 sMapMgr->SetMapUpdateInterval(getIntConfig(CONFIG_INTERVAL_MAPUPDATE));
201
204
207
210 }
211
213 {
215 LOG_INFO("server.loading", "Client cache version set to: {}", _dbClientCacheVersion);
216 }
217
218 //visibility on continents
219 _maxVisibleDistanceOnContinents = sConfigMgr->GetOption<float>("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE);
221 {
222 LOG_ERROR("server.loading", "Visibility.Distance.Continents can't be less max aggro radius {}", 45 * getRate(RATE_CREATURE_AGGRO));
224 }
226 {
227 LOG_ERROR("server.loading", "Visibility.Distance.Continents can't be greater {}", MAX_VISIBILITY_DISTANCE);
229 }
230
231 //visibility in instances
232 _maxVisibleDistanceInInstances = sConfigMgr->GetOption<float>("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE);
234 {
235 LOG_ERROR("server.loading", "Visibility.Distance.Instances can't be less max aggro radius {}", 45 * getRate(RATE_CREATURE_AGGRO));
237 }
239 {
240 LOG_ERROR("server.loading", "Visibility.Distance.Instances can't be greater {}", MAX_VISIBILITY_DISTANCE);
242 }
243
244 //visibility in BG/Arenas
245 _maxVisibleDistanceInBGArenas = sConfigMgr->GetOption<float>("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS);
247 {
248 LOG_ERROR("server.loading", "Visibility.Distance.BGArenas can't be less max aggro radius {}", 45 * getRate(RATE_CREATURE_AGGRO));
250 }
252 {
253 LOG_ERROR("server.loading", "Visibility.Distance.BGArenas can't be greater {}", MAX_VISIBILITY_DISTANCE);
255 }
256
257 LOG_INFO("server.loading", "Will clear `logs` table of entries older than {} seconds every {} minutes.",
259
261 std::string dataPath = sConfigMgr->GetOption<std::string>("DataDir", "./");
262 if (dataPath.empty() || (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\'))
263 dataPath.push_back('/');
264
265#if AC_PLATFORM == AC_PLATFORM_UNIX || AC_PLATFORM == AC_PLATFORM_APPLE
266 if (dataPath[0] == '~')
267 {
268 const char* home = getenv("HOME");
269 if (home)
270 dataPath.replace(0, 1, home);
271 }
272#endif
273
274 if (reload)
275 {
276 if (dataPath != _dataPath)
277 LOG_ERROR("server.loading", "DataDir option can't be changed at worldserver.conf reload, using current value ({}).", _dataPath);
278 }
279 else
280 {
281 _dataPath = dataPath;
282 LOG_INFO("server.loading", "Using DataDir {}", _dataPath);
283 }
284
285 bool const enableIndoor = getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
286 bool const enableLOS = sConfigMgr->GetOption<bool>("vmap.enableLOS", true);
287 bool const enablePetLOS = getBoolConfig(CONFIG_PET_LOS);
288 bool const enableHeight = sConfigMgr->GetOption<bool>("vmap.enableHeight", true);
289 if (!enableHeight)
290 LOG_ERROR("server.loading", "VMap height checking disabled! Creatures movements and other various things WILL be broken! Expect no support.");
291
294 LOG_INFO("server.loading", "WORLD: VMap support included. LineOfSight:{}, getHeight:{}, indoorCheck:{} PetLOS:{}", enableLOS, enableHeight, enableIndoor, enablePetLOS);
295
297
298 // call ScriptMgr if we're reloading the configuration
299 sScriptMgr->OnAfterConfigLoad(reload);
300}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
constexpr auto MINUTE
Definition Common.h:47
#define sLog
Definition Log.h:127
#define sMapMgr
Definition MapMgr.h:220
#define sMetric
Definition Metric.h:134
#define MAX_VISIBILITY_DISTANCE
Definition ObjectDefines.h:30
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
#define DEFAULT_VISIBILITY_BGARENAS
Definition ObjectDefines.h:42
#define DEFAULT_VISIBILITY_INSTANCE
Definition ObjectDefines.h:40
#define sScriptMgr
Definition ScriptMgr.h:728
#define MAX_MOVE_TYPE
Definition UnitDefines.h:360
float baseMoveSpeed[MAX_MOVE_TYPE]
Definition Unit.cpp:75
float playerBaseMoveSpeed[MAX_MOVE_TYPE]
Definition Unit.cpp:88
WorldUpdateTime sWorldUpdateTime
Definition UpdateTime.cpp:27
@ CONFIG_CLIENTCACHE_VERSION
Definition WorldConfig.h:302
@ RATE_CREATURE_AGGRO
Definition WorldConfig.h:456
@ CONFIG_LOGDB_CLEARTIME
Definition WorldConfig.h:298
@ CONFIG_AUTOBROADCAST_INTERVAL
Definition WorldConfig.h:313
@ RATE_MOVESPEED_PLAYER
Definition WorldConfig.h:476
@ RATE_MOVESPEED_NPC
Definition WorldConfig.h:477
@ CONFIG_VMAP_INDOOR_CHECK
Definition WorldConfig.h:81
@ CONFIG_LOGDB_CLEARINTERVAL
Definition WorldConfig.h:297
@ CONFIG_UPTIME_UPDATE
Definition WorldConfig.h:214
@ CONFIG_INTERVAL_MAPUPDATE
Definition WorldConfig.h:162
@ CONFIG_PET_LOS
Definition WorldConfig.h:82
void Initialize(bool reload)
Definition ConfigValueCache.h:45
void OverwriteConfigValue(ConfigEnum const config, T const &value)
Definition ConfigValueCache.h:86
static void InitializeDisabledMaps()
Definition MMapFactory.cpp:37
void setEnableHeightCalc(bool pVal)
Definition IVMapMgr.h:116
void setEnableLineOfSightCalc(bool pVal)
Definition IVMapMgr.h:111
static VMapMgr2 * createOrGetVMapMgr()
Definition VMapFactory.cpp:27
void LoadFromConfig()
Definition UpdateTime.cpp:152
bool getBoolConfig(ServerConfigs index) const override
Definition World.cpp:1342
float getRate(ServerConfigs index) const override
Definition World.cpp:1332
@ WUPDATE_CLEANDB
Definition World.h:64
@ WUPDATE_AUTOBROADCAST
Definition World.h:65
@ WUPDATE_UPTIME
Definition World.h:62

References _dataPath, _dbClientCacheVersion, _maxVisibleDistanceInBGArenas, _maxVisibleDistanceInInstances, _maxVisibleDistanceOnContinents, _timers, _worldConfig, baseMoveSpeed, CONFIG_AUTOBROADCAST_INTERVAL, CONFIG_CLIENTCACHE_VERSION, CONFIG_INTERVAL_MAPUPDATE, CONFIG_LOGDB_CLEARINTERVAL, CONFIG_LOGDB_CLEARTIME, CONFIG_PET_LOS, CONFIG_UPTIME_UPDATE, CONFIG_VMAP_INDOOR_CHECK, VMAP::VMapFactory::createOrGetVMapMgr(), DEFAULT_VISIBILITY_BGARENAS, DEFAULT_VISIBILITY_DISTANCE, DEFAULT_VISIBILITY_INSTANCE, getBoolConfig(), getIntConfig(), getRate(), Realm::Id, IN_MILLISECONDS, ConfigValueCache< ConfigEnum >::Initialize(), MMAP::MMapFactory::InitializeDisabledMaps(), WorldUpdateTime::LoadFromConfig(), LOG_ERROR, LOG_INFO, MAX_MOVE_TYPE, MAX_VISIBILITY_DISTANCE, MINUTE, ConfigValueCache< ConfigEnum >::OverwriteConfigValue(), playerBaseMoveSpeed, RATE_CREATURE_AGGRO, RATE_MOVESPEED_NPC, RATE_MOVESPEED_PLAYER, realm, RealmHandle::Realm, IntervalTimer::Reset(), sConfigMgr, VMAP::IVMapMgr::setEnableHeightCalc(), VMAP::IVMapMgr::setEnableLineOfSightCalc(), IntervalTimer::SetInterval(), sLog, sMapMgr, sMetric, sScriptMgr, sWorldSessionMgr, sWorldUpdateTime, WUPDATE_AUTOBROADCAST, WUPDATE_CLEANDB, and WUPDATE_UPTIME.

Referenced by SetInitialWorldSettings().

◆ LoadDBAllowedSecurityLevel()

void World::LoadDBAllowedSecurityLevel ( )
overridevirtual

Implements IWorld.

1682{
1684 stmt->SetData(0, int32(realm.Id.Realm));
1685 PreparedQueryResult result = LoginDatabase.Query(stmt);
1686
1687 if (result)
1688 SetPlayerSecurityLimit(AccountTypes(result->Fetch()->Get<uint8>()));
1689}
AccountTypes
Definition Common.h:56
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
@ LOGIN_SEL_REALMLIST_SECURITY_LEVEL
Definition LoginDatabase.h:99
void SetPlayerSecurityLimit(AccountTypes sec) override
Definition World.cpp:1691

References Realm::Id, LOGIN_SEL_REALMLIST_SECURITY_LEVEL, LoginDatabase, realm, RealmHandle::Realm, PreparedStatementBase::SetData(), and SetPlayerSecurityLimit().

Referenced by SetInitialWorldSettings().

◆ LoadDBVersion()

void World::LoadDBVersion ( )
overridevirtual

Implements IWorld.

1781{
1782 QueryResult result = WorldDatabase.Query("SELECT db_version, cache_id FROM version LIMIT 1");
1783 if (result)
1784 {
1785 Field* fields = result->Fetch();
1786
1787 _dbVersion = fields[0].Get<std::string>();
1788
1789 // will be overwrite by config values if different and non-0
1790 _dbClientCacheVersion = fields[1].Get<uint32>();
1791 }
1792
1793 if (_dbVersion.empty())
1794 _dbVersion = "Unknown world database.";
1795}
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112

References _dbClientCacheVersion, _dbVersion, Field::Get(), and WorldDatabase.

◆ ProcessCliCommands()

void World::ProcessCliCommands ( )
overridevirtual

Implements IWorld.

1554{
1555 CliCommandHolder::Print zprint = nullptr;
1556 void* callbackArg = nullptr;
1557 CliCommandHolder* command = nullptr;
1558 while (_cliCmdQueue.next(command))
1559 {
1560 LOG_DEBUG("server.worldserver", "CLI command under processing...");
1561 zprint = command->m_print;
1562 callbackArg = command->m_callbackArg;
1563 CliHandler handler(callbackArg, zprint);
1564 handler.ParseCommands(command->m_command);
1565 if (command->m_commandFinished)
1566 command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage());
1567 delete command;
1568 }
1569}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
Definition Chat.h:255
CommandFinished m_commandFinished
Definition IWorld.h:42
void * m_callbackArg
Definition IWorld.h:39
Print m_print
Definition IWorld.h:41
void(*)(void *, std::string_view) Print
Definition IWorld.h:36
char * m_command
Definition IWorld.h:40

References _cliCmdQueue, ChatHandler::HasSentErrorMessage(), LOG_DEBUG, CliCommandHolder::m_callbackArg, CliCommandHolder::m_command, CliCommandHolder::m_commandFinished, CliCommandHolder::m_print, LockedQueue< T, StorageType >::next(), and CliHandler::ParseCommands().

Referenced by Update().

◆ ProcessQueryCallbacks()

void World::ProcessQueryCallbacks ( )
private
1809{
1811}
void ProcessReadyCallbacks()
Definition AsyncCallbackProcessor.h:40
QueryCallbackProcessor _queryProcessor
Definition World.h:306

References _queryProcessor, and AsyncCallbackProcessor< T >::ProcessReadyCallbacks().

Referenced by Update().

◆ QueueCliCommand()

void World::QueueCliCommand ( CliCommandHolder commandHolder)
inlineoverridevirtual

Implements IWorld.

222{ _cliCmdQueue.add(commandHolder); }
void add(const T &item)
Adds an item to the back of the queue.
Definition LockedQueue.h:52

References _cliCmdQueue, and LockedQueue< T, StorageType >::add().

◆ ResetDailyQuests()

void World::ResetDailyQuests ( )
protected
1665{
1667 CharacterDatabase.Execute(stmt);
1668
1669 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1670 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1671 if (itr->second->GetPlayer())
1672 itr->second->GetPlayer()->ResetDailyQuestStatus();
1673
1676
1677 // change available dailies
1678 sPoolMgr->ChangeDailyQuests();
1679}
@ CHAR_DEL_QUEST_STATUS_DAILY
Definition CharacterDatabase.h:55
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
#define sPoolMgr
Definition PoolMgr.h:163
std::unordered_map< uint32, WorldSession * > SessionMap
Definition WorldSessionMgr.h:56

References _nextDailyQuestReset, CHAR_DEL_QUEST_STATUS_DAILY, CharacterDatabase, Acore::Time::GetNextTimeWithDayAndHour(), sPoolMgr, sWorldSessionMgr, sWorldState, and WORLD_STATE_CUSTOM_DAILY_QUEST_RESET_TIME.

Referenced by Update().

◆ ResetEventSeasonalQuests()

void World::ResetEventSeasonalQuests ( uint16  event_id)
overridevirtual

Implements IWorld.

1734{
1736 stmt->SetData(0, event_id);
1737 CharacterDatabase.Execute(stmt);
1738
1739 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1740 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1741 if (itr->second->GetPlayer())
1742 itr->second->GetPlayer()->ResetSeasonalQuestStatus(event_id);
1743}
@ CHAR_DEL_QUEST_STATUS_SEASONAL
Definition CharacterDatabase.h:58

References CHAR_DEL_QUEST_STATUS_SEASONAL, CharacterDatabase, PreparedStatementBase::SetData(), and sWorldSessionMgr.

◆ ResetGuildCap()

void World::ResetGuildCap ( )
protected
1771{
1772 LOG_INFO("server.worldserver", "Guild Daily Cap reset.");
1773
1776
1777 sGuildMgr->ResetTimes();
1778}
#define sGuildMgr
Definition GuildMgr.h:51

References _nextGuildReset, Acore::Time::GetNextTimeWithDayAndHour(), LOG_INFO, sGuildMgr, sWorldState, and WORLD_STATE_CUSTOM_GUILD_DAILY_RESET_TIME.

Referenced by Update().

◆ ResetMonthlyQuests()

void World::ResetMonthlyQuests ( )
protected
1718{
1719 LOG_INFO("server.worldserver", "Monthly quests reset for all characters.");
1720
1722 CharacterDatabase.Execute(stmt);
1723
1724 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1725 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1726 if (itr->second->GetPlayer())
1727 itr->second->GetPlayer()->ResetMonthlyQuestStatus();
1728
1731}
@ CHAR_DEL_QUEST_STATUS_MONTHLY
Definition CharacterDatabase.h:57
AC_COMMON_API time_t GetNextTimeWithMonthAndHour(int8 month, int8 hour)
Definition Timer.cpp:333

References _nextMonthlyQuestReset, CHAR_DEL_QUEST_STATUS_MONTHLY, CharacterDatabase, Acore::Time::GetNextTimeWithMonthAndHour(), LOG_INFO, sWorldSessionMgr, sWorldState, and WORLD_STATE_CUSTOM_MONTHLY_QUEST_RESET_TIME.

Referenced by Update().

◆ ResetRandomBG()

void World::ResetRandomBG ( )
protected
1746{
1747 LOG_DEBUG("server.worldserver", "Random BG status reset for all characters.");
1748
1750 CharacterDatabase.Execute(stmt);
1751
1752 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1753 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1754 if (itr->second->GetPlayer())
1755 itr->second->GetPlayer()->SetRandomWinner(false);
1756
1759}
@ CHAR_DEL_BATTLEGROUND_RANDOM
Definition CharacterDatabase.h:63

References _nextRandomBGReset, CHAR_DEL_BATTLEGROUND_RANDOM, CharacterDatabase, Acore::Time::GetNextTimeWithDayAndHour(), LOG_DEBUG, sWorldSessionMgr, sWorldState, and WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME.

Referenced by Update().

◆ ResetWeeklyQuests()

void World::ResetWeeklyQuests ( )
protected
1701{
1703 CharacterDatabase.Execute(stmt);
1704
1705 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1706 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1707 if (itr->second->GetPlayer())
1708 itr->second->GetPlayer()->ResetWeeklyQuestStatus();
1709
1712
1713 // change available weeklies
1714 sPoolMgr->ChangeWeeklyQuests();
1715}
@ CHAR_DEL_QUEST_STATUS_WEEKLY
Definition CharacterDatabase.h:56

References _nextWeeklyQuestReset, CHAR_DEL_QUEST_STATUS_WEEKLY, CharacterDatabase, Acore::Time::GetNextTimeWithDayAndHour(), sPoolMgr, sWorldSessionMgr, sWorldState, and WORLD_STATE_CUSTOM_WEEKLY_QUEST_RESET_TIME.

Referenced by Update().

◆ SetAllowMovement()

void World::SetAllowMovement ( bool  allow)
inlineoverridevirtual

Allow/Disallow object movements.

Implements IWorld.

160{ _allowMovement = allow; }

References _allowMovement.

◆ setBoolConfig()

void World::setBoolConfig ( ServerConfigs  index,
bool  value 
)
overridevirtual

Implements IWorld.

1338{
1339 _worldConfig.OverwriteConfigValue<bool>(index, value);
1340}

References _worldConfig, and ConfigValueCache< ConfigEnum >::OverwriteConfigValue().

◆ SetCleaningFlags()

void World::SetCleaningFlags ( uint32  flags)
inlineoverridevirtual

Implements IWorld.

237{ _cleaningFlags = flags; }

References _cleaningFlags.

◆ SetClosed()

void World::SetClosed ( bool  val)
overridevirtual

Close world.

Implements IWorld.

156{
157 _isClosed = val;
158
159 // Invert the value, for simplicity for scripters.
160 sScriptMgr->OnOpenStateChange(!val);
161}

References _isClosed, and sScriptMgr.

◆ setFloatConfig()

void World::setFloatConfig ( ServerConfigs  index,
float  value 
)
overridevirtual

Implements IWorld.

1348{
1349 _worldConfig.OverwriteConfigValue<float>(index, value);
1350}

References _worldConfig, and ConfigValueCache< ConfigEnum >::OverwriteConfigValue().

Referenced by setRate().

◆ SetInitialWorldSettings()

void World::SetInitialWorldSettings ( )
overridevirtual

Initialize the World.

  • Server startup begin
  • Initialize the random number generator
  • Initialize detour memory management
  • Initialize VMapMgr function pointers (to untangle game/collision circular deps)
  • Initialize config settings
  • Initialize Allowed Security Level
  • Init highest guids before any table loading to prevent using not initialized guids in some code.
  • Check the existence of the map files for all starting areas.
  • Initialize pool manager
  • Initialize game event manager
  • Loading strings. Getting no records means core load has to be canceled because no error message can be output.
  • Update the realm entry in the database with the realm type from the config file
  • Custom Hook for loading DB items
  • Load the DBC files
  • Initilize static helper structures
  • Load dynamic data tables from the database
  • Handle outdated emails (delete/return)
  • Load AutoBroadCast
  • Load Motd
  • Load and initialize scripts
  • Initialize game time and timers
  • Initialize Battlegrounds
  • Initialize outdoor pvp

Implements IWorld.

304{
306 uint32 startupBegin = getMSTime();
307
309 srand((unsigned int)GameTime::GetGameTime().count());
310
312 dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
313
318
321
324
326 sObjectMgr->SetHighestGuids();
327
328 if (!sConfigMgr->isDryRun())
329 {
331 if (!MapMgr::ExistMapAndVMap(MAP_EASTERN_KINGDOMS, -6240.32f, 331.033f)
332 || !MapMgr::ExistMapAndVMap(MAP_EASTERN_KINGDOMS, -8949.95f, -132.493f)
333 || !MapMgr::ExistMapAndVMap(MAP_KALIMDOR, -618.518f, -4251.67f)
334 || !MapMgr::ExistMapAndVMap(MAP_EASTERN_KINGDOMS, 1676.35f, 1677.45f)
335 || !MapMgr::ExistMapAndVMap(MAP_KALIMDOR, 10311.3f, 832.463f)
336 || !MapMgr::ExistMapAndVMap(MAP_KALIMDOR, -2917.58f, -257.98f)
338 !MapMgr::ExistMapAndVMap(MAP_OUTLAND, 10349.6f, -6357.29f) ||
339 !MapMgr::ExistMapAndVMap(MAP_OUTLAND, -3961.64f, -13931.2f))))
340 {
341 LOG_ERROR("server.loading", "Failed to find map files for starting areas");
342 exit(1);
343 }
344 }
345
347 sPoolMgr->Initialize();
348
350 sGameEventMgr->Initialize();
351
353 LOG_INFO("server.loading", " ");
354 LOG_INFO("server.loading", "Loading Acore Strings...");
355 if (!sObjectMgr->LoadAcoreStrings())
356 exit(1); // Error message displayed in function already
357
358 LOG_INFO("server.loading", "Loading Module Strings...");
359 sObjectMgr->LoadModuleStrings();
360 LOG_INFO("server.loading", "Loading Module Strings Locale...");
361 sObjectMgr->LoadModuleStringsLocale();
362
364 //No SQL injection as values are treated as integers
365
366 // not send custom type REALM_FFA_PVP to realm list
367 uint32 server_type;
368 if (IsFFAPvPRealm())
369 server_type = REALM_TYPE_PVP;
370 else
371 server_type = getIntConfig(CONFIG_GAME_TYPE);
372
374
375 LoginDatabase.Execute("UPDATE realmlist SET icon = {}, timezone = {} WHERE id = '{}'", server_type, realm_zone, realm.Id.Realm); // One-time query
376
378 sScriptMgr->OnLoadCustomDatabaseTable();
379
381 LOG_INFO("server.loading", "Initialize Data Stores...");
384
385 // Load cinematic cameras
387
388 // Load IP Location Database
389 sIPLocation->Load();
390
391 std::vector<uint32> mapIds;
392 for (auto const& map : sMapStore)
393 {
394 mapIds.emplace_back(map->MapID);
395 }
396
397 vmmgr2->InitializeThreadUnsafe(mapIds);
398
400 mmmgr->InitializeThreadUnsafe(mapIds);
401
402 LOG_INFO("server.loading", "Loading Game Graveyard...");
403 sGraveyard->LoadGraveyardFromDB();
404
405 LOG_INFO("server.loading", "Initializing PlayerDump Tables...");
407
410
411 LOG_INFO("server.loading", "Loading SpellInfo Store...");
412 sSpellMgr->LoadSpellInfoStore();
413
414 LOG_INFO("server.loading", "Loading Spell Cooldown Overrides...");
415 sSpellMgr->LoadSpellCooldownOverrides();
416
417 LOG_INFO("server.loading", "Loading SpellInfo Data Corrections...");
418 sSpellMgr->LoadSpellInfoCorrections();
419
420 LOG_INFO("server.loading", "Loading Spell Rank Data...");
421 sSpellMgr->LoadSpellRanks();
422
423 LOG_INFO("server.loading", "Loading Spell Specific And Aura State...");
424 sSpellMgr->LoadSpellSpecificAndAuraState();
425
426 LOG_INFO("server.loading", "Loading SkillLineAbilityMultiMap Data...");
427 sSpellMgr->LoadSkillLineAbilityMap();
428
429 LOG_INFO("server.loading", "Loading SpellInfo Custom Attributes...");
430 sSpellMgr->LoadSpellInfoCustomAttributes();
431
432 LOG_INFO("server.loading", "Loading Player Totem models...");
433 sObjectMgr->LoadPlayerTotemModels();
434
435 LOG_INFO("server.loading", "Loading Player Shapeshift models...");
436 sObjectMgr->LoadPlayerShapeshiftModels();
437
438 LOG_INFO("server.loading", "Loading GameObject Models...");
440
441 LOG_INFO("server.loading", "Loading Script Names...");
442 sObjectMgr->LoadScriptNames();
443
444 LOG_INFO("server.loading", "Loading Instance Template...");
445 sObjectMgr->LoadInstanceTemplate();
446
447 LOG_INFO("server.loading", "Loading Character Cache...");
448 sCharacterCache->LoadCharacterCacheStorage();
449
450 // Must be called before `creature_respawn`/`gameobject_respawn` tables
451 LOG_INFO("server.loading", "Loading Instances...");
452 sInstanceSaveMgr->LoadInstances();
453
454 LOG_INFO("server.loading", "Loading Broadcast Texts...");
455 sObjectMgr->LoadBroadcastTexts();
456 sObjectMgr->LoadBroadcastTextLocales();
457
458 LOG_INFO("server.loading", "Loading Localization Strings...");
459 uint32 oldMSTime = getMSTime();
460 sObjectMgr->LoadCreatureLocales();
461 sObjectMgr->LoadGameObjectLocales();
462 sObjectMgr->LoadItemLocales();
463 sObjectMgr->LoadItemSetNameLocales();
464 sObjectMgr->LoadQuestLocales();
465 sObjectMgr->LoadQuestOfferRewardLocale();
466 sObjectMgr->LoadQuestRequestItemsLocale();
467 sObjectMgr->LoadNpcTextLocales();
468 sObjectMgr->LoadPageTextLocales();
469 sObjectMgr->LoadGossipMenuItemsLocales();
470 sObjectMgr->LoadPointOfInterestLocales();
471 sObjectMgr->LoadPetNamesLocales();
472
473 sObjectMgr->SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts)
474 LOG_INFO("server.loading", ">> Localization Strings loaded in {} ms", GetMSTimeDiffToNow(oldMSTime));
475 LOG_INFO("server.loading", " ");
476
477 LOG_INFO("server.loading", "Loading Page Texts...");
478 sObjectMgr->LoadPageTexts();
479
480 LOG_INFO("server.loading", "Loading Game Object Templates..."); // must be after LoadPageTexts
481 sObjectMgr->LoadGameObjectTemplate();
482
483 LOG_INFO("server.loading", "Loading Game Object Template Addons...");
484 sObjectMgr->LoadGameObjectTemplateAddons();
485
486 LOG_INFO("server.loading", "Loading Transport Templates...");
487 sTransportMgr->LoadTransportTemplates();
488
489 LOG_INFO("server.loading", "Loading Spell Required Data...");
490 sSpellMgr->LoadSpellRequired();
491
492 LOG_INFO("server.loading", "Loading Spell Group Types...");
493 sSpellMgr->LoadSpellGroups();
494
495 LOG_INFO("server.loading", "Loading Spell Learn Skills...");
496 sSpellMgr->LoadSpellLearnSkills(); // must be after LoadSpellRanks
497
498 LOG_INFO("server.loading", "Loading Spell Proc Event Conditions...");
499 sSpellMgr->LoadSpellProcEvents();
500
501 LOG_INFO("server.loading", "Loading Spell Proc Conditions and Data...");
502 sSpellMgr->LoadSpellProcs();
503
504 LOG_INFO("server.loading", "Loading Spell Bonus Data...");
505 sSpellMgr->LoadSpellBonuses();
506
507 LOG_INFO("server.loading", "Loading Aggro Spells Definitions...");
508 sSpellMgr->LoadSpellThreats();
509
510 LOG_INFO("server.loading", "Loading Mixology Bonuses...");
511 sSpellMgr->LoadSpellMixology();
512
513 LOG_INFO("server.loading", "Loading Spell Group Stack Rules...");
514 sSpellMgr->LoadSpellGroupStackRules();
515
516 LOG_INFO("server.loading", "Loading NPC Texts...");
517 sObjectMgr->LoadGossipText();
518
519 LOG_INFO("server.loading", "Loading Enchant Spells Proc Datas...");
520 sSpellMgr->LoadSpellEnchantProcData();
521
522 LOG_INFO("server.loading", "Loading Item Random Enchantments Table...");
524
525 LOG_INFO("server.loading", "Loading Disables");
526 sDisableMgr->LoadDisables(); // must be before loading quests and items
527
528 LOG_INFO("server.loading", "Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
529 sObjectMgr->LoadItemTemplates();
530
531 LOG_INFO("server.loading", "Loading Item Set Names..."); // must be after LoadItemPrototypes
532 sObjectMgr->LoadItemSetNames();
533
534 LOG_INFO("server.loading", "Loading Creature Model Based Info Data...");
535 sObjectMgr->LoadCreatureModelInfo();
536
537 LOG_INFO("server.loading", "Loading Creature Custom IDs Config...");
538 sObjectMgr->LoadCreatureCustomIDs();
539
540 LOG_INFO("server.loading", "Loading Creature Templates...");
541 sObjectMgr->LoadCreatureTemplates();
542
543 LOG_INFO("server.loading", "Loading Equipment Templates..."); // must be after LoadCreatureTemplates
544 sObjectMgr->LoadEquipmentTemplates();
545
546 LOG_INFO("server.loading", "Loading Creature Template Addons...");
547 sObjectMgr->LoadCreatureTemplateAddons();
548
549 LOG_INFO("server.loading", "Loading Reputation Reward Rates...");
550 sObjectMgr->LoadReputationRewardRate();
551
552 LOG_INFO("server.loading", "Loading Creature Reputation OnKill Data...");
553 sObjectMgr->LoadReputationOnKill();
554
555 LOG_INFO("server.loading", "Loading Reputation Spillover Data..." );
556 sObjectMgr->LoadReputationSpilloverTemplate();
557
558 LOG_INFO("server.loading", "Loading Points Of Interest Data...");
559 sObjectMgr->LoadPointsOfInterest();
560
561 LOG_INFO("server.loading", "Loading Creature Base Stats...");
562 sObjectMgr->LoadCreatureClassLevelStats();
563
564 LOG_INFO("server.loading", "Loading Creature Data...");
565 sObjectMgr->LoadCreatures();
566
567 LOG_INFO("server.loading", "Loading Creature sparring...");
568 sObjectMgr->LoadCreatureSparring();
569
570 LOG_INFO("server.loading", "Loading Temporary Summon Data...");
571 sObjectMgr->LoadTempSummons(); // must be after LoadCreatureTemplates() and LoadGameObjectTemplates()
572
573 LOG_INFO("server.loading", "Loading Pet Levelup Spells...");
574 sSpellMgr->LoadPetLevelupSpellMap();
575
576 LOG_INFO("server.loading", "Loading Pet default Spells additional to Levelup Spells...");
577 sSpellMgr->LoadPetDefaultSpells();
578
579 LOG_INFO("server.loading", "Loading Creature Addon Data...");
580 sObjectMgr->LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
581
582 LOG_INFO("server.loading", "Loading Creature Movement Overrides...");
583 sObjectMgr->LoadCreatureMovementOverrides(); // must be after LoadCreatures()
584
585 LOG_INFO("server.loading", "Loading Gameobject Data...");
586 sObjectMgr->LoadGameobjects();
587
588 LOG_INFO("server.loading", "Loading GameObject Addon Data...");
589 sObjectMgr->LoadGameObjectAddons(); // must be after LoadGameObjectTemplate() and LoadGameobjects()
590
591 LOG_INFO("server.loading", "Loading GameObject Quest Items...");
592 sObjectMgr->LoadGameObjectQuestItems();
593
594 LOG_INFO("server.loading", "Loading Creature Quest Items...");
595 sObjectMgr->LoadCreatureQuestItems();
596
597 LOG_INFO("server.loading", "Loading Creature Linked Respawn...");
598 sObjectMgr->LoadLinkedRespawn(); // must be after LoadCreatures(), LoadGameObjects()
599
600 LOG_INFO("server.loading", "Loading Weather Data...");
602
603 LOG_INFO("server.loading", "Loading Quests...");
604 sObjectMgr->LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables
605
606 LOG_INFO("server.loading", "Checking Quest Disables");
607 sDisableMgr->CheckQuestDisables(); // must be after loading quests
608
609 LOG_INFO("server.loading", "Loading Quest POI");
610 sObjectMgr->LoadQuestPOI();
611
612 LOG_INFO("server.loading", "Loading Quests Starters and Enders...");
613 sObjectMgr->LoadQuestStartersAndEnders(); // must be after quest load
614
615 LOG_INFO("server.loading", "Loading Quest Greetings...");
616 sObjectMgr->LoadQuestGreetings(); // must be loaded after creature_template, gameobject_template tables
617 LOG_INFO("server.loading", "Loading Quest Greeting Locales...");
618 sObjectMgr->LoadQuestGreetingsLocales(); // must be loaded after creature_template, gameobject_template tables, quest_greeting
619
620 LOG_INFO("server.loading", "Loading Quest Money Rewards...");
621 sObjectMgr->LoadQuestMoneyRewards();
622
623 LOG_INFO("server.loading", "Loading Objects Pooling Data...");
624 sPoolMgr->LoadFromDB();
625
626 LOG_INFO("server.loading", "Loading Game Event Data..."); // must be after loading pools fully
627 sGameEventMgr->LoadHolidayDates(); // Must be after loading DBC
628 sGameEventMgr->LoadFromDB(); // Must be after loading holiday dates
629
630 LOG_INFO("server.loading", "Loading UNIT_NPC_FLAG_SPELLCLICK Data..."); // must be after LoadQuests
631 sObjectMgr->LoadNPCSpellClickSpells();
632
633 LOG_INFO("server.loading", "Loading Vehicle Template Accessories...");
634 sObjectMgr->LoadVehicleTemplateAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
635
636 LOG_INFO("server.loading", "Loading Vehicle Accessories...");
637 sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
638
639 LOG_INFO("server.loading", "Loading Vehicle Seat Addon Data...");
640 sObjectMgr->LoadVehicleSeatAddon(); // must be after loading DBC
641
642 LOG_INFO("server.loading", "Loading SpellArea Data..."); // must be after quest load
643 sSpellMgr->LoadSpellAreas();
644
645 LOG_INFO("server.loading", "Loading Area Trigger Definitions");
646 sObjectMgr->LoadAreaTriggers();
647
648 LOG_INFO("server.loading", "Loading Area Trigger Teleport Definitions...");
649 sObjectMgr->LoadAreaTriggerTeleports();
650
651 LOG_INFO("server.loading", "Loading Access Requirements...");
652 sObjectMgr->LoadAccessRequirements(); // must be after item template load
653
654 LOG_INFO("server.loading", "Loading Quest Area Triggers...");
655 sObjectMgr->LoadQuestAreaTriggers(); // must be after LoadQuests
656
657 LOG_INFO("server.loading", "Loading Tavern Area Triggers...");
658 sObjectMgr->LoadTavernAreaTriggers();
659
660 LOG_INFO("server.loading", "Loading AreaTrigger Script Names...");
661 sObjectMgr->LoadAreaTriggerScripts();
662
663 LOG_INFO("server.loading", "Loading LFG Entrance Positions..."); // Must be after areatriggers
664 sLFGMgr->LoadLFGDungeons();
665
666 LOG_INFO("server.loading", "Loading Dungeon Boss Data...");
667 sObjectMgr->LoadInstanceEncounters();
668
669 LOG_INFO("server.loading", "Loading LFG Rewards...");
670 sLFGMgr->LoadRewards();
671
672 LOG_INFO("server.loading", "Loading Graveyard-Zone Links...");
673 sGraveyard->LoadGraveyardZones();
674
675 LOG_INFO("server.loading", "Loading Spell Pet Auras...");
676 sSpellMgr->LoadSpellPetAuras();
677
678 LOG_INFO("server.loading", "Loading Spell Target Coordinates...");
679 sSpellMgr->LoadSpellTargetPositions();
680
681 LOG_INFO("server.loading", "Loading Enchant Custom Attributes...");
682 sSpellMgr->LoadEnchantCustomAttr();
683
684 LOG_INFO("server.loading", "Loading linked Spells...");
685 sSpellMgr->LoadSpellLinked();
686
687 LOG_INFO("server.loading", "Loading Player Create Data...");
688 sObjectMgr->LoadPlayerInfo();
689
690 LOG_INFO("server.loading", "Loading Exploration BaseXP Data...");
691 sObjectMgr->LoadExplorationBaseXP();
692
693 LOG_INFO("server.loading", "Loading Pet Name Parts...");
694 sObjectMgr->LoadPetNames();
695
697
698 LOG_INFO("server.loading", "Loading The Max Pet Number...");
699 sObjectMgr->LoadPetNumber();
700
701 LOG_INFO("server.loading", "Loading Pet Level Stats...");
702 sObjectMgr->LoadPetLevelInfo();
703
704 LOG_INFO("server.loading", "Loading Player Level Dependent Mail Rewards...");
705 sObjectMgr->LoadMailLevelRewards();
706
707 LOG_INFO("server.loading", "Load Mail Server definitions...");
708 sServerMailMgr->LoadMailServerTemplates();
709
710 // Loot tables
712
713 LOG_INFO("server.loading", "Loading Skill Discovery Table...");
715
716 LOG_INFO("server.loading", "Loading Skill Extra Item Table...");
718
719 LOG_INFO("server.loading", "Loading Skill Perfection Data Table...");
721
722 LOG_INFO("server.loading", "Loading Skill Fishing Base Level Requirements...");
723 sObjectMgr->LoadFishingBaseSkillLevel();
724
725 LOG_INFO("server.loading", "Loading Achievements...");
726 sAchievementMgr->LoadAchievementReferenceList();
727 LOG_INFO("server.loading", "Loading Achievement Criteria Lists...");
728 sAchievementMgr->LoadAchievementCriteriaList();
729 LOG_INFO("server.loading", "Loading Achievement Criteria Data...");
730 sAchievementMgr->LoadAchievementCriteriaData();
731 LOG_INFO("server.loading", "Loading Achievement Rewards...");
732 sAchievementMgr->LoadRewards();
733 LOG_INFO("server.loading", "Loading Achievement Reward Locales...");
734 sAchievementMgr->LoadRewardLocales();
735 LOG_INFO("server.loading", "Loading Completed Achievements...");
736 sAchievementMgr->LoadCompletedAchievements();
737
739 LOG_INFO("server.loading", "Loading Item Auctions...");
740 sAuctionMgr->LoadAuctionItems();
741 LOG_INFO("server.loading", "Loading Auctions...");
742 sAuctionMgr->LoadAuctions();
743
744 sGuildMgr->LoadGuilds();
745
746 LOG_INFO("server.loading", "Loading ArenaTeams...");
747 sArenaTeamMgr->LoadArenaTeams();
748
749 LOG_INFO("server.loading", "Loading Groups...");
750 sGroupMgr->LoadGroups();
751
752 LOG_INFO("server.loading", "Loading Reserved Names...");
753 sObjectMgr->LoadReservedPlayerNamesDB();
754 sObjectMgr->LoadReservedPlayerNamesDBC(); // Needs to be after LoadReservedPlayerNamesDB()
755
756 LOG_INFO("server.loading", "Loading Profanity Names...");
757 sObjectMgr->LoadProfanityNamesFromDB();
758 sObjectMgr->LoadProfanityNamesFromDBC(); // Needs to be after LoadProfanityNamesFromDB()
759
760 LOG_INFO("server.loading", "Loading GameObjects for Quests...");
761 sObjectMgr->LoadGameObjectForQuests();
762
763 LOG_INFO("server.loading", "Loading BattleMasters...");
764 sBattlegroundMgr->LoadBattleMastersEntry();
765
766 LOG_INFO("server.loading", "Loading GameTeleports...");
767 sObjectMgr->LoadGameTele();
768
769 LOG_INFO("server.loading", "Loading Gossip Menu...");
770 sObjectMgr->LoadGossipMenu();
771
772 LOG_INFO("server.loading", "Loading Gossip Menu Options...");
773 sObjectMgr->LoadGossipMenuItems();
774
775 LOG_INFO("server.loading", "Loading Vendors...");
776 sObjectMgr->LoadVendors(); // must be after load CreatureTemplate and ItemTemplate
777
778 LOG_INFO("server.loading", "Loading Trainers...");
779 sObjectMgr->LoadTrainerSpell(); // must be after load CreatureTemplate
780
781 LOG_INFO("server.loading", "Loading Waypoints...");
782 sWaypointMgr->Load();
783
784 LOG_INFO("server.loading", "Loading SmartAI Waypoints...");
785 sSmartWaypointMgr->LoadFromDB();
786
787 LOG_INFO("server.loading", "Loading Creature Formations...");
788 sFormationMgr->LoadCreatureFormations();
789
790 LOG_INFO("server.loading", "Loading WorldStates..."); // must be loaded before battleground, outdoor PvP and conditions
791 sWorldState->LoadWorldStates();
792
793 LOG_INFO("server.loading", "Loading Conditions...");
794 sConditionMgr->LoadConditions();
795
796 LOG_INFO("server.loading", "Loading Faction Change Achievement Pairs...");
797 sObjectMgr->LoadFactionChangeAchievements();
798
799 LOG_INFO("server.loading", "Loading Faction Change Spell Pairs...");
800 sObjectMgr->LoadFactionChangeSpells();
801
802 LOG_INFO("server.loading", "Loading Faction Change Item Pairs...");
803 sObjectMgr->LoadFactionChangeItems();
804
805 LOG_INFO("server.loading", "Loading Faction Change Reputation Pairs...");
806 sObjectMgr->LoadFactionChangeReputations();
807
808 LOG_INFO("server.loading", "Loading Faction Change Title Pairs...");
809 sObjectMgr->LoadFactionChangeTitles();
810
811 LOG_INFO("server.loading", "Loading Faction Change Quest Pairs...");
812 sObjectMgr->LoadFactionChangeQuests();
813
814 LOG_INFO("server.loading", "Loading GM Tickets...");
815 sTicketMgr->LoadTickets();
816
817 LOG_INFO("server.loading", "Loading GM Surveys...");
818 sTicketMgr->LoadSurveys();
819
820 LOG_INFO("server.loading", "Loading Client Addons...");
822
823 // pussywizard:
824 LOG_INFO("server.loading", "Deleting Invalid Mail Items...");
825 LOG_INFO("server.loading", " ");
826 CharacterDatabase.Execute("DELETE mi FROM mail_items mi LEFT JOIN item_instance ii ON mi.item_guid = ii.guid WHERE ii.guid IS NULL");
827 CharacterDatabase.Execute("DELETE mi FROM mail_items mi LEFT JOIN mail m ON mi.mail_id = m.id WHERE m.id IS NULL");
828 CharacterDatabase.Execute("UPDATE mail m LEFT JOIN mail_items mi ON m.id = mi.mail_id SET m.has_items=0 WHERE m.has_items<>0 AND mi.mail_id IS NULL");
829
831 LOG_INFO("server.loading", "Returning Old Mails...");
832 LOG_INFO("server.loading", " ");
833 sObjectMgr->ReturnOrDeleteOldMails(false);
834
836 LOG_INFO("server.loading", "Loading Autobroadcasts...");
837 sAutobroadcastMgr->LoadAutobroadcasts();
838 sAutobroadcastMgr->LoadAutobroadcastsLocalized();
839
841 LOG_INFO("server.loading", "Loading Motd...");
842 sMotdMgr->LoadMotd();
843
845 sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
846 sObjectMgr->LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data)
847 sObjectMgr->LoadWaypointScripts();
848
849 LOG_INFO("server.loading", "Loading Spell Script Names...");
850 sObjectMgr->LoadSpellScriptNames();
851
852 LOG_INFO("server.loading", "Loading Creature Texts...");
853 sCreatureTextMgr->LoadCreatureTexts();
854
855 LOG_INFO("server.loading", "Loading Creature Text Locales...");
856 sCreatureTextMgr->LoadCreatureTextLocales();
857
858 LOG_INFO("server.loading", "Loading Scripts...");
859 sScriptMgr->LoadDatabase();
860
861 LOG_INFO("server.loading", "Validating Spell Scripts...");
862 sObjectMgr->ValidateSpellScripts();
863
864 LOG_INFO("server.loading", "Loading SmartAI Scripts...");
865 sSmartScriptMgr->LoadSmartAIFromDB();
866
867 LOG_INFO("server.loading", "Loading Calendar Data...");
868 sCalendarMgr->LoadFromDB();
869
870 LOG_INFO("server.loading", "Initializing SpellInfo Precomputed Data..."); // must be called after loading items, professions, spells and pretty much anything
871 LOG_INFO("server.loading", " ");
872 sObjectMgr->InitializeSpellInfoPrecomputedData();
873
874 LOG_INFO("server.loading", "Initialize Commands...");
876
878 LOG_INFO("server.loading", "Initialize Game Time and Timers");
879 LOG_INFO("server.loading", " ");
880
882 stmt->SetData(0, realm.Id.Realm);
883 stmt->SetData(1, uint32(GameTime::GetStartTime().count()));
885 LoginDatabase.Execute(stmt);
886
889 //Update "uptime" table based on configuration entry in minutes.
890
892 // clean logs table every 14 days by default
894
896
897 // our speed up
899
900 _timers[WUPDATE_WHO_LIST].SetInterval(5 * IN_MILLISECONDS); // update who list cache every 5 seconds
901
903
905 LOG_INFO("server.loading", "Starting Map System");
906 LOG_INFO("server.loading", " ");
907 sMapMgr->Initialize();
908
909 LOG_INFO("server.loading", "Starting Game Event system...");
910 LOG_INFO("server.loading", " ");
911 uint32 nextGameEvent = sGameEventMgr->StartSystem();
912 _timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event
913
914 LOG_INFO("server.loading", "Loading WorldState...");
915 sWorldState->Load(); // must be called after loading game events
916
917 // Delete all characters which have been deleted X days before
919
920 // Delete all items which have been deleted X days before
922
923 // Delete all custom channels which haven't been used for PreserveCustomChannelDuration days.
925
926 LOG_INFO("server.loading", "Initializing Opcodes...");
928
929 LOG_INFO("server.loading", "Loading Arena Season Rewards...");
930 sArenaSeasonMgr->LoadRewards();
931 LOG_INFO("server.loading", "Loading Active Arena Season...");
932 sArenaSeasonMgr->LoadActiveSeason();
933
934 sTicketMgr->Initialize();
935
937 LOG_INFO("server.loading", "Starting Battleground System");
938 sBattlegroundMgr->LoadBattlegroundTemplates();
939 sBattlegroundMgr->InitAutomaticArenaPointDistribution();
940
942 LOG_INFO("server.loading", "Starting Outdoor PvP System");
943 sOutdoorPvPMgr->InitOutdoorPvP();
944
946 LOG_INFO("server.loading", "Starting Battlefield System");
947 sBattlefieldMgr->InitBattlefield();
948
949 LOG_INFO("server.loading", "Loading Transports...");
950 sTransportMgr->SpawnContinentTransports();
951
953 LOG_INFO("server.loading", "Loading Warden Checks..." );
954 sWardenCheckMgr->LoadWardenChecks();
955
956 LOG_INFO("server.loading", "Loading Warden Action Overrides..." );
957 sWardenCheckMgr->LoadWardenOverrides();
958
959 LOG_INFO("server.loading", "Deleting Expired Bans...");
960 LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate"); // One-time query
961
962 LOG_INFO("server.loading", "Calculate Next Daily Quest Reset Time...");
964
965 LOG_INFO("server.loading", "Calculate Next Weekly Quest Reset Time..." );
967
968 LOG_INFO("server.loading", "Calculate Next Monthly Quest Reset Time...");
970
971 LOG_INFO("server.loading", "Calculate Random Battleground Reset Time..." );
973
974 LOG_INFO("server.loading", "Calculate Deletion Of Old Calendar Events Time...");
976
977 LOG_INFO("server.loading", "Calculate Guild Cap Reset Time...");
978 LOG_INFO("server.loading", " ");
980
981 LOG_INFO("server.loading", "Load Petitions...");
982 sPetitionMgr->LoadPetitions();
983
984 LOG_INFO("server.loading", "Load Petition Signs...");
985 sPetitionMgr->LoadSignatures();
986
987 LOG_INFO("server.loading", "Load Stored Loot Items...");
988 sLootItemStorage->LoadStorageFromDB();
989
990 LOG_INFO("server.loading", "Load Channel Rights...");
992
993 LOG_INFO("server.loading", "Load Channels...");
995
996 LOG_INFO("server.loading", "Loading AntiDos opcode policies");
997 sWorldGlobals->LoadAntiDosOpcodePolicies();
998
999 sScriptMgr->OnBeforeWorldInitialized();
1000
1002 {
1003 LOG_INFO("server.loading", "Loading All Grids For All Non-Instanced Maps...");
1004
1005 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
1006 {
1007 MapEntry const* mapEntry = sMapStore.LookupEntry(i);
1008
1009 if (mapEntry && !mapEntry->Instanceable())
1010 {
1011 if (sMapMgr->GetMapUpdater()->activated())
1012 sMapMgr->GetMapUpdater()->schedule_map_preload(mapEntry->MapID);
1013 else
1014 {
1015 Map* map = sMapMgr->CreateBaseMap(mapEntry->MapID);
1016
1017 if (map)
1018 {
1019 LOG_INFO("server.loading", ">> Loading All Grids For Map {}", map->GetId());
1020 map->LoadAllGrids();
1021 }
1022 }
1023 }
1024 }
1025
1026 if (sMapMgr->GetMapUpdater()->activated())
1027 sMapMgr->GetMapUpdater()->wait();
1028 }
1029
1030 uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
1031
1032 LOG_INFO("server.loading", " ");
1033 LOG_INFO("server.loading", "WORLD: World Initialized In {} Minutes {} Seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000)); // outError for red color in console
1034 LOG_INFO("server.loading", " ");
1035
1036 METRIC_EVENT("events", "World initialized", "World Initialized In " + std::to_string(startupDuration / 60000) + " Minutes " + std::to_string((startupDuration % 60000) / 1000) + " Seconds");
1037
1038 if (sConfigMgr->isDryRun())
1039 {
1040 sMapMgr->UnloadAll();
1041 LOG_INFO("server.loading", "AzerothCore Dry Run Completed, Terminating.");
1042 exit(0);
1043 }
1044}
#define sAchievementMgr
Definition AchievementMgr.h:451
@ MAP_OUTLAND
Definition AreaDefines.h:216
@ MAP_KALIMDOR
Definition AreaDefines.h:186
@ MAP_EASTERN_KINGDOMS
Definition AreaDefines.h:185
#define sArenaSeasonMgr
Definition ArenaSeasonMgr.h:124
#define sArenaTeamMgr
Definition ArenaTeamMgr.h:69
#define sAuctionMgr
Definition AuctionHouseMgr.h:224
#define sAutobroadcastMgr
Definition AutobroadcastMgr.h:54
#define sBattlefieldMgr
Definition BattlefieldMgr.h:77
#define sBattlegroundMgr
Definition BattlegroundMgr.h:187
#define sCharacterCache
Definition CharacterCache.h:83
#define sConditionMgr
Definition ConditionMgr.h:291
#define sFormationMgr
Definition CreatureGroups.h:127
#define sCreatureTextMgr
Definition CreatureTextMgr.h:119
uint32 GetLiquidFlags(uint32 liquidType)
Definition DBCStores.cpp:834
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
void LoadDBCStores(const std::string &dataPath)
Definition DBCStores.cpp:261
#define sDisableMgr
Definition DisableMgr.h:88
#define sGraveyard
Definition GameGraveyard.h:74
void LoadGameObjectModelList(std::string const &dataPath)
Definition GameObjectModel.cpp:45
#define sGroupMgr
Definition GroupMgr.h:51
#define sIPLocation
Definition IPLocation.h:49
#define sInstanceSaveMgr
Definition InstanceSaveMgr.h:202
void LoadRandomEnchantmentsTable()
Definition ItemEnchantmentMgr.cpp:47
#define sLFGMgr
Definition LFGMgr.h:641
@ LOGIN_INS_UPTIME
Definition LoginDatabase.h:127
#define sLootItemStorage
Definition LootItemStorage.h:73
void LoadLootTables()
Definition LootMgr.h:443
void LoadM2Cameras(std::string const &dataPath)
Definition M2Stores.cpp:173
void dtCustomFree(void *ptr)
Definition MMapMgr.h:34
void * dtCustomAlloc(std::size_t size, dtAllocHint)
Definition MMapMgr.h:29
#define METRIC_EVENT(category, title, description)
Definition Metric.h:189
#define sMotdMgr
Definition MotdMgr.h:52
#define sObjectMgr
Definition ObjectMgr.h:1650
#define sOutdoorPvPMgr
Definition OutdoorPvPMgr.h:102
#define sPetitionMgr
Definition PetitionMgr.h:104
#define sServerMailMgr
Definition ServerMailMgr.h:231
void LoadSkillDiscoveryTable()
Definition SkillDiscovery.cpp:46
void LoadSkillPerfectItemTable()
Definition SkillExtraItems.cpp:52
void LoadSkillExtraItemTable()
Definition SkillExtraItems.cpp:138
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2241
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2240
#define sSpellMgr
Definition SpellMgr.h:825
#define sTicketMgr
Definition TicketMgr.h:260
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
#define sTransportMgr
Definition TransportMgr.h:163
#define sWardenCheckMgr
Definition WardenCheckMgr.h:89
#define sWaypointMgr
Definition WaypointMgr.h:78
@ CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS
Definition WorldConfig.h:116
@ CONFIG_REALM_ZONE
Definition WorldConfig.h:170
@ CONFIG_EXPANSION
Definition WorldConfig.h:226
@ CONFIG_DB_PING_INTERVAL
Definition WorldConfig.h:316
#define sWorldGlobals
Definition WorldGlobals.h:42
static void LoadChannelRights()
Definition ChannelMgr.cpp:166
static void LoadChannels()
Definition ChannelMgr.cpp:50
static void CleanOldChannelsInDB()
Definition Channel.cpp:140
static bool IsVMAPDisabledFor(uint32 entry, uint8 flags)
Definition DisableMgr.cpp:432
static MMapMgr * createOrGetMMapMgr()
Definition MMapFactory.cpp:27
Definition MMapMgr.h:74
void InitializeThreadUnsafe(const std::vector< uint32 > &mapIds)
Definition MMapMgr.cpp:41
static bool ExistMapAndVMap(uint32 mapid, float x, float y)
Definition MapMgr.cpp:305
Definition Map.h:160
void LoadAllGrids()
Definition Map.cpp:213
uint32 GetId() const
Definition Map.h:226
static void InitializeTables()
Definition PlayerDump.cpp:253
static void DeleteOldCharacters()
Definition Player.cpp:4350
static void DeleteOldRecoveryItems()
Definition Player.cpp:4385
Definition VMapMgr2.h:76
IsVMAPDisabledForFn IsVMAPDisabledForPtr
Definition VMapMgr2.h:137
void InitializeThreadUnsafe(const std::vector< uint32 > &mapIds)
Definition VMapMgr2.cpp:54
GetLiquidFlagsFn GetLiquidFlagsPtr
Definition VMapMgr2.h:134
bool IsFFAPvPRealm() const override
Definition World.cpp:1818
void LoadConfigSettings(bool reload=false) override
Initialize config values.
Definition World.cpp:164
void InitCalendarOldEventsDeletionTime()
Definition World.cpp:1642
void InitDailyQuestResetTime()
Definition World.cpp:1609
void LoadDBAllowedSecurityLevel() override
Definition World.cpp:1681
void DetectDBCLang()
Definition World.cpp:1046
void InitGuildResetTime()
Definition World.cpp:1653
void InitRandomBGResetTime()
Definition World.cpp:1631
void InitWeeklyQuestResetTime()
Definition World.cpp:1598
void InitMonthlyQuestResetTime()
Definition World.cpp:1620
OpcodeTable opcodeTable
Definition Opcodes.cpp:51
void Initialize()
Correspondence between opcodes and their names.
Definition Opcodes.cpp:123
void LoadWeatherData()
Definition WeatherMgr.cpp:82
@ WUPDATE_PINGDB
Definition World.h:67
@ WUPDATE_WHO_LIST
Definition World.h:69
@ WUPDATE_WEATHERS
Definition World.h:61
void Initialize()
Definition CreatureAIRegistry.cpp:34
AC_GAME_API void LoadCommandMap()
Definition ChatCommand.cpp:530
void LoadFromDB()
Definition AddonMgr.cpp:39
void CleanDatabase()
Definition CharacterDatabaseCleaner.cpp:27
Seconds GetStartTime()
Definition GameTime.cpp:33
AC_COMMON_API char const * GetFullVersion()
Definition GitRevision.cpp:82
Definition DBCStructure.h:1326
uint32 MapID
Definition DBCStructure.h:1327
bool Instanceable() const
Definition DBCStructure.h:1354

References _dataPath, _mail_expire_check_timer, _timers, CharacterDatabase, CharacterDatabaseCleaner::CleanDatabase(), Channel::CleanOldChannelsInDB(), CONFIG_AUTOBROADCAST_INTERVAL, CONFIG_DB_PING_INTERVAL, CONFIG_EXPANSION, CONFIG_GAME_TYPE, CONFIG_LOGDB_CLEARINTERVAL, CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS, CONFIG_REALM_ZONE, CONFIG_UPTIME_UPDATE, MMAP::MMapFactory::createOrGetMMapMgr(), VMAP::VMapFactory::createOrGetVMapMgr(), Player::DeleteOldCharacters(), Player::DeleteOldRecoveryItems(), DetectDBCLang(), dtCustomAlloc(), dtCustomFree(), MapMgr::ExistMapAndVMap(), getBoolConfig(), GetDefaultDbcLocale(), GitRevision::GetFullVersion(), GameTime::GetGameTime(), Map::GetId(), getIntConfig(), GetLiquidFlags(), VMAP::VMapMgr2::GetLiquidFlagsPtr, getMSTime(), GetMSTimeDiffToNow(), GameTime::GetStartTime(), Realm::Id, IN_MILLISECONDS, InitCalendarOldEventsDeletionTime(), InitDailyQuestResetTime(), InitGuildResetTime(), AIRegistry::Initialize(), OpcodeTable::Initialize(), PlayerDump::InitializeTables(), MMAP::MMapMgr::InitializeThreadUnsafe(), VMAP::VMapMgr2::InitializeThreadUnsafe(), InitMonthlyQuestResetTime(), InitRandomBGResetTime(), InitWeeklyQuestResetTime(), MapEntry::Instanceable(), IsFFAPvPRealm(), DisableMgr::IsVMAPDisabledFor(), VMAP::VMapMgr2::IsVMAPDisabledForPtr, Map::LoadAllGrids(), ChannelMgr::LoadChannelRights(), ChannelMgr::LoadChannels(), Acore::ChatCommands::LoadCommandMap(), LoadConfigSettings(), LoadDBAllowedSecurityLevel(), LoadDBCStores(), AddonMgr::LoadFromDB(), LoadGameObjectModelList(), LoadLootTables(), LoadM2Cameras(), LoadRandomEnchantmentsTable(), LoadSkillDiscoveryTable(), LoadSkillExtraItemTable(), LoadSkillPerfectItemTable(), WeatherMgr::LoadWeatherData(), LOG_ERROR, LOG_INFO, LOGIN_INS_UPTIME, LoginDatabase, MAP_EASTERN_KINGDOMS, MAP_KALIMDOR, MAP_OUTLAND, MapEntry::MapID, METRIC_EVENT, MINUTE, opcodeTable, realm, RealmHandle::Realm, REALM_TYPE_PVP, sAchievementMgr, sArenaSeasonMgr, sArenaTeamMgr, sAuctionMgr, sAutobroadcastMgr, sBattlefieldMgr, sBattlegroundMgr, sCalendarMgr, sCharacterCache, sConditionMgr, sConfigMgr, sCreatureTextMgr, sDisableMgr, PreparedStatementBase::SetData(), IntervalTimer::SetInterval(), sFormationMgr, sGameEventMgr, sGraveyard, sGroupMgr, sGuildMgr, sInstanceSaveMgr, sIPLocation, sLFGMgr, sLootItemStorage, sMapMgr, sMapStore, sMotdMgr, sObjectMgr, sOutdoorPvPMgr, sPetitionMgr, sPoolMgr, sScriptMgr, sServerMailMgr, sSmartScriptMgr, sSmartWaypointMgr, sSpellMgr, sTicketMgr, sTransportMgr, sWardenCheckMgr, sWaypointMgr, sWorldGlobals, sWorldState, WUPDATE_5_SECS, WUPDATE_AUTOBROADCAST, WUPDATE_CLEANDB, WUPDATE_EVENTS, WUPDATE_PINGDB, WUPDATE_UPTIME, WUPDATE_WEATHERS, and WUPDATE_WHO_LIST.

◆ setIntConfig()

void World::setIntConfig ( ServerConfigs  index,
uint32  value 
)
overridevirtual

◆ SetPlayerSecurityLimit()

void World::SetPlayerSecurityLimit ( AccountTypes  sec)
overridevirtual

Implements IWorld.

1692{
1693 AccountTypes sec = _sec < SEC_CONSOLE ? _sec : SEC_PLAYER;
1694 bool update = sec > _allowedSecurityLevel;
1696 if (update)
1698}
@ SEC_CONSOLE
Definition Common.h:61

References _allowedSecurityLevel, SEC_CONSOLE, SEC_PLAYER, and sWorldSessionMgr.

Referenced by LoadDBAllowedSecurityLevel().

◆ setRate()

void World::setRate ( ServerConfigs  index,
float  value 
)
overridevirtual

Implements IWorld.

1327{
1328 setFloatConfig(index, value);
1329}
void setFloatConfig(ServerConfigs index, float value) override
Definition World.cpp:1347

References setFloatConfig().

◆ SetRealmName()

void World::SetRealmName ( std::string  name)
inlineoverridevirtual

Implements IWorld.

241{ _realmName = name; } // pussywizard

References _realmName.

◆ setStringConfig()

void World::setStringConfig ( ServerConfigs  index,
std::string const &  value 
)
overridevirtual

Implements IWorld.

1368{
1369 _worldConfig.OverwriteConfigValue<std::string>(index, value);
1370}

References _worldConfig, and ConfigValueCache< ConfigEnum >::OverwriteConfigValue().

◆ ShutdownCancel()

void World::ShutdownCancel ( )
overridevirtual

Cancel a planned server shutdown.

Implements IWorld.

1535{
1536 // nothing cancel or too later
1537 if (!_shutdownTimer || _stopEvent)
1538 return;
1539
1541
1542 _shutdownMask = 0;
1543 _shutdownTimer = 0;
1544 _exitCode = SHUTDOWN_EXIT_CODE; // to default value
1545 sWorldSessionMgr->SendServerMessage(msgid);
1546
1547 LOG_DEBUG("server.worldserver", "Server {} cancelled.", (_shutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
1548
1549 sScriptMgr->OnShutdownCancel();
1550}
ServerMessageType
Definition IWorld.h:54
@ SERVER_MSG_SHUTDOWN_CANCELLED
Definition IWorld.h:58
@ SERVER_MSG_RESTART_CANCELLED
Definition IWorld.h:59
@ SHUTDOWN_EXIT_CODE
Definition World.h:53
@ SHUTDOWN_MASK_RESTART
Definition World.h:47

References _exitCode, _shutdownMask, _shutdownTimer, _stopEvent, LOG_DEBUG, SERVER_MSG_RESTART_CANCELLED, SERVER_MSG_SHUTDOWN_CANCELLED, SHUTDOWN_EXIT_CODE, SHUTDOWN_MASK_RESTART, sScriptMgr, and sWorldSessionMgr.

◆ ShutdownMsg()

void World::ShutdownMsg ( bool  show = false,
Player player = nullptr,
std::string const &  reason = std::string() 
)
overridevirtual

Displays a shutdown message at specific intervals or immediately if required.

Show the time remaining for a server shutdown/restart with a reason appended if one is provided. Messages are displayed at regular intervals such as every 12 hours, 1 hour, 5 minutes, 1 minute, 30 seconds, 10 seconds, and every second in the last 10 seconds.

Parameters
showForces the message to be displayed immediately.
playerThe player who should recieve the message (can be nullptr for global messages).
reasonThe reason for the shutdown, appended to the message if provided.
  • Display a message every 12 hours, hour, 5 minutes, minute, 30 seconds, 10 seconds and finally seconds

Implements IWorld.

1504{
1505 // Do not show a message for idle shutdown
1507 return;
1508
1509 bool twelveHours = (_shutdownTimer > 12 * HOUR && (_shutdownTimer % (12 * HOUR)) == 0); // > 12 h ; every 12 h
1510 bool oneHour = (_shutdownTimer < 12 * HOUR && (_shutdownTimer % HOUR) == 0); // < 12 h ; every 1 h
1511 bool fiveMin = (_shutdownTimer < 30 * MINUTE && (_shutdownTimer % (5 * MINUTE)) == 0); // < 30 min ; every 5 min
1512 bool oneMin = (_shutdownTimer < 15 * MINUTE && (_shutdownTimer % MINUTE) == 0); // < 15 min ; every 1 min
1513 bool thirtySec = (_shutdownTimer < 5 * MINUTE && (_shutdownTimer % 30) == 0); // < 5 min; every 30 sec
1514 bool tenSec = (_shutdownTimer < 1 * MINUTE && (_shutdownTimer % 10) == 0); // < 1 min; every 10 sec
1515 bool oneSec = (_shutdownTimer < 10 * SECOND && (_shutdownTimer % 1) == 0); // < 10 sec; every 1 sec
1516
1518 if (show || twelveHours || oneHour || fiveMin || oneMin || thirtySec || tenSec || oneSec)
1519 {
1520 std::string str = secsToTimeString(_shutdownTimer).append(".");
1521 if (!reason.empty())
1522 str += " - " + reason;
1523 // Display the reason every 12 hours, hour, 5 minutes, minute. At 60 seconds and at 10 seconds
1524 else if (!_shutdownReason.empty() && (twelveHours || oneHour || fiveMin || oneMin || _shutdownTimer == 60 || _shutdownTimer == 10))
1525 str += " - " + _shutdownReason;
1526
1528 sWorldSessionMgr->SendServerMessage(msgid, str, player);
1529 LOG_WARN("server.worldserver", "Server {} in {}", (_shutdownMask & SHUTDOWN_MASK_RESTART ? "restarting" : "shutdown"), str);
1530 }
1531}
constexpr auto SECOND
Definition Common.h:46
constexpr auto HOUR
Definition Common.h:48
@ SERVER_MSG_SHUTDOWN_TIME
Definition IWorld.h:55
@ SERVER_MSG_RESTART_TIME
Definition IWorld.h:56
#define LOG_WARN(filterType__,...)
Definition Log.h:162
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition Util.cpp:73
std::string _shutdownReason
Definition World.h:267

References _shutdownMask, _shutdownReason, _shutdownTimer, HOUR, LOG_WARN, MINUTE, SECOND, secsToTimeString(), SERVER_MSG_RESTART_TIME, SERVER_MSG_SHUTDOWN_TIME, SHUTDOWN_MASK_IDLE, SHUTDOWN_MASK_RESTART, and sWorldSessionMgr.

Referenced by _UpdateGameTime(), and ShutdownServ().

◆ ShutdownServ()

void World::ShutdownServ ( uint32  time,
uint32  options,
uint8  exitcode,
std::string const &  reason = std::string() 
)
overridevirtual

Shutdown the server.

  • If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
  • Else set the shutdown timer and warn users

Implements IWorld.

1462{
1463 // ignore if server shutdown at next tick
1464 if (IsStopped())
1465 return;
1466
1467 _shutdownMask = options;
1468 _exitCode = exitcode;
1469 _shutdownReason = reason;
1470
1471 LOG_DEBUG("server.worldserver", "Server shutdown called with ShutdownMask {}, ExitCode {}, Time {}, Reason {}", ShutdownMask(options), ShutdownExitCode(exitcode), secsToTimeString(time), reason);
1472
1474 if (time == 0)
1475 {
1476 if (!(options & SHUTDOWN_MASK_IDLE) || sWorldSessionMgr->GetActiveAndQueuedSessionCount() == 0)
1477 _stopEvent = true; // exist code already set
1478 else
1479 _shutdownTimer = 1; //So that the session count is re-evaluated at next world tick
1480 }
1482 else
1483 {
1484 _shutdownTimer = time;
1485 ShutdownMsg(true, nullptr, reason);
1486 }
1487
1488 sScriptMgr->OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options));
1489}
ShutdownExitCode
Definition World.h:52
ShutdownMask
Definition World.h:46

References _exitCode, _shutdownMask, _shutdownReason, _shutdownTimer, _stopEvent, IsStopped(), LOG_DEBUG, secsToTimeString(), SHUTDOWN_MASK_IDLE, ShutdownMsg(), sScriptMgr, and sWorldSessionMgr.

◆ StopNow()

◆ Update()

void World::Update ( uint32  diff)
overridevirtual

Update the World !

  • Update the game time and check for shutdown time
  • Update the different timers
  • Update Who List Cache

Handle daily quests reset time

Handle weekly quests reset time

Handle monthly quests reset time

Handle weather updates when the timer has passed

Clean logs table

  • Update objects when the timer has passed (maps, transport, creatures, ...)

Update uptime table

  • Process Game events when necessary
  • Ping to keep MySQL connections alive

Implements IWorld.

1091{
1092 METRIC_TIMER("world_update_time_total");
1093
1096 Seconds currentGameTime = GameTime::GetGameTime();
1097
1099
1100 // Record update if recording set in log and diff is greater then minimum set in log
1102
1103 DynamicVisibilityMgr::Update(sWorldSessionMgr->GetActiveSessionCount());
1104
1106 for (int i = 0; i < WUPDATE_COUNT; ++i)
1107 {
1108 if (_timers[i].GetCurrent() >= 0)
1109 _timers[i].Update(diff);
1110 else
1111 _timers[i].SetCurrent(0);
1112 }
1113
1114 // pussywizard: our speed up and functionality
1115 if (_timers[WUPDATE_5_SECS].Passed())
1116 {
1118
1119 // moved here from HandleCharEnumOpcode
1121 CharacterDatabase.Execute(stmt);
1122 }
1123
1125 if (_timers[WUPDATE_WHO_LIST].Passed())
1126 {
1127 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update who list"));
1129 sWhoListCacheMgr->Update();
1130 }
1131
1132 {
1133 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Check quest reset times"));
1134
1136 if (currentGameTime > _nextDailyQuestReset)
1137 {
1139 }
1140
1142 if (currentGameTime > _nextWeeklyQuestReset)
1143 {
1145 }
1146
1148 if (currentGameTime > _nextMonthlyQuestReset)
1149 {
1151 }
1152 }
1153
1154 if (currentGameTime > _nextRandomBGReset)
1155 {
1156 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Reset random BG"));
1157 ResetRandomBG();
1158 }
1159
1160 if (currentGameTime > _nextCalendarOldEventsDeletionTime)
1161 {
1162 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Delete old calendar events"));
1164 }
1165
1166 if (currentGameTime > _nextGuildReset)
1167 {
1168 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Reset guild cap"));
1169 ResetGuildCap();
1170 }
1171
1172 {
1173 // pussywizard: handle expired auctions, auctions expired when realm was offline are also handled here (not during loading when many required things aren't loaded yet)
1174 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update expired auctions"));
1175 sAuctionMgr->Update(diff);
1176 }
1177
1178 if (currentGameTime > _mail_expire_check_timer)
1179 {
1180 sObjectMgr->ReturnOrDeleteOldMails(true);
1181 _mail_expire_check_timer = currentGameTime + 6h;
1182 }
1183
1184 {
1185 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update sessions"));
1186 sWorldSessionMgr->UpdateSessions(diff);
1187 }
1188
1190 if (_timers[WUPDATE_WEATHERS].Passed())
1191 {
1194 }
1195
1197 if (getIntConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer
1198 {
1199 if (_timers[WUPDATE_CLEANDB].Passed())
1200 {
1201 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Clean logs table"));
1202
1204
1207 stmt->SetData(1, uint32(currentGameTime.count()));
1208 LoginDatabase.Execute(stmt);
1209 }
1210 }
1211
1212 {
1213 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update LFG 0"));
1214 sLFGMgr->Update(diff, 0); // pussywizard: remove obsolete stuff before finding compatibility during map update
1215 }
1216
1217 {
1219 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update maps"));
1220 sMapMgr->Update(diff);
1221 }
1222
1224 {
1225 if (_timers[WUPDATE_AUTOBROADCAST].Passed())
1226 {
1227 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Send autobroadcast"));
1229 sAutobroadcastMgr->SendAutobroadcasts();
1230 }
1231 }
1232
1233 {
1234 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update battlegrounds"));
1235 sBattlegroundMgr->Update(diff);
1236 }
1237
1238 {
1239 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update outdoor pvp"));
1240 sOutdoorPvPMgr->Update(diff);
1241 }
1242
1243 {
1244 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update worldstate"));
1245 sWorldState->Update(diff);
1246 }
1247
1248 {
1249 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update battlefields"));
1250 sBattlefieldMgr->Update(diff);
1251 }
1252
1253 {
1254 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update LFG 2"));
1255 sLFGMgr->Update(diff, 2); // pussywizard: handle created proposals
1256 }
1257
1258 {
1259 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process query callbacks"));
1260 // execute callbacks from sql queries that were queued recently
1262 }
1263
1265 if (_timers[WUPDATE_UPTIME].Passed())
1266 {
1267 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update uptime"));
1268
1270
1272 stmt->SetData(0, uint32(GameTime::GetUptime().count()));
1273 stmt->SetData(1, uint16(sWorldSessionMgr->GetMaxPlayerCount()));
1274 stmt->SetData(2, realm.Id.Realm);
1275 stmt->SetData(3, uint32(GameTime::GetStartTime().count()));
1276 LoginDatabase.Execute(stmt);
1277 }
1278
1280 if (_timers[WUPDATE_EVENTS].Passed())
1281 {
1282 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update game events"));
1283 _timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed
1284 uint32 nextGameEvent = sGameEventMgr->Update();
1285 _timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
1287 }
1288
1290 if (_timers[WUPDATE_PINGDB].Passed())
1291 {
1292 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Ping MySQL"));
1294 LOG_DEBUG("sql.driver", "Ping MySQL to keep connection alive");
1295 CharacterDatabase.KeepAlive();
1296 LoginDatabase.KeepAlive();
1297 WorldDatabase.KeepAlive();
1298 }
1299
1300 {
1301 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update instance reset times"));
1302 // update the instance reset times
1303 sInstanceSaveMgr->Update();
1304 }
1305
1306 {
1307 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process cli commands"));
1308 // And last, but not least handle the issued cli commands
1310 }
1311
1312 {
1313 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update world scripts"));
1314 sScriptMgr->OnWorldUpdate(diff);
1315 }
1316
1317 {
1318 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update metrics"));
1319 // Stats logger update
1320 sMetric->Update();
1321 METRIC_VALUE("update_time_diff", diff);
1322 }
1323}
@ CHAR_DEL_EXPIRED_BANS
Definition CharacterDatabase.h:34
@ LOGIN_UPD_UPTIME_PLAYERS
Definition LoginDatabase.h:77
@ LOGIN_DEL_OLD_LOGS
Definition LoginDatabase.h:78
#define METRIC_VALUE(category, value,...)
Definition Metric.h:197
#define METRIC_TAG(name, value)
Definition Metric.h:163
#define METRIC_TIMER(category,...)
Definition Metric.h:206
#define sWhoListCacheMgr
Definition WhoListCacheMgr.h:96
@ CONFIG_AUTOBROADCAST
Definition WorldConfig.h:92
static void Update(uint32 sessionCount)
Definition DynamicVisibility.cpp:22
void UpdateWithDiff(uint32 diff)
Definition UpdateTime.cpp:102
void RecordUpdateTime(Milliseconds gameTimeMs, uint32 diff, uint32 sessionCount)
Definition UpdateTime.cpp:163
void ProcessCliCommands() override
Definition World.cpp:1553
void _UpdateGameTime()
Update the game time.
Definition World.cpp:1431
void ResetMonthlyQuests()
Definition World.cpp:1717
void ResetGuildCap()
Definition World.cpp:1770
void ResetWeeklyQuests()
Definition World.cpp:1700
void ResetRandomBG()
Definition World.cpp:1745
void ResetDailyQuests()
Definition World.cpp:1664
void CalendarDeleteOldEvents()
Definition World.cpp:1761
void ProcessQueryCallbacks()
Definition World.cpp:1808
void Update(uint32 diff)
Definition WeatherMgr.cpp:150
@ WUPDATE_COUNT
Definition World.h:70
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:43
Seconds GetUptime()
Uptime.
Definition GameTime.cpp:58
void Update(time_t diff)
Definition Timer.h:152
void SetCurrent(time_t current)
Definition Timer.h:174

References _mail_expire_check_timer, _nextCalendarOldEventsDeletionTime, _nextDailyQuestReset, _nextGuildReset, _nextMonthlyQuestReset, _nextRandomBGReset, _nextWeeklyQuestReset, _timers, _UpdateGameTime(), CalendarDeleteOldEvents(), CHAR_DEL_EXPIRED_BANS, CharacterDatabase, CONFIG_AUTOBROADCAST, CONFIG_LOGDB_CLEARTIME, getBoolConfig(), GameTime::GetGameTime(), GameTime::GetGameTimeMS(), getIntConfig(), GameTime::GetStartTime(), GameTime::GetUptime(), Realm::Id, LOG_DEBUG, LOGIN_DEL_OLD_LOGS, LOGIN_UPD_UPTIME_PLAYERS, LoginDatabase, METRIC_TAG, METRIC_TIMER, METRIC_VALUE, ProcessCliCommands(), ProcessQueryCallbacks(), realm, RealmHandle::Realm, WorldUpdateTime::RecordUpdateTime(), IntervalTimer::Reset(), ResetDailyQuests(), ResetGuildCap(), ResetMonthlyQuests(), ResetRandomBG(), ResetWeeklyQuests(), sAuctionMgr, sAutobroadcastMgr, sBattlefieldMgr, sBattlegroundMgr, IntervalTimer::SetCurrent(), PreparedStatementBase::SetData(), IntervalTimer::SetInterval(), sGameEventMgr, sInstanceSaveMgr, sLFGMgr, sMapMgr, sMetric, sObjectMgr, sOutdoorPvPMgr, sScriptMgr, sWhoListCacheMgr, sWorldSessionMgr, sWorldState, sWorldUpdateTime, IntervalTimer::Update(), WeatherMgr::Update(), DynamicVisibilityMgr::Update(), UpdateTime::UpdateWithDiff(), WorldDatabase, WUPDATE_5_SECS, WUPDATE_AUTOBROADCAST, WUPDATE_CLEANDB, WUPDATE_COUNT, WUPDATE_EVENTS, WUPDATE_PINGDB, WUPDATE_UPTIME, WUPDATE_WEATHERS, and WUPDATE_WHO_LIST.

◆ UpdateAreaDependentAuras()

void World::UpdateAreaDependentAuras ( )
overridevirtual

Implements IWorld.

1798{
1799 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1800 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1801 if (itr->second && itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld())
1802 {
1803 itr->second->GetPlayer()->UpdateAreaDependentAuras(itr->second->GetPlayer()->GetAreaId());
1804 itr->second->GetPlayer()->UpdateZoneDependentAuras(itr->second->GetPlayer()->GetZoneId());
1805 }
1806}

References sWorldSessionMgr.

◆ UpdateRealmCharCount()

void World::UpdateRealmCharCount ( uint32  accid)
overridevirtual

Implements IWorld.

1572{
1574 stmt->SetData(0, accountId);
1575 _queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&World::_UpdateRealmCharCount, this, std::placeholders::_1,accountId)));
1576}
@ CHAR_SEL_CHARACTER_COUNT
Definition CharacterDatabase.h:136
T & AddCallback(T &&query)
Definition AsyncCallbackProcessor.h:34
void _UpdateRealmCharCount(PreparedQueryResult resultCharCount, uint32 accountId)
Definition World.cpp:1578

References _queryProcessor, _UpdateRealmCharCount(), AsyncCallbackProcessor< T >::AddCallback(), CHAR_SEL_CHARACTER_COUNT, CharacterDatabase, and PreparedStatementBase::SetData().

Member Data Documentation

◆ _allowedSecurityLevel

AccountTypes World::_allowedSecurityLevel
private

◆ _allowMovement

bool World::_allowMovement
private

◆ _availableDbcLocaleMask

uint32 World::_availableDbcLocaleMask
private

◆ _cleaningFlags

uint32 World::_cleaningFlags
private

◆ _cliCmdQueue

LockedQueue<CliCommandHolder*> World::_cliCmdQueue
private

◆ _dataPath

std::string World::_dataPath
private

◆ _dbClientCacheVersion

uint32 World::_dbClientCacheVersion
private

◆ _dbVersion

std::string World::_dbVersion
private

Referenced by GetDBVersion(), and LoadDBVersion().

◆ _defaultDbcLocale

LocaleConstant World::_defaultDbcLocale
private

◆ _exitCode

uint8 World::_exitCode = SHUTDOWN_EXIT_CODE
staticprivate

◆ _isClosed

bool World::_isClosed
private

Referenced by IsClosed(), SetClosed(), and World().

◆ _mail_expire_check_timer

Seconds World::_mail_expire_check_timer
private

◆ _maxVisibleDistanceInBGArenas

float World::_maxVisibleDistanceInBGArenas = DEFAULT_VISIBILITY_BGARENAS
staticprivate

◆ _maxVisibleDistanceInInstances

float World::_maxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE
staticprivate

◆ _maxVisibleDistanceOnContinents

float World::_maxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE
staticprivate

◆ _nextCalendarOldEventsDeletionTime

Seconds World::_nextCalendarOldEventsDeletionTime
private

◆ _nextDailyQuestReset

Seconds World::_nextDailyQuestReset
private

◆ _nextGuildReset

Seconds World::_nextGuildReset
private

◆ _nextMonthlyQuestReset

Seconds World::_nextMonthlyQuestReset
private

◆ _nextRandomBGReset

Seconds World::_nextRandomBGReset
private

◆ _nextWeeklyQuestReset

Seconds World::_nextWeeklyQuestReset
private

◆ _queryProcessor

QueryCallbackProcessor World::_queryProcessor
private

◆ _realmName

std::string World::_realmName
private

Referenced by GetRealmName(), and SetRealmName().

◆ _shutdownMask

uint32 World::_shutdownMask
private

◆ _shutdownReason

std::string World::_shutdownReason
private

Referenced by ShutdownMsg(), and ShutdownServ().

◆ _shutdownTimer

◆ _stopEvent

std::atomic_long World::_stopEvent = false
staticprivate

◆ _timers

◆ _worldConfig

◆ m_worldLoopCounter

uint32 World::m_worldLoopCounter = 0
static

The documentation for this class was generated from the following files: