feat(Core/Movement): time synchronisation to better interpret client timestamps (#5300)

This commit is contained in:
Chaouki Dhib
2021-04-23 15:53:09 +02:00
committed by GitHub
parent 970d371442
commit 2d21bfc915
11 changed files with 367 additions and 96 deletions

View File

@@ -929,11 +929,6 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
m_ChampioningFaction = 0;
m_timeSyncCounter = 0;
m_timeSyncTimer = 0;
m_timeSyncClient = 0;
m_timeSyncServer = 0;
for (uint8 i = 0; i < MAX_POWERS; ++i)
m_powerFraction[i] = 0;
@@ -1833,14 +1828,6 @@ void Player::Update(uint32 p_time)
m_zoneUpdateTimer -= p_time;
}
if (m_timeSyncTimer > 0)
{
if (p_time >= m_timeSyncTimer)
SendTimeSync();
else
m_timeSyncTimer -= p_time;
}
if (IsAlive())
{
m_regenTimer += p_time;
@@ -23804,8 +23791,8 @@ void Player::SendInitialPacketsAfterAddToMap()
{
UpdateVisibilityForPlayer(true);
ResetTimeSync();
SendTimeSync();
GetSession()->ResetTimeSync();
GetSession()->SendTimeSync();
CastSpell(this, 836, true); // LOGINEFFECT
@@ -27558,25 +27545,6 @@ uint8 Player::GetMostPointsTalentTree() const
return maxIndex;
}
void Player::ResetTimeSync()
{
m_timeSyncCounter = 0;
m_timeSyncTimer = 0;
m_timeSyncClient = 0;
m_timeSyncServer = World::GetGameTimeMS();
}
void Player::SendTimeSync()
{
WorldPacket data(SMSG_TIME_SYNC_REQ, 4);
data << uint32(m_timeSyncCounter++);
GetSession()->SendPacket(&data);
// Schedule next sync in 10 sec
m_timeSyncTimer = 10000;
m_timeSyncServer = World::GetGameTimeMS();
}
void Player::SetReputation(uint32 factionentry, uint32 value)
{
GetReputationMgr().SetReputation(sFactionStore.LookupEntry(factionentry), value);