aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/masterserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/masterserver.cpp')
-rw-r--r--NorthstarDedicatedTest/masterserver.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp
index 8f3a6d53..9e0e2486 100644
--- a/NorthstarDedicatedTest/masterserver.cpp
+++ b/NorthstarDedicatedTest/masterserver.cpp
@@ -664,18 +664,18 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name
requestThread.detach();
}
-void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist)
+void MasterServerManager::UpdateServerMapAndPlaylist(char* map, char* playlist, int maxPlayers)
{
// dont call this if we don't have a server id
if (!*m_ownServerId)
return;
- std::thread requestThread([this, map, playlist] {
+ std::thread requestThread([this, map, playlist, maxPlayers] {
httplib::Client http(Cvar_ns_masterserver_hostname->m_pszString);
http.set_connection_timeout(25);
// we dont process this at all atm, maybe do later, but atm not necessary
- if (auto result = http.Post(fmt::format("/server/update_values?id={}&map={}&playlist={}", m_ownServerId, map, playlist).c_str()))
+ if (auto result = http.Post(fmt::format("/server/update_values?id={}&map={}&playlist={}&maxPlayers={}", m_ownServerId, map, playlist, maxPlayers).c_str()))
{
m_successfullyConnected = true;
}
@@ -790,7 +790,7 @@ void CHostState__State_NewGameHook(CHostState* hostState)
CHostState__State_NewGame(hostState);
int maxPlayers = 6;
- char* maxPlayersVar = GetCurrentPlaylistVar("max_players", true);
+ char* maxPlayersVar = GetCurrentPlaylistVar("max_players", false);
if (maxPlayersVar) // GetCurrentPlaylistVar can return null so protect against this
maxPlayers = std::stoi(maxPlayersVar);
@@ -801,13 +801,23 @@ void CHostState__State_NewGameHook(CHostState* hostState)
void CHostState__State_ChangeLevelMPHook(CHostState* hostState)
{
- g_MasterServerManager->UpdateServerMapAndPlaylist(hostState->m_levelName, (char*)GetCurrentPlaylistName());
+ int maxPlayers = 6;
+ char* maxPlayersVar = GetCurrentPlaylistVar("max_players", false);
+ if (maxPlayersVar) // GetCurrentPlaylistVar can return null so protect against this
+ maxPlayers = std::stoi(maxPlayersVar);
+
+ g_MasterServerManager->UpdateServerMapAndPlaylist(hostState->m_levelName, (char*)GetCurrentPlaylistName(), maxPlayers);
CHostState__State_ChangeLevelMP(hostState);
}
void CHostState__State_ChangeLevelSPHook(CHostState* hostState)
{
- g_MasterServerManager->UpdateServerMapAndPlaylist(hostState->m_levelName, (char*)GetCurrentPlaylistName());
+ int maxPlayers = 6;
+ char* maxPlayersVar = GetCurrentPlaylistVar("max_players", false);
+ if (maxPlayersVar) // GetCurrentPlaylistVar can return null so protect against this
+ maxPlayers = std::stoi(maxPlayersVar);
+
+ g_MasterServerManager->UpdateServerMapAndPlaylist(hostState->m_levelName, (char*)GetCurrentPlaylistName(), maxPlayers);
CHostState__State_ChangeLevelSP(hostState);
}