aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/dedicated.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/dedicated.cpp')
-rw-r--r--NorthstarDedicatedTest/dedicated.cpp19
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)));
}
}