From 7268e779a74b28ded15d83f9ed77ee61ca1b629c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Nov 2021 23:01:27 +0100 Subject: [PATCH] - checkhitswitch_d --- source/games/duke/src/sectors_d.cpp | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 71496941f..c81291081 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -225,8 +225,9 @@ void operateforcefields_d(DDukeActor* act, int low) bool checkhitswitch_d(int snum, int ww, DDukeActor *act) { uint8_t switchpal; - int i, x, lotag, hitag, picnum, correctdips, numdips; + int lotag, hitag, picnum, correctdips, numdips; int sx, sy; + walltype* wwal = nullptr; if (ww < 0 && act == nullptr) return 0; correctdips = 1; @@ -244,14 +245,14 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act) } else { - auto wal = &wall[ww]; - lotag = wal->lotag; + wwal = &wall[ww]; + lotag = wwal->lotag; if (lotag == 0) return 0; - hitag = wal->hitag; - sx = wal->x; - sy = wal->y; - picnum = wal->picnum; - switchpal = wal->pal; + hitag = wwal->hitag; + sx = wwal->x; + sy = wwal->y; + picnum = wwal->picnum; + switchpal = wwal->pal; } switch (picnum) @@ -415,33 +416,32 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act) } } - for (i = 0; i < numwalls; i++) + for (auto& wal : walls()) { - x = i; - if (lotag == wall[x].lotag) - switch (wall[x].picnum) + if (lotag == wal.lotag) + switch (wal.picnum) { case DIPSWITCH: case TECHSWITCH: case ALIENSWITCH: - if (!act && i == ww) wall[x].picnum++; - else if (wall[x].hitag == 0) correctdips++; + if (!act && &wal == wwal) wal.picnum++; + else if (wal.hitag == 0) correctdips++; numdips++; break; case DIPSWITCH + 1: case TECHSWITCH + 1: case ALIENSWITCH + 1: - if (!act && i == ww) wall[x].picnum--; - else if (wall[x].hitag == 1) correctdips++; + if (!act && &wal == wwal) wal.picnum--; + else if (wal.hitag == 1) correctdips++; numdips++; break; case MULTISWITCH: case MULTISWITCH + 1: case MULTISWITCH + 2: case MULTISWITCH + 3: - wall[x].picnum++; - if (wall[x].picnum > (MULTISWITCH + 3)) - wall[x].picnum = MULTISWITCH; + wal.picnum++; + if (wal.picnum > (MULTISWITCH + 3)) + wal.picnum = MULTISWITCH; break; case ACCESSSWITCH: case ACCESSSWITCH2: @@ -457,7 +457,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act) case HANDSWITCH: case DIPSWITCH2: case DIPSWITCH3: - wall[x].picnum++; + wal.picnum++; break; case HANDSWITCH + 1: case PULLSWITCH + 1: @@ -471,7 +471,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act) case SPACEDOORSWITCH + 1: case DIPSWITCH2 + 1: case DIPSWITCH3 + 1: - wall[x].picnum--; + wal.picnum--; break; } }