aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/dedicated.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-21 10:27:34 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-21 10:27:34 +0000
commit34aaaf1ce6819e9a5fdd2c0cd04259d89e085052 (patch)
tree4b943c80780a9a2b2dec0ba8e644d24713971d78 /NorthstarDedicatedTest/dedicated.cpp
parente2c028702096367c6d10f3659d4c11f598829e2c (diff)
downloadNorthstarLauncher-34aaaf1ce6819e9a5fdd2c0cd04259d89e085052.tar.gz
NorthstarLauncher-34aaaf1ce6819e9a5fdd2c0cd04259d89e085052.zip
fix some timing issues on dedi
Diffstat (limited to 'NorthstarDedicatedTest/dedicated.cpp')
-rw-r--r--NorthstarDedicatedTest/dedicated.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp
index f7b6f325..524deb9f 100644
--- a/NorthstarDedicatedTest/dedicated.cpp
+++ b/NorthstarDedicatedTest/dedicated.cpp
@@ -61,6 +61,7 @@ void RunServer(CDedicatedExports* dedicated)
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
@@ -68,8 +69,8 @@ void RunServer(CDedicatedExports* dedicated)
if (!maxPlayers)
maxPlayers = "6";
- SetConsoleTitleA(fmt::format("Titanfall 2 dedicated server - {} {}/{} players ({})", g_pHostState->m_levelName, g_ServerAuthenticationManager->m_additionalPlayerData.size(), maxPlayers, GetCurrentPlaylistName()).c_str());
- Sleep(1.0 / Cvar_base_tickinterval_mp->m_fValue); // currently only supports mp, doesnt really matter rn though since most sp levels crash on dedi
+ 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)));
}
}