From bd23ea144cf78cb74b982cc22581d8a0747a77eb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Jul 2021 22:11:53 +0200 Subject: [PATCH] - validate 'nextsector' fields on walls. Build utterly relied on the map having these right and put the entire responsibility on the mapper. There's maps, however which have bad values here causing either render glitches or crashes so these bad indices need to be fixed. Two good examples where this causes problems are RR's E3L1 and the second map of SW's Last Warrior mod where this even glitches in Polymost. --- source/core/maploader.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 88449a4597d..60928599c47 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -493,4 +493,18 @@ void setWallSectors() wall[sector[i].wallptr + w].sector = i; } } + + // validate 'nextsector' fields. Some maps have these wrong which can cause render glitches and occasionally even crashes. + for (int i = 0; i < numwalls; i++) + { + if (wall[i].nextwall != -1) + { + if (wall[i].nextsector != wall[wall[i].nextwall].sector) + { + DPrintf(DMSG_ERROR, "Bad 'nextsector' reference %d on wall %d\n", wall[i].nextsector, i); + wall[i].nextsector = wall[wall[i].nextwall].sector; + } + } + } + } \ No newline at end of file