From 59df3b0e19675d343dd7e6798f3111f2dc3a1f47 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Nov 2021 17:27:05 +0100 Subject: [PATCH] - added a little utility that allows iterating over the walls of a sector with C++ for's. --- source/core/gamefuncs.h | 9 +++++++++ source/games/duke/src/actors.cpp | 13 +++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 6a9a8e158..8faba43aa 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -160,3 +160,12 @@ inline int32_t getangle(walltype* wal) wall[wal->point2].y - wal->y); } +inline TArrayView wallsofsector(sectortype* sec) +{ + return TArrayView(sec->firstWall(), sec->wallnum); +} + +inline TArrayView wallsofsector(int sec) +{ + return wallsofsector(§or[sec]); +} diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 1ff6b6e33..4c16cb94c 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -331,16 +331,17 @@ void movecyclers(void) c->lotag += sect->extra; if (c->state) { - auto wal = sect->firstWall(); - for (int x = sect->wallnum; x > 0; x--, wal++) - if (wal->hitag != 1) + for (auto& wal : wallsofsector(sect)) + { + if (wal.hitag != 1) { - wal->shade = j; + wal.shade = j; - if ((wal->cstat & CSTAT_WALL_BOTTOM_SWAP) && wal->nextwall >= 0) - wal->nextWall()->shade = j; + if ((wal.cstat & CSTAT_WALL_BOTTOM_SWAP) && wal.nextwall >= 0) + wal.nextWall()->shade = j; } + } sect->floorshade = sect->ceilingshade = j; } }