Core/Movement: Add time synchronisation (Needs tested)

Port From (https://github.com/TrinityCore/TrinityCore/commit/c19a4db1c12b8864d6c486ee8e2f0e058fb4155a)
This commit is contained in:
hondacrx
2021-12-02 22:34:04 -05:00
parent f5695f0cf2
commit a96fe1e47f
11 changed files with 586 additions and 75 deletions
-19
View File
@@ -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();
}
}
}