From e35d1b545766979b3041882566ceea2c3c7e60f2 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Tue, 30 Mar 2021 15:41:05 +0200 Subject: [PATCH] attempt to fix mass timeout kick --- src/TPPSMonitor.cpp | 2 +- src/TServer.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/TPPSMonitor.cpp b/src/TPPSMonitor.cpp index a92f0c9..4a32208 100644 --- a/src/TPPSMonitor.cpp +++ b/src/TPPSMonitor.cpp @@ -42,13 +42,13 @@ void TPPSMonitor::operator()() { } // kick on "no ping" if (c->SecondsSinceLastPing() > 10 && c->IsSynced() && !c->IsSyncing()) { + debug("client " + std::string("(") + std::to_string(c->GetID()) + ")" + c->GetName() + " timing out: " + std::to_string(c->SecondsSinceLastPing()) + ", pps: " + Application::PPS()); TimedOutClients.push_back(c); } } return true; }); for (auto& ClientToKick : TimedOutClients) { - debug("client " + std::string("(") + std::to_string(ClientToKick->GetID()) + ")" + ClientToKick->GetName() + " kicked due to timeout!"); Network().ClientKick(*ClientToKick, "Timeout (no ping for >10 seconds)"); } TimedOutClients.clear(); diff --git a/src/TServer.cpp b/src/TServer.cpp index 5ac21c6..2664415 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -76,8 +76,6 @@ 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); @@ -98,6 +96,7 @@ 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) {