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 SaveSessionEnd (bool finished) override
 Records how this session ended in uptime; finished marks the shutdown as complete (not a crash)
 
Optional< PreviousSessionInfo > const & GetPreviousSessionInfo () const override
 
uint32 GetLifetimeMaxPlayerCount () const override
 
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
 
void ReloadRBAC () 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 World * instance ()
 
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.
 
bool RescheduleShutdownForWintergrasp ()
 
void LoadPreviousSessionInfo ()
 
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
 
Optional< PreviousSessionInfo > _previousSession
 
uint32 _lifetimeMaxPlayerCount
 
Optional< SessionOutcome > _sessionOutcome
 
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 std::atomic< uint8 > _exitCode = SHUTDOWN_EXIT_CODE
 
static std::atomic< bool > _stoppedByStopNow = false
 
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.

121{
123 _allowMovement = true;
124 _shutdownMask = 0;
125 _shutdownTimer = 0;
132 _nextGuildReset = 0s;
135 _isClosed = false;
136 _cleaningFlags = 0;
138}
@ LOCALE_enUS
Definition Common.h:126
@ SEC_PLAYER
Definition Common.h:57
Seconds _nextGuildReset
Definition World.h:319
uint32 _shutdownMask
Definition World.h:282
uint32 _cleaningFlags
Definition World.h:289
LocaleConstant _defaultDbcLocale
Definition World.h:297
Seconds _nextDailyQuestReset
Definition World.h:314
bool _isClosed
Definition World.h:291
uint32 _dbClientCacheVersion
Definition World.h:323
Seconds _nextMonthlyQuestReset
Definition World.h:316
Seconds _nextCalendarOldEventsDeletionTime
Definition World.h:318
Seconds _nextWeeklyQuestReset
Definition World.h:315
uint32 _shutdownTimer
Definition World.h:281
uint32 _lifetimeMaxPlayerCount
Definition World.h:286
Seconds _nextRandomBGReset
Definition World.h:317
bool _allowMovement
Definition World.h:300
AccountTypes _allowedSecurityLevel
Definition World.h:296
Seconds _mail_expire_check_timer
Definition World.h:294

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

◆ ~World()

World::~World ( )
override

World destructor.

142{
143 CliCommandHolder* command = nullptr;
144 while (_cliCmdQueue.next(command))
145 delete command;
146
148}
bool next(T &result)
Gets the next item in the queue and removes it.
Definition LockedQueue.h:77
static void clear()
Definition VMapFactory.cpp:39
LockedQueue< CliCommandHolder * > _cliCmdQueue
Definition World.h:311
Storage class for commands issued for delayed execution.
Definition IWorld.h:36

References _cliCmdQueue, 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)
  • ... unless a Wintergrasp battle is running and deferral is enabled, in which case the shutdown/restart is pushed past the end of the current battle and the world keeps running
  • ... else decrease it and if necessary display a shutdown countdown to the users
1492{
1494 Seconds lastGameTime = GameTime::GetGameTime();
1496
1497 Seconds elapsed = GameTime::GetGameTime() - lastGameTime;
1498
1500 if (!IsStopped() && _shutdownTimer > 0 && elapsed > 0s)
1501 {
1503 if (_shutdownTimer <= elapsed.count())
1504 {
1508 {
1509 if (!(_shutdownMask & SHUTDOWN_MASK_IDLE) || sWorldSessionMgr->GetActiveAndQueuedSessionCount() == 0)
1510 _stopEvent = true; // exist code already set
1511 else
1512 _shutdownTimer = 1; // minimum timer value to wait idle state
1513 }
1514 }
1516 else
1517 {
1518 _shutdownTimer -= elapsed.count();
1519
1520 ShutdownMsg();
1521 }
1522 }
1523}
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
#define sWorldSessionMgr
Definition WorldSessionMgr.h:118
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:1600
bool RescheduleShutdownForWintergrasp()
Definition World.cpp:1527
static std::atomic_long _stopEvent
Definition World.h:277
static bool IsStopped()
Definition World.h:196
@ SHUTDOWN_MASK_IDLE
Definition World.h:48
void UpdateGameTimers()
Update all timers.
Definition GameTime.cpp:64
Seconds GetGameTime()
Definition GameTime.cpp:39

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

Referenced by Update().

◆ _UpdateRealmCharCount()

void World::_UpdateRealmCharCount ( PreparedQueryResult  resultCharCount,
uint32  accountId 
)
protected
1748{
1749 uint8 charCount{0};
1750 if (resultCharCount)
1751 {
1752 Field* fields = resultCharCount->Fetch();
1753 charCount = uint8(fields[1].Get<uint64>());
1754 }
1755
1756 LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
1757
1759 stmt->SetData(0, charCount);
1760 stmt->SetData(1, accountId);
1761 stmt->SetData(2, realm.Id.Realm);
1762 trans->Append(stmt);
1763
1764 LoginDatabase.CommitTransaction(trans);
1765}
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:99
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:117
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
1941{
1942 LOG_INFO("server.worldserver", "Calendar deletion of old events.");
1943
1946 sCalendarMgr->DeleteOldEvents();
1947}
#define sCalendarMgr
Definition CalendarMgr.h:344
#define LOG_INFO(filterType__,...)
Definition Log.h:153
@ CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR
Definition WorldConfig.h:318
@ 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:1422
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
1089{
1090 uint8 m_lang_confid = sConfigMgr->GetOption<int32>("DBC.Locale", 255);
1091
1092 if (m_lang_confid != 255 && m_lang_confid >= TOTAL_LOCALES)
1093 {
1094 LOG_ERROR("server.loading", "Incorrect DBC.Locale! Must be >= 0 and < {} (set to 0)", TOTAL_LOCALES);
1095 m_lang_confid = LOCALE_enUS;
1096 }
1097
1098 ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1);
1099 std::string availableLocalsStr;
1100
1101 uint8 default_locale = TOTAL_LOCALES;
1102 for (uint8 i = default_locale - 1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8
1103 {
1104 if (IsLocaleRegistered(LocaleConstant(i)) && race->name[i][0] != '\0') // check by race names
1105 {
1106 default_locale = i;
1107 _availableDbcLocaleMask |= (1 << i);
1108 availableLocalsStr += localeNames[i];
1109 availableLocalsStr += " ";
1110 }
1111 }
1112
1113 if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES &&
1114 (_availableDbcLocaleMask & (1 << m_lang_confid)))
1115 {
1116 default_locale = m_lang_confid;
1117 }
1118
1119 if (default_locale >= TOTAL_LOCALES)
1120 {
1121 LOG_ERROR("server.loading", "Unable to determine your DBC Locale! (corrupt DBC?)");
1122 exit(1);
1123 }
1124
1125 _defaultDbcLocale = LocaleConstant(default_locale);
1126
1127 LOG_INFO("server.loading", "Using {} DBC Locale As Default. All Available DBC locales: {}", localeNames[GetDefaultDbcLocale()], availableLocalsStr.empty() ? "<none>" : availableLocalsStr);
1128 LOG_INFO("server.loading", " ");
1129}
char const * localeNames[TOTAL_LOCALES]
Definition Common.cpp:20
LocaleConstant
Definition Common.h:125
@ TOTAL_LOCALES
Definition Common.h:137
bool IsLocaleRegistered(LocaleConstant locale)
Definition Common.h:147
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
std::int32_t int32
Definition Define.h:103
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
uint32 _availableDbcLocaleMask
Definition World.h:298
LocaleConstant GetDefaultDbcLocale() const override
Definition World.h:168
#define sConfigMgr
Definition Config.h:93
Definition DBCStructure.h:706
char const * name[16]
Definition DBCStructure.h:718

References _availableDbcLocaleMask, _defaultDbcLocale, GetDefaultDbcLocale(), IsLocaleRegistered(), 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.

1438{
1439 _timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed
1440 uint32 nextGameEvent = sGameEventMgr->Update();
1441 _timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
1443}
std::uint32_t uint32
Definition Define.h:107
#define sGameEventMgr
Definition GameEventMgr.h:204
IntervalTimer _timers[WUPDATE_COUNT]
Definition World.h:293
@ WUPDATE_EVENTS
Definition World.h:62
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.

164{ return _allowMovement; }

References _allowMovement.

◆ GetAvailableDbcLocale()

LocaleConstant World::GetAvailableDbcLocale ( LocaleConstant  locale) const
inlineoverridevirtual

Implements IWorld.

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

References _availableDbcLocaleMask, and _defaultDbcLocale.

◆ getBoolConfig()

bool World::getBoolConfig ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1403{
1404 return _worldConfig.GetConfigValue<bool>(index);
1405}
T GetConfigValue(ConfigEnum const config) const
Definition ConfigValueCache.h:97
WorldConfig _worldConfig
Definition World.h:275

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

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

◆ GetCleaningFlags()

uint32 World::GetCleaningFlags ( ) const
inlineoverridevirtual

Implements IWorld.

247{ return _cleaningFlags; }

References _cleaningFlags.

◆ GetConfigMaxSkillValue()

uint16 World::GetConfigMaxSkillValue ( ) const
inlineoverridevirtual

Get the maximum skill level a player can reach.

Implements IWorld.

180 {
182 return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl * 5;
183 }
std::uint16_t uint16
Definition Define.h:108
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:194

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.

171{ return _dataPath; }
std::string _dataPath
Definition World.h:301

References _dataPath.

◆ GetDBVersion()

char const * World::GetDBVersion ( ) const
inlineoverridevirtual

Implements IWorld.

243{ return _dbVersion.c_str(); }
std::string _dbVersion
Definition World.h:322

References _dbVersion.

◆ GetDefaultDbcLocale()

LocaleConstant World::GetDefaultDbcLocale ( ) const
inlineoverridevirtual

Implements IWorld.

168{ return _defaultDbcLocale; }

References _defaultDbcLocale.

Referenced by DetectDBCLang(), and SetInitialWorldSettings().

◆ GetExitCode()

static uint8 World::GetExitCode ( )
inlinestatic
194{ return _exitCode; }
static std::atomic< uint8 > _exitCode
Definition World.h:278

References _exitCode.

Referenced by main().

◆ getFloatConfig()

float World::getFloatConfig ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1413{
1414 return _worldConfig.GetConfigValue<float>(index);
1415}

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

Referenced by getRate().

◆ getIntConfig()

◆ GetLifetimeMaxPlayerCount()

uint32 World::GetLifetimeMaxPlayerCount ( ) const
overridevirtual

Implements IWorld.

1717{
1718 return std::max(_lifetimeMaxPlayerCount, sWorldSessionMgr->GetMaxPlayerCount());
1719}

References _lifetimeMaxPlayerCount, and sWorldSessionMgr.

◆ GetMaxVisibleDistanceInBGArenas()

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

References _maxVisibleDistanceInBGArenas.

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

◆ GetMaxVisibleDistanceInInstances()

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

References _maxVisibleDistanceInInstances.

Referenced by InstanceMap::InitVisibilityDistance().

◆ GetMaxVisibleDistanceOnContinents()

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

References _maxVisibleDistanceOnContinents.

Referenced by Map::InitVisibilityDistance().

◆ GetNextDailyQuestsResetTime()

Seconds World::GetNextDailyQuestsResetTime ( ) const
inlineoverridevirtual

Next daily quests and random bg reset time.

Implements IWorld.

174{ return _nextDailyQuestReset; }

References _nextDailyQuestReset.

◆ GetNextRandomBGResetTime()

Seconds World::GetNextRandomBGResetTime ( ) const
inlineoverridevirtual

Implements IWorld.

176{ return _nextRandomBGReset; }

References _nextRandomBGReset.

◆ GetNextWeeklyQuestsResetTime()

Seconds World::GetNextWeeklyQuestsResetTime ( ) const
inlineoverridevirtual

Implements IWorld.

