From 9b8a6d155a7a2cf1bfb4e8d98980bfb0b6e94d92 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sun, 17 Oct 2021 23:46:12 +0100 Subject: fix a crashing GetCurrentPlaylistVar call, fix mod sorting --- NorthstarDedicatedTest/masterserver.cpp | 7 ++++++- NorthstarDedicatedTest/modmanager.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'NorthstarDedicatedTest') diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp index 36b360a1..4597213c 100644 --- a/NorthstarDedicatedTest/masterserver.cpp +++ b/NorthstarDedicatedTest/masterserver.cpp @@ -561,7 +561,12 @@ void CHostState__State_NewGameHook(CHostState* hostState) Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", cmd_source_t::kCommandSrcCode); Cbuf_Execute(); - g_MasterServerManager->AddSelfToServerList(Cvar_hostport->m_nValue, Cvar_ns_player_auth_port->m_nValue, Cvar_ns_server_name->m_pszString, Cvar_ns_server_desc->m_pszString, hostState->m_levelName, (char*)GetCurrentPlaylistName(), std::stoi(GetCurrentPlaylistVar("max_players", true)), Cvar_ns_server_password->m_pszString); + int maxPlayers = 6; + char* maxPlayersVar = GetCurrentPlaylistVar("max_players", true); + if (maxPlayersVar) // GetCurrentPlaylistVar can return null so protect against this + std::stoi(maxPlayersVar); + + g_MasterServerManager->AddSelfToServerList(Cvar_hostport->m_nValue, Cvar_ns_player_auth_port->m_nValue, Cvar_ns_server_name->m_pszString, Cvar_ns_server_desc->m_pszString, hostState->m_levelName, (char*)GetCurrentPlaylistName(), maxPlayers, Cvar_ns_server_password->m_pszString); g_ServerAuthenticationManager->StartPlayerAuthServer(); CHostState__State_NewGame(hostState); diff --git a/NorthstarDedicatedTest/modmanager.cpp b/NorthstarDedicatedTest/modmanager.cpp index 42ad0545..956ea90f 100644 --- a/NorthstarDedicatedTest/modmanager.cpp +++ b/NorthstarDedicatedTest/modmanager.cpp @@ -261,7 +261,7 @@ void ModManager::LoadMods() // sort by load prio, lowest-highest std::sort(m_loadedMods.begin(), m_loadedMods.end(), [](Mod* a, Mod* b) { - return a->LoadPriority > b->LoadPriority; + return a->LoadPriority < b->LoadPriority; }); for (Mod* mod : m_loadedMods) -- cgit v1.2.3