From 667bd7f7c845a067c7607265f9494aad18680ec9 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Tue, 30 Mar 2021 15:57:16 +0200 Subject: [PATCH] add name to debug print, update ping time each packet --- src/Client.cpp | 2 +- src/TNetwork.cpp | 2 ++ src/TServer.cpp | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Client.cpp b/src/Client.cpp index 6f07966..562f646 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -81,7 +81,7 @@ TClient::TClient(TServer& Server) void TClient::UpdatePingTime() { mLastPingTime = std::chrono::high_resolution_clock::now(); - debug(std::string("ping time updated!: ") + ((SecondsSinceLastPing() == 0) ? "OK" : "ERR")); + debug(GetName() + ": " + std::string("ping time updated!: ") + ((SecondsSinceLastPing() == 0) ? "OK" : "ERR")); } int TClient::SecondsSinceLastPing() { auto seconds = std::chrono::duration_cast( diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index 8a193b3..ed5aa0f 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -467,6 +467,8 @@ std::string TNetwork::TCPRcv(TClient& c) { //debug("Parsing from " + c->GetName() + " -> " +std::to_string(Ret.size())); #endif + c.UpdatePingTime(); + return Ret; } diff --git a/src/TServer.cpp b/src/TServer.cpp index 2664415..561924a 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -96,7 +96,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) {