[10687] UInt32 timer class copies instead using time_t timers for mstime cases.

Also cleanup weather update code and some random code cleanups.
This commit is contained in:
VladimirMangos 2010-11-06 21:54:05 +03:00
parent 478bf3b367
commit 464908f453
15 changed files with 87 additions and 67 deletions

View file

@ -1286,7 +1286,7 @@ void World::SetInitialWorldSettings()
//one second is 1000 -(tested on win system)
mail_timer = uint32((((localtime( &m_gameTime )->tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval() );
//1440
mail_timer_expires = uint32( (DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval()));
mail_timer_expires = (DAY * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval();
DEBUG_LOG("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires);
///- Initialize static helper structures
@ -1384,12 +1384,7 @@ void World::Update(uint32 diff)
{
///- Update the different timers
for(int i = 0; i < WUPDATE_COUNT; ++i)
{
if (m_timers[i].GetCurrent()>=0)
m_timers[i].Update(diff);
else
m_timers[i].SetCurrent(0);
}
m_timers[i].Update(diff);
///- Update the game time and check for shutdown time
_UpdateGameTime();
@ -1434,23 +1429,21 @@ void World::Update(uint32 diff)
/// <li> Handle weather updates when the timer has passed
if (m_timers[WUPDATE_WEATHERS].Passed())
{
m_timers[WUPDATE_WEATHERS].Reset();
///- Send an update signal to Weather objects
WeatherMap::iterator itr, next;
for (itr = m_weathers.begin(); itr != m_weathers.end(); itr = next)
for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end(); )
{
next = itr;
++next;
///- and remove Weather objects for zones with no player
//As interval > WorldTick
if(!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval()))
{
delete itr->second;
m_weathers.erase(itr);
m_weathers.erase(itr++);
}
else
++itr;
}
m_timers[WUPDATE_WEATHERS].SetCurrent(0);
}
/// <li> Update uptime table
if (m_timers[WUPDATE_UPTIME].Passed())