diff options
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/dedicated.cpp | 5 | ||||
-rw-r--r-- | NorthstarDedicatedTest/gameutils.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/serverauthentication.cpp | 9 |
3 files changed, 11 insertions, 5 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))); } } diff --git a/NorthstarDedicatedTest/gameutils.cpp b/NorthstarDedicatedTest/gameutils.cpp index c0c01aad..32947ac6 100644 --- a/NorthstarDedicatedTest/gameutils.cpp +++ b/NorthstarDedicatedTest/gameutils.cpp @@ -73,7 +73,7 @@ void InitialiseServerGameUtilFunctions(HMODULE baseAddress) { Server_GetEntityByIndex = (Server_GetEntityByIndexType)((char*)baseAddress + 0xFB820); Cvar_base_tickinterval_mp = (ConVar*)((char*)baseAddress + 0xBFC360); - Cvar_base_tickinterval_mp = (ConVar*)((char*)baseAddress + 0xBFBEA0); + Cvar_base_tickinterval_sp = (ConVar*)((char*)baseAddress + 0xBFBEA0); } void InitialiseTier0GameUtilFunctions(HMODULE baseAddress) diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp index 51e0a184..0e82b5e0 100644 --- a/NorthstarDedicatedTest/serverauthentication.cpp +++ b/NorthstarDedicatedTest/serverauthentication.cpp @@ -72,7 +72,7 @@ void ServerAuthenticationManager::StartPlayerAuthServer() addrPtr = typeStart + 3; hostent* resolvedRemoteAddr = gethostbyname((const char*)addrPtr); - if (!request.has_param("id") || !request.has_param("authToken") || !resolvedRemoteAddr || ((in_addr**)resolvedRemoteAddr->h_addr_list)[0]->S_un.S_addr != remoteAddr) + if (!request.has_param("id") || !request.has_param("authToken") || request.body.size() >= 65335 || !resolvedRemoteAddr || ((in_addr**)resolvedRemoteAddr->h_addr_list)[0]->S_un.S_addr != remoteAddr) { response.set_content("{\"success\":false}", "application/json"); return; @@ -344,7 +344,12 @@ char __fastcall CNetChan___ProcessMessagesHook(void* self, void* buf) } g_ServerAuthenticationManager->m_additionalPlayerData[sender].netChanProcessingLimitTime += (Plat_FloatTime() * 1000) - (startTime * 1000); - if (g_ServerAuthenticationManager->m_additionalPlayerData[sender].netChanProcessingLimitTime >= Cvar_net_chan_limit_msec_per_sec->m_nValue) + + int32_t limit = Cvar_net_chan_limit_msec_per_sec->m_nValue; + if (g_pHostState->m_iCurrentState != HostState_t::HS_RUN) + limit *= 2; // give clients more headroom in these states, as alot of clients will tend to time out here + + if (g_ServerAuthenticationManager->m_additionalPlayerData[sender].netChanProcessingLimitTime >= limit) { spdlog::warn("Client {} hit netchan processing limit with {}ms of processing time this second (max is {})", (char*)sender + 0x16, g_ServerAuthenticationManager->m_additionalPlayerData[sender].netChanProcessingLimitTime, Cvar_net_chan_limit_msec_per_sec->m_nValue); |