Core/Movement: Add time synchronisation (#18189)

(cherry picked from commit 975f1e364a)
This commit is contained in:
Chaouki Dhib
2019-04-15 23:31:25 +02:00
committed by Shauren
parent 2f6f1c7089
commit c19a4db1c1
11 changed files with 177 additions and 95 deletions

View File

@@ -468,6 +468,9 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
/* fallthrough */
default:
{
if (opcode == CMSG_TIME_SYNC_RESPONSE)
packet.SetReceiveTime(std::chrono::steady_clock::now());
sessionGuard.lock();
LogOpcodeText(opcode, sessionGuard);
@@ -1035,10 +1038,7 @@ bool WorldSocket::HandlePing(WorldPackets::Auth::Ping& ping)
std::lock_guard<std::mutex> sessionGuard(_worldSessionLock);
if (_worldSession)
{
_worldSession->SetLatency(ping.Latency);
_worldSession->ResetClientTimeDelay();
}
else
{
TC_LOG_ERROR("network", "WorldSocket::HandlePing: peer sent CMSG_PING, but is not authenticated or got recently kicked, address = %s", GetRemoteIpAddress().to_string().c_str());