diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index e92bdceca..655402825 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -973,7 +973,7 @@ void movemasterswitch(DDukeActor *actor, int spectype1, int spectype2) spri->hitag--; if (spri->hitag <= 0) { - operatesectors(spri->sectnum, actor); + operatesectors(spri->sector(), actor); DukeSectIterator it(spri->sectnum); while (auto effector = it.Next()) @@ -3597,7 +3597,7 @@ void handle_se10(DDukeActor* actor, const int* specialtags) return; } } - fi.activatebysector(s->sectnum, actor); + fi.activatebysector(s->sector(), actor); t[0] = 0; } else t[0]++; diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index 50aaed5a9..36cae4a61 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -109,7 +109,7 @@ static const char* cheatUnlock() { if (j & (0xffff - 16384)) sect.lotag &= (0xffff - 16384); - operatesectors(sectnum(§), ps[myconnectindex].GetActor()); + operatesectors(§, ps[myconnectindex].GetActor()); } } fi.operateforcefields(ps[myconnectindex].GetActor(), -1); diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 1e2e87973..fdd68fd6b 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -45,8 +45,8 @@ void operateforcefields_r(DDukeActor* act, int low); void operateforcefields_d(DDukeActor* act, int low); bool checkhitswitch_d(int snum, walltype* w, DDukeActor *act); bool checkhitswitch_r(int snum, walltype* w, DDukeActor* act); -void activatebysector_d(int sect, DDukeActor* j); -void activatebysector_r(int sect, DDukeActor* j); +void activatebysector_d(sectortype* sect, DDukeActor* j); +void activatebysector_r(sectortype* sect, DDukeActor* j); void checkhitwall_d(DDukeActor* spr, walltype* dawall, int x, int y, int z, int atwith); void checkhitwall_r(DDukeActor* spr, walltype* dawall, int x, int y, int z, int atwith); bool checkhitceiling_d(sectortype* sn); diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 44e402c6a..65ffde440 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -83,7 +83,7 @@ struct Dispatcher void (*operaterespawns)(int low); void (*operateforcefields)(DDukeActor* act, int low); bool (*checkhitswitch)(int snum, walltype* w, DDukeActor* act); - void (*activatebysector)(int sect, DDukeActor* j); + void (*activatebysector)(sectortype* sect, DDukeActor* j); void (*checkhitwall)(DDukeActor* spr, walltype* dawall, int x, int y, int z, int atwith); bool (*checkhitceiling)(sectortype* sn); void (*checkhitsprite)(DDukeActor* i, DDukeActor* sn); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 88cdfe230..abffcddf0 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -148,7 +148,7 @@ int check_activator_motion(int lotag); void operateactivators(int l, int w); void operateforcefields_common(DDukeActor* s, int low, const std::initializer_list& tiles); void operatemasterswitches(int lotag); -void operatesectors(int s, DDukeActor* i); +void operatesectors(sectortype* 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 c863849c2..1c68272a6 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2495,7 +2495,7 @@ int ParseState::parse(void) break; } if (a2 == nullptr) - operatesectors(sectnum(sectp), g_ac); + operatesectors(sectp, g_ac); } } } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index fbbdacaaf..5a2f19c1e 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -3092,7 +3092,7 @@ HORIZONLY: { if (!(s->sector()->lotag & 0x8000) && (isanunderoperator(s->sector()->lotag) || isanearoperator(s->sector()->lotag))) - fi.activatebysector(s->sectnum, pact); + fi.activatebysector(s->sector(), pact); if (j) { quickkill(p); @@ -3100,7 +3100,7 @@ HORIZONLY: } } else if (abs(fz - cz) < (32 << 8) && isanunderoperator(psectp->lotag)) - fi.activatebysector(psect, pact); + fi.activatebysector(psectp, pact); } // center_view diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 3d1b89907..c4609b307 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3923,7 +3923,7 @@ HORIZONLY: { if (!(s->sector()->lotag & 0x8000) && (isanunderoperator(s->sector()->lotag) || isanearoperator(s->sector()->lotag))) - fi.activatebysector(s->sectnum, pact); + fi.activatebysector(s->sector(), pact); if (j) { quickkill(p); @@ -3931,7 +3931,7 @@ HORIZONLY: } } else if (abs(fz - cz) < (32 << 8) && isanunderoperator(psectp->lotag)) - fi.activatebysector(psect, pact); + fi.activatebysector(psectp, pact); } if (ud.clipping == 0 && p->cursector()->ceilingz > (p->cursector()->floorz - (12 << 8))) diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 9886668c5..d86170a50 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -967,13 +967,10 @@ static void handle_st28(sectortype* sptr, DDukeActor* actor) // //--------------------------------------------------------------------------- -void operatesectors(int sn, DDukeActor *actor) +void operatesectors(sectortype* sptr, DDukeActor *actor) { int j=0; int i; - sectortype* sptr; - - sptr = §or[sn]; switch (sptr->lotag & (0x3fff)) { @@ -986,8 +983,8 @@ void operatesectors(int sn, DDukeActor *actor) if (!isRR()) break; for (auto& wal : wallsofsector(sptr)) { - setanimation(sn, anim_vertexx, &wal, wal.x + 1024, 4); - if (wal.nextwall >= 0) setanimation(sn, anim_vertexx, wal.nextwall, wal.nextWall()->x + 1024, 4); + setanimation(sptr, anim_vertexx, &wal, wal.x + 1024, 4); + if (wal.nextwall >= 0) setanimation(sptr, anim_vertexx, wal.nextWall(), wal.nextWall()->x + 1024, 4); } break; @@ -995,7 +992,7 @@ void operatesectors(int sn, DDukeActor *actor) { auto act = ScriptIndexToActor(sptr->hitag); if (!act) break; - if (act->tempang == 0 || act->tempang == 256) callsound(sn, actor); + if (act->tempang == 0 || act->tempang == 256) callsound(sptr, actor); if (act->s->extra == 1) act->s->extra = 3; else act->s->extra = 1; break; @@ -1008,20 +1005,20 @@ void operatesectors(int sn, DDukeActor *actor) if (act->temp_data[4] == 0) act->temp_data[4] = 1; - callsound(sn, actor); + callsound(sptr, actor); break; } case ST_26_SPLITTING_ST_DOOR: //The split doors - i = getanimationgoal(anim_ceilingz, sn); + i = getanimationgoal(anim_ceilingz, sectnum(sptr)); if (i == -1) //if the door has stopped { haltsoundhack = 1; sptr->lotag &= 0xff00; sptr->lotag |= ST_22_SPLITTING_DOOR; - operatesectors(sn, actor); + operatesectors(sptr, actor); sptr->lotag &= 0xff00; sptr->lotag |= ST_9_SLIDING_ST_DOOR; - operatesectors(sn, actor); + operatesectors(sptr, actor); sptr->lotag &= 0xff00; sptr->lotag |= ST_26_SPLITTING_ST_DOOR; } @@ -1169,7 +1166,7 @@ void operateactivators(int low, int plnum) if (k == -1 && (act->getSector()->lotag & 0xff) == 22) k = callsound(act->s->sectnum, act); - operatesectors(act->s->sectnum, act); + operatesectors(act->s->sector(), act); } } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 0cfa5fdcf..463c715fe 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -613,7 +613,7 @@ bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act) // //--------------------------------------------------------------------------- -void activatebysector_d(int sect, DDukeActor* activator) +void activatebysector_d(sectortype* sect, DDukeActor* activator) { int didit = 0; @@ -1801,7 +1801,7 @@ void checksectors_d(int snum) if (act->s->picnum == ACTIVATOR || act->s->picnum == MASTERSWITCH) return; } - operatesectors(sectnum(ntsector), p->GetActor()); + operatesectors(ntsector, p->GetActor()); } else if ((p->GetActor()->getSector()->lotag & 16384) == 0) { @@ -1812,7 +1812,7 @@ void checksectors_d(int snum) { if (act->s->picnum == ACTIVATOR || act->s->picnum == MASTERSWITCH) return; } - operatesectors(p->GetActor()->s->sectnum, p->GetActor()); + operatesectors(p->GetActor()->s->sector(), p->GetActor()); } else fi.checkhitswitch(snum, ntwall, nullptr); } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 042ee3288..724915ec1 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -900,7 +900,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act) // //--------------------------------------------------------------------------- -void activatebysector_r(int sect, DDukeActor* activator) +void activatebysector_r(sectortype* sect, DDukeActor* activator) { DukeSectIterator it(sect); while (auto act = it.Next()) @@ -912,7 +912,7 @@ void activatebysector_r(int sect, DDukeActor* activator) } } - if (sector[sect].lotag != 22) + if (sect->lotag != 22) operatesectors(sect, activator); } @@ -926,9 +926,9 @@ void activatebysector_r(int sect, DDukeActor* activator) static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n) { int j, z; - int sect, a; + int a; - sect = -1; + sectortype* sect = nullptr; auto sp = actor->s; if (wal == nullptr) @@ -960,9 +960,9 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n) y1 += delta.y; updatesector(x1, y1, §); - if (sect >= 0) + if (sect) { - z = sector[sect].floorz - (krand() & (abs(sector[sect].ceilingz - sector[sect].floorz))); + z = sect->floorz - (krand() & (abs(sect->ceilingz - sect->floorz))); if (z < -(32 << 8) || z >(32 << 8)) z = sp->z - (32 << 8) + (krand() & ((64 << 8) - 1)); a = sp->ang - 1024; @@ -2746,7 +2746,7 @@ void checksectors_r(int snum) return; } if (haskey(sectnum(ntsector), snum)) - operatesectors(sectnum(ntsector), p->GetActor()); + operatesectors(ntsector, p->GetActor()); else { if (neartagsprite && neartagsprite->spriteextra > 3) @@ -2767,7 +2767,7 @@ void checksectors_r(int snum) return; } if (haskey(sectnum(ntsector), snum)) - operatesectors(p->GetActor()->s->sectnum, p->GetActor()); + operatesectors(p->GetActor()->s->sector(), p->GetActor()); else { if (neartagsprite && neartagsprite->spriteextra > 3)