Add 'GetNumClients'

Gets the total amount of clients on the server (both fake and real clients).
This commit is contained in:
Kawe Mazidjatari 2023-02-12 15:20:11 +01:00
parent b1f2f47058
commit decf3552ea
2 changed files with 21 additions and 0 deletions

View File

@ -57,6 +57,26 @@ int CServer::GetNumFakeClients(void) const
return nBots;
}
//---------------------------------------------------------------------------------
// Purpose: Gets the number of clients on the server
// Output : int
//---------------------------------------------------------------------------------
int CServer::GetNumClients(void) const
{
int nClients = 0;
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
{
CClient* pClient = g_pClient->GetClient(i);
if (!pClient)
continue;
if (pClient->IsConnected())
nClients++;
}
return nClients;
}
//---------------------------------------------------------------------------------
// Purpose: client to server authentication
// Input : *pChallenge -

View File

@ -33,6 +33,7 @@ public:
#ifndef CLIENT_DLL // Only the connectionless packet handler is implemented on the client via the IServer base class.
int GetNumHumanPlayers(void) const;
int GetNumFakeClients(void) const;
int GetNumClients(void) const;
const char* GetMapName(void) const { return m_szMapname; }
const char* GetMapGroupName(void) const { return m_szMapGroupName; }
int GetNumClasses(void) const { return m_nServerClasses; }