mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[10924] Send time diff between Update() calls for object - should help with mob respawn on inactive grids etc. Based on patches by VladimirMangos and cipherCOM. All issues from previous patches should be finally fixed now.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
72b1d30a1c
commit
b11820593c
39 changed files with 284 additions and 149 deletions
|
|
@ -530,7 +530,7 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
|
||||||
bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
|
bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
|
||||||
if (!bg)
|
if (!bg)
|
||||||
continue;
|
continue;
|
||||||
uint32 remainingTime = getMSTimeDiff(getMSTime(), ginfo.RemoveInviteTime);
|
uint32 remainingTime = WorldTimer::getMSTimeDiff(WorldTimer::getMSTime(), ginfo.RemoveInviteTime);
|
||||||
// send status invited to BattleGround
|
// send status invited to BattleGround
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, STATUS_WAIT_JOIN, remainingTime, 0, arenaType);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, STATUS_WAIT_JOIN, remainingTime, 0, arenaType);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
|
|
@ -548,7 +548,7 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
|
||||||
|
|
||||||
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(&ginfo, bracketEntry->GetBracketId());
|
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(&ginfo, bracketEntry->GetBracketId());
|
||||||
// send status in BattleGround Queue
|
// send status in BattleGround Queue
|
||||||
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, STATUS_WAIT_QUEUE, avgTime, getMSTimeDiff(ginfo.JoinTime, getMSTime()), arenaType);
|
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, i, STATUS_WAIT_QUEUE, avgTime, WorldTimer::getMSTimeDiff(ginfo.JoinTime, WorldTimer::getMSTime()), arenaType);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
|
||||||
ginfo->ArenaTeamId = arenateamid;
|
ginfo->ArenaTeamId = arenateamid;
|
||||||
ginfo->IsRated = isRated;
|
ginfo->IsRated = isRated;
|
||||||
ginfo->IsInvitedToBGInstanceGUID = 0;
|
ginfo->IsInvitedToBGInstanceGUID = 0;
|
||||||
ginfo->JoinTime = getMSTime();
|
ginfo->JoinTime = WorldTimer::getMSTime();
|
||||||
ginfo->RemoveInviteTime = 0;
|
ginfo->RemoveInviteTime = 0;
|
||||||
ginfo->GroupTeam = leader->GetTeam();
|
ginfo->GroupTeam = leader->GetTeam();
|
||||||
ginfo->ArenaTeamRating = arenaRating;
|
ginfo->ArenaTeamRating = arenaRating;
|
||||||
|
|
@ -176,7 +176,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
|
||||||
|
|
||||||
DEBUG_LOG("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
|
DEBUG_LOG("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
|
||||||
|
|
||||||
uint32 lastOnlineTime = getMSTime();
|
uint32 lastOnlineTime = WorldTimer::getMSTime();
|
||||||
|
|
||||||
//announce world (this don't need mutex)
|
//announce world (this don't need mutex)
|
||||||
if (isRated && sWorld.getConfig(CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN))
|
if (isRated && sWorld.getConfig(CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN))
|
||||||
|
|
@ -253,7 +253,7 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG
|
||||||
|
|
||||||
void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id)
|
void BattleGroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id)
|
||||||
{
|
{
|
||||||
uint32 timeInQueue = getMSTimeDiff(ginfo->JoinTime, getMSTime());
|
uint32 timeInQueue = WorldTimer::getMSTimeDiff(ginfo->JoinTime, WorldTimer::getMSTime());
|
||||||
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||||
if (!ginfo->ArenaType)
|
if (!ginfo->ArenaType)
|
||||||
{
|
{
|
||||||
|
|
@ -460,7 +460,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
|
||||||
if (bg->isArena() && bg->isRated())
|
if (bg->isArena() && bg->isRated())
|
||||||
bg->SetArenaTeamIdForTeam(ginfo->GroupTeam, ginfo->ArenaTeamId);
|
bg->SetArenaTeamIdForTeam(ginfo->GroupTeam, ginfo->ArenaTeamId);
|
||||||
|
|
||||||
ginfo->RemoveInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME;
|
ginfo->RemoveInviteTime = WorldTimer::getMSTime() + INVITE_ACCEPT_WAIT_TIME;
|
||||||
|
|
||||||
// loop through the players
|
// loop through the players
|
||||||
for(GroupQueueInfoPlayers::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
|
for(GroupQueueInfoPlayers::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr)
|
||||||
|
|
@ -626,7 +626,7 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint
|
||||||
// this could be 2 cycles but i'm checking only first team in queue - it can cause problem -
|
// this could be 2 cycles but i'm checking only first team in queue - it can cause problem -
|
||||||
// if first is invited to BG and seconds timer expired, but we can ignore it, because players have only 80 seconds to click to enter bg
|
// if first is invited to BG and seconds timer expired, but we can ignore it, because players have only 80 seconds to click to enter bg
|
||||||
// and when they click or after 80 seconds the queue info is removed from queue
|
// and when they click or after 80 seconds the queue info is removed from queue
|
||||||
uint32 time_before = getMSTime() - sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH);
|
uint32 time_before = WorldTimer::getMSTime() - sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH);
|
||||||
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty())
|
if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty())
|
||||||
|
|
@ -932,7 +932,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
|
||||||
// (after what time the ratings aren't taken into account when making teams) then
|
// (after what time the ratings aren't taken into account when making teams) then
|
||||||
// the discard time is current_time - time_to_discard, teams that joined after that, will have their ratings taken into account
|
// the discard time is current_time - time_to_discard, teams that joined after that, will have their ratings taken into account
|
||||||
// else leave the discard time on 0, this way all ratings will be discarded
|
// else leave the discard time on 0, this way all ratings will be discarded
|
||||||
uint32 discardTime = getMSTime() - sBattleGroundMgr.GetRatingDiscardTimer();
|
uint32 discardTime = WorldTimer::getMSTime() - sBattleGroundMgr.GetRatingDiscardTimer();
|
||||||
|
|
||||||
// we need to find 2 teams which will play next game
|
// we need to find 2 teams which will play next game
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -717,7 +717,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
|
||||||
|
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());
|
CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow());
|
||||||
LoginDatabase.PExecute("UPDATE account SET active_realm_id = %u WHERE id = '%u'", realmID, GetAccountId());
|
LoginDatabase.PExecute("UPDATE account SET active_realm_id = %u WHERE id = '%u'", realmID, GetAccountId());
|
||||||
pCurrChar->SetInGameTime( getMSTime() );
|
pCurrChar->SetInGameTime( WorldTimer::getMSTime() );
|
||||||
|
|
||||||
// announce group about member online (must be after add to player list to receive announce to self)
|
// announce group about member online (must be after add to player list to receive announce to self)
|
||||||
if (Group *group = pCurrChar->GetGroup())
|
if (Group *group = pCurrChar->GetGroup())
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,7 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *
|
||||||
return display_id;
|
return display_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::Update(uint32 diff)
|
void Creature::Update(uint32 update_diff, uint32 diff)
|
||||||
{
|
{
|
||||||
if (m_needNotify)
|
if (m_needNotify)
|
||||||
{
|
{
|
||||||
|
|
@ -467,7 +467,7 @@ void Creature::Update(uint32 diff)
|
||||||
if (m_isDeadByDefault)
|
if (m_isDeadByDefault)
|
||||||
break;
|
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
|
// 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;
|
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
|
||||||
|
|
@ -482,11 +482,11 @@ void Creature::Update(uint32 diff)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_corpseDecayTimer -= diff;
|
m_corpseDecayTimer -= update_diff;
|
||||||
if (m_groupLootId)
|
if (m_groupLootId)
|
||||||
{
|
{
|
||||||
if(diff < m_groupLootTimer)
|
if(update_diff < m_groupLootTimer)
|
||||||
m_groupLootTimer -= diff;
|
m_groupLootTimer -= update_diff;
|
||||||
else
|
else
|
||||||
StopGroupLoot();
|
StopGroupLoot();
|
||||||
}
|
}
|
||||||
|
|
@ -498,7 +498,7 @@ void Creature::Update(uint32 diff)
|
||||||
{
|
{
|
||||||
if (m_isDeadByDefault)
|
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
|
// 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;
|
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
|
||||||
|
|
@ -516,11 +516,11 @@ void Creature::Update(uint32 diff)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_corpseDecayTimer -= diff;
|
m_corpseDecayTimer -= update_diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit::Update( diff );
|
Unit::Update( update_diff, diff );
|
||||||
|
|
||||||
// creature can be dead after Unit::Update call
|
// 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)
|
// 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
|
// do not allow the AI to be changed during update
|
||||||
m_AI_locked = true;
|
m_AI_locked = true;
|
||||||
i_AI->UpdateAI(diff);
|
i_AI->UpdateAI(diff); // AI not react good at real update delays (while freeze in non-active part of map)
|
||||||
m_AI_locked = false;
|
m_AI_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -541,10 +541,10 @@ void Creature::Update(uint32 diff)
|
||||||
break;
|
break;
|
||||||
if(m_regenTimer > 0)
|
if(m_regenTimer > 0)
|
||||||
{
|
{
|
||||||
if(diff >= m_regenTimer)
|
if(update_diff >= m_regenTimer)
|
||||||
m_regenTimer = 0;
|
m_regenTimer = 0;
|
||||||
else
|
else
|
||||||
m_regenTimer -= diff;
|
m_regenTimer -= update_diff;
|
||||||
}
|
}
|
||||||
if (m_regenTimer != 0)
|
if (m_regenTimer != 0)
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -405,7 +405,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||||
char const* GetSubName() const { return GetCreatureInfo()->SubName; }
|
char const* GetSubName() const { return GetCreatureInfo()->SubName; }
|
||||||
|
|
||||||
void Update(uint32 time); // overwrite Unit::Update
|
void Update(uint32 update_diff, uint32 time); // overwrite Unit::Update
|
||||||
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
|
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
|
||||||
uint32 GetEquipmentId() const { return m_equipmentId; }
|
uint32 GetEquipmentId() const { return m_equipmentId; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellE
|
||||||
|
|
||||||
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
|
SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
|
||||||
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
|
SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
|
||||||
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime()); // new 2.4.0
|
SetUInt32Value(DYNAMICOBJECT_CASTTIME, WorldTimer::getMSTime()); // new 2.4.0
|
||||||
|
|
||||||
m_aliveDuration = duration;
|
m_aliveDuration = duration;
|
||||||
m_radius = radius;
|
m_radius = radius;
|
||||||
|
|
@ -106,7 +106,7 @@ Unit* DynamicObject::GetCaster() const
|
||||||
return ObjectAccessor::GetUnit(*this, GetCasterGuid());
|
return ObjectAccessor::GetUnit(*this, GetCasterGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicObject::Update(uint32 p_time)
|
void DynamicObject::Update(uint32 update_diff, uint32 p_time)
|
||||||
{
|
{
|
||||||
// caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
|
// caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
|
||||||
Unit* caster = GetCaster();
|
Unit* caster = GetCaster();
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class DynamicObject : public WorldObject
|
||||||
void RemoveFromWorld();
|
void RemoveFromWorld();
|
||||||
|
|
||||||
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius);
|
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius);
|
||||||
void Update(uint32 p_time);
|
void Update(uint32 update_diff, uint32 p_time);
|
||||||
void Delete();
|
void Delete();
|
||||||
uint32 GetSpellId() const { return m_spellId; }
|
uint32 GetSpellId() const { return m_spellId; }
|
||||||
SpellEffectIndex GetEffIndex() const { return m_effIndex; }
|
SpellEffectIndex GetEffIndex() const { return m_effIndex; }
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameObject::Update(uint32 /*p_time*/)
|
void GameObject::Update(uint32 update_diff, uint32 /*p_time*/)
|
||||||
{
|
{
|
||||||
if (GetObjectGuid().IsMOTransport())
|
if (GetObjectGuid().IsMOTransport())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -588,7 +588,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
|
||||||
void RemoveFromWorld();
|
void RemoveFromWorld();
|
||||||
|
|
||||||
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint8 animprogress, GOState go_state);
|
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint8 animprogress, GOState go_state);
|
||||||
void Update(uint32 p_time);
|
void Update(uint32 update_diff, uint32 p_time);
|
||||||
GameObjectInfo const* GetGOInfo() const;
|
GameObjectInfo const* GetGOInfo() const;
|
||||||
|
|
||||||
bool IsTransport() const;
|
bool IsTransport() const;
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,8 @@ ObjectUpdater::Visit(GridRefManager<T> &m)
|
||||||
{
|
{
|
||||||
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||||
{
|
{
|
||||||
iter->getSource()->Update(i_timeDiff);
|
WorldObject::UpdateHelper helper(iter->getSource());
|
||||||
|
helper.Update(i_timeDiff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,10 @@ inline void MaNGOS::VisibleNotifier::Visit(GridRefManager<T> &m)
|
||||||
inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType &m)
|
inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType &m)
|
||||||
{
|
{
|
||||||
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||||
iter->getSource()->Update(i_timeDiff);
|
{
|
||||||
|
WorldObject::UpdateHelper helper(iter->getSource());
|
||||||
|
helper.Update(i_timeDiff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void PlayerCreatureRelocationWorker(Player* pl, WorldObject const* viewPoint, Creature* c)
|
inline void PlayerCreatureRelocationWorker(Player* pl, WorldObject const* viewPoint, Creature* c)
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,6 @@ void Map::Update(const uint32 &t_diff)
|
||||||
Player* plr = m_mapRefIter->getSource();
|
Player* plr = m_mapRefIter->getSource();
|
||||||
if(plr && plr->IsInWorld())
|
if(plr && plr->IsInWorld())
|
||||||
{
|
{
|
||||||
//plr->Update(t_diff);
|
|
||||||
WorldSession * pSession = plr->GetSession();
|
WorldSession * pSession = plr->GetSession();
|
||||||
MapSessionFilter updater(pSession);
|
MapSessionFilter updater(pSession);
|
||||||
|
|
||||||
|
|
@ -468,7 +467,10 @@ void Map::Update(const uint32 &t_diff)
|
||||||
{
|
{
|
||||||
Player* plr = m_mapRefIter->getSource();
|
Player* plr = m_mapRefIter->getSource();
|
||||||
if(plr && plr->IsInWorld())
|
if(plr && plr->IsInWorld())
|
||||||
plr->Update(t_diff);
|
{
|
||||||
|
WorldObject::UpdateHelper helper(plr);
|
||||||
|
helper.Update(t_diff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// update active cells around players and active objects
|
/// update active cells around players and active objects
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,10 @@ MapManager::Update(uint32 diff)
|
||||||
iter->second->Update((uint32)i_timer.GetCurrent());
|
iter->second->Update((uint32)i_timer.GetCurrent());
|
||||||
|
|
||||||
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
|
for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
|
||||||
(*iter)->Update((uint32)i_timer.GetCurrent());
|
{
|
||||||
|
WorldObject::UpdateHelper helper((*iter));
|
||||||
|
helper.Update((uint32)i_timer.GetCurrent());
|
||||||
|
}
|
||||||
|
|
||||||
//remove all maps which can be unloaded
|
//remove all maps which can be unloaded
|
||||||
MapMapType::iterator iter = i_maps.begin();
|
MapMapType::iterator iter = i_maps.begin();
|
||||||
|
|
|
||||||
|
|
@ -957,7 +957,7 @@ void WorldSession::HandleNextCinematicCamera( WorldPacket & /*recv_data*/ )
|
||||||
|
|
||||||
void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data )
|
void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data )
|
||||||
{
|
{
|
||||||
/* WorldSession::Update( getMSTime() );*/
|
/* WorldSession::Update( WorldTimer::getMSTime() );*/
|
||||||
DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
|
DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
|
||||||
|
|
||||||
ObjectGuid guid;
|
ObjectGuid guid;
|
||||||
|
|
@ -1339,7 +1339,7 @@ void WorldSession::HandleTimeSyncResp( WorldPacket & recv_data )
|
||||||
|
|
||||||
DEBUG_LOG("Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient);
|
DEBUG_LOG("Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient);
|
||||||
|
|
||||||
uint32 ourTicks = clientTicks + (getMSTime() - _player->m_timeSyncServer);
|
uint32 ourTicks = clientTicks + (WorldTimer::getMSTime() - _player->m_timeSyncServer);
|
||||||
|
|
||||||
// diff should be small
|
// diff should be small
|
||||||
DEBUG_LOG("Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
|
DEBUG_LOG("Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
|
||||||
|
|
|
||||||
|
|
@ -526,7 +526,7 @@ bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, ObjectGu
|
||||||
|
|
||||||
void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
|
void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
|
||||||
{
|
{
|
||||||
movementInfo.UpdateTime(getMSTime());
|
movementInfo.UpdateTime(WorldTimer::getMSTime());
|
||||||
|
|
||||||
Unit *mover = _player->GetMover();
|
Unit *mover = _player->GetMover();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update movement info time
|
// Update movement info time
|
||||||
unit->m_movementInfo.UpdateTime(getMSTime());
|
unit->m_movementInfo.UpdateTime(WorldTimer::getMSTime());
|
||||||
// Write movement info
|
// Write movement info
|
||||||
unit->m_movementInfo.Write(*data);
|
unit->m_movementInfo.Write(*data);
|
||||||
|
|
||||||
|
|
@ -502,7 +502,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
|
||||||
// 0x2
|
// 0x2
|
||||||
if(updateFlags & UPDATEFLAG_TRANSPORT)
|
if(updateFlags & UPDATEFLAG_TRANSPORT)
|
||||||
{
|
{
|
||||||
*data << uint32(getMSTime()); // ms time
|
*data << uint32(WorldTimer::getMSTime()); // ms time
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x80
|
// 0x80
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,28 @@ struct WorldLocation
|
||||||
: mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {}
|
: mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//use this class to measure time between world update ticks
|
||||||
|
//essential for units updating their spells after cells become active
|
||||||
|
class WorldUpdateCounter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WorldUpdateCounter() : m_tmStart(0) {}
|
||||||
|
|
||||||
|
time_t timeElapsed()
|
||||||
|
{
|
||||||
|
if(!m_tmStart)
|
||||||
|
m_tmStart = WorldTimer::tickPrevTime();
|
||||||
|
|
||||||
|
return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset() { m_tmStart = WorldTimer::tickTime(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32 m_tmStart;
|
||||||
|
};
|
||||||
|
|
||||||
class MANGOS_DLL_SPEC Object
|
class MANGOS_DLL_SPEC Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -378,9 +400,31 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
||||||
friend struct WorldObjectChangeAccumulator;
|
friend struct WorldObjectChangeAccumulator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//class is used to manipulate with WorldUpdateCounter
|
||||||
|
//it is needed in order to get time diff between two object's Update() calls
|
||||||
|
class MANGOS_DLL_SPEC UpdateHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit UpdateHelper(WorldObject * obj) : m_obj(obj) {}
|
||||||
|
~UpdateHelper() { }
|
||||||
|
|
||||||
|
void Update( uint32 time_diff )
|
||||||
|
{
|
||||||
|
m_obj->Update( m_obj->m_updateTracker.timeElapsed(), time_diff);
|
||||||
|
m_obj->m_updateTracker.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
UpdateHelper( const UpdateHelper& );
|
||||||
|
UpdateHelper& operator=( const UpdateHelper& );
|
||||||
|
|
||||||
|
WorldObject * const m_obj;
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~WorldObject ( ) {}
|
virtual ~WorldObject ( ) {}
|
||||||
|
|
||||||
virtual void Update ( uint32 /*time_diff*/ ) { }
|
virtual void Update ( uint32 /*update_diff*/, uint32 /*time_diff*/ ) {}
|
||||||
|
|
||||||
void _Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
|
void _Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
|
||||||
|
|
||||||
|
|
@ -555,6 +599,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
||||||
float m_orientation;
|
float m_orientation;
|
||||||
|
|
||||||
ViewPoint m_viewPoint;
|
ViewPoint m_viewPoint;
|
||||||
|
|
||||||
|
WorldUpdateCounter m_updateTracker;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,7 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::Update(uint32 diff)
|
void Pet::Update(uint32 update_diff, uint32 diff)
|
||||||
{
|
{
|
||||||
if(m_removed) // pet already removed, just wait in remove queue, no updates
|
if(m_removed) // pet already removed, just wait in remove queue, no updates
|
||||||
return;
|
return;
|
||||||
|
|
@ -490,7 +490,7 @@ void Pet::Update(uint32 diff)
|
||||||
{
|
{
|
||||||
case CORPSE:
|
case CORPSE:
|
||||||
{
|
{
|
||||||
if (m_corpseDecayTimer <= diff)
|
if (m_corpseDecayTimer <= update_diff)
|
||||||
{
|
{
|
||||||
MANGOS_ASSERT(getPetType()!=SUMMON_PET && "Must be already removed.");
|
MANGOS_ASSERT(getPetType()!=SUMMON_PET && "Must be already removed.");
|
||||||
Unsummon(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER!
|
Unsummon(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER!
|
||||||
|
|
@ -519,8 +519,8 @@ void Pet::Update(uint32 diff)
|
||||||
|
|
||||||
if (m_duration > 0)
|
if (m_duration > 0)
|
||||||
{
|
{
|
||||||
if(m_duration > (int32)diff)
|
if(m_duration > (int32)update_diff)
|
||||||
m_duration -= (int32)diff;
|
m_duration -= (int32)update_diff;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Unsummon(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, owner);
|
Unsummon(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, owner);
|
||||||
|
|
@ -529,7 +529,7 @@ void Pet::Update(uint32 diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
//regenerate focus for hunter pets or energy for deathknight's ghoul
|
//regenerate focus for hunter pets or energy for deathknight's ghoul
|
||||||
if(m_regenTimer <= diff)
|
if(m_regenTimer <= update_diff)
|
||||||
{
|
{
|
||||||
switch (getPowerType())
|
switch (getPowerType())
|
||||||
{
|
{
|
||||||
|
|
@ -543,25 +543,26 @@ void Pet::Update(uint32 diff)
|
||||||
m_regenTimer = 4000;
|
m_regenTimer = 4000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_regenTimer -= diff;
|
m_regenTimer -= update_diff;
|
||||||
|
|
||||||
if(getPetType() != HUNTER_PET)
|
if(getPetType() != HUNTER_PET)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(m_happinessTimer <= diff)
|
if(m_happinessTimer <= update_diff)
|
||||||
{
|
{
|
||||||
LooseHappiness();
|
LooseHappiness();
|
||||||
m_happinessTimer = 7500;
|
m_happinessTimer = 7500;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_happinessTimer -= diff;
|
m_happinessTimer -= update_diff;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Creature::Update(diff);
|
|
||||||
|
Creature::Update(update_diff, diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::Regenerate(Powers power)
|
void Pet::Regenerate(Powers power)
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ class Pet : public Creature
|
||||||
static void DeleteFromDB(uint32 guidlow);
|
static void DeleteFromDB(uint32 guidlow);
|
||||||
|
|
||||||
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
||||||
void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update
|
void Update(uint32 update_diff, uint32 diff); // overwrite virtual Creature::Update and Unit::Update
|
||||||
|
|
||||||
uint8 GetPetAutoSpellSize() const { return m_autospells.size(); }
|
uint8 GetPetAutoSpellSize() const { return m_autospells.size(); }
|
||||||
uint32 GetPetAutoSpellOnPos(uint8 pos) const
|
uint32 GetPetAutoSpellOnPos(uint8 pos) const
|
||||||
|
|
|
||||||
|
|
@ -1190,7 +1190,7 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId)
|
||||||
SendMessageToSet(&data, true);
|
SendMessageToSet(&data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Update( uint32 p_time )
|
void Player::Update( uint32 update_diff, uint32 p_time )
|
||||||
{
|
{
|
||||||
if(!IsInWorld())
|
if(!IsInWorld())
|
||||||
return;
|
return;
|
||||||
|
|
@ -1210,25 +1210,25 @@ void Player::Update( uint32 p_time )
|
||||||
|
|
||||||
//used to implement delayed far teleports
|
//used to implement delayed far teleports
|
||||||
SetCanDelayTeleport(true);
|
SetCanDelayTeleport(true);
|
||||||
Unit::Update( p_time );
|
Unit::Update( update_diff, p_time );
|
||||||
SetCanDelayTeleport(false);
|
SetCanDelayTeleport(false);
|
||||||
|
|
||||||
// update player only attacks
|
// update player only attacks
|
||||||
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
|
if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK))
|
||||||
{
|
{
|
||||||
setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) );
|
setAttackTimer(RANGED_ATTACK, (update_diff >= ranged_att ? 0 : ranged_att - update_diff) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uint32 off_att = getAttackTimer(OFF_ATTACK))
|
if(uint32 off_att = getAttackTimer(OFF_ATTACK))
|
||||||
{
|
{
|
||||||
setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) );
|
setAttackTimer(OFF_ATTACK, (update_diff >= off_att ? 0 : off_att - update_diff) );
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t now = time (NULL);
|
time_t now = time (NULL);
|
||||||
|
|
||||||
UpdatePvPFlag(now);
|
UpdatePvPFlag(now);
|
||||||
|
|
||||||
UpdateContestedPvP(p_time);
|
UpdateContestedPvP(update_diff);
|
||||||
|
|
||||||
UpdateDuelFlag(now);
|
UpdateDuelFlag(now);
|
||||||
|
|
||||||
|
|
@ -1246,7 +1246,7 @@ void Player::Update( uint32 p_time )
|
||||||
while (iter != m_timedquests.end())
|
while (iter != m_timedquests.end())
|
||||||
{
|
{
|
||||||
QuestStatusData& q_status = mQuestStatus[*iter];
|
QuestStatusData& q_status = mQuestStatus[*iter];
|
||||||
if( q_status.m_timer <= p_time )
|
if( q_status.m_timer <= update_diff )
|
||||||
{
|
{
|
||||||
uint32 quest_id = *iter;
|
uint32 quest_id = *iter;
|
||||||
++iter; // current iter will be removed in FailQuest
|
++iter; // current iter will be removed in FailQuest
|
||||||
|
|
@ -1254,7 +1254,7 @@ void Player::Update( uint32 p_time )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
q_status.m_timer -= p_time;
|
q_status.m_timer -= update_diff;
|
||||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
@ -1357,23 +1357,23 @@ void Player::Update( uint32 p_time )
|
||||||
|
|
||||||
if (m_regenTimer)
|
if (m_regenTimer)
|
||||||
{
|
{
|
||||||
if(p_time >= m_regenTimer)
|
if(update_diff >= m_regenTimer)
|
||||||
m_regenTimer = 0;
|
m_regenTimer = 0;
|
||||||
else
|
else
|
||||||
m_regenTimer -= p_time;
|
m_regenTimer -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_weaponChangeTimer > 0)
|
if (m_weaponChangeTimer > 0)
|
||||||
{
|
{
|
||||||
if(p_time >= m_weaponChangeTimer)
|
if(update_diff >= m_weaponChangeTimer)
|
||||||
m_weaponChangeTimer = 0;
|
m_weaponChangeTimer = 0;
|
||||||
else
|
else
|
||||||
m_weaponChangeTimer -= p_time;
|
m_weaponChangeTimer -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_zoneUpdateTimer > 0)
|
if (m_zoneUpdateTimer > 0)
|
||||||
{
|
{
|
||||||
if(p_time >= m_zoneUpdateTimer)
|
if(update_diff >= m_zoneUpdateTimer)
|
||||||
{
|
{
|
||||||
uint32 newzone, newarea;
|
uint32 newzone, newarea;
|
||||||
GetZoneAndAreaId(newzone,newarea);
|
GetZoneAndAreaId(newzone,newarea);
|
||||||
|
|
@ -1391,15 +1391,15 @@ void Player::Update( uint32 p_time )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_zoneUpdateTimer -= p_time;
|
m_zoneUpdateTimer -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_timeSyncTimer > 0)
|
if (m_timeSyncTimer > 0)
|
||||||
{
|
{
|
||||||
if(p_time >= m_timeSyncTimer)
|
if(update_diff >= m_timeSyncTimer)
|
||||||
SendTimeSync();
|
SendTimeSync();
|
||||||
else
|
else
|
||||||
m_timeSyncTimer -= p_time;
|
m_timeSyncTimer -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAlive())
|
if (isAlive())
|
||||||
|
|
@ -1417,29 +1417,29 @@ void Player::Update( uint32 p_time )
|
||||||
|
|
||||||
if(m_nextSave > 0)
|
if(m_nextSave > 0)
|
||||||
{
|
{
|
||||||
if(p_time >= m_nextSave)
|
if(update_diff >= m_nextSave)
|
||||||
{
|
{
|
||||||
// m_nextSave reseted in SaveToDB call
|
// m_nextSave reseted in SaveToDB call
|
||||||
SaveToDB();
|
SaveToDB();
|
||||||
DETAIL_LOG("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow());
|
DETAIL_LOG("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_nextSave -= p_time;
|
m_nextSave -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle Water/drowning
|
//Handle Water/drowning
|
||||||
HandleDrowning(p_time);
|
HandleDrowning(update_diff);
|
||||||
|
|
||||||
//Handle detect stealth players
|
//Handle detect stealth players
|
||||||
if (m_DetectInvTimer > 0)
|
if (m_DetectInvTimer > 0)
|
||||||
{
|
{
|
||||||
if (p_time >= m_DetectInvTimer)
|
if (update_diff >= m_DetectInvTimer)
|
||||||
{
|
{
|
||||||
HandleStealthedUnitsDetection();
|
HandleStealthedUnitsDetection();
|
||||||
m_DetectInvTimer = 3000;
|
m_DetectInvTimer = 3000;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_DetectInvTimer -= p_time;
|
m_DetectInvTimer -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Played time
|
// Played time
|
||||||
|
|
@ -1453,7 +1453,7 @@ void Player::Update( uint32 p_time )
|
||||||
|
|
||||||
if (m_drunk)
|
if (m_drunk)
|
||||||
{
|
{
|
||||||
m_drunkTimer += p_time;
|
m_drunkTimer += update_diff;
|
||||||
|
|
||||||
if (m_drunkTimer > 10*IN_MILLISECONDS)
|
if (m_drunkTimer > 10*IN_MILLISECONDS)
|
||||||
HandleSobering();
|
HandleSobering();
|
||||||
|
|
@ -1472,8 +1472,8 @@ void Player::Update( uint32 p_time )
|
||||||
m_deathTimer -= p_time;
|
m_deathTimer -= p_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateEnchantTime(p_time);
|
UpdateEnchantTime(update_diff);
|
||||||
UpdateHomebindTime(p_time);
|
UpdateHomebindTime(update_diff);
|
||||||
|
|
||||||
// group update
|
// group update
|
||||||
SendUpdateToOutOfRangeGroupMembers();
|
SendUpdateToOutOfRangeGroupMembers();
|
||||||
|
|
@ -21063,7 +21063,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
|
||||||
data << uint32(0); // counter?
|
data << uint32(0); // counter?
|
||||||
data << uint32(MOVEFLAG_ONTRANSPORT); // transport
|
data << uint32(MOVEFLAG_ONTRANSPORT); // transport
|
||||||
data << uint16(0); // special flags
|
data << uint16(0); // special flags
|
||||||
data << uint32(getMSTime()); // time
|
data << uint32(WorldTimer::getMSTime()); // time
|
||||||
data << vehicle->GetPositionX(); // x
|
data << vehicle->GetPositionX(); // x
|
||||||
data << vehicle->GetPositionY(); // y
|
data << vehicle->GetPositionY(); // y
|
||||||
data << vehicle->GetPositionZ(); // z
|
data << vehicle->GetPositionZ(); // z
|
||||||
|
|
@ -21074,7 +21074,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
|
||||||
data << float(veSeat->m_attachmentOffsetY); // transport offsetY
|
data << float(veSeat->m_attachmentOffsetY); // transport offsetY
|
||||||
data << float(veSeat->m_attachmentOffsetZ); // transport offsetZ
|
data << float(veSeat->m_attachmentOffsetZ); // transport offsetZ
|
||||||
data << float(0); // transport orientation
|
data << float(0); // transport orientation
|
||||||
data << uint32(getMSTime()); // transport time
|
data << uint32(WorldTimer::getMSTime()); // transport time
|
||||||
data << uint8(0); // seat
|
data << uint8(0); // seat
|
||||||
// end of transport part
|
// end of transport part
|
||||||
data << uint32(0); // fall time
|
data << uint32(0); // fall time
|
||||||
|
|
@ -21112,7 +21112,7 @@ void Player::ExitVehicle(Vehicle *vehicle)
|
||||||
data << uint32(0); // counter?
|
data << uint32(0); // counter?
|
||||||
data << uint32(MOVEFLAG_ROOT); // fly unk
|
data << uint32(MOVEFLAG_ROOT); // fly unk
|
||||||
data << uint16(MOVEFLAG2_UNK4); // special flags
|
data << uint16(MOVEFLAG2_UNK4); // special flags
|
||||||
data << uint32(getMSTime()); // time
|
data << uint32(WorldTimer::getMSTime()); // time
|
||||||
data << vehicle->GetPositionX(); // x
|
data << vehicle->GetPositionX(); // x
|
||||||
data << vehicle->GetPositionY(); // y
|
data << vehicle->GetPositionY(); // y
|
||||||
data << vehicle->GetPositionZ(); // z
|
data << vehicle->GetPositionZ(); // z
|
||||||
|
|
@ -22387,7 +22387,7 @@ void Player::BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z,
|
||||||
*data << uint32(0); // this value increments every time
|
*data << uint32(0); // this value increments every time
|
||||||
*data << uint32(m_movementInfo.GetMovementFlags()); // movement flags
|
*data << uint32(m_movementInfo.GetMovementFlags()); // movement flags
|
||||||
*data << uint16(0); // 2.3.0
|
*data << uint16(0); // 2.3.0
|
||||||
*data << uint32(getMSTime()); // time
|
*data << uint32(WorldTimer::getMSTime()); // time
|
||||||
*data << x;
|
*data << x;
|
||||||
*data << y;
|
*data << y;
|
||||||
*data << z;
|
*data << z;
|
||||||
|
|
@ -22405,7 +22405,7 @@ void Player::ResetTimeSync()
|
||||||
m_timeSyncCounter = 0;
|
m_timeSyncCounter = 0;
|
||||||
m_timeSyncTimer = 0;
|
m_timeSyncTimer = 0;
|
||||||
m_timeSyncClient = 0;
|
m_timeSyncClient = 0;
|
||||||
m_timeSyncServer = getMSTime();
|
m_timeSyncServer = WorldTimer::getMSTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendTimeSync()
|
void Player::SendTimeSync()
|
||||||
|
|
@ -22416,7 +22416,7 @@ void Player::SendTimeSync()
|
||||||
|
|
||||||
// Schedule next sync in 10 sec
|
// Schedule next sync in 10 sec
|
||||||
m_timeSyncTimer = 10000;
|
m_timeSyncTimer = 10000;
|
||||||
m_timeSyncServer = getMSTime();
|
m_timeSyncServer = WorldTimer::getMSTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendDuelCountdown(uint32 counter)
|
void Player::SendDuelCountdown(uint32 counter)
|
||||||
|
|
|
||||||
|
|
@ -1126,7 +1126,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
|
|
||||||
bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId );
|
bool Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId );
|
||||||
|
|
||||||
void Update( uint32 time );
|
void Update( uint32 update_diff, uint32 time );
|
||||||
|
|
||||||
static bool BuildEnumData( QueryResult * result, WorldPacket * p_data );
|
static bool BuildEnumData( QueryResult * result, WorldPacket * p_data );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3587,7 +3587,7 @@ void Spell::SendSpellGo()
|
||||||
data << uint8(m_cast_count); // pending spell cast?
|
data << uint8(m_cast_count); // pending spell cast?
|
||||||
data << uint32(m_spellInfo->Id); // spellId
|
data << uint32(m_spellInfo->Id); // spellId
|
||||||
data << uint32(castFlags); // cast flags
|
data << uint32(castFlags); // cast flags
|
||||||
data << uint32(getMSTime()); // timestamp
|
data << uint32(WorldTimer::getMSTime()); // timestamp
|
||||||
|
|
||||||
WriteSpellGoTargets(&data);
|
WriteSpellGoTargets(&data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ Creature(CREATURE_SUBTYPE_TEMPORARY_SUMMON), m_type(TEMPSUMMON_TIMED_OR_CORPSE_D
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemporarySummon::Update( uint32 diff )
|
void TemporarySummon::Update( uint32 update_diff, uint32 diff )
|
||||||
{
|
{
|
||||||
switch(m_type)
|
switch(m_type)
|
||||||
{
|
{
|
||||||
|
|
@ -34,26 +34,26 @@ void TemporarySummon::Update( uint32 diff )
|
||||||
break;
|
break;
|
||||||
case TEMPSUMMON_TIMED_DESPAWN:
|
case TEMPSUMMON_TIMED_DESPAWN:
|
||||||
{
|
{
|
||||||
if (m_timer <= diff)
|
if (m_timer <= update_diff)
|
||||||
{
|
{
|
||||||
UnSummon();
|
UnSummon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_timer -= diff;
|
m_timer -= update_diff;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT:
|
case TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT:
|
||||||
{
|
{
|
||||||
if (!isInCombat())
|
if (!isInCombat())
|
||||||
{
|
{
|
||||||
if (m_timer <= diff)
|
if (m_timer <= update_diff)
|
||||||
{
|
{
|
||||||
UnSummon();
|
UnSummon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_timer -= diff;
|
m_timer -= update_diff;
|
||||||
}
|
}
|
||||||
else if (m_timer != m_lifetime)
|
else if (m_timer != m_lifetime)
|
||||||
m_timer = m_lifetime;
|
m_timer = m_lifetime;
|
||||||
|
|
@ -65,13 +65,13 @@ void TemporarySummon::Update( uint32 diff )
|
||||||
{
|
{
|
||||||
if (IsCorpse())
|
if (IsCorpse())
|
||||||
{
|
{
|
||||||
if (m_timer <= diff)
|
if (m_timer <= update_diff)
|
||||||
{
|
{
|
||||||
UnSummon();
|
UnSummon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_timer -= diff;
|
m_timer -= update_diff;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -106,13 +106,13 @@ void TemporarySummon::Update( uint32 diff )
|
||||||
|
|
||||||
if (!isInCombat())
|
if (!isInCombat())
|
||||||
{
|
{
|
||||||
if (m_timer <= diff)
|
if (m_timer <= update_diff)
|
||||||
{
|
{
|
||||||
UnSummon();
|
UnSummon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_timer -= diff;
|
m_timer -= update_diff;
|
||||||
}
|
}
|
||||||
else if (m_timer != m_lifetime)
|
else if (m_timer != m_lifetime)
|
||||||
m_timer = m_lifetime;
|
m_timer = m_lifetime;
|
||||||
|
|
@ -129,13 +129,13 @@ void TemporarySummon::Update( uint32 diff )
|
||||||
|
|
||||||
if (!isInCombat() && isAlive() )
|
if (!isInCombat() && isAlive() )
|
||||||
{
|
{
|
||||||
if (m_timer <= diff)
|
if (m_timer <= update_diff)
|
||||||
{
|
{
|
||||||
UnSummon();
|
UnSummon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_timer -= diff;
|
m_timer -= update_diff;
|
||||||
}
|
}
|
||||||
else if (m_timer != m_lifetime)
|
else if (m_timer != m_lifetime)
|
||||||
m_timer = m_lifetime;
|
m_timer = m_lifetime;
|
||||||
|
|
@ -147,7 +147,7 @@ void TemporarySummon::Update( uint32 diff )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Creature::Update( diff );
|
Creature::Update( update_diff, diff );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemporarySummon::Summon(TempSummonType type, uint32 lifetime)
|
void TemporarySummon::Summon(TempSummonType type, uint32 lifetime)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class TemporarySummon : public Creature
|
||||||
public:
|
public:
|
||||||
explicit TemporarySummon(ObjectGuid summoner = ObjectGuid());
|
explicit TemporarySummon(ObjectGuid summoner = ObjectGuid());
|
||||||
virtual ~TemporarySummon(){};
|
virtual ~TemporarySummon(){};
|
||||||
void Update(uint32 time);
|
void Update(uint32 update_diff, uint32 time);
|
||||||
void Summon(TempSummonType type, uint32 lifetime);
|
void Summon(TempSummonType type, uint32 lifetime);
|
||||||
void MANGOS_DLL_SPEC UnSummon();
|
void MANGOS_DLL_SPEC UnSummon();
|
||||||
void SaveToDB();
|
void SaveToDB();
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
|
||||||
m_type = TOTEM_PASSIVE;
|
m_type = TOTEM_PASSIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Totem::Update( uint32 time )
|
void Totem::Update(uint32 update_diff, uint32 time )
|
||||||
{
|
{
|
||||||
Unit *owner = GetOwner();
|
Unit *owner = GetOwner();
|
||||||
if (!owner || !owner->isAlive() || !isAlive())
|
if (!owner || !owner->isAlive() || !isAlive())
|
||||||
|
|
@ -40,15 +40,15 @@ void Totem::Update( uint32 time )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_duration <= time)
|
if (m_duration <= update_diff)
|
||||||
{
|
{
|
||||||
UnSummon(); // remove self
|
UnSummon(); // remove self
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_duration -= time;
|
m_duration -= update_diff;
|
||||||
|
|
||||||
Creature::Update( time );
|
Creature::Update( update_diff, time );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Totem::Summon(Unit* owner)
|
void Totem::Summon(Unit* owner)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class Totem : public Creature
|
||||||
public:
|
public:
|
||||||
explicit Totem();
|
explicit Totem();
|
||||||
virtual ~Totem(){};
|
virtual ~Totem(){};
|
||||||
void Update( uint32 time );
|
void Update(uint32 update_diff, uint32 time );
|
||||||
void Summon(Unit* owner);
|
void Summon(Unit* owner);
|
||||||
void UnSummon();
|
void UnSummon();
|
||||||
uint32 GetSpell() const { return m_spells[0]; }
|
uint32 GetSpell() const { return m_spells[0]; }
|
||||||
|
|
|
||||||
|
|
@ -497,12 +497,12 @@ bool Transport::RemovePassenger(Player* passenger)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transport::Update(uint32 /*p_time*/)
|
void Transport::Update( uint32 update_diff, uint32 /*p_time*/)
|
||||||
{
|
{
|
||||||
if (m_WayPoints.size() <= 1)
|
if (m_WayPoints.size() <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_timer = getMSTime() % m_period;
|
m_timer = WorldTimer::getMSTime() % m_period;
|
||||||
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
|
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class Transport : public GameObject
|
||||||
|
|
||||||
bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue);
|
bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue);
|
||||||
bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids);
|
bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids);
|
||||||
void Update(uint32 p_time);
|
void Update(uint32 update_diff, uint32 p_time);
|
||||||
bool AddPassenger(Player* passenger);
|
bool AddPassenger(Player* passenger);
|
||||||
bool RemovePassenger(Player* passenger);
|
bool RemovePassenger(Player* passenger);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,12 +164,12 @@ void MovementInfo::Write(ByteBuffer &data) const
|
||||||
bool GlobalCooldownMgr::HasGlobalCooldown(SpellEntry const* spellInfo) const
|
bool GlobalCooldownMgr::HasGlobalCooldown(SpellEntry const* spellInfo) const
|
||||||
{
|
{
|
||||||
GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory);
|
GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory);
|
||||||
return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, getMSTime()) < itr->second.duration;
|
return itr != m_GlobalCooldowns.end() && itr->second.duration && WorldTimer::getMSTimeDiff(itr->second.cast_time, WorldTimer::getMSTime()) < itr->second.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalCooldownMgr::AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd)
|
void GlobalCooldownMgr::AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd)
|
||||||
{
|
{
|
||||||
m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, getMSTime());
|
m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, WorldTimer::getMSTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo)
|
void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo)
|
||||||
|
|
@ -289,7 +289,7 @@ Unit::~Unit()
|
||||||
MANGOS_ASSERT(m_deletedHolders.size() == 0);
|
MANGOS_ASSERT(m_deletedHolders.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::Update( uint32 p_time )
|
void Unit::Update( uint32 update_diff, uint32 p_time )
|
||||||
{
|
{
|
||||||
if(!IsInWorld())
|
if(!IsInWorld())
|
||||||
return;
|
return;
|
||||||
|
|
@ -304,21 +304,21 @@ void Unit::Update( uint32 p_time )
|
||||||
// WARNING! Order of execution here is important, do not change.
|
// WARNING! Order of execution here is important, do not change.
|
||||||
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
|
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
|
||||||
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
|
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
|
||||||
m_Events.Update( p_time );
|
m_Events.Update( update_diff );
|
||||||
_UpdateSpells( p_time );
|
_UpdateSpells( update_diff );
|
||||||
|
|
||||||
CleanupDeletedAuras();
|
CleanupDeletedAuras();
|
||||||
|
|
||||||
if (m_lastManaUseTimer)
|
if (m_lastManaUseTimer)
|
||||||
{
|
{
|
||||||
if (p_time >= m_lastManaUseTimer)
|
if (update_diff >= m_lastManaUseTimer)
|
||||||
m_lastManaUseTimer = 0;
|
m_lastManaUseTimer = 0;
|
||||||
else
|
else
|
||||||
m_lastManaUseTimer -= p_time;
|
m_lastManaUseTimer -= update_diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CanHaveThreatList())
|
if (CanHaveThreatList())
|
||||||
getThreatManager().UpdateForClient(p_time);
|
getThreatManager().UpdateForClient(update_diff);
|
||||||
|
|
||||||
// update combat timer only for players and pets
|
// update combat timer only for players and pets
|
||||||
if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->IsPet() || ((Creature*)this)->isCharmed()))
|
if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->IsPet() || ((Creature*)this)->isCharmed()))
|
||||||
|
|
@ -329,20 +329,20 @@ void Unit::Update( uint32 p_time )
|
||||||
if (m_HostileRefManager.isEmpty())
|
if (m_HostileRefManager.isEmpty())
|
||||||
{
|
{
|
||||||
// m_CombatTimer set at aura start and it will be freeze until aura removing
|
// m_CombatTimer set at aura start and it will be freeze until aura removing
|
||||||
if (m_CombatTimer <= p_time)
|
if (m_CombatTimer <= update_diff)
|
||||||
CombatStop();
|
CombatStop();
|
||||||
else
|
else
|
||||||
m_CombatTimer -= p_time;
|
m_CombatTimer -= update_diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uint32 base_att = getAttackTimer(BASE_ATTACK))
|
if (uint32 base_att = getAttackTimer(BASE_ATTACK))
|
||||||
{
|
{
|
||||||
setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time) );
|
setAttackTimer(BASE_ATTACK, (update_diff >= base_att ? 0 : base_att - update_diff) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// update abilities available only for fraction of time
|
// update abilities available only for fraction of time
|
||||||
UpdateReactives( p_time );
|
UpdateReactives( update_diff );
|
||||||
|
|
||||||
ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f);
|
ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f);
|
||||||
ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f);
|
ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f);
|
||||||
|
|
@ -371,7 +371,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy
|
||||||
data << GetPackGUID();
|
data << GetPackGUID();
|
||||||
data << uint8(0); // new in 3.1 bool, used to toggle MOVEFLAG2_UNK4 = 0x0040 on client side
|
data << uint8(0); // new in 3.1 bool, used to toggle MOVEFLAG2_UNK4 = 0x0040 on client side
|
||||||
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
data << GetPositionX() << GetPositionY() << GetPositionZ();
|
||||||
data << uint32(getMSTime());
|
data << uint32(WorldTimer::getMSTime());
|
||||||
|
|
||||||
data << uint8(type); // unknown
|
data << uint8(type); // unknown
|
||||||
switch(type)
|
switch(type)
|
||||||
|
|
@ -8351,7 +8351,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced)
|
||||||
data << GetPackGUID();
|
data << GetPackGUID();
|
||||||
data << uint32(0); // movement flags
|
data << uint32(0); // movement flags
|
||||||
data << uint16(0); // unk flags
|
data << uint16(0); // unk flags
|
||||||
data << uint32(getMSTime());
|
data << uint32(WorldTimer::getMSTime());
|
||||||
data << float(GetPositionX());
|
data << float(GetPositionX());
|
||||||
data << float(GetPositionY());
|
data << float(GetPositionY());
|
||||||
data << float(GetPositionZ());
|
data << float(GetPositionZ());
|
||||||
|
|
@ -8820,7 +8820,7 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)
|
||||||
return DIMINISHING_LEVEL_1;
|
return DIMINISHING_LEVEL_1;
|
||||||
|
|
||||||
// If last spell was casted more than 15 seconds ago - reset the count.
|
// If last spell was casted more than 15 seconds ago - reset the count.
|
||||||
if (i->stack==0 && getMSTimeDiff(i->hitTime,getMSTime()) > 15*IN_MILLISECONDS)
|
if (i->stack==0 && WorldTimer::getMSTimeDiff(i->hitTime,WorldTimer::getMSTime()) > 15*IN_MILLISECONDS)
|
||||||
{
|
{
|
||||||
i->hitCount = DIMINISHING_LEVEL_1;
|
i->hitCount = DIMINISHING_LEVEL_1;
|
||||||
return DIMINISHING_LEVEL_1;
|
return DIMINISHING_LEVEL_1;
|
||||||
|
|
@ -8845,7 +8845,7 @@ void Unit::IncrDiminishing(DiminishingGroup group)
|
||||||
i->hitCount += 1;
|
i->hitCount += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_Diminishing.push_back(DiminishingReturn(group,getMSTime(),DIMINISHING_LEVEL_2));
|
m_Diminishing.push_back(DiminishingReturn(group,WorldTimer::getMSTime(),DIMINISHING_LEVEL_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level, int32 limitduration)
|
void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level, int32 limitduration)
|
||||||
|
|
@ -8901,7 +8901,7 @@ void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply )
|
||||||
i->stack -= 1;
|
i->stack -= 1;
|
||||||
// Remember time after last aura from group removed
|
// Remember time after last aura from group removed
|
||||||
if (i->stack == 0)
|
if (i->stack == 0)
|
||||||
i->hitTime = getMSTime();
|
i->hitTime = WorldTimer::getMSTime();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1186,7 +1186,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
|
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
|
||||||
void ClearDiminishings() { m_Diminishing.clear(); }
|
void ClearDiminishings() { m_Diminishing.clear(); }
|
||||||
|
|
||||||
virtual void Update( uint32 time );
|
virtual void Update( uint32 update_diff, uint32 time );
|
||||||
|
|
||||||
void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
|
void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; }
|
||||||
void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
|
void resetAttackTimer(WeaponAttackType type = BASE_ATTACK);
|
||||||
|
|
@ -2132,7 +2132,7 @@ inline void Unit::SendMonsterMoveByPath(Path<Elem,Node> const& path, uint32 star
|
||||||
data << GetPositionX();
|
data << GetPositionX();
|
||||||
data << GetPositionY();
|
data << GetPositionY();
|
||||||
data << GetPositionZ();
|
data << GetPositionZ();
|
||||||
data << uint32(getMSTime());
|
data << uint32(WorldTimer::getMSTime());
|
||||||
data << uint8(SPLINETYPE_NORMAL);
|
data << uint8(SPLINETYPE_NORMAL);
|
||||||
data << uint32(flags);
|
data << uint32(flags);
|
||||||
data << uint32(traveltime);
|
data << uint32(traveltime);
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,9 @@ void Vehicle::SetDeathState(DeathState s) // overwrite vir
|
||||||
Creature::SetDeathState(s);
|
Creature::SetDeathState(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vehicle::Update(uint32 diff)
|
void Vehicle::Update( uint32 update_diff, uint32 diff)
|
||||||
{
|
{
|
||||||
Creature::Update(diff);
|
Creature::Update(update_diff, diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, Team team)
|
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, Team team)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class Vehicle : public Creature
|
||||||
bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, Team team);
|
bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, Team team);
|
||||||
|
|
||||||
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
||||||
void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update
|
void Update(uint32 update_diff, uint32 diff); // overwrite virtual Creature::Update and Unit::Update
|
||||||
|
|
||||||
uint32 GetVehicleId() { return m_vehicleId; }
|
uint32 GetVehicleId() { return m_vehicleId; }
|
||||||
void SetVehicleId(uint32 vehicleid) { m_vehicleId = vehicleid; }
|
void SetVehicleId(uint32 vehicleid) { m_vehicleId = vehicleid; }
|
||||||
|
|
|
||||||
|
|
@ -875,7 +875,7 @@ void World::SetInitialWorldSettings()
|
||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
|
|
||||||
///- Time server startup
|
///- Time server startup
|
||||||
uint32 uStartTime = getMSTime();
|
uint32 uStartTime = WorldTimer::getMSTime();
|
||||||
|
|
||||||
///- Initialize config settings
|
///- Initialize config settings
|
||||||
LoadConfigSettings();
|
LoadConfigSettings();
|
||||||
|
|
@ -1330,7 +1330,7 @@ void World::SetInitialWorldSettings()
|
||||||
|
|
||||||
sLog.outString( "WORLD: World initialized" );
|
sLog.outString( "WORLD: World initialized" );
|
||||||
|
|
||||||
uint32 uStartInterval = getMSTimeDiff(uStartTime, getMSTime());
|
uint32 uStartInterval = WorldTimer::getMSTimeDiff(uStartTime, WorldTimer::getMSTime());
|
||||||
sLog.outString( "SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000 );
|
sLog.outString( "SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
{
|
{
|
||||||
ACE_Based::Thread::Sleep(1000);
|
ACE_Based::Thread::Sleep(1000);
|
||||||
|
|
||||||
uint32 curtime = getMSTime();
|
uint32 curtime = WorldTimer::getMSTime();
|
||||||
//DEBUG_LOG("anti-freeze: time=%u, counters=[%u; %u]",curtime,Master::m_masterLoopCounter,World::m_worldLoopCounter);
|
//DEBUG_LOG("anti-freeze: time=%u, counters=[%u; %u]",curtime,Master::m_masterLoopCounter,World::m_worldLoopCounter);
|
||||||
|
|
||||||
// normal work
|
// normal work
|
||||||
|
|
@ -83,7 +83,7 @@ public:
|
||||||
w_loops = World::m_worldLoopCounter;
|
w_loops = World::m_worldLoopCounter;
|
||||||
}
|
}
|
||||||
// possible freeze
|
// possible freeze
|
||||||
else if (getMSTimeDiff(w_lastchange, curtime) > _delaytime)
|
else if (WorldTimer::getMSTimeDiff(w_lastchange, curtime) > _delaytime)
|
||||||
{
|
{
|
||||||
sLog.outError("World Thread hangs, kicking out server!");
|
sLog.outError("World Thread hangs, kicking out server!");
|
||||||
*((uint32 volatile*)NULL) = 0; // bang crash
|
*((uint32 volatile*)NULL) = 0; // bang crash
|
||||||
|
|
@ -285,7 +285,7 @@ int Master::Run()
|
||||||
|
|
||||||
|
|
||||||
uint32 realCurrTime, realPrevTime;
|
uint32 realCurrTime, realPrevTime;
|
||||||
realCurrTime = realPrevTime = getMSTime();
|
realCurrTime = realPrevTime = WorldTimer::getMSTime();
|
||||||
|
|
||||||
///- Start up freeze catcher thread
|
///- Start up freeze catcher thread
|
||||||
ACE_Based::Thread* freeze_thread = NULL;
|
ACE_Based::Thread* freeze_thread = NULL;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ void WorldRunnable::run()
|
||||||
sWorld.InitResultQueue();
|
sWorld.InitResultQueue();
|
||||||
|
|
||||||
uint32 realCurrTime = 0;
|
uint32 realCurrTime = 0;
|
||||||
uint32 realPrevTime = getMSTime();
|
uint32 realPrevTime = WorldTimer::tick();
|
||||||
|
|
||||||
uint32 prevSleepTime = 0; // used for balanced full tick time length near WORLD_SLEEP_CONST
|
uint32 prevSleepTime = 0; // used for balanced full tick time length near WORLD_SLEEP_CONST
|
||||||
|
|
||||||
|
|
@ -53,9 +53,9 @@ void WorldRunnable::run()
|
||||||
while (!World::IsStopped())
|
while (!World::IsStopped())
|
||||||
{
|
{
|
||||||
++World::m_worldLoopCounter;
|
++World::m_worldLoopCounter;
|
||||||
realCurrTime = getMSTime();
|
realCurrTime = WorldTimer::getMSTime();
|
||||||
|
|
||||||
uint32 diff = getMSTimeDiff(realPrevTime,realCurrTime);
|
uint32 diff = WorldTimer::tick();
|
||||||
|
|
||||||
sWorld.Update( diff );
|
sWorld.Update( diff );
|
||||||
realPrevTime = realCurrTime;
|
realPrevTime = realCurrTime;
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ bool DatabaseMysql::_Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **p
|
||||||
// guarded block for thread-safe mySQL request
|
// guarded block for thread-safe mySQL request
|
||||||
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
|
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
|
||||||
|
|
||||||
uint32 _s = getMSTime();
|
uint32 _s = WorldTimer::getMSTime();
|
||||||
|
|
||||||
if(mysql_query(mMysql, sql))
|
if(mysql_query(mMysql, sql))
|
||||||
{
|
{
|
||||||
|
|
@ -196,7 +196,7 @@ bool DatabaseMysql::_Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **p
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", getMSTimeDiff(_s,getMSTime()), sql );
|
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql );
|
||||||
}
|
}
|
||||||
|
|
||||||
*pResult = mysql_store_result(mMysql);
|
*pResult = mysql_store_result(mMysql);
|
||||||
|
|
@ -290,7 +290,7 @@ bool DatabaseMysql::DirectExecute(const char* sql)
|
||||||
// guarded block for thread-safe mySQL request
|
// guarded block for thread-safe mySQL request
|
||||||
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
|
ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
|
||||||
|
|
||||||
uint32 _s = getMSTime();
|
uint32 _s = WorldTimer::getMSTime();
|
||||||
|
|
||||||
if(mysql_query(mMysql, sql))
|
if(mysql_query(mMysql, sql))
|
||||||
{
|
{
|
||||||
|
|
@ -300,7 +300,7 @@ bool DatabaseMysql::DirectExecute(const char* sql)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", getMSTimeDiff(_s,getMSTime()), sql );
|
DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql );
|
||||||
}
|
}
|
||||||
// end guarded block
|
// end guarded block
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,44 @@
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <ace/OS_NS_sys_time.h>
|
#include <ace/OS_NS_sys_time.h>
|
||||||
|
|
||||||
inline uint32 getMSTime()
|
class WorldTimer
|
||||||
{
|
{
|
||||||
static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday();
|
public:
|
||||||
return (ACE_OS::gettimeofday() - ApplicationStartTime).msec();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
|
//get current server time
|
||||||
{
|
static uint32 getMSTime();
|
||||||
// getMSTime() have limited data range and this is case when it overflow in this tick
|
|
||||||
|
//get time difference between two timestamps
|
||||||
|
static inline uint32 getMSTimeDiff(const uint32& oldMSTime, const uint32& newMSTime)
|
||||||
|
{
|
||||||
if (oldMSTime > newMSTime)
|
if (oldMSTime > newMSTime)
|
||||||
return (uint32(0xFFFFFFFF) - oldMSTime) + newMSTime;
|
{
|
||||||
else
|
const uint32 diff_1 = (uint32(0xFFFFFFFF) - oldMSTime) + newMSTime;
|
||||||
|
const uint32 diff_2 = oldMSTime - newMSTime;
|
||||||
|
|
||||||
|
return std::min(diff_1, diff_2);
|
||||||
|
}
|
||||||
|
|
||||||
return newMSTime - oldMSTime;
|
return newMSTime - oldMSTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get last world tick time
|
||||||
|
static MANGOS_DLL_SPEC uint32 tickTime();
|
||||||
|
//get previous world tick time
|
||||||
|
static MANGOS_DLL_SPEC uint32 tickPrevTime();
|
||||||
|
//tick world timer
|
||||||
|
static MANGOS_DLL_SPEC uint32 tick();
|
||||||
|
|
||||||
|
private:
|
||||||
|
WorldTimer();
|
||||||
|
WorldTimer(const WorldTimer& );
|
||||||
|
|
||||||
|
//analogue to getMSTime() but it persists m_SystemTickTime
|
||||||
|
static uint32 getMSTime_internal(bool savetime = false);
|
||||||
|
|
||||||
|
static MANGOS_DLL_SPEC uint32 m_iTime;
|
||||||
|
static MANGOS_DLL_SPEC uint32 m_iPrevTime;
|
||||||
|
};
|
||||||
|
|
||||||
class IntervalTimer
|
class IntervalTimer
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
#include "utf8cpp/utf8.h"
|
#include "utf8cpp/utf8.h"
|
||||||
#include "mersennetwister/MersenneTwister.h"
|
#include "mersennetwister/MersenneTwister.h"
|
||||||
|
|
@ -26,6 +27,60 @@
|
||||||
typedef ACE_TSS<MTRand> MTRandTSS;
|
typedef ACE_TSS<MTRand> MTRandTSS;
|
||||||
static MTRandTSS mtRand;
|
static MTRandTSS mtRand;
|
||||||
|
|
||||||
|
static uint64 g_SystemTickTime = ACE_OS::gettimeofday().get_msec();
|
||||||
|
|
||||||
|
uint32 WorldTimer::m_iTime = 0;
|
||||||
|
uint32 WorldTimer::m_iPrevTime = 0;
|
||||||
|
|
||||||
|
uint32 WorldTimer::tickTime() { return m_iTime; }
|
||||||
|
uint32 WorldTimer::tickPrevTime() { return m_iPrevTime; }
|
||||||
|
|
||||||
|
uint32 WorldTimer::tick()
|
||||||
|
{
|
||||||
|
//save previous world tick time
|
||||||
|
m_iPrevTime = m_iTime;
|
||||||
|
|
||||||
|
//get the new one and don't forget to persist current system time in m_SystemTickTime
|
||||||
|
m_iTime = WorldTimer::getMSTime_internal(true);
|
||||||
|
|
||||||
|
//return tick diff
|
||||||
|
return getMSTimeDiff(m_iPrevTime, m_iTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 WorldTimer::getMSTime()
|
||||||
|
{
|
||||||
|
return getMSTime_internal();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 WorldTimer::getMSTime_internal(bool savetime /*= false*/)
|
||||||
|
{
|
||||||
|
//get current time
|
||||||
|
const uint64 currTime = ACE_OS::gettimeofday().get_msec();
|
||||||
|
//calculate time diff between two world ticks
|
||||||
|
//special case: curr_time < old_time - we suppose that our time has not ticked at all
|
||||||
|
//this should be constant value otherwise it is possible that our time can start ticking backwards until next world tick!!!
|
||||||
|
uint32 diff = 0;
|
||||||
|
//regular case: curr_time >= old_time
|
||||||
|
if(currTime >= g_SystemTickTime)
|
||||||
|
diff = uint32(currTime - g_SystemTickTime);
|
||||||
|
|
||||||
|
//reset last system time value
|
||||||
|
if(savetime)
|
||||||
|
g_SystemTickTime = currTime;
|
||||||
|
|
||||||
|
//lets calculate current world time
|
||||||
|
uint32 iRes = m_iTime;
|
||||||
|
//normalize world time
|
||||||
|
const uint32 tmp = uint32(0xFFFFFFFF) - iRes;
|
||||||
|
if(tmp < diff)
|
||||||
|
iRes = diff - tmp;
|
||||||
|
else
|
||||||
|
iRes += diff;
|
||||||
|
|
||||||
|
return iRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
int32 irand (int32 min, int32 max)
|
int32 irand (int32 min, int32 max)
|
||||||
{
|
{
|
||||||
return int32 (mtRand->randInt (max - min)) + min;
|
return int32 (mtRand->randInt (max - min)) + min;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10923"
|
#define REVISION_NR "10924"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue