From 612ab83b20e9c9db3977433ec9f447b6efea15fd Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 12 Feb 2023 15:21:33 +0100 Subject: [PATCH] Use 'GetNumClients' for hosting and status bar Use 'GetNumClients' instead of iterating over the client array twice. Also fixed a bug causing the status bar only to display real clients, buts were never counted. --- r5dev/engine/host_state.cpp | 4 ++-- r5dev/gameui/IBrowser.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index 39f65ad8..2428f1a1 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -267,7 +267,7 @@ FORCEINLINE void CHostState::Think(void) const g_pNetKey->GetBase64NetKey(), std::to_string(*g_nServerRemoteChecksum), SDK_VERSION, - std::to_string(g_pServer->GetNumHumanPlayers() + g_pServer->GetNumFakeClients()), + std::to_string(g_pServer->GetNumClients()), std::to_string(g_ServerGlobalVariables->m_nMaxClients), std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() @@ -290,7 +290,7 @@ FORCEINLINE void CHostState::Think(void) const if (statsTimer.GetDurationInProgress().GetSeconds() > sv_statusRefreshRate->GetDouble()) { string svCurrentPlaylist = KeyValues_GetCurrentPlaylist(); - int32_t nPlayerCount = g_pServer->GetNumHumanPlayers(); + int32_t nPlayerCount = g_pServer->GetNumClients(); SetConsoleTitleA(fmt::format("{:s} - {:d}/{:d} Players ({:s} on {:s})", hostname->GetString(), nPlayerCount, g_ServerGlobalVariables->m_nMaxClients, svCurrentPlaylist, m_levelName).c_str()); diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index dfdf4f07..63eed7e4 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -727,7 +727,7 @@ void CBrowser::UpdateHostingStatus(void) g_pNetKey->GetBase64NetKey(), std::to_string(*g_nServerRemoteChecksum), SDK_VERSION, - std::to_string(g_pServer->GetNumHumanPlayers() + g_pServer->GetNumFakeClients()), + std::to_string(g_pServer->GetNumClients()), std::to_string(g_ServerGlobalVariables->m_nMaxClients), std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()