aboutsummaryrefslogtreecommitdiff
path: root/src/game/World.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2008-12-30 18:03:26 -0600
committermegamage <none@none>2008-12-30 18:03:26 -0600
commitd088021a507eadf0f985f2d6452bca8fc9714005 (patch)
treeee2ee3f62189689ad925cca3eb17b531871b5843 /src/game/World.cpp
parent8592e5606bf3d7342dc0c97df8d9e8a6206994a9 (diff)
*Write update time diff into log to display server performance.
--HG-- branch : trunk
Diffstat (limited to 'src/game/World.cpp')
-rw-r--r--src/game/World.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 7769c9a7942..0215426afbd 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -112,6 +112,9 @@ World::World()
m_defaultDbcLocale = LOCALE_enUS;
m_availableDbcLocaleMask = 0;
+
+ m_updateTimeSum = 0;
+ m_updateTimeCount = 0;
}
/// World destructor
@@ -989,6 +992,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_PVP_TOKEN_COUNT] = 1;
m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false);
m_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfig.GetBoolDefault("ShowKickInWorld", false);
+ m_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig.GetIntDefault("RecordUpdateTimeDiffInterval", 60000);
std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", "");
char * forbiddenMaps = new char[forbiddenmaps.length() + 1];
@@ -1409,6 +1413,22 @@ void World::DetectDBCLang()
/// Update the World !
void World::Update(time_t diff)
{
+ m_updateTime = uint32(diff);
+ if(m_configs[CONFIG_INTERVAL_LOG_UPDATE])
+ {
+ if(m_updateTimeSum > m_configs[CONFIG_INTERVAL_LOG_UPDATE])
+ {
+ sLog.outString("Update time diff: %u. Players online: %u.", m_updateTimeSum / m_updateTimeCount, GetActiveSessionCount());
+ m_updateTimeSum = m_updateTime;
+ m_updateTimeCount = 1;
+ }
+ else
+ {
+ m_updateTimeSum += m_updateTime;
+ ++m_updateTimeCount;
+ }
+ }
+
///- Update the different timers
for(int i = 0; i < WUPDATE_COUNT; i++)
if(m_timers[i].GetCurrent()>=0)