[10677] Send to creature/etc Update call real diff from last update and use it.

Now in case when creature/etc some tices not updates in result stay
in not active (no near players or active objects) cell some important
timers (corpse decay, summon timers, group loot expire, aura durations, etc) will
updates at real diff time from last prev. update call.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

For some systems added exclude use real diff time because current limitations
like move generators. So its stay use last tick diff and considered freeze and
skip all time while creature in not active map part.
This commit is contained in:
cipherCOM 2010-11-03 06:49:18 +03:00 committed by VladimirMangos
parent 62c0963f37
commit 555c1a9094
35 changed files with 162 additions and 149 deletions

View file

@ -406,7 +406,7 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *
return display_id;
}
void Creature::Update(uint32 diff)
void Creature::Update(uint32 update_diff, uint32 tick_diff)
{
if (m_needNotify)
{
@ -467,7 +467,7 @@ void Creature::Update(uint32 diff)
if (m_isDeadByDefault)
break;
if (m_corpseDecayTimer <= diff)
if (m_corpseDecayTimer <= update_diff)
{
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
@ -482,11 +482,11 @@ void Creature::Update(uint32 diff)
}
else
{
m_corpseDecayTimer -= diff;
m_corpseDecayTimer -= update_diff;
if (m_groupLootId)
{
if(diff < m_groupLootTimer)
m_groupLootTimer -= diff;
if(update_diff < m_groupLootTimer)
m_groupLootTimer -= update_diff;
else
StopGroupLoot();
}
@ -498,7 +498,7 @@ void Creature::Update(uint32 diff)
{
if (m_isDeadByDefault)
{
if (m_corpseDecayTimer <= diff)
if (m_corpseDecayTimer <= update_diff)
{
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
@ -516,11 +516,11 @@ void Creature::Update(uint32 diff)
}
else
{
m_corpseDecayTimer -= diff;
m_corpseDecayTimer -= update_diff;
}
}
Unit::Update( diff );
Unit::Update(update_diff, tick_diff);
// creature can be dead after Unit::Update call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
@ -531,7 +531,7 @@ void Creature::Update(uint32 diff)
{
// do not allow the AI to be changed during update
m_AI_locked = true;
i_AI->UpdateAI(diff);
i_AI->UpdateAI(tick_diff); // AI not react good at real update delays (while freeze in non-active part of map)
m_AI_locked = false;
}
@ -541,10 +541,10 @@ void Creature::Update(uint32 diff)
break;
if(m_regenTimer > 0)
{
if(diff >= m_regenTimer)
if(update_diff >= m_regenTimer)
m_regenTimer = 0;
else
m_regenTimer -= diff;
m_regenTimer -= update_diff;
}
if (m_regenTimer != 0)
break;