From 551840e6a385a1dbc47066049e81d67c7507ef2a Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:38:53 +0100 Subject: [PATCH] NetworkSystem: fix bug when checking for pending map change We need to check if it has a string before calling Playlists_Parse(), because if it has it will be emptied so the check afterwards won't work. --- src/networksystem/hostmanager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/networksystem/hostmanager.cpp b/src/networksystem/hostmanager.cpp index 9dd1671e..0d46db87 100644 --- a/src/networksystem/hostmanager.cpp +++ b/src/networksystem/hostmanager.cpp @@ -30,6 +30,8 @@ static void HostManager_HandleCommandInternal(const char* const map, const char* Msg(eDLL_T::ENGINE, "Starting server with name: \"%s\" map: \"%s\" mode: \"%s\"\n", hostname->GetString(), map, mode); + bool hasPendingMap = *g_pPlaylistMapToLoad != '\0'; + // NOTE: when the provided playlist is the same as the one we're currently // on, and there's already a pending map load request, the game will run // "map " in Playlists_Parse, where the map name is dictated by @@ -37,13 +39,16 @@ static void HostManager_HandleCommandInternal(const char* const map, const char* // requested map here as to prevent Playlists_Parse from running the map // command on it, as we are going to run the changelevel command anyways. // Not doing this will result in running both map and changelevel commands. - if (changeLevel) + if (changeLevel && hasPendingMap) + { *g_pPlaylistMapToLoad = '\0'; + hasPendingMap = false; + } const bool samePlaylist = v_Playlists_Parse(mode); char commandBuf[512]; - if (!samePlaylist || !*g_pPlaylistMapToLoad) + if (!samePlaylist || !hasPendingMap) { snprintf(commandBuf, sizeof(commandBuf), "%s %s\n", changeLevel ? "changelevel" : "map", map); Cbuf_AddText(Cbuf_GetCurrentPlayer(), commandBuf, cmd_source_t::kCommandSrcCode);