From d12c015d432202ebf6f9e6824e71f7e7448a2ec6 Mon Sep 17 00:00:00 2001 From: elexis Date: Wed, 2 Oct 2024 01:12:41 +0200 Subject: [PATCH] Erase client state hash on disconnect Fix `NetServerTurnManager` from pausing the simulation forever after a client sent a bad hash to it and disconnects before the bad hash has been processed. A client that sends a wrong simulation hash to the `NetServer` and disconnects before the server compares that hash causes a message box to appear and the game to be paused forever. 94e5d88169 introduced the bug by missing to delete `m_ClientStateHashes upon `UninitialiseClient. This causes `m_ClientData[hashPair.first].isOOS = true` to insert a client with blank values that the `NetServerTurnManager` will wait forever and hence the message box about an OOS with no players being OOS is shown (the playername is emptystring). 5ebf2020b0 exposed the bug by making observers able to lag behind, providing a longe enough timeframe for this to occur. Fix: Deleting `m_ClientStateHashes` upon disconnect solves the broken message box and the pausing. --- source/network/NetServerTurnManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/network/NetServerTurnManager.cpp b/source/network/NetServerTurnManager.cpp index 350aced5ab..d7ef688c9b 100644 --- a/source/network/NetServerTurnManager.cpp +++ b/source/network/NetServerTurnManager.cpp @@ -200,6 +200,9 @@ void CNetServerTurnManager::UninitialiseClient(int client) bool checkOOS = m_ClientsData[client].isOOS; m_ClientsData.erase(client); + for (std::pair>& clientStateHash : m_ClientStateHashes) + clientStateHash.second.erase(client); + // Check whether we're ready for the next turn now that we're not // waiting for this client any more CheckClientsReady();