175{ return _nextWeeklyQuestReset; }

References _nextWeeklyQuestReset.

◆ GetNextWhoListUpdateDelaySecs()

uint32 World::GetNextWhoListUpdateDelaySecs ( )
overridevirtual

Implements IWorld.

2003{
2004 if (_timers[WUPDATE_5_SECS].Passed())
2005 return 1;
2006
2008 t = std::min(t, (uint32)_timers[WUPDATE_5_SECS].GetInterval());
2009
2010 return uint32(std::ceil(t / 1000.0f));
2011}
@ WUPDATE_5_SECS
Definition World.h:67
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.

158{ return _allowedSecurityLevel; }

References _allowedSecurityLevel.

◆ GetPreviousSessionInfo()

Optional< PreviousSessionInfo > const & World::GetPreviousSessionInfo ( ) const
inlineoverridevirtual

Implements IWorld.

200{ return _previousSession; }
Optional< PreviousSessionInfo > _previousSession
Definition World.h:285

References _previousSession.

◆ getRate()

float World::getRate ( ServerConfigs  index) const
overridevirtual

Implements IWorld.

1393{
1394 return getFloatConfig(index);
1395}
float getFloatConfig(ServerConfigs index) const override
Definition World.cpp:1412

References getFloatConfig().

Referenced by LoadConfigSettings().

◆ GetRealmName()

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

Implements IWorld.

252{ return _realmName; } // pussywizard
std::string _realmName
Definition World.h:308

References _realmName.

◆ GetShutDownTimeLeft()

uint32 World::GetShutDownTimeLeft ( ) const
inlineoverridevirtual

Implements IWorld.

190{ return _shutdownTimer; }

References _shutdownTimer.

◆ getStringConfig()

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

Implements IWorld.

1433{
1434 return _worldConfig.GetConfigValue(index);
1435}

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

◆ InitCalendarOldEventsDeletionTime()

void World::InitCalendarOldEventsDeletionTime ( )
protected
1812{
1814 Seconds nextDeletionTime = currentDeletionTime > 0s ? currentDeletionTime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR)));
1815
1816 if (currentDeletionTime == 0s)
1817 {
1818 sWorldState->setWorldState(WORLD_STATE_CUSTOM_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME, nextDeletionTime.count());
1819 }
1820}

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
1779{
1782
1783 if (wstime == 0s)
1784 {
1786 }
1787}
@ 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
1823{
1825 _nextGuildReset = wstime > 0s ? wstime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, 6));
1826
1827 if (wstime == 0s)
1828 {
1830 }
1831}
@ 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
1790{
1793
1794 if (wstime == 0s)
1795 {
1797 }
1798}
@ 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
1801{
1804
1805 if (wstime == 0s)
1806 {
1808 }
1809}
@ CONFIG_RANDOM_BG_RESET_HOUR
Definition WorldConfig.h:317
@ WORLD_STATE_CUSTOM_BG_DAILY_RESET_TIME
Definition WorldStateDefines.h:608

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

Referenced by SetInitialWorldSettings().

◆ InitWeeklyQuestResetTime()

void World::InitWeeklyQuestResetTime ( )
protected
1768{
1771
1772 if (wstime == 0s)
1773 {
1775 }
1776}
@ 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.

157{
158 return _isClosed;
159}

References _isClosed.

◆ IsFFAPvPRealm()

bool World::IsFFAPvPRealm ( ) const
overridevirtual

Implements IWorld.

1998{
2000}
@ REALM_TYPE_FFA_PVP
Definition Realm.h:62
@ CONFIG_GAME_TYPE
Definition WorldConfig.h:176

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.

1993{
1995}
@ 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.

