aboutsummaryrefslogtreecommitdiff
path: root/src/game/MiscHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/MiscHandler.cpp')
-rw-r--r--src/game/MiscHandler.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 1e8e0e7ea3b..a6d4452df32 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1443,13 +1443,20 @@ void WorldSession::HandleTimeSyncResp(WorldPacket & recv_data)
{
sLog.outDebug("CMSG_TIME_SYNC_RESP");
- uint32 counter, time_;
- recv_data >> counter >> time_;
-
- // time_ seems always more than getMSTime()
- uint32 diff = getMSTimeDiff(getMSTime(),time_);
-
- sLog.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter, time_, time_, getMSTime(), diff);
+ uint32 counter, clientTicks;
+ recv_data >> counter >> clientTicks;
+
+ if (counter != _player->m_timeSyncCounter - 1)
+ sLog.outDebug("Wrong time sync counter from player %s (cheater?)", _player->GetName());
+
+ sLog.outDebug("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);
+
+ // diff should be small
+ sLog.outDebug("Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
+
+ _player->m_timeSyncClient = clientTicks;
}
void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/)