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.

(cherry picked from commit d12c015d43)
Signed-off-by: Itms <itms@wildfiregames.com>
This commit is contained in:
elexis
2024-10-02 01:12:41 +02:00
committed by Itms
parent c689991b9e
commit 7c6d2eef93
+3
View File
@@ -200,6 +200,9 @@ void CNetServerTurnManager::UninitialiseClient(int client)
bool checkOOS = m_ClientsData[client].isOOS;
m_ClientsData.erase(client);
for (std::pair<const u32, std::map<int, std::string>>& 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();