From 1388215b1afb5f361eb9855d1df0e999458d3f04 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:00:40 +0100 Subject: [PATCH] Finish 'CBaseServer::GetNumFakeClients()' function --- r5dev/engine/baseserver.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/r5dev/engine/baseserver.cpp b/r5dev/engine/baseserver.cpp index a8a5c36f..f5ea3165 100644 --- a/r5dev/engine/baseserver.cpp +++ b/r5dev/engine/baseserver.cpp @@ -15,12 +15,12 @@ //--------------------------------------------------------------------------------- // Purpose: Gets the number of human players on the server -// Output : +// Output : int64_t // !TODO : Rebuild properly.. //--------------------------------------------------------------------------------- int64_t CBaseServer::GetNumHumanPlayers(void) const { - uint32_t nHumans = 0; + uint32_t nHumans = 0i64; if (SHIDWORD(*g_dwMaxClients) > 0) { bool v13 = false; @@ -46,12 +46,24 @@ int64_t CBaseServer::GetNumHumanPlayers(void) const //--------------------------------------------------------------------------------- // Purpose: Gets the number of fake clients on the server -// Output : +// Output : int64_t +// !TODO : Rebuild properly.. //--------------------------------------------------------------------------------- int64_t CBaseServer::GetNumFakeClients(void) const { - // !TODO: Needs partial CBaseClient class rebuild. - return NULL; + int nBots = 0i64; + if (SHIDWORD(*g_dwMaxClients) > 0) + { + int32_t* v16 = reinterpret_cast(&*m_Clients); // CUtlVector m_Clients. + int64_t nBotCount = HIDWORD(*g_dwMaxClients); + do + { + if (*(v16 - 124) >= 2 && *v16) + nBots = (nBots + 1); + v16 += 76080; + --nBotCount; + } while (nBotCount); + } } CBaseServer* g_pServer = new CBaseServer(); // !TODO: Replace with engine global if found.