From 4d353318d9da6aa170a1f90cc6b44c9e094e11b5 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Thu, 25 Mar 2021 17:53:36 +0800 Subject: [PATCH] Don't let the game start if the saved game passed to -loadgame is invalid. Often times, especially during a multiplayer game, a player can accidentally pass an invalid save file to load at the command line, which results in the netgame starting anyway before immediately desyncing. This aims to address that. --- src/d_main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/d_main.cpp b/src/d_main.cpp index d72456099f..fe099331cd 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3158,6 +3158,19 @@ static int D_DoomMain_Internal (void) // Now that we have the IWADINFO, initialize the autoload ini sections. GameConfig->DoAutoloadSetup(iwad_man); + // Prevent the game from starting if the savegame passed to -loadgame is invalid + v = Args->CheckValue("-loadgame"); + if (v) + { + FString file(v); + FixPathSeperator(file); + DefaultExtension(file, "." SAVEGAME_EXT); + if (!FileExists(file)) + { + I_FatalError("Cannot find savegame %s", file.GetChars()); + } + } + // reinit from here do