From b003565ad277451e73264f537c856cec58caa650 Mon Sep 17 00:00:00 2001 From: RaveYard Date: Mon, 31 Oct 2022 02:19:11 +0100 Subject: [PATCH] Fix CheckAndMakePortal missing tagged sectors --- src/level/doomdata.h | 1 + src/level/level.cpp | 17 +++++++++++++++++ src/lightmap/levelmesh.cpp | 4 +--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/level/doomdata.h b/src/level/doomdata.h index d70d661..3406f58 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -156,6 +156,7 @@ struct IntSector TArray props; TArray lines; + TArray portals; // Utility functions inline const char* GetTextureName(int plane) const { return plane != PLANE_FLOOR ? data.ceilingpic : data.floorpic; } diff --git a/src/level/level.cpp b/src/level/level.cpp index 7662e60..060cd76 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -674,6 +674,23 @@ void FLevel::PostLoadInitialization() line->frontsector = (line->sidenum[0] != NO_INDEX) ? &Sectors[Sides[line->sidenum[0]].sector] : nullptr; line->backsector = (line->sidenum[1] != NO_INDEX) ? &Sectors[Sides[line->sidenum[1]].sector] : nullptr; } + + // Find plane portals + { + for (auto& line : Lines) + { + if (line.special == Sector_SetPortal && line.args[0]) + { + for (auto& sector : Sectors) + { + if (sector.HasTag(line.args[0])) + { + sector.portals.Push(&line); + } + } + } + } + } } void FProcessor::BuildNodes() diff --git a/src/lightmap/levelmesh.cpp b/src/lightmap/levelmesh.cpp index 41c98c1..d4b1f4c 100644 --- a/src/lightmap/levelmesh.cpp +++ b/src/lightmap/levelmesh.cpp @@ -512,9 +512,7 @@ int LevelMesh::CreateLinePortal(FLevel& doomMap, const IntLineDef& srcLine, cons int LevelMesh::CheckAndMakePortal(FLevel& doomMap, MapSubsectorEx* sub, IntSector* sector, int typeIndex, int plane) { - const auto& lines = doomMap.GetSectorFromSubSector(sub)->lines; - - for (const auto& line : lines) + for (const auto line : sector->portals) { if (line->special == Sector_SetPortal && line->args[0] && line->args[2] == plane && !line->args[3] && sector->HasTag(line->args[0])) {