From c6915fcf42854c9f5447d5ff1dbdc921f2ac2928 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 10 Apr 2023 23:11:52 +0200 Subject: [PATCH] Cleanup 'CHostState::Think' Reordered code and cleanup preprocessor directives. --- r5dev/engine/host_state.cpp | 44 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index 79a8de26..f4d0eeb2 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -237,29 +237,43 @@ void CHostState::Setup(void) //----------------------------------------------------------------------------- void CHostState::Think(void) const { +#ifndef CLIENT_DLL static bool bInitialized = false; - static CFastTimer banListTimer; - static CFastTimer pylonTimer; static CFastTimer statsTimer; + static CFastTimer banListTimer; +#ifdef DEDICATED + static CFastTimer pylonTimer; +#endif // DEDICATED if (!bInitialized) // Initialize clocks. { -#ifndef CLIENT_DLL + statsTimer.Start(); banListTimer.Start(); #ifdef DEDICATED pylonTimer.Start(); #endif // DEDICATED - statsTimer.Start(); -#endif // !CLIENT_DLL bInitialized = true; } -#ifndef CLIENT_DLL + if (sv_autoReloadRate->GetBool()) + { + if (g_ServerGlobalVariables->m_flCurTime > sv_autoReloadRate->GetDouble()) + { + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "reload\n", cmd_source_t::kCommandSrcCode); + } + } + if (statsTimer.GetDurationInProgress().GetSeconds() > sv_statusRefreshRate->GetDouble()) + { + SetConsoleTitleA(Format("%s - %d/%d Players (%s on %s)", + hostname->GetString(), g_pServer->GetNumClients(), + g_ServerGlobalVariables->m_nMaxClients, KeyValues_GetCurrentPlaylist(), m_levelName).c_str()); + + statsTimer.Start(); + } if (banListTimer.GetDurationInProgress().GetSeconds() > sv_banlistRefreshRate->GetDouble()) { g_pBanSystem->BanListCheck(); banListTimer.Start(); } -#endif // !CLIENT_DLL #ifdef DEDICATED if (pylonTimer.GetDurationInProgress().GetSeconds() > sv_pylonRefreshRate->GetDouble()) { @@ -286,22 +300,6 @@ void CHostState::Think(void) const pylonTimer.Start(); } #endif // DEDICATED -#ifndef CLIENT_DLL - if (sv_autoReloadRate->GetBool()) - { - if (g_ServerGlobalVariables->m_flCurTime > sv_autoReloadRate->GetDouble()) - { - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "reload\n", cmd_source_t::kCommandSrcCode); - } - } - if (statsTimer.GetDurationInProgress().GetSeconds() > sv_statusRefreshRate->GetDouble()) - { - SetConsoleTitleA(Format("%s - %d/%d Players (%s on %s)", - hostname->GetString(), g_pServer->GetNumClients(), - g_ServerGlobalVariables->m_nMaxClients, KeyValues_GetCurrentPlaylist(), m_levelName).c_str()); - - statsTimer.Start(); - } #endif // !CLIENT_DLL }