Core/Packets: Added CMSG_TIME_SYNC_REQ and SMSG_TIME_SYNC_RESP packets

This commit is contained in:
Intel
2014-11-15 18:21:06 +02:00
parent cd9be92395
commit eb7f4e79d6
6 changed files with 48 additions and 15 deletions

View File

@@ -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();
}