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
@@ -212,10 +212,6 @@ namespace Game.Entities
// only changed for direct client control (possess, vehicle etc.), not stuff you control using pet commands
public Unit m_unitMovedByMe;
Team m_team;
public Stack<uint> m_timeSyncQueue = new();
uint m_timeSyncTimer;
public uint m_timeSyncClient;
public uint m_timeSyncServer;
ReputationMgr reputationMgr;
QuestObjectiveCriteriaManager m_questObjectiveCriteriaMgr;
public AtLoginFlags atLoginFlags;
+2 -34
View File
@@ -74,8 +74,6 @@ namespace Game.Entities
m_logintime = GameTime.GetGameTime();
m_Last_tick = m_logintime;
m_timeSyncServer = GameTime.GetGameTimeMS();
m_dungeonDifficulty = Difficulty.Normal;
m_raidDifficulty = Difficulty.NormalRaid;
m_legacyRaidDifficulty = Difficulty.Raid10N;
@@ -533,13 +531,6 @@ namespace Game.Entities
else
m_zoneUpdateTimer -= diff;
}
if (m_timeSyncTimer > 0 && !IsBeingTeleportedFar())
{
if (diff >= m_timeSyncTimer)
SendTimeSync();
else
m_timeSyncTimer -= diff;
}
if (IsAlive())
{
@@ -848,29 +839,6 @@ namespace Game.Entities
Session.SendPacket(data);
}
//Time
void ResetTimeSync()
{
m_timeSyncTimer = 0;
m_timeSyncClient = 0;
m_timeSyncServer = GameTime.GetGameTimeMS();
}
void SendTimeSync()
{
m_timeSyncQueue.Push(m_movementCounter++);
TimeSyncRequest packet = new();
packet.SequenceIndex = m_timeSyncQueue.Last();
SendPacket(packet);
// Schedule next sync in 10 sec
m_timeSyncTimer = 10000;
m_timeSyncServer = GameTime.GetGameTimeMS();
if (m_timeSyncQueue.Count > 3)
Log.outError(LogFilter.Network, "Not received CMSG_TIME_SYNC_RESP for over 30 seconds from player {0} ({1}), possible cheater", GetGUID().ToString(), GetName());
}
public DeclinedName GetDeclinedNames() { return _declinedname; }
public void CreateGarrison(uint garrSiteId)
@@ -5460,10 +5428,10 @@ namespace Game.Entities
if (!m_teleport_options.HasAnyFlag(TeleportToOptions.Seamless))
{
m_movementCounter = 0;
ResetTimeSync();
GetSession().ResetTimeSync();
}
SendTimeSync();
GetSession().SendTimeSync();
GetSocial().SendSocialList(this, SocialFlag.All);