From bde644f77ff0d8c13f51d382e81e56d5a8e7e88e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 11 May 2021 00:59:23 +0200 Subject: [PATCH] - SW: replaced some asserts with proper value checks. These asserts can actually be triggered by some maps with incorrect setups. --- source/games/sw/src/rooms.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index cf561f10b..9f614a576 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -838,14 +838,18 @@ FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum if (*sectnum < 0) return false; - ASSERT(sp); - ASSERT(sp->hitag == VIEW_THRU_FLOOR); + if (!sp || sp->hitag != VIEW_THRU_FLOOR) + { + *sectnum = 0; + return false; + } - pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8; - newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128); if (!testnewrenderer) { + pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8; + newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128); + it.Reset(STAT_FAF); while ((i = it.NextIndex()) >= 0) { @@ -932,15 +936,18 @@ FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum) if (*sectnum < 0) return false; - ASSERT(sp); - ASSERT(sp->hitag == VIEW_THRU_CEILING); - - // move ceiling multiple of 128 so that the wall tile will line up - pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8; - newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128); + if (!sp || sp->hitag != VIEW_THRU_CEILING) + { + *sectnum = 0; + return false; + } if (!testnewrenderer) { + // move ceiling multiple of 128 so that the wall tile will line up + pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8; + newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128); + it.Reset(STAT_FAF); while ((i = it.NextIndex()) >= 0) {