Core/Movement: Add time synchronisation (Needs tested)
Port From (https://github.com/TrinityCore/TrinityCore/commit/c19a4db1c12b8864d6c486ee8e2f0e058fb4155a)
This commit is contained in:
@@ -31,24 +31,5 @@ namespace Game
|
||||
response.Time = GameTime.GetGameTime();
|
||||
SendPacket(response);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.TimeSyncResponse, Processing = PacketProcessing.Inplace)]
|
||||
void HandleTimeSyncResponse(TimeSyncResponse packet)
|
||||
{
|
||||
Log.outDebug(LogFilter.Network, "CMSG_TIME_SYNC_RESP");
|
||||
|
||||
if (packet.SequenceIndex != _player.m_timeSyncQueue.FirstOrDefault())
|
||||
Log.outError(LogFilter.Network, "Wrong time sync counter from player {0} (cheater?)", _player.GetName());
|
||||
|
||||
Log.outDebug(LogFilter.Network, "Time sync received: counter {0}, client ticks {1}, time since last sync {2}", packet.SequenceIndex, packet.ClientTime, packet.ClientTime - _player.m_timeSyncClient);
|
||||
|
||||
uint ourTicks = packet.ClientTime + (GameTime.GetGameTimeMS() - _player.m_timeSyncServer);
|
||||
|
||||
// diff should be small
|
||||
Log.outDebug(LogFilter.Network, "Our ticks: {0}, diff {1}, latency {2}", ourTicks, ourTicks - packet.ClientTime, GetLatency());
|
||||
|
||||
_player.m_timeSyncClient = packet.ClientTime;
|
||||
_player.m_timeSyncQueue.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user