189{ 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 from the config file
  • Read the "Data" directory from the config file

Implements IWorld.

171{
172 if (reload)
173 {
174 if (!sConfigMgr->Reload())
175 {
176 LOG_ERROR("server.loading", "World settings reload fail: can't read settings.");
177 return;
178 }
179
180 sLog->LoadFromConfig();
181 sMetric->LoadFromConfigs();
182 }
183
184 // Set realm id and enable db logging
185 sLog->SetRealmId(realm.Id.Realm);
186
187 sScriptMgr->OnBeforeConfigLoad(reload);
188
189 // load update time related configs
191
193 sWorldSessionMgr->SetPlayerAmountLimit(sConfigMgr->GetOption<int32>("PlayerLimit", 1000));
194
195 _worldConfig.Initialize(reload);
196
198
199 if (reload)
200 {
201 sMapMgr->SetMapUpdateInterval(getIntConfig(CONFIG_INTERVAL_MAPUPDATE));
202
205
208
211 }
212
214 {
216 LOG_INFO("server.loading", "Client cache version set to: {}", _dbClientCacheVersion);
217 }
218
219 //visibility on continents
220 _maxVisibleDistanceOnContinents = sConfigMgr->GetOption<float>("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE);
222 {
223 LOG_ERROR("server.loading", "Visibility.Distance.Continents can't be less max aggro radius {}", 45 * getRate(RATE_CREATURE_AGGRO));
225 }
227 {
228 LOG_ERROR("server.loading", "Visibility.Distance.Continents can't be greater {}", MAX_VISIBILITY_DISTANCE);
230 }
231
232 //visibility in instances
233 _maxVisibleDistanceInInstances = sConfigMgr->GetOption<float>("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE);
235 {
236 LOG_ERROR("server.loading", "Visibility.Distance.Instances can't be less max aggro radius {}", 45 * getRate(RATE_CREATURE_AGGRO));
238 }
240 {
241 LOG_ERROR("server.loading", "Visibility.Distance.Instances can't be greater {}", MAX_VISIBILITY_DISTANCE);
243 }
244
245 //visibility in BG/Arenas
246 _maxVisibleDistanceInBGArenas = sConfigMgr->GetOption<float>("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS);
248 {
249 LOG_ERROR("server.loading", "Visibility.Distance.BGArenas can't be less max aggro radius {}", 45 * getRate(RATE_CREATURE_AGGRO));
251 }
253 {
254 LOG_ERROR("server.loading", "Visibility.Distance.BGArenas can't be greater {}", MAX_VISIBILITY_DISTANCE);
256 }
257
258 LOG_INFO("server.loading", "Will clear `logs` table of entries older than {} seconds every {} minutes.",
260
262 std::string dataPath = sConfigMgr->GetOption<std::string>("DataDir", "./");
263 if (dataPath.empty() || (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\'))
264 dataPath.push_back('/');
265
266#if AC_PLATFORM == AC_PLATFORM_UNIX || AC_PLATFORM == AC_PLATFORM_APPLE
267 if (dataPath[0] == '~')
268 {
269 char const* home = getenv("HOME");
270 if (home)
271 dataPath.replace(0, 1, home);
272 }
273#endif
274
275 if (reload)
276 {
277 if (dataPath != _dataPath)
278 LOG_ERROR("server.loading", "DataDir option can't be changed at worldserver.conf reload, using current value ({}).", _dataPath);
279 }
280 else
281 {
282 _dataPath = dataPath;
283 LOG_INFO("server.loading", "Using DataDir {}", _dataPath);
284 }
285
286 bool const enableIndoor = getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
287 bool const enableLOS = getBoolConfig(CONFIG_VMAP_ENABLE_LOS);
288 bool const enablePetLOS = getBoolConfig(CONFIG_PET_LOS);
289 bool const enableHeight = getBoolConfig(CONFIG_VMAP_ENABLE_HEIGHT);
290 if (!enableHeight)
291 LOG_ERROR("server.loading", "VMap height checking disabled! Creatures movements and other various things WILL be broken! Expect no support.");
292
295 LOG_INFO("server.loading", "WORLD: VMap support included. LineOfSight:{}, getHeight:{}, indoorCheck:{} PetLOS:{}", enableLOS, enableHeight, enableIndoor, enablePetLOS);
296
297 // call ScriptMgr if we're reloading the configuration
298 sScriptMgr->OnAfterConfigLoad(reload);
299}
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:767
void ApplyMoveSpeedRates(float npcRate, float playerRate)
Definition Unit.cpp:97
WorldUpdateTime sWorldUpdateTime
Definition UpdateTime.cpp:27
@ CONFIG_VMAP_ENABLE_LOS
Definition WorldConfig.h:82
@ CONFIG_CLIENTCACHE_VERSION
Definition WorldConfig.h:313
@ RATE_CREATURE_AGGRO
Definition WorldConfig.h:477
@ CONFIG_VMAP_ENABLE_HEIGHT
Definition WorldConfig.h:83
@ CONFIG_LOGDB_CLEARTIME
Definition WorldConfig.h:311
@ CONFIG_AUTOBROADCAST_INTERVAL
Definition WorldConfig.h:324
@ RATE_MOVESPEED_PLAYER
Definition WorldConfig.h:500
@ RATE_MOVESPEED_NPC
Definition WorldConfig.h:501
@ CONFIG_VMAP_INDOOR_CHECK
Definition WorldConfig.h:81
@ CONFIG_LOGDB_CLEARINTERVAL
Definition WorldConfig.h:310
@ CONFIG_UPTIME_UPDATE
Definition WorldConfig.h:222
@ CONFIG_INTERVAL_MAPUPDATE
Definition WorldConfig.h:170
@ CONFIG_PET_LOS
Definition WorldConfig.h:84
void Initialize(bool reload)
Definition ConfigValueCache.h:45
void OverwriteConfigValue(ConfigEnum const config, T const &value)
Definition ConfigValueCache.h:86
void setEnableHeightCalc(bool pVal)
Definition IVMapMgr.h:109
void setEnableLineOfSightCalc(bool pVal)
Definition IVMapMgr.h:104
static VMapMgr2 * createOrGetVMapMgr()
Definition VMapFactory.cpp:27
void LoadFromConfig()
Definition UpdateTime.cpp:152
bool getBoolConfig(ServerConfigs index) const override
Definition World.cpp:1402
float getRate(ServerConfigs index) const override
Definition World.cpp:1392
@ WUPDATE_CLEANDB
Definition World.h:63
@ WUPDATE_AUTOBROADCAST
Definition World.h:64
@ WUPDATE_UPTIME
Definition World.h:61

References _dataPath, _dbClientCacheVersion, _maxVisibleDistanceInBGArenas, _maxVisibleDistanceInInstances, _maxVisibleDistanceOnContinents, _timers, _worldConfig, ApplyMoveSpeedRates(), CONFIG_AUTOBROADCAST_INTERVAL, CONFIG_CLIENTCACHE_VERSION, CONFIG_INTERVAL_MAPUPDATE, CONFIG_LOGDB_CLEARINTERVAL, CONFIG_LOGDB_CLEARTIME, CONFIG_PET_LOS, CONFIG_UPTIME_UPDATE, CONFIG_VMAP_ENABLE_HEIGHT, CONFIG_VMAP_ENABLE_LOS, 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(), WorldUpdateTime::LoadFromConfig(), LOG_ERROR, LOG_INFO, MAX_VISIBILITY_DISTANCE, MINUTE, ConfigValueCache< ConfigEnum >::OverwriteConfigValue(), 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.

1851{
1853 stmt->SetData(0, int32(realm.Id.Realm));
1854 PreparedQueryResult result = LoginDatabase.Query(stmt);
1855
1856 if (result)
1857 SetPlayerSecurityLimit(AccountTypes(result->Fetch()->Get<uint8>()));
1858}
AccountTypes
Definition Common.h:56
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
@ LOGIN_SEL_REALMLIST_SECURITY_LEVEL
Definition LoginDatabase.h:101
void SetPlayerSecurityLimit(AccountTypes sec) override
Definition World.cpp:1860

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.

1960{
1961 QueryResult result = WorldDatabase.Query("SELECT db_version, cache_id FROM version LIMIT 1");
1962 if (result)
1963 {
1964 Field* fields = result->Fetch();
1965
1966 _dbVersion = fields[0].Get<std::string>();
1967
1968 // will be overwrite by config values if different and non-0
1969 _dbClientCacheVersion = fields[1].Get<uint32>();
1970 }
1971
1972 if (_dbVersion.empty())
1973 _dbVersion = "Unknown world database.";
1974}
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:113

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

◆ LoadPreviousSessionInfo()

void World::LoadPreviousSessionInfo ( )
protected
1691{
1693 stmt->SetData(0, realm.Id.Realm);
1694 PreparedQueryResult result = LoginDatabase.Query(stmt);
1695 if (!result)
1696 return;
1697
1698 Field* fields = result->Fetch();
1699 PreviousSessionInfo& previous = _previousSession.emplace();
1700 previous.StartTime = Seconds(fields[0].Get<uint32>());
1701 previous.Uptime = Seconds(fields[1].Get<uint32>());
1702 previous.Crashed = fields[2].IsNull();
1703 previous.Type = SessionShutdownType(fields[3].Get<uint8>());
1704 previous.Reason = fields[4].Get<std::string>();
1705
1706 if (previous.Crashed)
1707 LOG_WARN("server.loading", "Previous session did not shut down cleanly. Last online {}.",
1708 Acore::Time::TimeToTimestampStr(previous.StartTime + previous.Uptime));
1709
1710 stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_UPTIME_MAXPLAYERS);
1711 stmt->SetData(0, realm.Id.Realm);
1712 if (PreparedQueryResult maxResult = LoginDatabase.Query(stmt))
1713 _lifetimeMaxPlayerCount = (*maxResult)[0].Get<uint16>();
1714}
SessionShutdownType
Definition IWorld.h:65
#define LOG_WARN(filterType__,...)
Definition Log.h:149
@ LOGIN_SEL_UPTIME_MAXPLAYERS
Definition LoginDatabase.h:140
@ LOGIN_SEL_UPTIME_PREVIOUS
Definition LoginDatabase.h:139
bool IsNull() const
Definition Field.h:107
AC_COMMON_API std::string TimeToTimestampStr(Seconds time=0s, std::string_view fmt={})
Definition Timer.cpp:272
Definition IWorld.h:73
SessionShutdownType Type
Definition IWorld.h:77
bool Crashed
Definition IWorld.h:76
std::string Reason
Definition IWorld.h:78
Seconds StartTime
Definition IWorld.h:74
Seconds Uptime
Definition IWorld.h:75

References _lifetimeMaxPlayerCount, _previousSession, PreviousSessionInfo::Crashed, Field::Get(), Realm::Id, Field::IsNull(), LOG_WARN, LOGIN_SEL_UPTIME_MAXPLAYERS, LOGIN_SEL_UPTIME_PREVIOUS, LoginDatabase, realm, RealmHandle::Realm, PreviousSessionInfo::Reason, PreparedStatementBase::SetData(), PreviousSessionInfo::StartTime, Acore::Time::TimeToTimestampStr(), PreviousSessionInfo::Type, and PreviousSessionInfo::Uptime.

Referenced by SetInitialWorldSettings().

◆ ProcessCliCommands()

void World::ProcessCliCommands ( )
overridevirtual

Implements IWorld.

1723{
1724 CliCommandHolder::Print zprint = nullptr;
1725 void* callbackArg = nullptr;
1726 CliCommandHolder* command = nullptr;
1727 while (_cliCmdQueue.next(command))
1728 {
1729 LOG_DEBUG("server.worldserver", "CLI command under processing...");
1730 zprint = command->m_print;
1731 callbackArg = command->m_callbackArg;
1732 CliHandler handler(callbackArg, zprint);
1733 handler.ParseCommands(command->m_command);
1734 if (command->m_commandFinished)
1735 command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage());
1736 delete command;
1737 }
1738}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
Definition Chat.h:256
CommandFinished m_commandFinished
Definition IWorld.h:43
void * m_callbackArg
Definition IWorld.h:40
Print m_print
Definition IWorld.h:42
void(*)(void *, std::string_view) Print
Definition IWorld.h:37
char * m_command
Definition IWorld.h:41

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
1988{
1990}
void ProcessReadyCallbacks()
Definition AsyncCallbackProcessor.h:40
QueryCallbackProcessor _queryProcessor
Definition World.h:326

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

Referenced by Update().

◆ QueueCliCommand()

void World::QueueCliCommand ( CliCommandHolder *  commandHolder)
inlineoverridevirtual

Implements IWorld.

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

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

◆ ReloadRBAC()

void World::ReloadRBAC ( )
overridevirtual

Implements IWorld.

1915{
1916 // Passive reload, we mark the data as invalidated and next time a permission is checked it will be reloaded
1917 LOG_INFO("rbac", "World::ReloadRBAC()");
1918 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1919 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1920 if (WorldSession* session = itr->second)
1921 session->InvalidateRBACData();
1922}
std::unordered_map< uint32, WorldSession * > SessionMap
Definition WorldSessionMgr.h:64
Player session in the World.
Definition WorldSession.h:430

References LOG_INFO, and sWorldSessionMgr.

◆ RescheduleShutdownForWintergrasp()

bool World::RescheduleShutdownForWintergrasp ( )
protected

Defer a pending shutdown/restart if a Wintergrasp battle is currently running. Returns true when the shutdown timer was extended (world should keep running).

1528{
1530 if (!bufferMinutes)
1531 return false;
1532
1533 // Idle shutdowns wait for an empty server anyway; don't interfere with them
1535 return false;
1536
1537 Battlefield* wg = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
1538 if (!wg || !wg->IsEnabled() || !wg->IsWarTime())
1539 return false;
1540
1541 // GetTimer() is the battle time remaining in milliseconds
1542 _shutdownTimer = wg->GetTimer() / IN_MILLISECONDS + bufferMinutes * MINUTE;
1543
1544 LOG_INFO("server.worldserver", "Server {} deferred: Wintergrasp battle in progress, rescheduled in {}",
1546
1547 sWorldSessionMgr->DoForAllOnlinePlayers([](Player* player)
1548 {
1549 LocaleConstant locale = player->GetSession()->GetSessionDbLocaleIndex();
1550 sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, sObjectMgr->GetAcoreString(LANG_WG_SHUTDOWN_DEFERRED, locale), player);
1551 });
1552
1553 ShutdownMsg(true);
1554 return true;
1555}
#define sBattlefieldMgr
Definition BattlefieldMgr.h:79
@ BATTLEFIELD_BATTLEID_WG
Definition Battlefield.h:36
@ SERVER_MSG_STRING
Definition IWorld.h:58
@ LANG_WG_SHUTDOWN_DEFERRED
Definition Language.h:1542
#define sObjectMgr
Definition ObjectMgr.h:1731
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition Util.cpp:73
@ CONFIG_WINTERGRASP_DEFER_SHUTDOWN
Definition WorldConfig.h:342
Definition Battlefield.h:196
bool IsWarTime() const
Return true if battle is started, false if battle is not started.
Definition Battlefield.h:239
uint32 GetTimer() const
Definition Battlefield.h:348
bool IsEnabled() const
Return if battlefield is enabled.
Definition Battlefield.h:244
Definition Player.h:1086
WorldSession * GetSession() const
Definition Player.h:2032
@ SHUTDOWN_MASK_RESTART
Definition World.h:47

References _shutdownMask, _shutdownTimer, BATTLEFIELD_BATTLEID_WG, CONFIG_WINTERGRASP_DEFER_SHUTDOWN, getIntConfig(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), Battlefield::GetTimer(), IN_MILLISECONDS, Battlefield::IsEnabled(), Battlefield::IsWarTime(), LANG_WG_SHUTDOWN_DEFERRED, LOG_INFO, MINUTE, sBattlefieldMgr, secsToTimeString(), SERVER_MSG_STRING, SHUTDOWN_MASK_IDLE, SHUTDOWN_MASK_RESTART, ShutdownMsg(), sObjectMgr, and sWorldSessionMgr.

Referenced by _UpdateGameTime().

◆ ResetDailyQuests()

void World::ResetDailyQuests ( )
protected
1834{
1836 CharacterDatabase.Execute(stmt);
1837
1838 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1839 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1840 if (itr->second->GetPlayer())
1841 itr->second->GetPlayer()->ResetDailyQuestStatus();
1842
1845
1846 // change available dailies
1847 sPoolMgr->ChangeDailyQuests();
1848}
@ 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:216

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.

1903{
1905 stmt->SetData(0, event_id);
1906 CharacterDatabase.Execute(stmt);
1907
1908 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1909 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1910 if (itr->second->GetPlayer())
1911 itr->second->GetPlayer()->ResetSeasonalQuestStatus(event_id);
1912}
@ 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
1950{
1951 LOG_INFO("server.worldserver", "Guild Daily Cap reset.");
1952
1955
1956 sGuildMgr->ResetTimes();
1957}
#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
1887{
1888 LOG_INFO("server.worldserver", "Monthly quests reset for all characters.");
1889
1891 CharacterDatabase.Execute(stmt);
1892
1893 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1894 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1895 if (itr->second->GetPlayer())
1896 itr->second->GetPlayer()->ResetMonthlyQuestStatus();
1897
1900}
@ 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
1925{
1926 LOG_DEBUG("server.worldserver", "Random BG status reset for all characters.");
1927
1929 CharacterDatabase.Execute(stmt);
1930
1931 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1932 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1933 if (itr->second->GetPlayer())
1934 itr->second->GetPlayer()->SetRandomWinner(false);
1935
1938}
@ CHAR_DEL_BATTLEGROUND_RANDOM
Definition CharacterDatabase.h:63

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

Referenced by Update().

◆ ResetWeeklyQuests()

void World::ResetWeeklyQuests ( )
protected
1870{
1872 CharacterDatabase.Execute(stmt);
1873
1874 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1875 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1876 if (itr->second->GetPlayer())
1877 itr->second->GetPlayer()->ResetWeeklyQuestStatus();
1878
1881
1882 // change available weeklies
1883 sPoolMgr->ChangeWeeklyQuests();
1884}
@ 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().

◆ SaveSessionEnd()

void World::SaveSessionEnd ( bool  finished)
overridevirtual

Records how this session ended in uptime; finished marks the shutdown as complete (not a crash)

Implements IWorld.

1650{
1651 // Fixed by the first call: main() has picked its exit code by the final call, and a later StopNow
1652 // (e.g. the CLI thread failing its read during teardown) no longer reflects how the session ended
1653 if (!_sessionOutcome)
1654 {
1655 SessionOutcome& outcome = _sessionOutcome.emplace();
1656 outcome.ExitCode = _exitCode;
1657
1658 bool restartScheduled = false;
1659 if (!_stoppedByStopNow)
1660 {
1661 restartScheduled = (_shutdownMask & SHUTDOWN_MASK_RESTART) != 0;
1662 outcome.Reason = _shutdownReason;
1663 }
1664
1665 outcome.Type = SHUTDOWN_TYPE_SHUTDOWN;
1666 if (outcome.ExitCode == ERROR_EXIT_CODE)
1667 outcome.Type = SHUTDOWN_TYPE_ERROR;
1668 else if (outcome.ExitCode == RESTART_EXIT_CODE || restartScheduled)
1669 outcome.Type = SHUTDOWN_TYPE_RESTART;
1670
1671 // Column limit; strict SQL mode rejects the whole UPDATE on overflow
1672 utf8truncate(outcome.Reason, 255);
1673 }
1674
1676 stmt->SetData(0, uint32(GameTime::GetUptime().count()));
1677 stmt->SetData(1, uint16(sWorldSessionMgr->GetMaxPlayerCount()));
1678 if (finished)
1679 stmt->SetData(2, uint32(std::time(nullptr)));
1680 else
1681 stmt->SetData(2);
1682 stmt->SetData(3, uint8(_sessionOutcome->Type));
1683 stmt->SetData(4, _sessionOutcome->ExitCode);
1684 stmt->SetData(5, _sessionOutcome->Reason);
1685 stmt->SetData(6, realm.Id.Realm);
1686 stmt->SetData(7, uint32(GameTime::GetStartTime().count()));
1687 LoginDatabase.DirectExecute(stmt);
1688}
@ SHUTDOWN_TYPE_ERROR
Definition IWorld.h:69
@ SHUTDOWN_TYPE_RESTART
Definition IWorld.h:68
@ SHUTDOWN_TYPE_SHUTDOWN
Definition IWorld.h:67
@ LOGIN_UPD_UPTIME_SHUTDOWN
Definition LoginDatabase.h:138
void utf8truncate(std::string &utf8str, std::size_t len)
Definition Util.cpp:258
std::string _shutdownReason
Definition World.h:283
Optional< SessionOutcome > _sessionOutcome
Definition World.h:287
static std::atomic< bool > _stoppedByStopNow
Definition World.h:280
@ RESTART_EXIT_CODE
Definition World.h:55
@ ERROR_EXIT_CODE
Definition World.h:54
Seconds GetStartTime()
Definition GameTime.cpp:34
Seconds GetUptime()
Time since server start, unaffected by wall clock changes.
Definition GameTime.cpp:59
Definition World.h:134
std::string Reason
Definition World.h:137
uint8 ExitCode
Definition World.h:136
SessionShutdownType Type
Definition World.h:135

References _exitCode, _sessionOutcome, _shutdownMask, _shutdownReason, _stoppedByStopNow, ERROR_EXIT_CODE, SessionOutcome::ExitCode, GameTime::GetStartTime(), GameTime::GetUptime(), Realm::Id, LOGIN_UPD_UPTIME_SHUTDOWN, LoginDatabase, realm, RealmHandle::Realm, SessionOutcome::Reason, RESTART_EXIT_CODE, PreparedStatementBase::SetData(), SHUTDOWN_MASK_RESTART, SHUTDOWN_TYPE_ERROR, SHUTDOWN_TYPE_RESTART, SHUTDOWN_TYPE_SHUTDOWN, sWorldSessionMgr, SessionOutcome::Type, and utf8truncate().

◆ SetAllowMovement()

void World::SetAllowMovement ( bool  allow)
inlineoverridevirtual

Allow/Disallow object movements.

Implements IWorld.

166{ _allowMovement = allow; }

References _allowMovement.

◆ setBoolConfig()

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

Implements IWorld.

1398{
1399 _worldConfig.OverwriteConfigValue<bool>(index, value);
1400}

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

◆ SetCleaningFlags()

void World::SetCleaningFlags ( uint32  flags)
inlineoverridevirtual

Implements IWorld.

248{ _cleaningFlags = flags; }

References _cleaningFlags.

◆ SetClosed()

void World::SetClosed ( bool  val)
overridevirtual

Close world.

Implements IWorld.

162{
163 _isClosed = val;
164
165 // Invert the value, for simplicity for scripters.
166 sScriptMgr->OnOpenStateChange(!val);
167}

References _isClosed, and sScriptMgr.

◆ setFloatConfig()

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

Implements IWorld.

1408{
1409 _worldConfig.OverwriteConfigValue<float>(index, value);
1410}

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.

303{
305 uint32 startupBegin = getMSTime();
306
308 srand((unsigned int)GameTime::GetGameTime().count());
309
311 dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
312
317
320
323
325 sObjectMgr->SetHighestGuids();
326
327 if (!sConfigMgr->isDryRun())
328 {
330 if (!MapMgr::ExistMapAndVMap(MAP_EASTERN_KINGDOMS, -6240.32f, 331.033f)
331 || !MapMgr::ExistMapAndVMap(MAP_EASTERN_KINGDOMS, -8949.95f, -132.493f)
332 || !MapMgr::ExistMapAndVMap(MAP_KALIMDOR, -618.518f, -4251.67f)
333 || !MapMgr::ExistMapAndVMap(MAP_EASTERN_KINGDOMS, 1676.35f, 1677.45f)
334 || !MapMgr::ExistMapAndVMap(MAP_KALIMDOR, 10311.3f, 832.463f)
335 || !MapMgr::ExistMapAndVMap(MAP_KALIMDOR, -2917.58f, -257.98f)
337 !MapMgr::ExistMapAndVMap(MAP_OUTLAND, 10349.6f, -6357.29f) ||
338 !MapMgr::ExistMapAndVMap(MAP_OUTLAND, -3961.64f, -13931.2f))))
339 {
340 LOG_ERROR("server.loading", "Failed to find map files for starting areas");
341 exit(1);
342 }
343 }
344
346 sPoolMgr->Initialize();
347
349 sGameEventMgr->Initialize();
350
352 LOG_INFO("server.loading", " ");
353 LOG_INFO("server.loading", "Loading Acore Strings...");
354 if (!sObjectMgr->LoadAcoreStrings())
355 exit(1); // Error message displayed in function already
356
357 LOG_INFO("server.loading", "Loading Module Strings...");
358 sObjectMgr->LoadModuleStrings();
359 LOG_INFO("server.loading", "Loading Module Strings Locale...");
360 sObjectMgr->LoadModuleStringsLocale();
361
363 //No SQL injection as values are treated as integers
364
365 // not send custom type REALM_FFA_PVP to realm list
366 uint32 server_type;
367 if (IsFFAPvPRealm())
368 server_type = REALM_TYPE_PVP;
369 else
370 server_type = getIntConfig(CONFIG_GAME_TYPE);
371
373
374 LoginDatabase.Execute("UPDATE realmlist SET icon = {}, timezone = {} WHERE id = '{}'", server_type, realm_zone, realm.Id.Realm); // One-time query
375
377 sScriptMgr->OnLoadCustomDatabaseTable();
378
380 LOG_INFO("server.loading", "Initialize Data Stores...");
383
384 // Load cinematic cameras
386
387 LOG_INFO("server.loading", "Loading Player race data...");
388 sRaceMgr->LoadRaces();
389
390 // Load IP Location Database
391 sIPLocation->Load();
392
393 LOG_INFO("server.loading", "Loading Game Graveyard...");
394 sGraveyard->LoadGraveyardFromDB();
395
396 LOG_INFO("server.loading", "Initializing PlayerDump Tables...");
398
401
402 LOG_INFO("server.loading", "Loading SpellInfo Store...");
403 sSpellMgr->LoadSpellInfoStore();
404
405 LOG_INFO("server.loading", "Loading Spell Cooldown Overrides...");
406 sSpellMgr->LoadSpellCooldownOverrides();
407
408 LOG_INFO("server.loading", "Loading SpellInfo Data Corrections...");
409 sSpellMgr->LoadSpellInfoCorrections();
410
411 LOG_INFO("server.loading", "Loading Spell Rank Data...");
412 sSpellMgr->LoadSpellRanks();
413
414 LOG_INFO("server.loading", "Loading Spell Specific And Aura State...");
415 sSpellMgr->LoadSpellSpecificAndAuraState();
416
417 LOG_INFO("server.loading", "Loading SkillLineAbilityMultiMap Data...");
418 sSpellMgr->LoadSkillLineAbilityMap();
419
420 LOG_INFO("server.loading", "Loading SpellInfo Custom Attributes...");
421 sSpellMgr->LoadSpellInfoCustomAttributes();
422
423 LOG_INFO("server.loading", "Loading Spell Jump Distances...");
424 sSpellMgr->LoadSpellJumpDistances();
425
426 LOG_INFO("server.loading", "Loading SpellInfo Immunity infos...");
427 sSpellMgr->LoadSpellInfoImmunities();
428
429 LOG_INFO("server.loading", "Loading Player Totem models...");
430 sObjectMgr->LoadPlayerTotemModels();
431
432 LOG_INFO("server.loading", "Loading Player Shapeshift models...");
433 sObjectMgr->LoadPlayerShapeshiftModels();
434
435 LOG_INFO("server.loading", "Loading GameObject Models...");
437
438 LOG_INFO("server.loading", "Loading Script Names...");
439 sObjectMgr->LoadScriptNames();
440
441 LOG_INFO("server.loading", "Loading Instance Template...");
442 sObjectMgr->LoadInstanceTemplate();
443
444 LOG_INFO("server.loading", "Loading Character Cache...");
445 sCharacterCache->LoadCharacterCacheStorage();
446
447 // Must be called before `creature_respawn`/`gameobject_respawn` tables
448 LOG_INFO("server.loading", "Loading Instances...");
449 sInstanceSaveMgr->LoadInstances();
450
451 LOG_INFO("server.loading", "Loading Broadcast Texts...");
452 sObjectMgr->LoadBroadcastTexts();
453 sObjectMgr->LoadBroadcastTextLocales();
454
455 LOG_INFO("server.loading", "Loading Localization Strings...");
456 uint32 oldMSTime = getMSTime();
457 sObjectMgr->LoadCreatureLocales();
458 sObjectMgr->LoadGameObjectLocales();
459 sObjectMgr->LoadItemLocales();
460 sObjectMgr->LoadItemSetNameLocales();
461 sObjectMgr->LoadQuestLocales();
462 sObjectMgr->LoadQuestOfferRewardLocale();
463 sObjectMgr->LoadQuestRequestItemsLocale();
464 sObjectMgr->LoadNpcTextLocales();
465 sObjectMgr->LoadPageTextLocales();
466 sObjectMgr->LoadGossipMenuItemsLocales();
467 sObjectMgr->LoadPointOfInterestLocales();
468 sObjectMgr->LoadPetNamesLocales();
469
470 sObjectMgr->SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts)
471 LOG_INFO("server.loading", ">> Localization Strings loaded in {} ms", GetMSTimeDiffToNow(oldMSTime));
472 LOG_INFO("server.loading", " ");
473
474 LOG_INFO("server.loading", "Loading Account Roles and Permissions...");
475 sAccountMgr->LoadRBAC();
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 Conditions and Data...");
499 sSpellMgr->LoadSpellProcs();
500
501 LOG_INFO("server.loading", "Loading Spell Bonus Data...");
502 sSpellMgr->LoadSpellBonuses();
503
504 LOG_INFO("server.loading", "Loading Aggro Spells Definitions...");
505 sSpellMgr->LoadSpellThreats();
506
507 LOG_INFO("server.loading", "Loading Mixology Bonuses...");
508 sSpellMgr->LoadSpellMixology();
509
510 LOG_INFO("server.loading", "Loading Spell Group Stack Rules...");
511 sSpellMgr->LoadSpellGroupStackRules();
512
513 LOG_INFO("server.loading", "Loading NPC Texts...");
514 sObjectMgr->LoadGossipText();
515
516 LOG_INFO("server.loading", "Loading Enchant Spells Proc Datas...");
517 sSpellMgr->LoadSpellEnchantProcData();
518
519 LOG_INFO("server.loading", "Loading Item Random Enchantments Table...");
521
522 LOG_INFO("server.loading", "Loading Disables");
523 sDisableMgr->LoadDisables(); // must be before loading quests and items
524
525 LOG_INFO("server.loading", "Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
526 sObjectMgr->LoadItemTemplates();
527
528 LOG_INFO("server.loading", "Loading Item Set Names..."); // must be after LoadItemPrototypes
529 sObjectMgr->LoadItemSetNames();
530
531 LOG_INFO("server.loading", "Loading Creature Model Based Info Data...");
532 sObjectMgr->LoadCreatureModelInfo();
533
534 LOG_INFO("server.loading", "Loading Creature Custom IDs Config...");
535 sObjectMgr->LoadCreatureCustomIDs();
536
537 LOG_INFO("server.loading", "Loading Creature Templates...");
538 sObjectMgr->LoadCreatureTemplates();
539
540 LOG_INFO("server.loading", "Loading Equipment Templates..."); // must be after LoadCreatureTemplates
541 sObjectMgr->LoadEquipmentTemplates();
542
543 LOG_INFO("server.loading", "Loading Creature Template Addons...");
544 sObjectMgr->LoadCreatureTemplateAddons();
545
546 LOG_INFO("server.loading", "Loading Reputation Reward Rates...");
547 sObjectMgr->LoadReputationRewardRate();
548
549 LOG_INFO("server.loading", "Loading Creature Reputation OnKill Data...");
550 sObjectMgr->LoadReputationOnKill();
551
552 LOG_INFO("server.loading", "Loading Reputation Spillover Data..." );
553 sObjectMgr->LoadReputationSpilloverTemplate();
554
555 LOG_INFO("server.loading", "Loading Points Of Interest Data...");
556 sObjectMgr->LoadPointsOfInterest();
557
558 LOG_INFO("server.loading", "Loading Creature Base Stats...");
559 sObjectMgr->LoadCreatureClassLevelStats();
560
561 LOG_INFO("server.loading", "Loading Spawn Group Templates...");
562 sObjectMgr->LoadSpawnGroupTemplates();
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 Gameobject Summon Data...");
574 sObjectMgr->LoadGameObjectSummons(); // must be after LoadCreatureTemplates() and LoadGameObjectTemplates()
575
576 LOG_INFO("server.loading", "Loading Pet Levelup Spells...");
577 sSpellMgr->LoadPetLevelupSpellMap();
578
579 LOG_INFO("server.loading", "Loading Pet default Spells additional to Levelup Spells...");
580 sSpellMgr->LoadPetDefaultSpells();
581
582 LOG_INFO("server.loading", "Loading Creature Addon Data...");
583 sObjectMgr->LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
584
585 LOG_INFO("server.loading", "Loading Creature Movement Overrides...");
586 sObjectMgr->LoadCreatureMovementOverrides(); // must be after LoadCreatures()
587
588 LOG_INFO("server.loading", "Loading Gameobject Data...");
589 sObjectMgr->LoadGameobjects();
590
591 LOG_INFO("server.loading", "Loading Spawn Group Data...");
592 sObjectMgr->LoadSpawnGroups(); // must be after LoadCreatures() and LoadGameobjects()
593
594 LOG_INFO("server.loading", "Loading GameObject Addon Data...");
595 sObjectMgr->LoadGameObjectAddons(); // must be after LoadGameObjectTemplate() and LoadGameobjects()
596
597 LOG_INFO("server.loading", "Loading GameObject Quest Items...");
598 sObjectMgr->LoadGameObjectQuestItems();
599
600 LOG_INFO("server.loading", "Loading Creature Quest Items...");
601 sObjectMgr->LoadCreatureQuestItems();
602
603 LOG_INFO("server.loading", "Loading Creature Linked Respawn...");
604 sObjectMgr->LoadLinkedRespawn(); // must be after LoadCreatures(), LoadGameObjects()
605
606 LOG_INFO("server.loading", "Loading Weather Data...");
608
609 LOG_INFO("server.loading", "Loading Quests...");
610 sObjectMgr->LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables
611
612 LOG_INFO("server.loading", "Checking Quest Disables");
613 sDisableMgr->CheckQuestDisables(); // must be after loading quests
614
615 LOG_INFO("server.loading", "Loading Quest POI");
616 sObjectMgr->LoadQuestPOI();
617
618 LOG_INFO("server.loading", "Loading Quests Starters and Enders...");
619 sObjectMgr->LoadQuestStartersAndEnders(); // must be after quest load
620
621 LOG_INFO("server.loading", "Loading Quest Greetings...");
622 sObjectMgr->LoadQuestGreetings(); // must be loaded after creature_template, gameobject_template tables
623 LOG_INFO("server.loading", "Loading Quest Greeting Locales...");
624 sObjectMgr->LoadQuestGreetingsLocales(); // must be loaded after creature_template, gameobject_template tables, quest_greeting
625
626 LOG_INFO("server.loading", "Loading Quest Money Rewards...");
627 sObjectMgr->LoadQuestMoneyRewards();
628
629 LOG_INFO("server.loading", "Loading Objects Pooling Data...");
630 sPoolMgr->LoadFromDB();
631
632 LOG_INFO("server.loading", "Loading Game Event Data..."); // must be after loading pools fully
633 sGameEventMgr->LoadHolidayDates(); // Must be after loading DBC
634 sGameEventMgr->LoadFromDB(); // Must be after loading holiday dates
635
636 LOG_INFO("server.loading", "Loading UNIT_NPC_FLAG_SPELLCLICK Data..."); // must be after LoadQuests
637 sObjectMgr->LoadNPCSpellClickSpells();
638
639 LOG_INFO("server.loading", "Loading Vehicle Template Accessories...");
640 sObjectMgr->LoadVehicleTemplateAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
641
642 LOG_INFO("server.loading", "Loading Vehicle Accessories...");
643 sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
644
645 LOG_INFO("server.loading", "Loading Vehicle Seat Addon Data...");
646 sObjectMgr->LoadVehicleSeatAddon(); // must be after loading DBC
647
648 LOG_INFO("server.loading", "Loading SpellArea Data..."); // must be after quest load
649 sSpellMgr->LoadSpellAreas();
650
651 LOG_INFO("server.loading", "Loading Area Trigger Definitions");
652 sObjectMgr->LoadAreaTriggers();
653
654 LOG_INFO("server.loading", "Loading Area Trigger Teleport Definitions...");
655 sObjectMgr->LoadAreaTriggerTeleports();
656
657 LOG_INFO("server.loading", "Loading Access Requirements...");
658 sObjectMgr->LoadAccessRequirements(); // must be after item template load
659
660 LOG_INFO("server.loading", "Loading Quest Area Triggers...");
661 sObjectMgr->LoadQuestAreaTriggers(); // must be after LoadQuests
662
663 LOG_INFO("server.loading", "Loading Tavern Area Triggers...");
664 sObjectMgr->LoadTavernAreaTriggers();
665
666 LOG_INFO("server.loading", "Loading AreaTrigger Script Names...");
667 sObjectMgr->LoadAreaTriggerScripts();
668
669 LOG_INFO("server.loading", "Loading LFG Entrance Positions..."); // Must be after areatriggers
670 sLFGMgr->LoadLFGDungeons();
671
672 LOG_INFO("server.loading", "Loading Dungeon Boss Data...");
673 sObjectMgr->LoadInstanceEncounters();
674
675 LOG_INFO("server.loading", "Loading LFG Rewards...");
676 sLFGMgr->LoadRewards();
677
678 LOG_INFO("server.loading", "Loading Graveyard-Zone Links...");
679 sGraveyard->LoadGraveyardZones();
680
681 LOG_INFO("server.loading", "Loading Spell Pet Auras...");
682 sSpellMgr->LoadSpellPetAuras();
683
684 LOG_INFO("server.loading", "Loading Spell Target Coordinates...");
685 sSpellMgr->LoadSpellTargetPositions();
686
687 LOG_INFO("server.loading", "Loading Spell Cone definitions...");
688 sSpellMgr->LoadSpellCones();
689
690 LOG_INFO("server.loading", "Loading Enchant Custom Attributes...");
691 sSpellMgr->LoadEnchantCustomAttr();
692
693 LOG_INFO("server.loading", "Loading linked Spells...");
694 sSpellMgr->LoadSpellLinked();
695
696 LOG_INFO("server.loading", "Loading Player Create Data...");
697 sObjectMgr->LoadPlayerInfo();
698
699 LOG_INFO("server.loading", "Loading Exploration BaseXP Data...");
700 sObjectMgr->LoadExplorationBaseXP();
701
702 LOG_INFO("server.loading", "Loading Pet Name Parts...");
703 sObjectMgr->LoadPetNames();
704
706
707 LOG_INFO("server.loading", "Loading The Max Pet Number...");
708 sObjectMgr->LoadPetNumber();
709
710 LOG_INFO("server.loading", "Loading Pet Level Stats...");
711 sObjectMgr->LoadPetLevelInfo();
712
713 LOG_INFO("server.loading", "Loading Player Level Dependent Mail Rewards...");
714 sObjectMgr->LoadMailLevelRewards();
715
716 LOG_INFO("server.loading", "Load Mail Server definitions...");
717 sServerMailMgr->LoadMailServerTemplates();
718
719 // Loot tables
721
722 LOG_INFO("server.loading", "Loading Skill Discovery Table...");
724
725 LOG_INFO("server.loading", "Loading Skill Extra Item Table...");
727
728 LOG_INFO("server.loading", "Loading Skill Perfection Data Table...");
730
731 LOG_INFO("server.loading", "Loading Skill Fishing Base Level Requirements...");
732 sObjectMgr->LoadFishingBaseSkillLevel();
733
734 LOG_INFO("server.loading", "Loading Achievements...");
735 sAchievementMgr->LoadAchievementReferenceList();
736 LOG_INFO("server.loading", "Loading Achievement Criteria Lists...");
737 sAchievementMgr->LoadAchievementCriteriaList();
738 LOG_INFO("server.loading", "Loading Achievement Criteria Data...");
739 sAchievementMgr->LoadAchievementCriteriaData();
740 LOG_INFO("server.loading", "Loading Achievement Rewards...");
741 sAchievementMgr->LoadRewards();
742 LOG_INFO("server.loading", "Loading Achievement Reward Locales...");
743 sAchievementMgr->LoadRewardLocales();
744 LOG_INFO("server.loading", "Loading Completed Achievements...");
745 sAchievementMgr->LoadCompletedAchievements();
746
748 LOG_INFO("server.loading", "Loading Item Auctions...");
749 sAuctionMgr->LoadAuctionItems();
750 LOG_INFO("server.loading", "Loading Auctions...");
751 sAuctionMgr->LoadAuctions();
752
753 sGuildMgr->LoadGuilds();
754
755 LOG_INFO("server.loading", "Loading ArenaTeams...");
756 sArenaTeamMgr->LoadArenaTeams();
757
758 LOG_INFO("server.loading", "Loading Groups...");
759 sGroupMgr->LoadGroups();
760
761 LOG_INFO("server.loading", "Loading Reserved Names...");
762 sObjectMgr->LoadReservedPlayerNamesDB();
763 sObjectMgr->LoadReservedPlayerNamesDBC(); // Needs to be after LoadReservedPlayerNamesDB()
764
765 LOG_INFO("server.loading", "Loading Profanity Names...");
766 sObjectMgr->LoadProfanityNamesFromDB();
767 sObjectMgr->LoadProfanityNamesFromDBC(); // Needs to be after LoadProfanityNamesFromDB()
768
769 LOG_INFO("server.loading", "Loading Chat Filter...");
770 sObjectMgr->LoadChatFilter();
771
772 LOG_INFO("server.loading", "Loading GameObjects for Quests...");
773 sObjectMgr->LoadGameObjectForQuests();
774
775 LOG_INFO("server.loading", "Loading BattleMasters...");
776 sBattlegroundMgr->LoadBattleMastersEntry();
777
778 LOG_INFO("server.loading", "Loading GameTeleports...");
779 sObjectMgr->LoadGameTele();
780
781 LOG_INFO("server.loading", "Loading Trainers..."); // must be after LoadCreatureTemplates
782 sObjectMgr->LoadTrainers();
783
784 LOG_INFO("server.loading", "Loading Creature default trainers...");
785 sObjectMgr->LoadCreatureDefaultTrainers();
786
787 LOG_INFO("server.loading", "Loading Gossip Menu...");
788 sObjectMgr->LoadGossipMenu();
789
790 LOG_INFO("server.loading", "Loading Gossip Menu Options...");
791 sObjectMgr->LoadGossipMenuItems();
792
793 LOG_INFO("server.loading", "Loading Vendors...");
794 sObjectMgr->LoadVendors(); // must be after load CreatureTemplate and ItemTemplate
795
796 LOG_INFO("server.loading", "Loading Waypoints...");
797 sWaypointMgr->Load();
798
799 LOG_INFO("server.loading", "Loading Waypoint Addons...");
800 sWaypointMgr->LoadWaypointAddons();
801
802 LOG_INFO("server.loading", "Loading SmartAI Waypoints...");
803 sSmartWaypointMgr->LoadFromDB();
804
805 LOG_INFO("server.loading", "Loading Creature Formations...");
806 sFormationMgr->LoadCreatureFormations();
807
808 LOG_INFO("server.loading", "Loading WorldStates..."); // must be loaded before battleground, outdoor PvP and conditions
809 sWorldState->LoadWorldStates();
810
811 LOG_INFO("server.loading", "Loading Conditions...");
812 sConditionMgr->LoadConditions();
813
814 LOG_INFO("server.loading", "Loading Faction Change Achievement Pairs...");
815 sObjectMgr->LoadFactionChangeAchievements();
816
817 LOG_INFO("server.loading", "Loading Faction Change Spell Pairs...");
818 sObjectMgr->LoadFactionChangeSpells();
819
820 LOG_INFO("server.loading", "Loading Faction Change Item Pairs...");
821 sObjectMgr->LoadFactionChangeItems();
822
823 LOG_INFO("server.loading", "Loading Faction Change Reputation Pairs...");
824 sObjectMgr->LoadFactionChangeReputations();
825
826 LOG_INFO("server.loading", "Loading Faction Change Title Pairs...");
827 sObjectMgr->LoadFactionChangeTitles();
828
829 LOG_INFO("server.loading", "Loading Faction Change Quest Pairs...");
830 sObjectMgr->LoadFactionChangeQuests();
831
832 LOG_INFO("server.loading", "Loading GM Tickets...");
833 sTicketMgr->LoadTickets();
834
835 LOG_INFO("server.loading", "Loading GM Surveys...");
836 sTicketMgr->LoadSurveys();
837
838 LOG_INFO("server.loading", "Loading Client Addons...");
840
841 // pussywizard:
842 LOG_INFO("server.loading", "Deleting Invalid Mail Items...");
843 LOG_INFO("server.loading", " ");
844 CharacterDatabase.Execute("DELETE mi FROM mail_items mi LEFT JOIN item_instance ii ON mi.item_guid = ii.guid WHERE ii.guid IS NULL");
845 CharacterDatabase.Execute("DELETE mi FROM mail_items mi LEFT JOIN mail m ON mi.mail_id = m.id WHERE m.id IS NULL");
846 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");
847
849 LOG_INFO("server.loading", "Returning Old Mails...");
850 LOG_INFO("server.loading", " ");
851 sMailMgr->ReturnOrDeleteOldMails(false);
852
854 LOG_INFO("server.loading", "Loading Autobroadcasts...");
855 sAutobroadcastMgr->LoadAutobroadcasts();
856 sAutobroadcastMgr->LoadAutobroadcastsLocalized();
857
859 LOG_INFO("server.loading", "Loading Motd...");
860 sMotdMgr->LoadMotd();
861
863 sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
864 sObjectMgr->LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data)
865 sObjectMgr->LoadWaypointScripts();
866
867 LOG_INFO("server.loading", "Loading Spell Script Names...");
868 sObjectMgr->LoadSpellScriptNames();
869
870 LOG_INFO("server.loading", "Loading Creature Texts...");
871 sCreatureTextMgr->LoadCreatureTexts();
872
873 LOG_INFO("server.loading", "Loading Creature Text Options...");
874 sCreatureTextMgr->LoadCreatureTextOptions();
875
876 LOG_INFO("server.loading", "Loading Creature Text Locales...");
877 sCreatureTextMgr->LoadCreatureTextLocales();
878
879 LOG_INFO("server.loading", "Loading Scripts...");
880 sScriptMgr->LoadDatabase();
881
882 LOG_INFO("server.loading", "Validating Spell Scripts...");
883 sObjectMgr->ValidateSpellScripts();
884
885 LOG_INFO("server.loading", "Loading SmartAI Scripts...");
886 sSmartScriptMgr->LoadSmartAIFromDB();
887
888 LOG_INFO("server.loading", "Loading Calendar Data...");
889 sCalendarMgr->LoadFromDB();
890
891 LOG_INFO("server.loading", "Initializing SpellInfo Precomputed Data..."); // must be called after loading items, professions, spells and pretty much anything
892 LOG_INFO("server.loading", " ");
893 sObjectMgr->InitializeSpellInfoPrecomputedData();
894
895 LOG_INFO("server.loading", "Initialize Commands...");
897
899 LOG_INFO("server.loading", "Initialize Game Time and Timers");
900 LOG_INFO("server.loading", " ");
901
902 // A dry run exits below without unwinding main(), so its row would never be marked as cleanly ended
903 if (!sConfigMgr->isDryRun())
904 {
905 // Must run before this session's row is inserted. Cluster nodes share the realm id, so the newest
906 // row may be another node's live session. The sidecar isn't initialized yet, so read the config.
907 if (!sConfigMgr->GetOption<bool>("Cluster.Enabled", false))
909
911 stmt->SetData(0, realm.Id.Realm);
912 stmt->SetData(1, uint32(GameTime::GetStartTime().count()));
914 // Synchronous so it can't land after the shutdown UPDATEs, which run on the synchronous connection
915 LoginDatabase.DirectExecute(stmt);
916 }
917
919 //Update "uptime" table based on configuration entry in minutes.
920
922 // clean logs table every 14 days by default
924
926
927 // our speed up
929
930 _timers[WUPDATE_WHO_LIST].SetInterval(5 * IN_MILLISECONDS); // update who list cache every 5 seconds
931
933
935 LOG_INFO("server.loading", "Starting Map System");
936 LOG_INFO("server.loading", " ");
937 sMapMgr->Initialize();
938
939 LOG_INFO("server.loading", "Starting Game Event system...");
940 LOG_INFO("server.loading", " ");
941 uint32 nextGameEvent = sGameEventMgr->StartSystem();
942 _timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event
943
944 LOG_INFO("server.loading", "Loading WorldState...");
945 sWorldState->Load(); // must be called after loading game events
946
947 // Delete all characters which have been deleted X days before
949
950 // Delete all items which have been deleted X days before
952
953 // Delete all custom channels which haven't been used for PreserveCustomChannelDuration days.
955
956 LOG_INFO("server.loading", "Initializing Opcodes...");
958
959 LOG_INFO("server.loading", "Loading Arena Season Rewards...");
960 sArenaSeasonMgr->LoadRewards();
961 LOG_INFO("server.loading", "Loading Active Arena Season...");
962 sArenaSeasonMgr->LoadActiveSeason();
963
964 sTicketMgr->Initialize();
965
967 LOG_INFO("server.loading", "Starting Battleground System");
968 sBattlegroundMgr->LoadBattlegroundTemplates();
969 sBattlegroundMgr->InitAutomaticArenaPointDistribution();
970
972 LOG_INFO("server.loading", "Starting Outdoor PvP System");
973 sOutdoorPvPMgr->InitOutdoorPvP();
974
976 LOG_INFO("server.loading", "Starting Battlefield System");
977 sBattlefieldMgr->InitBattlefield();
978
979 LOG_INFO("server.loading", "Loading Transports...");
980 sTransportMgr->SpawnContinentTransports();
981
983 LOG_INFO("server.loading", "Loading Warden Checks..." );
984 sWardenCheckMgr->LoadWardenChecks();
985
986 LOG_INFO("server.loading", "Loading Warden Action Overrides..." );
987 sWardenCheckMgr->LoadWardenOverrides();
988
989 LOG_INFO("server.loading", "Deleting Expired Bans...");
990 LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate"); // One-time query
991
992 LOG_INFO("server.loading", "Calculate Next Daily Quest Reset Time...");
994
995 LOG_INFO("server.loading", "Calculate Next Weekly Quest Reset Time..." );
997
998 LOG_INFO("server.loading", "Calculate Next Monthly Quest Reset Time...");
1000
1001 LOG_INFO("server.loading", "Calculate Random Battleground Reset Time..." );
1003
1004 LOG_INFO("server.loading", "Calculate Deletion Of Old Calendar Events Time...");
1006
1007 LOG_INFO("server.loading", "Calculate Guild Cap Reset Time...");
1008 LOG_INFO("server.loading", " ");
1010
1011 LOG_INFO("server.loading", "Load Petitions...");
1012 sPetitionMgr->LoadPetitions();
1013
1014 LOG_INFO("server.loading", "Load Petition Signs...");
1015 sPetitionMgr->LoadSignatures();
1016
1017 LOG_INFO("server.loading", "Load Stored Loot Items...");
1018 sLootItemStorage->LoadStorageFromDB();
1019
1020 LOG_INFO("server.loading", "Load Channel Rights...");
1022
1023 LOG_INFO("server.loading", "Load Channels...");
1025
1026 LOG_INFO("server.loading", "Loading AntiDos opcode policies");
1027 sWorldGlobals->LoadAntiDosOpcodePolicies();
1028
1029 sScriptMgr->OnBeforeWorldInitialized();
1030
1032 {
1033 LOG_INFO("server.loading", "Loading All Grids For All Non-Instanced Maps...");
1034
1035 for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
1036 {
1037 MapEntry const* mapEntry = sMapStore.LookupEntry(i);
1038
1039 if (mapEntry && !mapEntry->Instanceable())
1040 {
1041 if (sMapMgr->GetMapUpdater()->activated())
1042 sMapMgr->GetMapUpdater()->schedule_map_preload(mapEntry->MapID);
1043 else
1044 {
1045 Map* map = sMapMgr->CreateBaseMap(mapEntry->MapID);
1046
1047 if (map)
1048 {
1049 LOG_INFO("server.loading", ">> Loading All Grids For Map {}", map->GetId());
1050 map->LoadAllGrids();
1051 }
1052 }
1053 }
1054 }
1055
1056 if (sMapMgr->GetMapUpdater()->activated())
1057 sMapMgr->GetMapUpdater()->wait();
1058 }
1059
1060 uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
1061
1062 LOG_INFO("server.loading", " ");
1063 LOG_INFO("server.loading", "WORLD: World Initialized In {} Minutes {} Seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000)); // outError for red color in console
1064 LOG_INFO("server.loading", " ");
1065
1066 METRIC_EVENT("events", "World initialized", "World Initialized In " + std::to_string(startupDuration / 60000) + " Minutes " + std::to_string((startupDuration % 60000) / 1000) + " Seconds");
1067
1068 if (sConfigMgr->isDryRun())
1069 {
1070 // exit() below skips the ordered teardown in main() (mapManagementHandle):
1071 // OutdoorPvP holds raw Map pointers and must go before the maps
1072 sBattlegroundMgr->DeleteAllBattlegrounds();
1073 sOutdoorPvPMgr->Die();
1074 sMapMgr->UnloadAll();
1075 sScriptMgr->OnAfterUnloadAllMaps();
1076
1078 {
1079 LOG_FATAL("server.loading", "AzerothCore Dry Run Completed With {} Failed Database Update(s), Terminating.", failed);
1080 exit(1);
1081 }
1082
1083 LOG_INFO("server.loading", "AzerothCore Dry Run Completed, Terminating.");
1084 exit(0);
1085 }
1086}
#define sAccountMgr
Definition AccountMgr.h:93
#define sAchievementMgr
Definition AchievementMgr.h:451
@ MAP_OUTLAND
Definition AreaDefines.h:219
@ MAP_KALIMDOR
Definition AreaDefines.h:189
@ MAP_EASTERN_KINGDOMS
Definition AreaDefines.h:188
#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 sBattlegroundMgr
Definition BattlegroundMgr.h:190
#define sCharacterCache
Definition CharacterCache.h:88
#define sConditionMgr
Definition ConditionMgr.h:296
#define sFormationMgr
Definition CreatureGroups.h:136
#define sCreatureTextMgr
Definition CreatureTextMgr.h:123
uint32 GetLiquidFlags(uint32 liquidType)
Definition DBCStores.cpp:851
void LoadDBCStores(std::string const &dataPath)
Definition DBCStores.cpp:267
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sDisableMgr
Definition DisableMgr.h:88
#define sGraveyard
Definition GameGraveyard.h:76
void LoadGameObjectModelList(std::string const &dataPath)
Definition GameObjectModel.cpp:46
#define sGroupMgr
Definition GroupMgr.h:51
#define sIPLocation
Definition IPLocation.h:49
#define sInstanceSaveMgr
Definition InstanceSaveMgr.h:233
void LoadRandomEnchantmentsTable()
Definition ItemEnchantmentMgr.cpp:47
#define sLFGMgr
Definition LFGMgr.h:665
#define LOG_FATAL(filterType__,...)
Definition Log.h:141
@ LOGIN_INS_UPTIME
Definition LoginDatabase.h:137
#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:33
void * dtCustomAlloc(std::size_t size, dtAllocHint)
Definition MMapMgr.h:28
#define sMailMgr
Definition MailMgr.h:85
#define METRIC_EVENT(category, title, description)
Definition Metric.h:189
#define sMotdMgr
Definition MotdMgr.h:52
#define sOutdoorPvPMgr
Definition OutdoorPvPMgr.h:102
#define sPetitionMgr
Definition PetitionMgr.h:104
#define sRaceMgr
Definition RaceMgr.h:52
#define sServerMailMgr
Definition ServerMailMgr.h:233
void LoadSkillDiscoveryTable()
Definition SkillDiscovery.cpp:46
void LoadSkillPerfectItemTable()
Definition SkillExtraItems.cpp:52
void LoadSkillExtraItemTable()
Definition SkillExtraItems.cpp:138
#define sSmartWaypointMgr
Definition SmartScriptMgr.h:2282
#define sSmartScriptMgr
Definition SmartScriptMgr.h:2281
#define sSpellMgr
Definition SpellMgr.h:847
#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:165
#define sWardenCheckMgr
Definition WardenCheckMgr.h:89
#define sWaypointMgr
Definition WaypointMgr.h:54
@ CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS
Definition WorldConfig.h:119
@ CONFIG_REALM_ZONE
Definition WorldConfig.h:177
@ CONFIG_EXPANSION
Definition WorldConfig.h:234
@ CONFIG_DB_PING_INTERVAL
Definition WorldConfig.h:327
#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:141
static uint32 GetFailedUpdateCount()
Definition DBUpdater.cpp:86
static bool IsVMAPDisabledFor(uint32 entry, uint8 flags)
Definition DisableMgr.cpp:440
static bool ExistMapAndVMap(uint32 mapid, float x, float y)
Definition MapMgr.cpp:306
Definition Map.h:168
void LoadAllGrids()
Definition Map.cpp:221
uint32 GetId() const
Definition Map.h:234
static void InitializeTables()
Definition PlayerDump.cpp:253
static void DeleteOldCharacters()
Definition Player.cpp:4438
static void DeleteOldRecoveryItems()
Definition Player.cpp:4473
Definition VMapMgr2.h:55
IsVMAPDisabledForFn IsVMAPDisabledForPtr
Definition VMapMgr2.h:81
GetLiquidFlagsFn GetLiquidFlagsPtr
Definition VMapMgr2.h:78
bool IsFFAPvPRealm() const override
Definition World.cpp:1997
void LoadConfigSettings(bool reload=false) override
Initialize config values.
Definition World.cpp:170
void InitCalendarOldEventsDeletionTime()
Definition World.cpp:1811
void InitDailyQuestResetTime()
Definition World.cpp:1778
void LoadDBAllowedSecurityLevel() override
Definition World.cpp:1850
void DetectDBCLang()
Definition World.cpp:1088
void InitGuildResetTime()
Definition World.cpp:1822
void InitRandomBGResetTime()
Definition World.cpp:1800
void InitWeeklyQuestResetTime()
Definition World.cpp:1767
void InitMonthlyQuestResetTime()
Definition World.cpp:1789
void LoadPreviousSessionInfo()
Definition World.cpp:1690
OpcodeTable opcodeTable
Definition Opcodes.cpp:51
void Initialize()
Correspondence between opcodes and their names.
Definition Opcodes.cpp:123
void LoadWeatherData()
Definition WeatherMgr.cpp:44
@ WUPDATE_PINGDB
Definition World.h:66
@ WUPDATE_WHO_LIST
Definition World.h:68
void Initialize()
Definition CreatureAIRegistry.cpp:34
AC_GAME_API void LoadCommandMap()
Definition ChatCommand.cpp:535
void LoadFromDB()
Definition AddonMgr.cpp:39
void CleanDatabase()
Definition CharacterDatabaseCleaner.cpp:27
AC_COMMON_API char const * GetFullVersion()
Definition GitRevision.cpp:82
Definition DBCStructure.h:1361
uint32 MapID
Definition DBCStructure.h:1362
bool Instanceable() const
Definition DBCStructure.h:1389

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, VMAP::VMapFactory::createOrGetVMapMgr(), Player::DeleteOldCharacters(), Player::DeleteOldRecoveryItems(), DetectDBCLang(), dtCustomAlloc(), dtCustomFree(), MapMgr::ExistMapAndVMap(), getBoolConfig(), GetDefaultDbcLocale(), DBUpdaterUtil::GetFailedUpdateCount(), 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(), 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(), LoadPreviousSessionInfo(), LoadRandomEnchantmentsTable(), LoadSkillDiscoveryTable(), LoadSkillExtraItemTable(), LoadSkillPerfectItemTable(), WeatherMgr::LoadWeatherData(), LOG_ERROR, LOG_FATAL, 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, sAccountMgr, 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, sMailMgr, sMapMgr, sMapStore, sMotdMgr, sObjectMgr, sOutdoorPvPMgr, sPetitionMgr, sPoolMgr, sRaceMgr, sScriptMgr, sServerMailMgr, sSmartScriptMgr, sSmartWaypointMgr, sSpellMgr, sTicketMgr, sTransportMgr, sWardenCheckMgr, sWaypointMgr, sWorldGlobals, sWorldState, WUPDATE_5_SECS, WUPDATE_AUTOBROADCAST, WUPDATE_CLEANDB, WUPDATE_EVENTS, WUPDATE_PINGDB, WUPDATE_UPTIME, and WUPDATE_WHO_LIST.

◆ setIntConfig()

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

◆ SetPlayerSecurityLimit()

void World::SetPlayerSecurityLimit ( AccountTypes  sec)
overridevirtual

Implements IWorld.

1861{
1862 AccountTypes sec = _sec < SEC_CONSOLE ? _sec : SEC_PLAYER;
1863 bool update = sec > _allowedSecurityLevel;
1865 if (update)
1867}
@ 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.

1387{
1388 setFloatConfig(index, value);
1389}
void setFloatConfig(ServerConfigs index, float value) override
Definition World.cpp:1407

References setFloatConfig().

◆ SetRealmName()

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

Implements IWorld.

253{ _realmName = name; } // pussywizard

References _realmName.

◆ setStringConfig()

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

Implements IWorld.

1428{
1429 _worldConfig.OverwriteConfigValue<std::string>(index, value);
1430}

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

◆ ShutdownCancel()

void World::ShutdownCancel ( )
overridevirtual

Cancel a planned server shutdown.

Implements IWorld.

1632{
1633 // nothing cancel or too later
1634 if (!_shutdownTimer || _stopEvent)
1635 return;
1636
1638
1639 _shutdownMask = 0;
1640 _shutdownTimer = 0;
1641 _exitCode = SHUTDOWN_EXIT_CODE; // to default value
1642 sWorldSessionMgr->SendServerMessage(msgid);
1643
1644 LOG_DEBUG("server.worldserver", "Server {} cancelled.", (_shutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
1645
1646 sScriptMgr->OnShutdownCancel();
1647}
ServerMessageType
Definition IWorld.h:55
@ SERVER_MSG_SHUTDOWN_CANCELLED
Definition IWorld.h:59
@ SERVER_MSG_RESTART_CANCELLED
Definition IWorld.h:60
@ SHUTDOWN_EXIT_CODE
Definition World.h:53

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.

1601{
1602 // Do not show a message for idle shutdown
1604 return;
1605
1606 bool twelveHours = (_shutdownTimer > 12 * HOUR && (_shutdownTimer % (12 * HOUR)) == 0); // > 12 h ; every 12 h
1607 bool oneHour = (_shutdownTimer < 12 * HOUR && (_shutdownTimer % HOUR) == 0); // < 12 h ; every 1 h
1608 bool fiveMin = (_shutdownTimer < 30 * MINUTE && (_shutdownTimer % (5 * MINUTE)) == 0); // < 30 min ; every 5 min
1609 bool oneMin = (_shutdownTimer < 15 * MINUTE && (_shutdownTimer % MINUTE) == 0); // < 15 min ; every 1 min
1610 bool thirtySec = (_shutdownTimer < 5 * MINUTE && (_shutdownTimer % 30) == 0); // < 5 min; every 30 sec
1611 bool tenSec = (_shutdownTimer < 1 * MINUTE && (_shutdownTimer % 10) == 0); // < 1 min; every 10 sec
1612 bool oneSec = (_shutdownTimer < 10 * SECOND && (_shutdownTimer % 1) == 0); // < 10 sec; every 1 sec
1613
1615 if (show || twelveHours || oneHour || fiveMin || oneMin || thirtySec || tenSec || oneSec)
1616 {
1617 std::string str = secsToTimeString(_shutdownTimer).append(".");
1618 if (!reason.empty())
1619 str += " - " + reason;
1620 // Display the reason every 12 hours, hour, 5 minutes, minute. At 60 seconds and at 10 seconds
1621 else if (!_shutdownReason.empty() && (twelveHours || oneHour || fiveMin || oneMin || _shutdownTimer == 60 || _shutdownTimer == 10))
1622 str += " - " + _shutdownReason;
1623
1625 sWorldSessionMgr->SendServerMessage(msgid, str, player);
1626 LOG_WARN("server.worldserver", "Server {} in {}", (_shutdownMask & SHUTDOWN_MASK_RESTART ? "restarting" : "shutdown"), str);
1627 }
1628}
constexpr auto SECOND
Definition Common.h:46
constexpr auto HOUR
Definition Common.h:48
@ SERVER_MSG_SHUTDOWN_TIME
Definition IWorld.h:56
@ SERVER_MSG_RESTART_TIME
Definition IWorld.h:57

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(), RescheduleShutdownForWintergrasp(), 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.

1559{
1560 // ignore if server shutdown at next tick
1561 if (IsStopped())
1562 return;
1563
1564 _shutdownMask = options;
1565 _exitCode = exitcode;
1566 _shutdownReason = reason;
1567
1568 LOG_DEBUG("server.worldserver", "Server shutdown called with ShutdownMask {}, ExitCode {}, Time {}, Reason {}", ShutdownMask(options), ShutdownExitCode(exitcode), secsToTimeString(time), reason);
1569
1571 if (time == 0)
1572 {
1573 if (!(options & SHUTDOWN_MASK_IDLE) || sWorldSessionMgr->GetActiveAndQueuedSessionCount() == 0)
1574 _stopEvent = true; // exist code already set
1575 else
1576 _shutdownTimer = 1; //So that the session count is re-evaluated at next world tick
1577 }
1579 else
1580 {
1581 _shutdownTimer = time;
1582 ShutdownMsg(true, nullptr, reason);
1583 }
1584
1585 sScriptMgr->OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options));
1586}
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

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.

1133{
1134 METRIC_TIMER("world_update_time_total");
1135
1138 Seconds currentGameTime = GameTime::GetGameTime();
1139
1141
1142 // Record update if recording set in log and diff is greater then minimum set in log
1144
1145 DynamicVisibilityMgr::Update(sWorldSessionMgr->GetActiveSessionCount());
1146
1148 for (int i = 0; i < WUPDATE_COUNT; ++i)
1149 {
1150 if (_timers[i].GetCurrent() >= 0)
1151 _timers[i].Update(diff);
1152 else
1153 _timers[i].SetCurrent(0);
1154 }
1155
1156 // pussywizard: our speed up and functionality
1157 if (_timers[WUPDATE_5_SECS].Passed())
1158 {
1160
1161 // moved here from HandleCharEnumOpcode
1163 CharacterDatabase.Execute(stmt);
1164 }
1165
1167 if (_timers[WUPDATE_WHO_LIST].Passed())
1168 {
1169 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update who list"));
1171 sWhoListCacheMgr->Update();
1172 }
1173
1174 {
1175 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Check quest reset times"));
1176
1178 if (currentGameTime > _nextDailyQuestReset)
1179 {
1181 }
1182
1184 if (currentGameTime > _nextWeeklyQuestReset)
1185 {
1187 }
1188
1190 if (currentGameTime > _nextMonthlyQuestReset)
1191 {
1193 }
1194 }
1195
1196 if (currentGameTime > _nextRandomBGReset)
1197 {
1198 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Reset random BG"));
1199 ResetRandomBG();
1200 }
1201
1202 if (currentGameTime > _nextCalendarOldEventsDeletionTime)
1203 {
1204 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Delete old calendar events"));
1206 }
1207
1208 if (currentGameTime > _nextGuildReset)
1209 {
1210 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Reset guild cap"));
1211 ResetGuildCap();
1212 }
1213
1214 {
1215 // 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)
1216 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update expired auctions"));
1217 sAuctionMgr->Update(diff);
1218 }
1219
1220 if (currentGameTime > _mail_expire_check_timer)
1221 {
1222 sMailMgr->ReturnOrDeleteOldMails(true);
1223 _mail_expire_check_timer = currentGameTime + 6h;
1224 }
1225
1226 {
1227 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update sessions"));
1228 sWorldSessionMgr->UpdateSessions(diff);
1229 }
1230
1232 if (getIntConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer
1233 {
1234 if (_timers[WUPDATE_CLEANDB].Passed())
1235 {
1236 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Clean logs table"));
1237
1239
1242 stmt->SetData(1, uint32(currentGameTime.count()));
1243 LoginDatabase.Execute(stmt);
1244 }
1245 }
1246
1247 {
1248 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update LFG 0"));
1249 sLFGMgr->Update(diff, 0); // pussywizard: remove obsolete stuff before finding compatibility during map update
1250 }
1251
1252 {
1254 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update maps"));
1255 sMapMgr->Update(diff);
1256 }
1257
1259 {
1260 if (_timers[WUPDATE_AUTOBROADCAST].Passed())
1261 {
1262 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Send autobroadcast"));
1264 sAutobroadcastMgr->SendAutobroadcasts();
1265 }
1266 }
1267
1268 {
1269 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update battlegrounds"));
1270 sBattlegroundMgr->Update(diff);
1271 }
1272
1273 {
1274 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update outdoor pvp"));
1275 sOutdoorPvPMgr->Update(diff);
1276 }
1277
1278 {
1279 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update worldstate"));
1280 sWorldState->Update(diff);
1281 }
1282
1283 {
1284 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update battlefields"));
1285 sBattlefieldMgr->Update(diff);
1286 }
1287
1288 {
1289 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update LFG 2"));
1290 sLFGMgr->Update(diff, 2); // pussywizard: handle created proposals
1291 }
1292
1293 {
1294 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process query callbacks"));
1295 // execute callbacks from sql queries that were queued recently
1297 }
1298
1300 if (_timers[WUPDATE_UPTIME].Passed())
1301 {
1302 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update uptime"));
1303
1305
1307 stmt->SetData(0, uint32(GameTime::GetUptime().count()));
1308 stmt->SetData(1, uint16(sWorldSessionMgr->GetMaxPlayerCount()));
1309 stmt->SetData(2, realm.Id.Realm);
1310 stmt->SetData(3, uint32(GameTime::GetStartTime().count()));
1311 LoginDatabase.Execute(stmt);
1312
1313 // Re-assert this realm as online in case the offline flag was set externally (e.g. an authserver restart).
1314 LoginDatabasePreparedStatement* onlineStmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_REALM_ONLINE);
1315 onlineStmt->SetData(0, uint8(REALM_FLAG_OFFLINE));
1316 onlineStmt->SetData(1, realm.Id.Realm);
1317 LoginDatabase.Execute(onlineStmt);
1318 }
1319
1321 if (_timers[WUPDATE_EVENTS].Passed())
1322 {
1323 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update game events"));
1324 _timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed
1325 uint32 nextGameEvent = sGameEventMgr->Update();
1326 _timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
1328 }
1329
1331 if (_timers[WUPDATE_PINGDB].Passed())
1332 {
1333 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Ping MySQL"));
1335 LOG_DEBUG("sql.driver", "Ping MySQL to keep connection alive");
1336 CharacterDatabase.KeepAlive();
1337 LoginDatabase.KeepAlive();
1338 WorldDatabase.KeepAlive();
1339 sScriptMgr->OnModuleDatabasesKeepAlive();
1340 }
1341
1342 {
1343 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update instance reset times"));
1344 // update the instance reset times
1345 sInstanceSaveMgr->Update();
1346 }
1347
1348 {
1349 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process cli commands"));
1350 // And last, but not least handle the issued cli commands
1352 }
1353
1354 {
1355 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update world scripts"));
1356 sScriptMgr->OnWorldUpdate(diff);
1357 }
1358
1359 if (sToCloud9Sidecar->ClusterModeEnabled())
1360 {
1361 {
1362 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process TC9 async tasks"));
1363 sToCloud9Sidecar->ProcessAsyncTasks();
1364 }
1365
1366 {
1367 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process TC9 hooks"));
1368 sToCloud9Sidecar->ProcessHooks();
1369 }
1370
1371 {
1372 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Process TC9 gRPC and HTTP requests"));
1373 sToCloud9Sidecar->ProcessGrpcOrHttpRequests();
1374 }
1375 }
1376
1377 {
1378 METRIC_TIMER("world_update_time", METRIC_TAG("type", "Update metrics"));
1379 // Stats logger update
1380 sMetric->Update();
1381 METRIC_VALUE("update_time_diff", diff);
1382 }
1383}
@ CHAR_DEL_EXPIRED_BANS
Definition CharacterDatabase.h:34
@ LOGIN_UPD_UPTIME_PLAYERS
Definition LoginDatabase.h:77
@ LOGIN_UPD_REALM_ONLINE
Definition LoginDatabase.h:78
@ LOGIN_DEL_OLD_LOGS
Definition LoginDatabase.h:79
#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
@ REALM_FLAG_OFFLINE
Definition Realm.h:29
#define sToCloud9Sidecar
Definition TC9Sidecar.h:81
#define sWhoListCacheMgr
Definition WhoListCacheMgr.h:96
@ CONFIG_AUTOBROADCAST
Definition WorldConfig.h:94
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:1722
void _UpdateGameTime()
Update the game time.
Definition World.cpp:1491
void ResetMonthlyQuests()
Definition World.cpp:1886
void ResetGuildCap()
Definition World.cpp:1949
void ResetWeeklyQuests()
Definition World.cpp:1869
void ResetRandomBG()
Definition World.cpp:1924
void ResetDailyQuests()
Definition World.cpp:1833
void CalendarDeleteOldEvents()
Definition World.cpp:1940
void ProcessQueryCallbacks()
Definition World.cpp:1987
@ WUPDATE_COUNT
Definition World.h:69
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:44
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_REALM_ONLINE, LOGIN_UPD_UPTIME_PLAYERS, LoginDatabase, METRIC_TAG, METRIC_TIMER, METRIC_VALUE, ProcessCliCommands(), ProcessQueryCallbacks(), realm, RealmHandle::Realm, REALM_FLAG_OFFLINE, WorldUpdateTime::RecordUpdateTime(), IntervalTimer::Reset(), ResetDailyQuests(), ResetGuildCap(), ResetMonthlyQuests(), ResetRandomBG(), ResetWeeklyQuests(), sAuctionMgr, sAutobroadcastMgr, sBattlefieldMgr, sBattlegroundMgr, IntervalTimer::SetCurrent(), PreparedStatementBase::SetData(), IntervalTimer::SetInterval(), sGameEventMgr, sInstanceSaveMgr, sLFGMgr, sMailMgr, sMapMgr, sMetric, sOutdoorPvPMgr, sScriptMgr, sToCloud9Sidecar, sWhoListCacheMgr, sWorldSessionMgr, sWorldState, sWorldUpdateTime, IntervalTimer::Update(), DynamicVisibilityMgr::Update(), UpdateTime::UpdateWithDiff(), WorldDatabase, WUPDATE_5_SECS, WUPDATE_AUTOBROADCAST, WUPDATE_CLEANDB, WUPDATE_COUNT, WUPDATE_EVENTS, WUPDATE_PINGDB, WUPDATE_UPTIME, and WUPDATE_WHO_LIST.

◆ UpdateAreaDependentAuras()

void World::UpdateAreaDependentAuras ( )
overridevirtual

Implements IWorld.

1977{
1978 WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
1979 for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
1980 if (itr->second && itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld())
1981 {
1982 itr->second->GetPlayer()->UpdateAreaDependentAuras(itr->second->GetPlayer()->GetAreaId());
1983 itr->second->GetPlayer()->UpdateZoneDependentAuras(itr->second->GetPlayer()->GetZoneId());
1984 }
1985}

References sWorldSessionMgr.

◆ UpdateRealmCharCount()

void World::UpdateRealmCharCount ( uint32  accid)
overridevirtual

Implements IWorld.

1741{
1743 stmt->SetData(0, accountId);
1744 _queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&World::_UpdateRealmCharCount, this, std::placeholders::_1,accountId)));
1745}
@ CHAR_SEL_CHARACTER_COUNT
Definition CharacterDatabase.h:137
T & AddCallback(T &&query)
Definition AsyncCallbackProcessor.h:34
void _UpdateRealmCharCount(PreparedQueryResult resultCharCount, uint32 accountId)
Definition World.cpp:1747

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

std::atomic< uint8 > World::_exitCode = SHUTDOWN_EXIT_CODE
staticprivate

◆ _isClosed

bool World::_isClosed
private

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

◆ _lifetimeMaxPlayerCount

uint32 World::_lifetimeMaxPlayerCount
private

◆ _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

◆ _previousSession

Optional<PreviousSessionInfo> World::_previousSession
private

◆ _queryProcessor

QueryCallbackProcessor World::_queryProcessor
private

◆ _realmName

std::string World::_realmName
private

Referenced by GetRealmName(), and SetRealmName().

◆ _sessionOutcome

Optional<SessionOutcome> World::_sessionOutcome
private

Referenced by SaveSessionEnd().

◆ _shutdownMask

◆ _shutdownReason

std::string World::_shutdownReason
private

◆ _shutdownTimer

◆ _stopEvent

std::atomic_long World::_stopEvent = false
staticprivate

◆ _stoppedByStopNow

std::atomic< bool > World::_stoppedByStopNow = false
staticprivate

Referenced by SaveSessionEnd(), and StopNow().

◆ _timers

◆ _worldConfig

◆ m_worldLoopCounter

uint32 World::m_worldLoopCounter = 0
static

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