From f35d96679979f49dda73aa6eeda84f801ecfb8ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Mar 2016 10:09:02 +0100 Subject: [PATCH] - don't allow any ceiling portal that has a lower position than a floor portal in the same sector. The will inevitably lead to problematic situations. --- src/portal.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/portal.cpp b/src/portal.cpp index 6ec1c6c1d4..a6446a82b6 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1086,6 +1086,26 @@ void P_CreateLinkedPortals() sectors[i].lines[j]->flags |= ML_PORTALCONNECT; } } + if (sectors[i].PortalIsLinked(sector_t::ceiling) && sectors[i].PortalIsLinked(sector_t::floor)) + { + fixed_t cz = sectors[i].SkyBoxes[sector_t::ceiling]->threshold; + fixed_t fz = sectors[i].SkyBoxes[sector_t::floor]->threshold; + if (cz < fz) + { + // This is a fatal condition. We have to remove one of the two portals. Choose the one that doesn't match the current plane + Printf("Error in sector %d: Ceiling portal at z=%d is below floor portal at z=%d\n", i, cz, fz); + fixed_t cp = sectors[i].ceilingplane.Zat0(); + fixed_t fp = sectors[i].ceilingplane.Zat0(); + if (cp < fp || fz == fp) + { + sectors[i].SkyBoxes[sector_t::ceiling] = NULL; + } + else + { + sectors[i].SkyBoxes[sector_t::floor] = NULL; + } + } + } } //BuildBlockmap(); }