mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[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:
parent
62c0963f37
commit
555c1a9094
35 changed files with 162 additions and 149 deletions
|
|
@ -1175,7 +1175,7 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
|
|||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void Player::Update( uint32 p_time )
|
||||
void Player::Update(uint32 update_diff, uint32 tick_diff)
|
||||
{
|
||||
if(!IsInWorld())
|
||||
return;
|
||||
|
|
@ -1195,25 +1195,21 @@ void Player::Update( uint32 p_time )
|
|||
|
||||
//used to implement delayed far teleports
|
||||
SetCanDelayTeleport(true);
|
||||
Unit::Update( p_time );
|
||||
Unit::Update(update_diff, tick_diff);
|
||||
SetCanDelayTeleport(false);
|
||||
|
||||
// update player only attacks
|
||||
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
|
||||
{
|
||||
setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) );
|
||||
}
|
||||
if (uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
|
||||
setAttackTimer(RANGED_ATTACK, (update_diff >= ranged_att ? 0 : ranged_att - update_diff) );
|
||||
|
||||
if(uint32 off_att = getAttackTimer(OFF_ATTACK))
|
||||
{
|
||||
setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) );
|
||||
}
|
||||
if (uint32 off_att = getAttackTimer(OFF_ATTACK))
|
||||
setAttackTimer(OFF_ATTACK, (update_diff >= off_att ? 0 : off_att - update_diff) );
|
||||
|
||||
time_t now = time (NULL);
|
||||
|
||||
UpdatePvPFlag(now);
|
||||
|
||||
UpdateContestedPvP(p_time);
|
||||
UpdateContestedPvP(update_diff);
|
||||
|
||||
UpdateDuelFlag(now);
|
||||
|
||||
|
|
@ -1231,7 +1227,7 @@ void Player::Update( uint32 p_time )
|
|||
while (iter != m_timedquests.end())
|
||||
{
|
||||
QuestStatusData& q_status = mQuestStatus[*iter];
|
||||
if( q_status.m_timer <= p_time )
|
||||
if (q_status.m_timer <= update_diff)
|
||||
{
|
||||
uint32 quest_id = *iter;
|
||||
++iter; // current iter will be removed in FailQuest
|
||||
|
|
@ -1239,7 +1235,7 @@ void Player::Update( uint32 p_time )
|
|||
}
|
||||
else
|
||||
{
|
||||
q_status.m_timer -= p_time;
|
||||
q_status.m_timer -= update_diff;
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
++iter;
|
||||
}
|
||||
|
|
@ -1342,49 +1338,49 @@ void Player::Update( uint32 p_time )
|
|||
|
||||
if (m_regenTimer)
|
||||
{
|
||||
if(p_time >= m_regenTimer)
|
||||
if (update_diff >= m_regenTimer)
|
||||
m_regenTimer = 0;
|
||||
else
|
||||
m_regenTimer -= p_time;
|
||||
m_regenTimer -= update_diff;
|
||||
}
|
||||
|
||||
if (m_weaponChangeTimer > 0)
|
||||
{
|
||||
if(p_time >= m_weaponChangeTimer)
|
||||
if (update_diff >= m_weaponChangeTimer)
|
||||
m_weaponChangeTimer = 0;
|
||||
else
|
||||
m_weaponChangeTimer -= p_time;
|
||||
m_weaponChangeTimer -= update_diff;
|
||||
}
|
||||
|
||||
if (m_zoneUpdateTimer > 0)
|
||||
{
|
||||
if(p_time >= m_zoneUpdateTimer)
|
||||
if (update_diff >= m_zoneUpdateTimer)
|
||||
{
|
||||
uint32 newzone, newarea;
|
||||
GetZoneAndAreaId(newzone,newarea);
|
||||
|
||||
if( m_zoneUpdateId != newzone )
|
||||
if (m_zoneUpdateId != newzone)
|
||||
UpdateZone(newzone,newarea); // also update area
|
||||
else
|
||||
{
|
||||
// use area updates as well
|
||||
// needed for free far all arenas for example
|
||||
if( m_areaUpdateId != newarea )
|
||||
if (m_areaUpdateId != newarea)
|
||||
UpdateArea(newarea);
|
||||
|
||||
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_zoneUpdateTimer -= p_time;
|
||||
m_zoneUpdateTimer -= update_diff;
|
||||
}
|
||||
|
||||
if (m_timeSyncTimer > 0)
|
||||
{
|
||||
if(p_time >= m_timeSyncTimer)
|
||||
if (update_diff >= m_timeSyncTimer)
|
||||
SendTimeSync();
|
||||
else
|
||||
m_timeSyncTimer -= p_time;
|
||||
m_timeSyncTimer -= update_diff;
|
||||
}
|
||||
|
||||
if (isAlive())
|
||||
|
|
@ -1400,31 +1396,31 @@ void Player::Update( uint32 p_time )
|
|||
if (m_deathState == JUST_DIED)
|
||||
KillPlayer();
|
||||
|
||||
if(m_nextSave > 0)
|
||||
if (m_nextSave > 0)
|
||||
{
|
||||
if(p_time >= m_nextSave)
|
||||
if (update_diff >= m_nextSave)
|
||||
{
|
||||
// m_nextSave reseted in SaveToDB call
|
||||
SaveToDB();
|
||||
DETAIL_LOG("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow());
|
||||
}
|
||||
else
|
||||
m_nextSave -= p_time;
|
||||
m_nextSave -= update_diff;
|
||||
}
|
||||
|
||||
//Handle Water/drowning
|
||||
HandleDrowning(p_time);
|
||||
HandleDrowning(update_diff);
|
||||
|
||||
//Handle detect stealth players
|
||||
if (m_DetectInvTimer > 0)
|
||||
{
|
||||
if (p_time >= m_DetectInvTimer)
|
||||
if (update_diff >= m_DetectInvTimer)
|
||||
{
|
||||
HandleStealthedUnitsDetection();
|
||||
m_DetectInvTimer = 3000;
|
||||
}
|
||||
else
|
||||
m_DetectInvTimer -= p_time;
|
||||
m_DetectInvTimer -= update_diff;
|
||||
}
|
||||
|
||||
// Played time
|
||||
|
|
@ -1438,27 +1434,27 @@ void Player::Update( uint32 p_time )
|
|||
|
||||
if (m_drunk)
|
||||
{
|
||||
m_drunkTimer += p_time;
|
||||
m_drunkTimer += update_diff;
|
||||
|
||||
if (m_drunkTimer > 10*IN_MILLISECONDS)
|
||||
HandleSobering();
|
||||
}
|
||||
|
||||
// not auto-free ghost from body in instances
|
||||
if(m_deathTimer > 0 && !GetBaseMap()->Instanceable())
|
||||
if (m_deathTimer > 0 && !GetBaseMap()->Instanceable())
|
||||
{
|
||||
if(p_time >= m_deathTimer)
|
||||
if(update_diff >= m_deathTimer)
|
||||
{
|
||||
m_deathTimer = 0;
|
||||
BuildPlayerRepop();
|
||||
RepopAtGraveyard();
|
||||
}
|
||||
else
|
||||
m_deathTimer -= p_time;
|
||||
m_deathTimer -= update_diff;
|
||||
}
|
||||
|
||||
UpdateEnchantTime(p_time);
|
||||
UpdateHomebindTime(p_time);
|
||||
UpdateEnchantTime(update_diff);
|
||||
UpdateHomebindTime(update_diff);
|
||||
|
||||
// group update
|
||||
SendUpdateToOutOfRangeGroupMembers();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue