From 1875c8832db78fd213796f7eceeb174cf7681f26 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Tue, 30 Mar 2021 15:31:04 +0200 Subject: [PATCH] update ping time on any packet, not just ping packets, for now --- src/TPPSMonitor.cpp | 9 +++++---- src/TServer.cpp | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/TPPSMonitor.cpp b/src/TPPSMonitor.cpp index e079266..a92f0c9 100644 --- a/src/TPPSMonitor.cpp +++ b/src/TPPSMonitor.cpp @@ -37,12 +37,13 @@ void TPPSMonitor::operator()() { C++; V += c->GetCarCount(); } - // kick on "no ping" - if (c->SecondsSinceLastPing() > 10 && c->IsSynced()) { - TimedOutClients.push_back(c); - } else if (!c->IsSynced()) { + if (!c->IsSynced() || c->IsSyncing()) { c->UpdatePingTime(); } + // kick on "no ping" + if (c->SecondsSinceLastPing() > 10 && c->IsSynced() && !c->IsSyncing()) { + TimedOutClients.push_back(c); + } } return true; }); diff --git a/src/TServer.cpp b/src/TServer.cpp index 2664415..5ac21c6 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -76,6 +76,8 @@ void TServer::GlobalParser(const std::weak_ptr& Client, std::string Pac return; } auto LockedClient = Client.lock(); + // FIXME: this should not be needed here + LockedClient->UpdatePingTime(); std::any Res; char Code = Packet.at(0); @@ -96,7 +98,6 @@ void TServer::GlobalParser(const std::weak_ptr& Client, std::string Pac case 'p': Network.Respond(*LockedClient, ("p"), false); Network.UpdatePlayer(*LockedClient); - LockedClient->UpdatePingTime(); return; case 'O': if (Packet.length() > 1000) {