diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 0a04057a1..d98e57546 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -149,7 +149,7 @@ bool isablockdoor(int tileNum); bool activatewarpelevators(DDukeActor* s, int w); int check_activator_motion(int lotag); void operateactivators(int l, int w); -void operateforcefields_common(int s, int low, const std::initializer_list& tiles); +void operateforcefields_common(DDukeActor* s, int low, const std::initializer_list& tiles); void operatemasterswitches(int lotag); void operatesectors(int s, DDukeActor* i); void hud_input(int playerNum); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 92613cc86..00f14fc47 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -1173,7 +1173,7 @@ void operatemasterswitches(int low) // //--------------------------------------------------------------------------- -void operateforcefields_common(int s, int low, const std::initializer_list &tiles) +void operateforcefields_common(DDukeActor *effector, int low, const std::initializer_list &tiles) { int i, p; @@ -1190,8 +1190,7 @@ void operateforcefields_common(int s, int low, const std::initializer_list { wall[i].cstat = 0; - if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR && - sprite[s].lotag == 30) + if (effector && effector->s.picnum == SECTOREFFECTOR && effector->s.lotag == 30) wall[i].lotag = 0; } else @@ -1222,22 +1221,18 @@ void breakwall(short newpn, short spr, short dawallnum) void allignwarpelevators(void) { - int i, j; - - StatIterator it(STAT_EFFECTOR); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_EFFECTOR); + while (auto act = it.Next()) { - auto si = &sprite[i]; - if (si->lotag == SE_17_WARP_ELEVATOR && si->shade > 16) + if (act->s.lotag == SE_17_WARP_ELEVATOR && act->s.shade > 16) { - StatIterator it1(STAT_EFFECTOR); - while ((j = it1.NextIndex()) >= 0) + DukeStatIterator it1(STAT_EFFECTOR); + while (auto act2 = it1.Next()) { - if ((sprite[j].lotag) == SE_17_WARP_ELEVATOR && i != j && - (si->hitag) == (sprite[j].hitag)) + if ((act2->s.lotag) == SE_17_WARP_ELEVATOR && act != act2 && act->s.hitag == act2->s.hitag) { - sector[sprite[j].sectnum].floorz = sector[si->sectnum].floorz; - sector[sprite[j].sectnum].ceilingz = sector[si->sectnum].ceilingz; + sector[act2->s.sectnum].floorz = sector[act->s.sectnum].floorz; + sector[act2->s.sectnum].ceilingz = sector[act->s.sectnum].ceilingz; } } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 92d617693..1444efa06 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -214,7 +214,7 @@ void operaterespawns_d(int low) void operateforcefields_d(int s, int low) { - operateforcefields_common(s, low, { W_FORCEFIELD, W_FORCEFIELD + 1, W_FORCEFIELD + 2, BIGFORCE }); + operateforcefields_common(&hittype[s], low, { W_FORCEFIELD, W_FORCEFIELD + 1, W_FORCEFIELD + 2, BIGFORCE }); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 7b9c7a21e..4b0b9740d 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -334,7 +334,7 @@ void operaterespawns_r(int low) void operateforcefields_r(int s, int low) { - operateforcefields_common(s, low, { BIGFORCE }); + operateforcefields_common(&hittype[s], low, { BIGFORCE }); } //---------------------------------------------------------------------------