2022-03-26 00:24:13 +01:00
|
|
|
//=============================================================================//
|
|
|
|
//
|
|
|
|
// 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"
|
2022-03-27 19:35:33 +02:00
|
|
|
#include "public/include/edict.h"
|
2022-03-26 00:24:13 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: Gets the number of human players on the server
|
2022-03-28 12:02:11 +02:00
|
|
|
// Output : int
|
2022-03-26 00:24:13 +01:00
|
|
|
//---------------------------------------------------------------------------------
|
2022-03-27 19:35:33 +02:00
|
|
|
int CBaseServer::GetNumHumanPlayers(void) const
|
2022-03-26 00:24:13 +01:00
|
|
|
{
|
2022-03-27 19:35:33 +02:00
|
|
|
int nHumans = 0;
|
|
|
|
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
|
2022-03-26 00:24:13 +01:00
|
|
|
{
|
2022-04-02 02:48:54 +02:00
|
|
|
CBaseClient* pClient = g_pClient->GetClient(i);
|
|
|
|
if (!pClient)
|
2022-03-27 19:35:33 +02:00
|
|
|
continue;
|
|
|
|
|
2022-04-02 02:48:54 +02:00
|
|
|
if (pClient->IsHumanPlayer())
|
2022-03-27 19:35:33 +02:00
|
|
|
nHumans++;
|
2022-03-26 00:24:13 +01:00
|
|
|
}
|
2022-03-27 19:35:33 +02:00
|
|
|
|
2022-03-26 00:24:13 +01:00
|
|
|
return nHumans;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
// Purpose: Gets the number of fake clients on the server
|
2022-03-28 12:02:11 +02:00
|
|
|
// Output : int
|
2022-03-26 00:24:13 +01:00
|
|
|
//---------------------------------------------------------------------------------
|
2022-03-27 19:35:33 +02:00
|
|
|
int CBaseServer::GetNumFakeClients(void) const
|
2022-03-26 00:24:13 +01:00
|
|
|
{
|
2022-03-27 19:35:33 +02:00
|
|
|
int nBots = 0;
|
|
|
|
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
|
2022-03-26 02:00:40 +01:00
|
|
|
{
|
2022-04-02 02:48:54 +02:00
|
|
|
CBaseClient* pClient = g_pClient->GetClient(i);
|
|
|
|
if (!pClient)
|
2022-03-27 19:35:33 +02:00
|
|
|
continue;
|
|
|
|
|
2022-04-02 02:48:54 +02:00
|
|
|
if (pClient->IsConnected() && pClient->IsFakeClient())
|
2022-03-27 19:35:33 +02:00
|
|
|
nBots++;
|
2022-03-26 02:00:40 +01:00
|
|
|
}
|
2022-03-27 19:35:33 +02:00
|
|
|
|
|
|
|
return nBots;
|
2022-03-26 00:24:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CBaseServer* g_pServer = new CBaseServer(); // !TODO: Replace with engine global if found.
|