mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/Packets: Added CMSG_TIME_SYNC_REQ and SMSG_TIME_SYNC_RESP packets
This commit is contained in:
@@ -1522,24 +1522,21 @@ void WorldSession::HandleSetTitleOpcode(WorldPacket& recvData)
|
||||
GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE, title);
|
||||
}
|
||||
|
||||
void WorldSession::HandleTimeSyncResp(WorldPacket& recvData)
|
||||
void WorldSession::HandleTimeSyncResp(WorldPackets::Misc::TimeSyncResponse& packet)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "CMSG_TIME_SYNC_RESP");
|
||||
|
||||
uint32 counter, clientTicks;
|
||||
recvData >> counter >> clientTicks;
|
||||
|
||||
if (counter != _player->m_timeSyncQueue.front())
|
||||
if (packet.SequenceIndex != _player->m_timeSyncQueue.front())
|
||||
TC_LOG_ERROR("network", "Wrong time sync counter from player %s (cheater?)", _player->GetName().c_str());
|
||||
|
||||
TC_LOG_DEBUG("network", "Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient);
|
||||
TC_LOG_DEBUG("network", "Time sync received: counter %u, client ticks %u, time since last sync %u", packet.SequenceIndex, packet.ClientTime, packet.ClientTime - _player->m_timeSyncClient);
|
||||
|
||||
uint32 ourTicks = clientTicks + (getMSTime() - _player->m_timeSyncServer);
|
||||
uint32 ourTicks = packet.ClientTime + (getMSTime() - _player->m_timeSyncServer);
|
||||
|
||||
// diff should be small
|
||||
TC_LOG_DEBUG("network", "Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
|
||||
TC_LOG_DEBUG("network", "Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - packet.ClientTime, GetLatency());
|
||||
|
||||
_player->m_timeSyncClient = clientTicks;
|
||||
_player->m_timeSyncClient = packet.ClientTime;
|
||||
_player->m_timeSyncQueue.pop();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user