aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/masterserver.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-24 21:52:00 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-24 21:52:00 +0000
commit352952bd8b12ef0a5d66fa2dc5341a4d5777f9b7 (patch)
tree8f0b6bcac5ac2ec4e07a879f2e57f8d847e8f25c /NorthstarDedicatedTest/masterserver.cpp
parent3dcd9f6b6da1c3f277b27a296f58bca3cbc3a775 (diff)
downloadNorthstarLauncher-352952bd8b12ef0a5d66fa2dc5341a4d5777f9b7.tar.gz
NorthstarLauncher-352952bd8b12ef0a5d66fa2dc5341a4d5777f9b7.zip
prevent playlist var names over 64 characters and send maxplayers on map change
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);
}