diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp index 9443f89ad..f1738a1b6 100644 --- a/source/games/duke/src/bowling.cpp +++ b/source/games/duke/src/bowling.cpp @@ -63,8 +63,9 @@ void pinsectorresetdown(int sect) if (j == -1) { - j = sector[sect].floorz; - setanimation(sect, anim_ceilingz, sect, j, 64); + auto sec = §or[sect]; + j = sec->floorz; + setanimation(sec, anim_ceilingz, sec, j, 64); } } @@ -74,8 +75,9 @@ int pinsectorresetup(int sect) if (j == -1) { - j = nextsectorneighborzptr(§or[sect], sector[sect].ceilingz, -1, -1)->ceilingz; - setanimation(sect, anim_ceilingz, sect, j, 64); + auto sec = §or[sect]; + j = nextsectorneighborzptr(sec, sec->ceilingz, -1, -1)->ceilingz; + setanimation(sec, anim_ceilingz, sec, j, 64); return 1; } return 0; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index c4bb0155a..13895c206 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -153,7 +153,8 @@ void hud_input(int playerNum); int getanimationgoal(int animtype, int animindex); bool isanearoperator(int lotag); bool isanunderoperator(int lotag); -int setanimation(int animsect, int animtype, int animindex, int thegoal, int thevel); +int setanimation(sectortype* animsect, int animtype, walltype* animtarget, int thegoal, int thevel); +int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, int thegoal, int thevel); void dofurniture(walltype* wallNum, sectortype* sectnum, int playerNum); void dotorch(); int hitawall(struct player_struct* pl, walltype** hitWall); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index 824ce4a48..40ca78e78 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -102,7 +102,7 @@ DDukeActor* spriteq[1024]; animwalltype animwall[MAXANIMWALLS]; // animated walls int numanimwalls; int animatecnt; // sector plane movement -int animatesect[MAXANIMATES]; +sectortype* animatesect[MAXANIMATES]; int8_t animatetype[MAXANIMATES]; int animatetarget[MAXANIMATES]; int animategoal[MAXANIMATES]; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index a736f6fb5..c301b8c46 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -84,7 +84,7 @@ enum animtype_t anim_vertexx, anim_vertexy, }; -extern int animatesect[MAXANIMATES]; +extern sectortype* animatesect[MAXANIMATES]; extern int animatetarget[MAXANIMATES]; extern int8_t animatetype[MAXANIMATES]; extern int animategoal[MAXANIMATES]; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index d86170a50..fa0e6fb4c 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -123,7 +123,7 @@ int check_activator_motion(int lotag) if (act->s->lotag == lotag) { for (int j = animatecnt - 1; j >= 0; j--) - if (act->s->sectnum == animatesect[j]) + if (act->s->sector() == animatesect[j]) return(1); DukeStatIterator it1(STAT_EFFECTOR); @@ -310,13 +310,13 @@ int* animateptr(int i) void doanimations(void) { - int i, a, p, v, dasect; + int i, a, p, v; for (i = animatecnt - 1; i >= 0; i--) { a = *animateptr(i); v = animatevel[i] * TICSPERFRAME; - dasect = animatesect[i]; + auto dasectp = animatesect[i]; if (a == animategoal[i]) { @@ -328,12 +328,13 @@ void doanimations(void) animategoal[i] = animategoal[animatecnt]; animatevel[i] = animatevel[animatecnt]; animatesect[i] = animatesect[animatecnt]; - if (sector[animatesect[i]].lotag == ST_18_ELEVATOR_DOWN || sector[animatesect[i]].lotag == ST_19_ELEVATOR_UP) + dasectp = animatesect[i]; + if (dasectp->lotag == ST_18_ELEVATOR_DOWN || dasectp->lotag == ST_19_ELEVATOR_UP) if (animatetype[i] == anim_ceilingz) continue; - if ((sector[dasect].lotag & 0xff) != ST_22_SPLITTING_DOOR) - callsound(dasect, nullptr); + if ((dasectp->lotag & 0xff) != ST_22_SPLITTING_DOOR) + callsound(dasectp, nullptr); continue; } @@ -344,22 +345,22 @@ void doanimations(void) if (animatetype[i] == anim_floorz) { for (p = connecthead; p >= 0; p = connectpoint2[p]) - if (ps[p].cursectnum == dasect) - if ((sector[dasect].floorz - ps[p].pos.z) < (64 << 8)) + if (ps[p].cursector() == dasectp) + if ((dasectp->floorz - ps[p].pos.z) < (64 << 8)) if (ps[p].GetActor()->GetOwner() != nullptr) { ps[p].pos.z += v; ps[p].poszv = 0; } - DukeSectIterator it(dasect); + DukeSectIterator it(dasectp); while (auto act = it.Next()) { if (act->s->statnum != STAT_EFFECTOR) { act->s->backupz(); act->s->z += v; - act->floorz = sector[dasect].floorz + v; + act->floorz = dasectp->floorz + v; } } } @@ -394,7 +395,7 @@ int getanimationgoal(int animtype, int animtarget) // //--------------------------------------------------------------------------- -int setanimation(int animsect, int animtype, int animtarget, int thegoal, int thevel) +static int dosetanimation(sectortype* animsect, int animtype, int animtarget, int thegoal, int thevel) { int i, j; @@ -425,28 +426,16 @@ int setanimation(int animsect, int animtype, int animtarget, int thegoal, int th return(j); } -int setanimation(int animsect, int animtype, walltype* animtarget, int thegoal, int thevel) -{ - assert(animtype == anim_vertexx || animtype == anim_vertexy); - return setanimation(animsect, animtype, wallnum(animtarget), thegoal, thevel); -} - -int setanimation(int animsect, int animtype, sectortype* animtarget, int thegoal, int thevel) -{ - assert(animtype == anim_ceilingz || animtype == anim_floorz); - return setanimation(animsect, animtype, sectnum(animtarget), thegoal, thevel); -} - int setanimation(sectortype* animsect, int animtype, walltype* animtarget, int thegoal, int thevel) { assert(animtype == anim_vertexx || animtype == anim_vertexy); - return setanimation(sectnum(animsect), animtype, wallnum(animtarget), thegoal, thevel); + return dosetanimation(animsect, animtype, wallnum(animtarget), thegoal, thevel); } int setanimation(sectortype* animsect, int animtype, sectortype* animtarget, int thegoal, int thevel) { assert(animtype == anim_ceilingz || animtype == anim_floorz); - return setanimation(sectnum(animsect), animtype, sectnum(animtarget), thegoal, thevel); + return dosetanimation(animsect, animtype, sectnum(animtarget), thegoal, thevel); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 24938b89e..80c46152e 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -557,7 +557,7 @@ bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act) switch (other->s->lotag) { case SE_12_LIGHT_SWITCH: - sector[other->s->sectnum].floorpal = 0; + other->getSector()->floorpal = 0; other->temp_data[0]++; if (other->temp_data[0] == 2) other->temp_data[0]++; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 0817288d1..dba54dc62 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -844,7 +844,7 @@ bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act) if (!isRRRA()) break; [[fallthrough]]; case SE_12_LIGHT_SWITCH: - sector[other->s->sectnum].floorpal = 0; + other->getSector()->floorpal = 0; other->temp_data[0]++; if (other->temp_data[0] == 2) other->temp_data[0]++;