diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-25 18:06:57 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-25 18:06:57 +0000 |
commit | fc10ac473811f2497ef3f4c9c0b885f8efb3025f (patch) | |
tree | c4af81b026e6d72b79d1b11e939e04183ece4b84 /NorthstarDedicatedTest/dedicated.cpp | |
parent | 32277386b62877999c2017146750a2449d52d447 (diff) | |
parent | a23232aad6bccc3dc0e5ecd38365303863222a73 (diff) | |
download | NorthstarLauncher-fc10ac473811f2497ef3f4c9c0b885f8efb3025f.tar.gz NorthstarLauncher-fc10ac473811f2497ef3f4c9c0b885f8efb3025f.zip |
Merge branch 'main' of https://github.com/R2Northstar/NorthstarLauncher
Diffstat (limited to 'NorthstarDedicatedTest/dedicated.cpp')
-rw-r--r-- | NorthstarDedicatedTest/dedicated.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp index e6115415..e140281a 100644 --- a/NorthstarDedicatedTest/dedicated.cpp +++ b/NorthstarDedicatedTest/dedicated.cpp @@ -3,7 +3,7 @@ #include "hookutils.h" #include "gameutils.h" #include "serverauthentication.h" - +#include "masterserver.h" bool IsDedicated() { //return CommandLine()->CheckParm("-dedicated"); @@ -58,17 +58,24 @@ void RunServer(CDedicatedExports* dedicated) // note: we no longer manually set map and hoststate to start server in g_pHostState, we just use +map which seems to initialise stuff better // main loop + double frameTitle = 0; while (g_pEngine->m_nQuitting == EngineQuitState::QUIT_NOTQUITTING) { double frameStart = Plat_FloatTime(); g_pEngine->Frame(); - // this way of getting playercount/maxplayers honestly really sucks, but not got any other methods of doing it rn - const char* maxPlayers = GetCurrentPlaylistVar("max_players", false); - if (!maxPlayers) - maxPlayers = "6"; + // only update the title after at least 500ms since the last update + if ((frameStart - frameTitle) > 0.5) { + frameTitle = frameStart; + + // this way of getting playercount/maxplayers honestly really sucks, but not got any other methods of doing it rn + const char* maxPlayers = GetCurrentPlaylistVar("max_players", false); + if (!maxPlayers) + maxPlayers = "6"; + + SetConsoleTitleA(fmt::format("{} - {} {}/{} players ({})", g_MasterServerManager->ns_auth_srvName, g_pHostState->m_levelName, g_ServerAuthenticationManager->m_additionalPlayerData.size(), maxPlayers, GetCurrentPlaylistName()).c_str()); + } - SetConsoleTitleA(fmt::format("Titanfall 2 dedicated server - {} {}/{} players ({})", g_pHostState->m_levelName, g_ServerAuthenticationManager->m_additionalPlayerData.size(), maxPlayers, GetCurrentPlaylistName()).c_str()); std::this_thread::sleep_for(std::chrono::duration<double, std::ratio<1>>(Cvar_base_tickinterval_mp->m_fValue - fmin(Plat_FloatTime() - frameStart, 0.25))); } } |