From 963837d7789bdffbfbb24418cbc02e09f515e936 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 2 Dec 2021 01:05:07 +0100 Subject: [PATCH] - MarkSectorSeen --- source/core/automap.cpp | 23 +++++++++++------------ source/core/automap.h | 2 +- source/games/duke/src/game_misc.cpp | 2 +- source/games/exhumed/src/map.cpp | 7 +++---- source/games/sw/src/draw.cpp | 2 +- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 07bfd613106..e0fbed31e68 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -293,21 +293,20 @@ void ClearAutomap() // //--------------------------------------------------------------------------- -void MarkSectorSeen(int i) +void MarkSectorSeen(sectortype* sec) { - if (validSectorIndex(i)) + if (sec) { - show2dsector.Set(i); - auto wal = &wall[sector[i].wallptr]; - for (int j = sector[i].wallnum; j > 0; j--, wal++) + show2dsector.Set(sectnum(sec)); + for (auto& wal : wallsofsector(sec)) { - i = wal->nextsector; - if (i < 0) continue; - if (wal->cstat & 0x0071) continue; - if (wal->nextWall()->cstat & 0x0071) continue; - if (sector[i].lotag == 32767) continue; - if (sector[i].ceilingz >= sector[i].floorz) continue; - show2dsector.Set(i); + if (!wal.twoSided()) continue; + if (wal.cstat & 0x0071) continue; + if (wal.nextWall()->cstat & 0x0071) continue; + auto osec = wal.nextSector(); + if (osec->lotag == 32767) continue; + if (osec->ceilingz >= osec->floorz) continue; + show2dsector.Set(sectnum(osec)); } } } diff --git a/source/core/automap.h b/source/core/automap.h index 9e6bbd63a87..5be3194bd51 100644 --- a/source/core/automap.h +++ b/source/core/automap.h @@ -15,7 +15,7 @@ extern BitArray show2dwall; void SerializeAutomap(FSerializer& arc); void ClearAutomap(); -void MarkSectorSeen(int sect); +void MarkSectorSeen(sectortype* sect); void DrawOverheadMap(int x, int y, int ang, double const smoothratio); bool AM_Responder(event_t* ev, bool last); void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry p); diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index b95f748aaa5..ad620ad9a88 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -238,7 +238,7 @@ void drawoverlays(double smoothratio) else videoclearFade(); - MarkSectorSeen(sectnum(pp->cursector)); + MarkSectorSeen(pp->cursector); if (ud.cameraactor == nullptr) { diff --git a/source/games/exhumed/src/map.cpp b/source/games/exhumed/src/map.cpp index e48c40ef939..3285b708bac 100644 --- a/source/games/exhumed/src/map.cpp +++ b/source/games/exhumed/src/map.cpp @@ -32,16 +32,15 @@ bool bShowTowers = false; void GrabMap() { - for (int i = 0; i < numsectors; i++) { - MarkSectorSeen(i); - } + for(auto&sec : sectors()) + MarkSectorSeen(&sec); } void UpdateMap() { if (initsectp->ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) { - MarkSectorSeen(sectnum(initsectp)); + MarkSectorSeen(initsectp); } } diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index f8d75dadf05..e83d2793f1e 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1580,7 +1580,7 @@ drawscreen(PLAYERp pp, double smoothratio) } - MarkSectorSeen(sectnum(pp->cursector)); + MarkSectorSeen(pp->cursector); if ((automapMode != am_off) && pp == Player+myconnectindex) {