From e84d61e80a809bc74c20a0679275b68a2cbb462e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Oct 2021 21:01:22 +0200 Subject: [PATCH] - redid the iterators in _polymost.cpp. --- source/games/sw/src/_polymost.cpp | 21 +++++++++------------ source/games/sw/src/jsector.h | 25 ++++++++----------------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/source/games/sw/src/_polymost.cpp b/source/games/sw/src/_polymost.cpp index b838b1aeb..38bd7b458 100644 --- a/source/games/sw/src/_polymost.cpp +++ b/source/games/sw/src/_polymost.cpp @@ -11,10 +11,10 @@ ViewSectorInScene(short cursectnum, short level) SPRITEp sp; short match; - StatIterator it(STAT_FAF); - while ((i = it.NextIndex()) >= 0) + SWStatIterator it(STAT_FAF); + while (auto actor = it.Next()) { - sp = &sprite[i]; + sp = &actor->s(); if (sp->hitag == level) { @@ -102,17 +102,16 @@ DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, shor void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short sectnum) { - int i; - StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE); - while ((i = it.NextIndex()) >= 0) + SWStatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE); + while (auto actor = it.Next()) { - auto sp = &sprite[i]; + auto sp = &actor->s(); if (SP_TAG3(sp) == 0) { // back up ceilingpicnum and ceilingstat SP_TAG5(sp) = sector[sp->sectnum].ceilingpicnum; sector[sp->sectnum].ceilingpicnum = SP_TAG2(sp); - SP_TAG4(sp) = sector[sprite[i].sectnum].ceilingstat; + SP_TAG4(sp) = sector[sp->sectnum].ceilingstat; //SET(sp->sectnum].ceilingstat, ((int)SP_TAG7(sp))<<7); SET(sector[sp->sectnum].ceilingstat, SP_TAG6(sp)); RESET(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX); @@ -131,9 +130,9 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short renderDrawRoomsQ16(x,y,z,q16ang,q16horiz,sectnum); it.Reset(STAT_CEILING_FLOOR_PIC_OVERRIDE); - while ((i = it.NextIndex()) >= 0) + while (auto actor = it.Next()) { - auto sp = &sprite[i]; + auto sp = &actor->s(); // manually set gotpic if (gotsector[sp->sectnum]) { @@ -252,8 +251,6 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed sp = &sprite[mirror[cnt].camera]; - ASSERT(sp); - // Calculate the angle of the mirror wall w = mirror[cnt].mirrorwall; diff --git a/source/games/sw/src/jsector.h b/source/games/sw/src/jsector.h index 5a26cf222..ed2eef270 100644 --- a/source/games/sw/src/jsector.h +++ b/source/games/sw/src/jsector.h @@ -40,26 +40,17 @@ typedef enum typedef struct { - short mirrorwall; // Wall number containing the mirror - // tile - short mirrorsector; // nextsector used internally to draw - // mirror rooms - short camera; // Contains number of ST1 sprite used - // as a camera + short mirrorwall; // Wall number containing the mirror tile + short mirrorsector; // nextsector used internally to draw mirror rooms + short camera; // Contains number of ST1 sprite used as a camera short camsprite; // sprite pointing to campic - short campic; // Editart tile number to draw a - // screen to + short campic; // Editart tile number to draw a screen to short numspawnspots; // Number of spawnspots used - short spawnspots[MAXMIRRORMONSTERS]; // One spot for each possible skill - // level for a - // max of up to 4 coolie ghosts to spawn. + short spawnspots[MAXMIRRORMONSTERS]; // One spot for each possible skill level for a max of up to 4 coolie ghosts to spawn. bool ismagic; // Is this a magic mirror? - uint8_t mstate; // What state the mirror is currently - // in - int maxtics; // Tic count used to time mirror - // events - int tics; // How much viewing time has been - // used on mirror? + uint8_t mstate; // What state the mirror is currently in + int maxtics; // Tic count used to time mirror events + int tics; // How much viewing time has been used on mirror? } MIRRORTYPE, *MIRRORTYPEp; extern MIRRORTYPE mirror[MAXMIRRORS];