r5sdk/r5dev/engine/baseserver.cpp

58 lines
1.7 KiB
C++
Raw Normal View History

//=============================================================================//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
// baseserver.cpp: implementation of the CBaseServer class.
//
/////////////////////////////////////////////////////////////////////////////////
#include "core/stdafx.h"
#include "common/protocol.h"
#include "engine/baseserver.h"
#include "engine/baseclient.h"
#include "public/include/edict.h"
//---------------------------------------------------------------------------------
// Purpose: Gets the number of human players on the server
2022-03-28 12:02:11 +02:00
// Output : int
//---------------------------------------------------------------------------------
int CBaseServer::GetNumHumanPlayers(void) const
{
int nHumans = 0;
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
{
CBaseClient* pClient = g_pClient->GetClient(i);
if (!pClient)
continue;
if (pClient->IsHumanPlayer())
nHumans++;
}
return nHumans;
}
//---------------------------------------------------------------------------------
// Purpose: Gets the number of fake clients on the server
2022-03-28 12:02:11 +02:00
// Output : int
//---------------------------------------------------------------------------------
int CBaseServer::GetNumFakeClients(void) const
{
int nBots = 0;
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
{
CBaseClient* pClient = g_pClient->GetClient(i);
if (!pClient)
continue;
if (pClient->IsConnected() && pClient->IsFakeClient())
nBots++;
}
return nBots;
}
CBaseServer* g_pServer = new CBaseServer(); // !TODO: Replace with engine global if found.