diff options
Diffstat (limited to 'src/game/World.cpp')
-rw-r--r-- | src/game/World.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/game/World.cpp b/src/game/World.cpp index 21b1372f1af..9fe7f77fd5c 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -68,6 +68,7 @@ #include "CreatureGroups.h" #include "Transports.h" #include "ProgressBar.h" +#include "TimeMgr.h" INSTANTIATE_SINGLETON_1(World); @@ -96,7 +97,7 @@ World::World() m_allowMovement = true; m_ShutdownMask = 0; m_ShutdownTimer = 0; - m_gameTime=time(NULL); + m_gameTime=sGameTime.GetGameTime(); m_startTime=m_gameTime; m_maxActiveSessionCount = 0; m_maxQueuedSessionCount = 0; @@ -287,7 +288,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session) { for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();) { - if (difftime(i->second, time(NULL)) < tolerance) + if (difftime(i->second, sGameTime.GetGameTime()) < tolerance) { if (i->first == session->GetAccountId()) return true; @@ -1234,7 +1235,7 @@ void World::LoadConfigSettings(bool reload) void World::SetInitialWorldSettings() { ///- Initialize the random number generator - srand((unsigned int)time(NULL)); + srand((unsigned int)sGameTime.GetGameTime()); ///- Initialize config settings LoadConfigSettings(); @@ -1625,7 +1626,7 @@ void World::SetInitialWorldSettings() ///- Initialize game time and timers sLog.outDebug("DEBUG:: Initialize game time and timers"); - m_gameTime = time(NULL); + m_gameTime=sGameTime.GetGameTime(); m_startTime=m_gameTime; tm local; @@ -1637,7 +1638,7 @@ void World::SetInitialWorldSettings() local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime, revision) VALUES('%u', " UI64FMTD ", '%s', 0, '%s')", - realmID, uint64(m_startTime), isoDate, _FULLVERSION); + realmID, sGameTime, isoDate, _FULLVERSION); static uint32 abtimer = 0; abtimer = sConfig.GetIntDefault("AutoBroadcast.Timer", 60000); @@ -1656,7 +1657,7 @@ void World::SetInitialWorldSettings() //to set mailtimer to return mails every day between 4 and 5 am //mailtimer is increased when updating auctions //one second is 1000 -(tested on win system) - mail_timer = ((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); + mail_timer = ((((localtime(&sGameTime.GetGameTime())->tm_hour + 20) % 24)* HOUR * IN_MILISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); //1440 mail_timer_expires = ((DAY * IN_MILISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); sLog.outDebug("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires); @@ -1857,7 +1858,7 @@ void World::Update(uint32 diff) _UpdateGameTime(); /// Handle daily quests reset time - if (m_gameTime > m_NextDailyQuestReset) + if (sGameTime.GetGameTime() > m_NextDailyQuestReset) { ResetDailyQuests(); m_NextDailyQuestReset += DAY; @@ -1914,7 +1915,7 @@ void World::Update(uint32 diff) uint32 maxClientsNum = GetMaxActiveSessionCount(); m_timers[WUPDATE_UPTIME].Reset(); - loginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, uint64(m_startTime)); + loginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxClientsNum, realmID, sGameTime); } /// <li> Clean logs table @@ -1922,7 +1923,6 @@ void World::Update(uint32 diff) { if (m_timers[WUPDATE_CLEANDB].Passed()) { - uint32 tmpDiff = (m_gameTime - m_startTime); uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount(); m_timers[WUPDATE_CLEANDB].Reset(); @@ -2281,9 +2281,9 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) void World::_UpdateGameTime() { ///- update the time - time_t thisTime = time(NULL); - uint32 elapsed = uint32(thisTime - m_gameTime); - m_gameTime = thisTime; + time_t thisTime = sGameTime.GetGameTime(); + uint32 elapsed = uint32(thisTime - sGameTime.GetGameTime()); + sGameTime.SetGameTime(); ///- if there is a shutdown timer if (!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) @@ -2412,7 +2412,7 @@ void World::UpdateSessions(uint32 diff) if (!itr->second->Update(diff)) // As interval = 0 { if (!RemoveQueuedPlayer(itr->second) && itr->second && getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) - m_disconnects[itr->second->GetAccountId()] = time(NULL); + m_disconnects[itr->second->GetAccountId()] = sGameTime.GetGameTime(); delete itr->second; m_sessions.erase(itr); } @@ -2523,7 +2523,7 @@ void World::InitDailyQuestResetTime() // client built-in time for reset is 6:00 AM // FIX ME: client not show day start time - time_t curTime = time(NULL); + time_t curTime = sGameTime.GetGameTime(); tm localTm = *localtime(&curTime); localTm.tm_hour = 6; localTm.tm_min = 0; |