From 4a4b5101eb50c05579e17050483a5bf0858c0291 Mon Sep 17 00:00:00 2001 From: dashodanger Date: Tue, 24 Oct 2023 22:16:13 -0600 Subject: [PATCH] Fix CTD with UMAPINFO null sky entries --- CHANGELOG.txt | 3 ++- source_files/edge/w_wad.cc | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6ae9c8fad..c3374500e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,4 +19,5 @@ General Improvements/Changes Bugs fixed ----------- \ No newline at end of file +---------- +- Fixed UMAPINFO entries with no sky defined and past the range of stock levels causing a CTD \ No newline at end of file diff --git a/source_files/edge/w_wad.cc b/source_files/edge/w_wad.cc index b54253613..ffd55f68d 100644 --- a/source_files/edge/w_wad.cc +++ b/source_files/edge/w_wad.cc @@ -1901,6 +1901,28 @@ void W_ReadUMAPINFOLumps(void) if (!good_epi) I_Error("MAPINFO: No valid episode found for level %s\n", temp_level->name.c_str()); } + // Validate that important things aren't null/empty (right now it's just the sky until I catch something else - Dasho) + if (temp_level->sky.empty()) + { + // Search for first prior mapdef with a sky and fill it in + size_t entry = mapdefs.GetSize() - 1; + for (entry; entry > 0; entry--) + { + if (mapdefs[entry] == temp_level) + break; + } + entry--; + for (entry; entry > 0; entry--) + { + if (!mapdefs[entry]->sky.empty()) + { + temp_level->sky = mapdefs[entry]->sky; + break; + } + } + if (temp_level->sky.empty()) + I_Error("MAPINFO: No sky defined for %s!\n", temp_level->name.c_str()); + } } FreeMapList();