From 4236f800f6c80a0583ff98fd188d82d6f0969fe0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Oct 2020 19:35:59 +0200 Subject: [PATCH] - operateactivators and operatemasterswitches. --- source/games/duke/src/cheats.cpp | 2 +- source/games/duke/src/dukeactor.h | 5 --- source/games/duke/src/funct.h | 2 +- source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/sectors.cpp | 58 ++++++++++++++--------------- source/games/duke/src/sectors_d.cpp | 6 +-- source/games/duke/src/sectors_r.cpp | 6 +-- 7 files changed, 36 insertions(+), 45 deletions(-) diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index 81eab90bf..dfe7362ad 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -107,7 +107,7 @@ static const char* cheatUnlock() { if (j & (0xffff - 16384)) sector[i].lotag &= (0xffff - 16384); - operatesectors(i, ps[myconnectindex].i); + operatesectors(i, ps[myconnectindex].GetActor()); } } fi.operateforcefields(ps[myconnectindex].i, -1); diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index d95f62300..e0428a943 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -279,11 +279,6 @@ inline int findplayer(spritetype* act, int* x) return findplayer(&hittype[act - sprite], x); } -inline void operatesectors(int s, DDukeActor* i) -{ - operatesectors(s, i->GetIndex()); -} - inline void detonate(int i, int explosion) { detonate(&hittype[i], explosion); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index a3546fe15..0a04057a1 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -151,7 +151,7 @@ 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 operatemasterswitches(int lotag); -void operatesectors(int s, int i); +void operatesectors(int s, DDukeActor* i); void hud_input(int playerNum); int getanimationgoal(int animtype, int animindex); bool isanearoperator(int lotag); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index e315ad697..4c645ba27 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2519,7 +2519,7 @@ int ParseState::parse(void) break; } if (j == -1) - operatesectors(neartagsector, g_i); + operatesectors(neartagsector, g_ac); } } break; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 4401cf416..92613cc86 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -944,9 +944,8 @@ static void handle_st28(int sn, DDukeActor* actor) // //--------------------------------------------------------------------------- -void operatesectors(int sn, int ii) +void operatesectors(int sn, DDukeActor *actor) { - auto actor = &hittype[ii]; int j=0, startwall, endwall; int i; sectortype* sptr; @@ -1064,7 +1063,7 @@ void operatesectors(int sn, int ii) // //--------------------------------------------------------------------------- -void operateactivators(int low, int snum) +void operateactivators(int low, int plnum) { int i, j, k; short * p; @@ -1086,66 +1085,65 @@ void operateactivators(int low, int snum) } k = -1; - StatIterator it(STAT_ACTIVATOR); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_ACTIVATOR); + while (auto act = it.Next()) { - auto si = &hittype[i].s; - if (si->lotag == low) + if (act->s.lotag == low) { - if (si->picnum == ACTIVATORLOCKED) + if (act->s.picnum == ACTIVATORLOCKED) { - sector[si->sectnum].lotag ^= 16384; + sector[act->s.sectnum].lotag ^= 16384; - if (snum >= 0) + if (plnum >= 0) { - if (sector[si->sectnum].lotag & 16384) - FTA(4, &ps[snum]); - else FTA(8, &ps[snum]); + if (sector[act->s.sectnum].lotag & 16384) + FTA(4, &ps[plnum]); + else FTA(8, &ps[plnum]); } } else { - switch (si->hitag) + switch (act->s.hitag) { case 0: break; case 1: - if (sector[si->sectnum].floorz != sector[si->sectnum].ceilingz) + if (sector[act->s.sectnum].floorz != sector[act->s.sectnum].ceilingz) { continue; } break; case 2: - if (sector[si->sectnum].floorz == sector[si->sectnum].ceilingz) + if (sector[act->s.sectnum].floorz == sector[act->s.sectnum].ceilingz) { continue; } break; } - if (sector[si->sectnum].lotag < 3) + if (sector[act->s.sectnum].lotag < 3) { - SectIterator it(si->sectnum); - while ((j = it.NextIndex()) >= 0) + DukeSectIterator it(act->s.sectnum); + while (auto a2 = it.Next()) { - if (sprite[j].statnum == 3) switch (sprite[j].lotag) + if (a2->s.statnum == 3) switch (a2->s.lotag) { case SE_18_INCREMENTAL_SECTOR_RISE_FALL: if (isRRRA()) break; case SE_36_PROJ_SHOOTER: case SE_31_FLOOR_RISE_FALL: case SE_32_CEILING_RISE_FALL: - hittype[j].temp_data[0] = 1 - hittype[j].temp_data[0]; - callsound(si->sectnum, j); + a2->temp_data[0] = 1 - a2->temp_data[0]; + callsound(act->s.sectnum, a2); break; } } } - if (k == -1 && (sector[si->sectnum].lotag & 0xff) == 22) - k = callsound(si->sectnum, i); + if (k == -1 && (sector[act->s.sectnum].lotag & 0xff) == 22) + k = callsound(act->s.sectnum, act); - operatesectors(si->sectnum, i); + operatesectors(act->s.sectnum, act); } } } @@ -1161,13 +1159,11 @@ void operateactivators(int low, int snum) void operatemasterswitches(int low) { - int i; - - StatIterator it(STAT_STANDABLE); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_STANDABLE); + while (auto act2 = it.Next()) { - if (sprite[i].picnum == MASTERSWITCH && sprite[i].lotag == low && sprite[i].yvel == 0) - sprite[i].yvel = 1; + if (act2->s.picnum == MASTERSWITCH && act2->s.lotag == low && act2->s.yvel == 0) + act2->s.yvel = 1; } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 246ecc252..92d617693 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -630,7 +630,7 @@ void activatebysector_d(int sect, int j) } if (didit == 0) - operatesectors(sect, j); + operatesectors(sect, &hittype[j]); } //--------------------------------------------------------------------------- @@ -1775,7 +1775,7 @@ void checksectors_d(int snum) if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; } - operatesectors(neartagsector, p->i); + operatesectors(neartagsector, p->GetActor()); } else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0) { @@ -1786,7 +1786,7 @@ void checksectors_d(int snum) { if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; } - operatesectors(sprite[p->i].sectnum, p->i); + operatesectors(sprite[p->i].sectnum, p->GetActor()); } else fi.checkhitswitch(snum, neartagwall, 0); } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 5266b3842..7b9c7a21e 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -906,7 +906,7 @@ void activatebysector_r(int sect, int j) } if (sector[sect].lotag != 22) - operatesectors(sect, j); + operatesectors(sect, &hittype[j]); } @@ -2723,7 +2723,7 @@ void checksectors_r(int snum) return; } if (haskey(neartagsector, snum)) - operatesectors(neartagsector, p->i); + operatesectors(neartagsector, p->GetActor()); else { if (hittype[neartagsprite].spriteextra > 3) @@ -2743,7 +2743,7 @@ void checksectors_r(int snum) if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; } if (haskey(neartagsector, snum)) - operatesectors(sprite[p->i].sectnum, p->i); + operatesectors(sprite[p->i].sectnum, p->GetActor()); else { if (hittype[neartagsprite].spriteextra > 3)