- one third of SW's iterators.

This commit is contained in:
Christoph Oelckers 2020-10-15 17:30:55 +02:00
parent eb78b88598
commit a506b45369
20 changed files with 164 additions and 87 deletions

View file

@ -490,7 +490,8 @@ TARGETACTOR:
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;

View file

@ -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)
{
@ -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];

View file

@ -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];

View file

@ -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));

View file

@ -107,13 +107,14 @@ 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];
@ -121,7 +122,8 @@ void CopySectorMatch(short match)
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];
@ -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);

View file

@ -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];
@ -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];
@ -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);
}
@ -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])
{
@ -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)
{
@ -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)
{
@ -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))

View file

@ -507,7 +507,8 @@ 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));
@ -515,10 +516,10 @@ void TerminateLevel(void)
}
// 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);
}

View file

@ -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];

View file

@ -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;

View file

@ -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];
@ -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];
@ -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];

View file

@ -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];

View file

@ -1164,7 +1164,8 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets)
for (shp = StatDamageList; shp < &StatDamageList[SIZ(StatDamageList)]; shp++)
{
TRAVERSE_SPRITE_STAT(headspritestat[*shp], i, nexti)
StatIterator it(*shp);
while ((i = it.NextIndex()) >= 0)
{
ep = &sprite[i];
eu = User[i];
@ -2403,7 +2404,8 @@ void PlaySOsound(short sectnum, short sound_num)
short i,nexti;
// play idle sound - sound 1
TRAVERSE_SPRITE_SECT(headspritesect[sectnum], i, nexti)
SectIterator it(StatDamageList[sectnum]);
while ((i = it.NextIndex()) >= 0)
{
if (sprite[i].statnum == STAT_SOUND_SPOT)
{
@ -2418,7 +2420,8 @@ void StopSOsound(short sectnum)
short i,nexti;
// play idle sound - sound 1
TRAVERSE_SPRITE_SECT(headspritesect[sectnum], i, nexti)
SectIterator it(StatDamageList[sectnum]);
while ((i = it.NextIndex()) >= 0)
{
if (sprite[i].statnum == STAT_SOUND_SPOT)
DoSoundSpotStopSound(sprite[i].lotag);
@ -2531,7 +2534,8 @@ void DoTankTreads(PLAYERp pp)
for (sectp = pp->sop->sectp, j = 0; *sectp; sectp++, j++)
{
TRAVERSE_SPRITE_SECT(headspritesect[*sectp - sector], i, nexti)
SectIterator it(*sectp - sector);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -2650,7 +2654,8 @@ DriveCrush(PLAYERp pp, int *x, int *y)
return;
// main sector
TRAVERSE_SPRITE_SECT(headspritesect[sop->op_main_sector], i, nexti)
SectIterator it(StatDamageList[sop->op_main_sector]);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];
@ -2687,7 +2692,8 @@ DriveCrush(PLAYERp pp, int *x, int *y)
}
// all enemys
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it2(STAT_ENEMY);
while ((i = it2.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -2715,7 +2721,8 @@ DriveCrush(PLAYERp pp, int *x, int *y)
}
// all dead actors
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEAD_ACTOR], i, nexti)
it2.Reset(STAT_DEAD_ACTOR);
while ((i = it2.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -2763,7 +2770,8 @@ DriveCrush(PLAYERp pp, int *x, int *y)
// if it ends up actually in the drivable sector kill it
for (sectp = sop->sectp; *sectp; sectp++)
{
TRAVERSE_SPRITE_SECT(headspritesect[(*sectp) - sector], i, nexti)
SectIterator it((*sectp) - sector);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];
@ -4390,7 +4398,8 @@ DoPlayerWarpToUnderwater(PLAYERp pp)
// search for DIVE_AREA "over" sprite for reference point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DIVE_AREA], i, nexti)
StatIterator it(STAT_DIVE_AREA);
while ((i = it.NextIndex()) >= 0)
{
over_sp = &sprite[i];
@ -4407,7 +4416,8 @@ DoPlayerWarpToUnderwater(PLAYERp pp)
Found = false;
// search for UNDERWATER "under" sprite for reference point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_UNDERWATER], i, nexti)
it.Reset(STAT_UNDERWATER);
while ((i = it.NextIndex()) >= 0)
{
under_sp = &sprite[i];
@ -4465,7 +4475,8 @@ DoPlayerWarpToSurface(PLAYERp pp)
return;
// search for UNDERWATER "under" sprite for reference point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_UNDERWATER], i, nexti)
StatIterator it(STAT_UNDERWATER);
while ((i = it.NextIndex()) >= 0)
{
under_sp = &sprite[i];
@ -4482,7 +4493,8 @@ DoPlayerWarpToSurface(PLAYERp pp)
Found = false;
// search for DIVE_AREA "over" sprite for reference point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DIVE_AREA], i, nexti)
it.Reset(STAT_DIVE_AREA);
while ((i = it.NextIndex()) >= 0)
{
over_sp = &sprite[i];
@ -5294,7 +5306,8 @@ void DoPlayerOperateMatch(PLAYERp pp, bool starting)
if (!pp->sop)
return;
TRAVERSE_SPRITE_SECT(headspritesect[pp->sop->mid_sector], i, nexti)
SectIterator it(pp->sop->mid_sector);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -6343,7 +6356,8 @@ SPRITEp DoPlayerDeathCheckKick(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];
@ -6972,7 +6986,8 @@ MoveSkipSavePos(void)
for (stat = STAT_SKIP4_START; stat <= STAT_SKIP4_INTERP_END; stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[stat], i, nexti)
StatIterator it(stat);
while ((i = it.NextIndex()) >= 0)
{
if ((unsigned)i >= MAXSPRITES)
continue;
@ -6997,7 +7012,8 @@ MoveSkipSavePos(void)
for (stat = STAT_SKIP2_START; stat <= STAT_SKIP2_INTERP_END; stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[stat], i, nexti)
StatIterator it(stat);
while ((i = it.NextIndex()) >= 0)
{
if ((unsigned)i >= MAXSPRITES)
continue;

View file

@ -82,7 +82,8 @@ void DoQuakeMatch(short match)
short i, nexti;
SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_QUAKE_SPOT], i, nexti)
StatIterator it(STAT_QUAKE_SPOT);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -112,7 +113,8 @@ void ProcessQuakeOn(void)
short i, nexti;
SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_QUAKE_ON], i, nexti)
StatIterator it(STAT_QUAKE_ON);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -133,7 +135,8 @@ void ProcessQuakeSpot(void)
int rand_test;
// check timed quakes and random quakes
TRAVERSE_SPRITE_STAT(headspritestat[STAT_QUAKE_SPOT], i, nexti)
StatIterator it(STAT_QUAKE_SPOT);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -193,7 +196,8 @@ void QuakeViewChange(PLAYERp pp, int *z_diff, int *x_diff, int *y_diff, short *a
return;
// find the closest quake - should be a strength value
TRAVERSE_SPRITE_STAT(headspritestat[STAT_QUAKE_ON], i, nexti)
StatIterator it(STAT_QUAKE_ON);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];

View file

@ -355,7 +355,8 @@ GetZadjustment(short sectnum, short hitag)
if (sectnum < 0 || !TEST(sector[sectnum].extra, SECTFX_Z_ADJUST))
return 0L;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ST1], i, nexti)
StatIterator it(STAT_ST1);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -650,10 +651,11 @@ PicInView(short tile_num, bool reset)
void
SetupMirrorTiles(void)
{
short i, nexti;
int i, nexti;
SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
StatIterator it(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -809,7 +811,8 @@ FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum
// Search Stat List For closest ceiling view sprite
// Get the match, xoff, yoff from this point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
StatIterator it(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -821,7 +824,8 @@ FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum
}
}
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
it.Reset(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -852,7 +856,8 @@ FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum
pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8;
newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128);
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
it.Reset(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -896,7 +901,8 @@ FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
// Search Stat List For closest ceiling view sprite
// Get the match, xoff, yoff from this point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
StatIterator it(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -909,7 +915,8 @@ FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
}
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
it.Reset(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -941,7 +948,8 @@ FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8;
newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128);
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
it.Reset(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -979,7 +987,8 @@ ViewSectorInScene(short cursectnum, short level)
SPRITEp sp;
short match;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
StatIterator it(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];

View file

@ -80,7 +80,8 @@ RotatorSwitch(short match, short setting)
short i,nexti;
bool found = false;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEFAULT], i, nexti)
StatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -162,7 +163,8 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual)
//RotatorSwitch(match, ON);
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ROTATOR], i, nexti)
StatIterator it(STAT_ROTATOR);
while ((i = it.NextIndex()) >= 0)
{
fsp = &sprite[i];
@ -238,7 +240,8 @@ TestRotatorMatchActive(short match)
short i,nexti;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ROTATOR], i, nexti)
StatIterator it(STAT_ROTATOR);
while ((i = it.NextIndex()) >= 0)
{
fsp = &sprite[i];
@ -390,7 +393,8 @@ int DoRotatorMove(short SpriteNum)
}
closest = 99999;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ROTATOR_PIVOT], i, nexti)
StatIterator it(STAT_ROTATOR_PIVOT);
while ((i = it.NextIndex()) >= 0)
{
if (sprite[i].lotag == sp->lotag)
{

View file

@ -836,7 +836,8 @@ DoSpawnActorTrigger(short match)
short spawn_count = 0;
SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPAWN_TRIGGER], i, nexti)
StatIterator it(STAT_SPAWN_TRIGGER);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -1347,7 +1348,8 @@ SearchExplodeSectorMatch(short match)
short i,nexti;
// THIS IS ONLY CALLED FROM DoMatchEverything
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPRITE_HIT_MATCH], i, nexti)
StatIterator it(STAT_SPRITE_HIT_MATCH);
while ((i = it.NextIndex()) >= 0)
{
SPRITEp sp = &sprite[i];
@ -1368,7 +1370,8 @@ KillMatchingCrackSprites(short match)
short i,nexti;
SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPRITE_HIT_MATCH], i, nexti)
StatIterator it(STAT_SPRITE_HIT_MATCH);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -1392,7 +1395,8 @@ WeaponExplodeSectorInRange(short weapon)
int dist;
int radius;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPRITE_HIT_MATCH], i, nexti)
StatIterator it(STAT_SPRITE_HIT_MATCH);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -1474,7 +1478,8 @@ void DoDeleteSpriteMatch(short match)
found = -1;
// search for a DELETE_SPRITE with same match tag
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DELETE_SPRITE], i, nexti)
StatIterator it(STAT_DELETE_SPRITE);
while ((i = it.NextIndex()) >= 0)
{
if (sprite[i].lotag == match)
{
@ -1490,7 +1495,8 @@ void DoDeleteSpriteMatch(short match)
for (stat = 0; stat < SIZ(StatList); stat++)
{
TRAVERSE_SPRITE_STAT(headspritestat[StatList[stat]], i, nexti)
StatIterator it(StatList[stat]);
while ((i = it.NextIndex()) >= 0)
{
if (del_x == sprite[i].x && del_y == sprite[i].y)
{
@ -1627,7 +1633,8 @@ bool ComboSwitchTest(short combo_type, short match)
SPRITEp sp;
int state;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEFAULT], i, nexti)
StatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
@ -1977,7 +1984,8 @@ int DoTrapReset(short match)
SPRITEp sp;
USERp u;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_TRAP], i, nexti)
StatIterator it(STAT_TRAP);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];
@ -2008,7 +2016,8 @@ int DoTrapMatch(short match)
// may need to be reset to fire immediately
TRAVERSE_SPRITE_STAT(headspritestat[STAT_TRAP], i, nexti)
StatIterator it(STAT_TRAP);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];
@ -2162,7 +2171,8 @@ OperateTripTrigger(PLAYERp pp)
dist = sectp->hitag;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];
@ -2235,7 +2245,8 @@ OperateContinuousTrigger(PLAYERp pp)
SPRITEp sp;
USERp u;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_TRAP], i, nexti)
StatIterator it(STAT_TRAP);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];

