Core/Players: Improve setting ActivePlayerData::TransportServerTime by including TIME_SYNC and CMSG_QUEUED_MESSAGES_END values in its calculation

Port From (https://github.com/TrinityCore/TrinityCore/commit/821ecf8fa3b6b922ba178cde7593ef5d84ef734b)
This commit is contained in:
Hondacrx
2025-08-10 17:05:31 -04:00
parent d0bc3cecfd
commit 9340c89bb1
7 changed files with 72 additions and 22 deletions
+10 -2
View File
@@ -25,6 +25,9 @@ namespace Game
{
public partial class WorldSession : IDisposable
{
public static uint SPECIAL_INIT_ACTIVE_MOVER_TIME_SYNC_COUNTER = 0xFFFFFFFF;
public static uint SPECIAL_RESUME_COMMS_TIME_SYNC_COUNTER = 0xFFFFFFFE;
public WorldSession(uint id, string name, uint battlenetAccountId, WorldSocket sock, AccountTypes sec, Expansion expansion, long mute_time, string os, TimeSpan timezoneOffset, uint build, Framework.ClientBuild.ClientBuildVariantId clientBuildVariant, Locale locale, uint recruiter, bool isARecruiter)
{
m_muteTime = mute_time;
@@ -888,13 +891,18 @@ namespace Game
timeSyncRequest.SequenceIndex = _timeSyncNextCounter;
SendPacket(timeSyncRequest);
_pendingTimeSyncRequests[_timeSyncNextCounter] = Time.GetMSTime();
RegisterTimeSync(_timeSyncNextCounter);
// Schedule next sync in 10 sec (except for the 2 first packets, which are spaced by only 5s)
_timeSyncTimer = _timeSyncNextCounter == 0 ? 5000 : 10000u;
_timeSyncNextCounter++;
}
public void RegisterTimeSync(uint counter)
{
_pendingTimeSyncRequests[counter] = Time.GetMSTime();
}
uint AdjustClientMovementTime(uint time)
{
long movementTime = (long)time + _timeSyncClockDelta;
@@ -998,7 +1006,7 @@ namespace Game
CircularBuffer<Tuple<long, uint>> _timeSyncClockDeltaQueue = new(6); // first member: clockDelta. Second member: latency of the packet exchange that was used to compute that clockDelta.
long _timeSyncClockDelta;
Dictionary<uint, uint> _pendingTimeSyncRequests = new(); // key: counter. value: server time when packet with that counter was sent.
Dictionary<uint, long> _pendingTimeSyncRequests = new(); // key: counter. value: server time when packet with that counter was sent.
uint _timeSyncNextCounter;
uint _timeSyncTimer;