Skip to content

Commit

Permalink
- one third of SW's iterators.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Oct 15, 2020
1 parent eb78b88 commit a506b45
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 87 deletions.
3 changes: 2 additions & 1 deletion source/sw/src/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ DoActorPickClosePlayer(short SpriteNum)
if (!found && TEST(u->Flags2, SPR2_DONT_TARGET_OWNER))
{
near_dist = MAX_ACTIVE_RANGE;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
if (i == SpriteNum)
continue;
Expand Down
6 changes: 4 additions & 2 deletions source/sw/src/break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ short FindBreakSpriteMatch(short match)
{
short i,nexti;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_BREAKABLE], i, nexti)
StatIterator it(STAT_BREAKABLE);
while ((i = it.NextIndex()) >= 0)
{
if (SPRITE_TAG2(i) == match && sprite[i].picnum == ST1)
{
Expand Down Expand Up @@ -1120,7 +1121,8 @@ static void DoWallBreakSpriteMatch(short match)
{
short i,nexti;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
SPRITEp sp = &sprite[i];

Expand Down
3 changes: 2 additions & 1 deletion source/sw/src/bunny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ DoPickCloseBunny(short SpriteNum)
int look_height = SPRITEp_TOS(sp);
bool ICanSee = false;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
tsp = &sprite[i];
tu = User[i];
Expand Down
3 changes: 2 additions & 1 deletion source/sw/src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ void PreCacheOverride(void)
{
int i,nexti;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti)
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
ASSERT(SPRITE_TAG2(i) >= 0 && SPRITE_TAG2(i) <= MAXTILES);
SET_GOTPIC(SPRITE_TAG2(i));
Expand Down
14 changes: 9 additions & 5 deletions source/sw/src/copysect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,23 @@ void CopySectorWalls(short dest_sectnum, short src_sectnum)

void CopySectorMatch(short match)
{
short ed,nexted,ss,nextss;
int ed,ss;
SPRITEp dest_sp, src_sp;
SECTORp dsectp,ssectp;
short kill, nextkill;
SPRITEp k;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_COPY_DEST], ed, nexted)
StatIterator it(STAT_COPY_DEST);
while ((ed = it.NextIndex()) >= 0)
{
dest_sp = &sprite[ed];
dsectp = &sector[dest_sp->sectnum];

if (match != sprite[ed].lotag)
continue;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_COPY_SOURCE], ss, nextss)
StatIterator it2(STAT_COPY_SOURCE);
while ((ss = it2.NextIndex()) >= 0)
{
src_sp = &sprite[ss];

Expand Down Expand Up @@ -247,14 +249,16 @@ void CopySectorMatch(short match)
// do this outside of processing loop for safety

// kill all matching dest
TRAVERSE_SPRITE_STAT(headspritestat[STAT_COPY_DEST], ed, nexted)
it.Reset(STAT_COPY_DEST);
while ((ed = it.NextIndex()) >= 0)
{
if (match == sprite[ed].lotag)
KillSprite(ed);
}

// kill all matching sources
TRAVERSE_SPRITE_STAT(headspritestat[STAT_COPY_SOURCE], ss, nextss)
it.Reset(STAT_COPY_SOURCE);
while ((ss = it.NextIndex()) >= 0)
{
if (match == sprite[ss].lotag)
KillSprite(ss);
Expand Down
32 changes: 20 additions & 12 deletions source/sw/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,22 @@ void SetVoxelSprite(SPRITEp sp, short pic)
void WarpCopySprite(void)
{
SPRITEp sp1, sp2, sp;
short sn, nsn;
short sn2, nsn2;
short spnum, next_spnum;
int sn, sn2;
int spnum, next_spnum;
int xoff,yoff,zoff;
short match;
short sect1, sect2;

// look for the first one
TRAVERSE_SPRITE_STAT(headspritestat[STAT_WARP_COPY_SPRITE1], sn, nsn)
StatIterator it(STAT_WARP_COPY_SPRITE1);
while ((sn = it.NextIndex()) >= 0)
{
sp1 = &sprite[sn];
match = sp1->lotag;

// look for the second one
TRAVERSE_SPRITE_STAT(headspritestat[STAT_WARP_COPY_SPRITE2], sn2, nsn2)
StatIterator it1(STAT_WARP_COPY_SPRITE2);
while ((sn2 = it1.NextIndex()) >= 0)
{
sp = &sprite[sn2];

Expand Down Expand Up @@ -1272,7 +1273,8 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, binangle

if (pp == &Player[screenpeek])
{
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEMO_CAMERA], i, nexti)
StatIterator it(STAT_DEMO_CAMERA);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];

Expand Down Expand Up @@ -1381,7 +1383,8 @@ PreDraw(void)

PreDrawStackedWater();

TRAVERSE_SPRITE_STAT(headspritestat[STAT_FLOOR_SLOPE_DONT_DRAW], i, nexti)
StatIterator it(STAT_FLOOR_SLOPE_DONT_DRAW);
while ((i = it.NextIndex()) >= 0)
{
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_SLOPE);
}
Expand All @@ -1392,12 +1395,14 @@ PostDraw(void)
{
short i, nexti;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_FLOOR_SLOPE_DONT_DRAW], i, nexti)
StatIterator it(STAT_FLOOR_SLOPE_DONT_DRAW);
while ((i = it.NextIndex()) >= 0)
{
SET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_SLOPE);
}

TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF_COPY], i, nexti)
it.Reset(STAT_FAF_COPY);
while ((i = it.NextIndex()) >= 0)
{
if (User[i])
{
Expand Down Expand Up @@ -1483,7 +1488,8 @@ void PreDrawStackedWater(void)
USERp u,nu;
short New;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], si, snexti)
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((si = it.NextIndex()) >= 0)
{
TRAVERSE_SPRITE_SECT(headspritesect[sprite[si].sectnum], i, nexti)
{
Expand Down Expand Up @@ -1542,7 +1548,8 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short
{
short i,nexti;

TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti)
StatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
if (SPRITE_TAG3(i) == 0)
{
Expand All @@ -1567,7 +1574,8 @@ void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short

renderDrawRoomsQ16(x,y,z,q16ang,q16horiz,sectnum);

TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti)
it.Reset(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while ((i = it.NextIndex()) >= 0)
{
// manually set gotpic
if (TEST_GOTSECTOR(sprite[i].sectnum))
Expand Down
7 changes: 4 additions & 3 deletions source/sw/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,18 +507,19 @@ void TerminateLevel(void)

pnum = stat - STAT_PLAYER0;

TRAVERSE_SPRITE_STAT(headspritestat[stat], i, nexti)
StatIterator it(stat);
while ((i = it.NextIndex()) >= 0)
{
if (User[i])
memcpy(&puser[pnum], User[i], sizeof(USER));
}
}

// Kill User memory and delete sprites
// for (stat = 0; stat < STAT_ALL; stat++)
for (stat = 0; stat < MAXSTATUS; stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[stat], i, nexti)
StatIterator it(stat);
while ((i = it.NextIndex()) >= 0)
{
KillSprite(i);
}
Expand Down
3 changes: 2 additions & 1 deletion source/sw/src/hornet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ int DoCheckSwarm(short SpriteNum)
return 0;

// all enemys
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
tsp = &sprite[i];
tu = User[i];
Expand Down
3 changes: 2 additions & 1 deletion source/sw/src/jsector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ JS_ProcessEchoSpot()
bool reverb_set = false;

// Process echo sprites
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ECHO], i, nexti)
StatIterator it(STAT_ECHO);
while ((i = it.NextIndex()) >= 0)
{
dist = 0x7fffffff;

Expand Down
9 changes: 6 additions & 3 deletions source/sw/src/jweapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,8 @@ PlayerInitFlashBomb(PLAYERp pp)

for (stat = 0; stat < SIZ(StatDamageList); stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[StatDamageList[stat]], i, nexti)
StatIterator it(StatDamageList[stat]);
while ((i = it.NextIndex()) >= 0)
{
hp = &sprite[i];
hu = User[i];
Expand Down Expand Up @@ -1665,7 +1666,8 @@ InitFlashBomb(int16_t SpriteNum)

for (stat = 0; stat < SIZ(StatDamageList); stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[StatDamageList[stat]], i, nexti)
StatIterator it(StatDamageList[stat]);
while ((i = it.NextIndex()) >= 0)
{
hp = &sprite[i];
hu = User[i];
Expand Down Expand Up @@ -2143,7 +2145,8 @@ DoFlagRangeTest(short Weapon, short range)

for (stat = 0; stat < SIZ(StatDamageList); stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[StatDamageList[stat]], i, nexti)
StatIterator it(StatDamageList[stat]);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];

Expand Down
3 changes: 2 additions & 1 deletion source/sw/src/miscactr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@ int PachinkoCheckWin(short SpriteNum)
SET_BOOL1(sp);

// Turn on the pachinko lights
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
tsp = &sprite[i];
tu = User[i];
Expand Down

0 comments on commit a506b45

Please sign in to comment.