From 39b34bf40c0ea3870c12f3aab7145552bb7e5119 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 2 Jan 2023 11:10:05 +0100 Subject: [PATCH] Don't count (connecting) players for voting --- src/engine/server/server.cpp | 3 ++- src/game/server/gamecontext.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index f7f8b2d9c..71e17c5a6 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -702,7 +702,8 @@ int CServer::DistinctClientCount() const int ClientCount = 0; for(int i = 0; i < MAX_CLIENTS; i++) { - if(m_aClients[i].m_State != CClient::STATE_EMPTY) + // connecting clients with spoofed ips can clog slots without being ingame + if(ClientIngame(i)) { ClientCount++; for(int j = 0; j < i; j++) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 100569b98..0bcc60f75 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -930,7 +930,7 @@ void CGameContext::OnTick() continue; // connecting clients with spoofed ips can clog slots without being ingame - if(((CServer *)Server())->m_aClients[i].m_State != CServer::CClient::STATE_INGAME) + if(!Server()->ClientIngame(i)) continue; // don't count votes by blacklisted clients @@ -1507,7 +1507,8 @@ void CGameContext::OnClientConnected(int ClientID, void *pData) bool Empty = true; for(auto &pPlayer : m_apPlayers) { - if(pPlayer) + // connecting clients with spoofed ips can clog slots without being ingame + if(pPlayer && Server()->ClientIngame(pPlayer->GetCID())) { Empty = false; break;