mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-19 06:29:50 -04:00
Core/PacketIO: Allow to queue up to 3 time sync requests to prevent very long loading screns from printing cheater warnings
Closes #10063
This commit is contained in:
@@ -26481,7 +26481,6 @@ void Player::ActivateSpec(uint8 spec)
|
||||
|
||||
void Player::ResetTimeSync()
|
||||
{
|
||||
m_timeSyncCounter = 0;
|
||||
m_timeSyncTimer = 0;
|
||||
m_timeSyncClient = 0;
|
||||
m_timeSyncServer = getMSTime();
|
||||
@@ -26489,15 +26488,18 @@ void Player::ResetTimeSync()
|
||||
|
||||
void Player::SendTimeSync()
|
||||
{
|
||||
m_timeSyncCounter = m_movementCounter;
|
||||
m_timeSyncQueue.push(m_movementCounter++);
|
||||
|
||||
WorldPacket data(SMSG_TIME_SYNC_REQ, 4);
|
||||
data << uint32(m_movementCounter++);
|
||||
data << uint32(m_timeSyncQueue.back());
|
||||
GetSession()->SendPacket(&data);
|
||||
|
||||
// Schedule next sync in 10 sec
|
||||
m_timeSyncTimer = 10000;
|
||||
m_timeSyncServer = getMSTime();
|
||||
|
||||
if (m_timeSyncQueue.size() > 3)
|
||||
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Not received CMSG_TIME_SYNC_RESP for over 30 seconds from player %u (%s), possible cheater", GetGUIDLow(), GetName().c_str());
|
||||
}
|
||||
|
||||
void Player::SetReputation(uint32 factionentry, uint32 value)
|
||||
|
||||
@@ -2862,7 +2862,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
|
||||
uint32 m_ChampioningFaction;
|
||||
|
||||
uint32 m_timeSyncCounter;
|
||||
std::queue<uint32> m_timeSyncQueue;
|
||||
uint32 m_timeSyncTimer;
|
||||
uint32 m_timeSyncClient;
|
||||
uint32 m_timeSyncServer;
|
||||
|
||||
@@ -1488,7 +1488,7 @@ void WorldSession::HandleTimeSyncResp(WorldPacket& recvData)
|
||||
uint32 counter, clientTicks;
|
||||
recvData >> counter >> clientTicks;
|
||||
|
||||
if (counter != _player->m_timeSyncCounter)
|
||||
if (counter != _player->m_timeSyncQueue.front())
|
||||
TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "Wrong time sync counter from player %s (cheater?)", _player->GetName().c_str());
|
||||
|
||||
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient);
|
||||
@@ -1499,6 +1499,7 @@ void WorldSession::HandleTimeSyncResp(WorldPacket& recvData)
|
||||
TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
|
||||
|
||||
_player->m_timeSyncClient = clientTicks;
|
||||
_player->m_timeSyncQueue.pop();
|
||||
}
|
||||
|
||||
void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recvData*/)
|
||||
|
||||
Reference in New Issue
Block a user