From 7b1345d3e52d19216867522c7888c29ab66d0a82 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Nov 2021 00:52:32 +0100 Subject: [PATCH] - Exhumed: wall stuff in AddFlash --- source/build/include/buildtypes.h | 1 + source/games/exhumed/src/lighting.cpp | 35 +++++++++++---------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index 2c20ec8a1..793002fd4 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -140,6 +140,7 @@ struct walltype walltype* nextWall() const; walltype* point2Wall() const; vec2_t delta() const { return point2Wall()->pos - pos; } + vec2_t center() const { return(point2Wall()->pos + pos) / 2; } int deltax() const { return point2Wall()->x - x; } int deltay() const { return point2Wall()->y - y; } bool twoSided() const { return nextsector >= 0; } diff --git a/source/games/exhumed/src/lighting.cpp b/source/games/exhumed/src/lighting.cpp index c5391dc50..fbdb7da7d 100644 --- a/source/games/exhumed/src/lighting.cpp +++ b/source/games/exhumed/src/lighting.cpp @@ -231,33 +231,26 @@ void AddFlash(int nSector, int x, int y, int z, int val) int var_14 = 0; - int startwall = sectp->wallptr; - int endwall = sectp->wallptr + sectp->wallnum; - - for (int i = startwall; i < endwall; i++) + for (auto& wal : wallsofsector(sectp)) { - short wall2 = wall[i].point2; - - int xAverage = (wall[i].x + wall[wall2].x) / 2; - int yAverage = (wall[i].y + wall[wall2].y) / 2; + auto average = wal.center(); sectortype *pNextSector = NULL; - if (wall[i].nextsector > -1) { - pNextSector = §or[wall[i].nextsector]; - } + if (wal.nextsector > -1) + pNextSector = wal.nextSector(); int ebx = -255; if (!var_18) { - int x2 = x - xAverage; + int x2 = x - average.x; if (x2 < 0) { x2 = -x2; } ebx = x2; - int y2 = y - yAverage; + int y2 = y - average.y; if (y2 < 0) { y2 = -y2; } @@ -270,7 +263,7 @@ void AddFlash(int nSector, int x, int y, int z, int val) var_14++; var_28 += ebx; - if (wall[i].pal < 5) + if (wal.pal < 5) { if (!pNextSector || pNextSector->floorz < sectp->floorz) { @@ -280,23 +273,23 @@ void AddFlash(int nSector, int x, int y, int z, int val) } sFlash[nFlash].nType = var_20 | 2; - sFlash[nFlash].shade = wall[i].shade; - sFlash[nFlash].nIndex = i; + sFlash[nFlash].shade = wal.shade; + sFlash[nFlash].nIndex = wallnum(&wal); - wall[i].pal += 7; + wal.pal += 7; - ebx += wall[i].shade; + ebx += wal.shade; int eax = ebx; if (ebx < -127) { eax = -127; } - wall[i].shade = eax; + wal.shade = eax; - if (!var_1C && !wall[i].overpicnum && pNextSector) + if (!var_1C && !wal.overpicnum && pNextSector) { - AddFlash(wall[i].nextsector, x, y, z, val); + AddFlash(wal.nextsector, x, y, z, val); } } }