1
0
mirror of https://github.com/Mauler125/r5sdk.git synced 2025-02-09 19:15:03 +01:00

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.
This commit is contained in:
Kawe Mazidjatari 2023-02-12 15:21:33 +01:00
parent decf3552ea
commit 612ab83b20
2 changed files with 3 additions and 3 deletions

@ -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::milliseconds>(
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());

@ -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::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()