From 3eef0db6f6dec8e4bc289953be382e85c940c41e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 4 Sep 2020 20:47:40 +0200 Subject: [PATCH] - check if a map file exists before starting it. --- source/blood/src/blood.cpp | 1 + source/core/cheats.cpp | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index c9d12af74..de5578ecc 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -242,6 +242,7 @@ void StartLevel(MapRecord* level) paused = 0; levelTryPlayMusic(); gChoke.reset(); + Printf(TEXTCOLOR_GOLD "%s: %s\n", level->LabelName(), level->DisplayName()); } diff --git a/source/core/cheats.cpp b/source/core/cheats.cpp index a6734d160..63f90d4d9 100644 --- a/source/core/cheats.cpp +++ b/source/core/cheats.cpp @@ -282,6 +282,10 @@ static MapRecord* levelwarp_common(FCommandLine& argv, const char *cmdname, cons else Printf(PRINT_BOLD, "Level %s not found!\n", argv[1]); return nullptr; } + if (fileSystem.FindFile(map->fileName) < 0) + { + Printf(PRINT_BOLD, "%s: map file not found\n", map->fileName.GetChars()); + } return map; } @@ -363,9 +367,6 @@ CCMD(changemap) #endif FString mapname = argv[1]; - FString mapfilename = mapname; - DefaultExtension(mapfilename, ".map"); - auto map = FindMapByName(mapname); if (map == nullptr) { @@ -379,6 +380,11 @@ CCMD(changemap) Printf(PRINT_BOLD, "%s: Cannot warp to user maps.\n", mapname.GetChars()); return; } + if (fileSystem.FindFile(map->fileName) < 0) + { + Printf(PRINT_BOLD, "%s: map file not found\n", map->fileName.GetChars()); + } + ChangeLevel(map, -1); } @@ -420,6 +426,11 @@ CCMD(map) } if (map) { + if (fileSystem.FindFile(map->fileName) < 0) + { + Printf(PRINT_BOLD, "%s: map file not found\n", map->fileName.GetChars()); + } + DeferedStartGame(map, -1); } }