View file

@ -769,7 +769,8 @@ KillSprite(int16_t SpriteNum)
if (sp->statnum == STAT_ENEMY)
{
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
if ((unsigned)i < MAXSPRITES && User[i] != NULL && User[i]->tgt_sp == sp)
{
@ -1592,7 +1593,7 @@ void PreMapCombineFloors(void)
#define MAX_FLOORS 32
SPRITEp sp;
int i, j, k;
int16_t SpriteNum, NextSprite;
int SpriteNum;
int base_offset;
int dx,dy;
short sectlist[MAXSECTORS];
@ -1608,7 +1609,8 @@ void PreMapCombineFloors(void)
memset(BoundList, 0, MAX_FLOORS * sizeof(BOUND_LIST));
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite)
StatIterator it(0);
while ((SpriteNum = it.NextIndex()) >= 0)
{
sp = &sprite[SpriteNum];
@ -1689,7 +1691,8 @@ void PreMapCombineFloors(void)
}
// get rid of the sprites used
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], SpriteNum, NextSprite)
it.Reset(STAT_FAF);
while ((SpriteNum = it.NextIndex()) >= 0)
{
KillSprite(SpriteNum);
}
@ -2878,7 +2881,8 @@ SpriteSetup(void)
{
int i,nexti;
// make sure there is only one set per level of these
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
StatIterator it(STAT_FAF);
while ((i = it.NextIndex()) >= 0)
{
if (sprite[i].hitag == sp->hitag && sprite[i].lotag == sp->lotag)
{
@ -6733,7 +6737,8 @@ SpriteControl(void)
if (MoveSkip2 == 0) // limit to 20 times a second
{
// move bad guys around
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
ASSERT(User[i]);

View file

@ -835,7 +835,8 @@ BossHealthMeter(void)
(currentLevel->levelNumber == 5 && BossSpriteNum[0] == -1) ||
(currentLevel->levelNumber == 11 && BossSpriteNum[1] == -1))
{
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
sp = &sprite[i];
u = User[i];

View file

@ -1550,7 +1550,8 @@ PlaceActorsOnTracks(void)
TRACK_POINTp tpoint = NULL;
// place each actor on the track
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
int low_dist = 999999, dist;

View file

@ -4945,7 +4945,7 @@ SetSuicide(short SpriteNum)
ChangeState(SpriteNum, s_Suicide);
#else
// this will NOT work because
// TRAVERSE_SPRITE_STAT(headspritestat[STAT_MISSILE], i, nexti)
// TRAVERSE_SPRITE_STAT([STAT_MISSILE], i, nexti)
// nexti will still be valid but will be on a different list
// and will have a different nextspritestat[nexti] result
changespritestat(SpriteNum, STAT_SUICIDE);
@ -12285,7 +12285,8 @@ DoBloodWorm(int16_t Weapon)
InitBloodSpray(Weapon, false, 1);
// Kill any old zombies you own
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
tsp = &sprite[i];
tu = User[i];
@ -12398,7 +12399,8 @@ DoBloodWorm(int16_t Weapon)
InitBloodSpray(Weapon, false, 1);
// Kill any old zombies you own
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
StatIterator it(STAT_ENEMY);
while ((i = it.NextIndex()) >= 0)
{
tsp = &sprite[i];
tu = User[i];