- another batch in SW.

This commit is contained in:
Christoph Oelckers 2020-10-15 18:07:35 +02:00
parent 727e2ceb29
commit 6eb6938bbe
9 changed files with 93 additions and 60 deletions

View file

@ -110,7 +110,7 @@ void CopySectorMatch(short match)
int ed,ss; int ed,ss;
SPRITEp dest_sp, src_sp; SPRITEp dest_sp, src_sp;
SECTORp dsectp,ssectp; SECTORp dsectp,ssectp;
short kill, nextkill; int kill;
SPRITEp k; SPRITEp k;
StatIterator it(STAT_COPY_DEST); StatIterator it(STAT_COPY_DEST);
@ -130,7 +130,7 @@ void CopySectorMatch(short match)
if (SP_TAG2(src_sp) == SPRITE_TAG2(ed) && if (SP_TAG2(src_sp) == SPRITE_TAG2(ed) &&
SP_TAG3(src_sp) == SPRITE_TAG3(ed)) SP_TAG3(src_sp) == SPRITE_TAG3(ed))
{ {
short src_move, nextsrc_move; int src_move;
ssectp = &sector[src_sp->sectnum]; ssectp = &sector[src_sp->sectnum];
// !!!!!AAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHH // !!!!!AAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHH
@ -140,7 +140,8 @@ void CopySectorMatch(short match)
#if 1 #if 1
// kill all sprites in the dest sector that need to be // kill all sprites in the dest sector that need to be
TRAVERSE_SPRITE_SECT(headspritesect[dest_sp->sectnum], kill, nextkill) SectIterator itsec(dest_sp->sectnum);
while ((kill = itsec.NextIndex()) >= 0)
{ {
k = &sprite[kill]; k = &sprite[kill];
@ -163,7 +164,8 @@ void CopySectorMatch(short match)
CopySectorWalls(dest_sp->sectnum, src_sp->sectnum); CopySectorWalls(dest_sp->sectnum, src_sp->sectnum);
TRAVERSE_SPRITE_SECT(headspritesect[src_sp->sectnum], src_move, nextsrc_move) itsec.Reset(src_sp->sectnum);
while ((src_move = itsec.NextIndex()) >= 0)
{ {
// don't move ST1 Copy Tags // don't move ST1 Copy Tags
if (SPRITE_TAG1(src_move) != SECT_COPY_SOURCE) if (SPRITE_TAG1(src_move) != SECT_COPY_SOURCE)

View file

@ -454,7 +454,7 @@ void WarpCopySprite(void)
{ {
SPRITEp sp1, sp2, sp; SPRITEp sp1, sp2, sp;
int sn, sn2; int sn, sn2;
int spnum, next_spnum; int spnum;
int xoff,yoff,zoff; int xoff,yoff,zoff;
short match; short match;
short sect1, sect2; short sect1, sect2;
@ -478,7 +478,8 @@ void WarpCopySprite(void)
sect1 = sp1->sectnum; sect1 = sp1->sectnum;
sect2 = sp2->sectnum; sect2 = sp2->sectnum;
TRAVERSE_SPRITE_SECT(headspritesect[sect1], spnum, next_spnum) SectIterator it(sect1);
while ((spnum = it.NextIndex()) >= 0)
{ {
if (&sprite[spnum] == sp1) if (&sprite[spnum] == sp1)
continue; continue;
@ -499,7 +500,8 @@ void WarpCopySprite(void)
New->sectnum = sp2->sectnum; New->sectnum = sp2->sectnum;
} }
TRAVERSE_SPRITE_SECT(headspritesect[sect2], spnum, next_spnum) it.Reset(sect2);
while ((spnum = it.NextIndex()) >= 0)
{ {
if (&sprite[spnum] == sp2) if (&sprite[spnum] == sp2)
continue; continue;
@ -1900,7 +1902,9 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
// Draw sprites // Draw sprites
k = Player[screenpeek].PlayerSprite; k = Player[screenpeek].PlayerSprite;
for (i = 0; i < numsectors; i++) for (i = 0; i < numsectors; i++)
for (j = headspritesect[i]; j >= 0; j = nextspritesect[j]) {
SectIterator it(i);
while ((j = it.NextIndex()) >= 0)
{ {
for (p = connecthead; p >= 0; p = connectpoint2[p]) for (p = connecthead; p >= 0; p = connectpoint2[p])
{ {
@ -2074,7 +2078,8 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
} }
} }
} }
return true; }
return true;
} }

View file

@ -170,12 +170,12 @@ void
JS_SpriteSetup(void) JS_SpriteSetup(void)
{ {
SPRITEp sp; SPRITEp sp;
short SpriteNum = 0, NextSprite; int SpriteNum;
USERp u; USERp u;
short i; short i;
StatIterator it(STAT_DEFAULT);
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite) while ((SpriteNum = it.NextIndex()) >= 0)
{ {
short tag; short tag;
@ -288,7 +288,7 @@ void JS_InitMirrors(void)
{ {
short startwall, endwall; short startwall, endwall;
int i, j, s; int i, j, s;
short SpriteNum = 0, NextSprite; int SpriteNum;
bool Found_Cam = false; bool Found_Cam = false;
@ -384,7 +384,8 @@ void JS_InitMirrors(void)
Found_Cam = false; Found_Cam = false;
if (TEST_BOOL1(&sprite[mirror[mirrorcnt].camera])) if (TEST_BOOL1(&sprite[mirror[mirrorcnt].camera]))
{ {
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite) StatIterator it(STAT_DEFAULT);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];
if (sp->picnum >= CAMSPRITE && sp->picnum < CAMSPRITE + 8 && if (sp->picnum >= CAMSPRITE && sp->picnum < CAMSPRITE + 8 &&
@ -1390,7 +1391,7 @@ void
UnlockKeyLock(short key_num, short hit_sprite) UnlockKeyLock(short key_num, short hit_sprite)
{ {
SPRITEp sp; SPRITEp sp;
int SpriteNum = 0, NextSprite = 0, color = 0; int SpriteNum = 0, color = 0;
// Get palette by looking at key number // Get palette by looking at key number
switch (key_num - 1) switch (key_num - 1)
@ -1421,7 +1422,8 @@ UnlockKeyLock(short key_num, short hit_sprite)
break; break;
} }
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite) StatIterator it(STAT_DEFAULT);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];

View file

@ -2114,9 +2114,10 @@ void
DoFlagScore(int16_t pal) DoFlagScore(int16_t pal)
{ {
SPRITEp sp; SPRITEp sp;
int SpriteNum = 0, NextSprite = 0; int SpriteNum;
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite) StatIterator it(STAT_DEFAULT);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];

View file

@ -7533,7 +7533,7 @@ InitMultiPlayerInfo(void)
SPRITEp sp; SPRITEp sp;
short pnum, start0; short pnum, start0;
unsigned stat; unsigned stat;
short SpriteNum, NextSprite, tag; int SpriteNum, tag;
static short MultiStatList[] = static short MultiStatList[] =
{ {
STAT_MULTI_START, STAT_MULTI_START,
@ -7541,7 +7541,8 @@ InitMultiPlayerInfo(void)
}; };
// this routine is called before SpriteSetup - process start positions NOW // this routine is called before SpriteSetup - process start positions NOW
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite) StatIterator it(STAT_DEFAULT);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];

View file

@ -89,10 +89,11 @@ int COVERinsertsprite(short sectnum, short stat)
bool bool
FAF_Sector(short sectnum) FAF_Sector(short sectnum)
{ {
short SpriteNum, Next; int SpriteNum;
SPRITEp sp; SPRITEp sp;
TRAVERSE_SPRITE_SECT(headspritesect[sectnum], SpriteNum, Next) SectIterator it(sectnum);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];
@ -687,7 +688,7 @@ GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
int i; int i;
short sectorlist[16]; short sectorlist[16];
int sln = 0; int sln = 0;
short SpriteNum, Next; int SpriteNum;
SPRITEp sp; SPRITEp sp;
// keep a list of the last stacked sectors the view was in and // keep a list of the last stacked sectors the view was in and
@ -700,7 +701,8 @@ GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
{ {
bool found = false; bool found = false;
TRAVERSE_SPRITE_SECT(headspritesect[GlobStackSect[i]], SpriteNum, Next) SectIterator it(GlobStackSect[i]);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];
@ -730,7 +732,8 @@ GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
{ {
bool found = false; bool found = false;
TRAVERSE_SPRITE_SECT(headspritesect[i], SpriteNum, Next) SectIterator it(i);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];

View file

@ -1134,14 +1134,15 @@ int DoSpawnSpot(short SpriteNum)
void void
DoSpawnSpotsForKill(short match) DoSpawnSpotsForKill(short match)
{ {
short sn, next_sn; int sn;
SPRITEp sp; SPRITEp sp;
USERp u; USERp u;
if (match < 0) if (match < 0)
return; return;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPAWN_SPOT], sn, next_sn) StatIterator it(STAT_SPAWN_SPOT);
while ((sn = it.NextIndex()) >= 0)
{ {
sp = &sprite[sn]; sp = &sprite[sn];
@ -1163,14 +1164,15 @@ DoSpawnSpotsForKill(short match)
void void
DoSpawnSpotsForDamage(short match) DoSpawnSpotsForDamage(short match)
{ {
short sn, next_sn; int sn;
SPRITEp sp; SPRITEp sp;
USERp u; USERp u;
if (match < 0) if (match < 0)
return; return;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPAWN_SPOT], sn, next_sn) StatIterator it(STAT_SPAWN_SPOT);
while ((sn = it.NextIndex()) >= 0)
{ {
sp = &sprite[sn]; sp = &sprite[sn];
@ -1191,7 +1193,7 @@ DoSpawnSpotsForDamage(short match)
void void
DoSoundSpotMatch(short match, short sound_num, short sound_type) DoSoundSpotMatch(short match, short sound_num, short sound_type)
{ {
short sn, next_sn; int sn;
SPRITEp sp; SPRITEp sp;
int flags; int flags;
short snd2play; short snd2play;
@ -1202,7 +1204,8 @@ DoSoundSpotMatch(short match, short sound_num, short sound_type)
ASSERT(sound_num >= 0); ASSERT(sound_num >= 0);
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SOUND_SPOT], sn, next_sn) StatIterator it(STAT_SOUND_SPOT);
while ((sn = it.NextIndex()) >= 0)
{ {
sp = &sprite[sn]; sp = &sprite[sn];
@ -1278,10 +1281,11 @@ DoSoundSpotMatch(short match, short sound_num, short sound_type)
void void
DoSoundSpotStopSound(short match) DoSoundSpotStopSound(short match)
{ {
short sn, next_sn; int sn;
SPRITEp sp; SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SOUND_SPOT], sn, next_sn) StatIterator it(STAT_SOUND_SPOT);
while ((sn = it.NextIndex()) >= 0)
{ {
sp = &sprite[sn]; sp = &sprite[sn];
@ -1296,10 +1300,11 @@ DoSoundSpotStopSound(short match)
void void
DoStopSoundSpotMatch(short match) DoStopSoundSpotMatch(short match)
{ {
short sn, next_sn; int sn;
SPRITEp sp; SPRITEp sp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_STOP_SOUND_SPOT], sn, next_sn) StatIterator it(STAT_STOP_SOUND_SPOT);
while ((sn = it.NextIndex()) >= 0)
{ {
sp = &sprite[sn]; sp = &sprite[sn];
@ -1528,11 +1533,12 @@ void DoDeleteSpriteMatch(short match)
void void
DoChangorMatch(short match) DoChangorMatch(short match)
{ {
short sn, next_sn; int sn;
SPRITEp sp; SPRITEp sp;
SECTORp sectp; SECTORp sectp;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_CHANGOR], sn, next_sn) StatIterator it(STAT_CHANGOR);
while ((sn = it.NextIndex()) >= 0)
{ {
sp = &sprite[sn]; sp = &sprite[sn];
sectp = &sector[sp->sectnum]; sectp = &sector[sp->sectnum];

View file

@ -1648,7 +1648,8 @@ void PreMapCombineFloors(void)
{ {
dasect = sectlist[sectlistplc++]; dasect = sectlist[sectlistplc++];
for (j=headspritesect[dasect]; j>=0; j=nextspritesect[j]) SectIterator it(dasect);
while ((j = it.NextIndex()) >= 0)
{ {
sprite[j].x += dx; sprite[j].x += dx;
sprite[j].y += dy; sprite[j].y += dy;
@ -1758,14 +1759,15 @@ SpriteSetupPost(void)
{ {
SPRITEp ds; SPRITEp ds;
USERp u; USERp u;
short SpriteNum, NextSprite; int SpriteNum;
int i; int i;
int cz,fz; int cz,fz;
// Post processing of some sprites after gone through the main SpriteSetup() // Post processing of some sprites after gone through the main SpriteSetup()
// routine // routine
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FLOOR_PAN], SpriteNum, NextSprite) StatIterator it(STAT_FLOOR_PAN);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
SectIterator it(sprite[SpriteNum].sectnum); SectIterator it(sprite[SpriteNum].sectnum);
while ((i = it.NextIndex()) >= 0) while ((i = it.NextIndex()) >= 0)
@ -1803,7 +1805,7 @@ void
SpriteSetup(void) SpriteSetup(void)
{ {
SPRITEp sp; SPRITEp sp;
short SpriteNum = 0, NextSprite; int SpriteNum;
USERp u; USERp u;
short i, num; short i, num;
int cz,fz; int cz,fz;
@ -1827,7 +1829,8 @@ SpriteSetup(void)
// Call my little sprite setup routine first // Call my little sprite setup routine first
JS_SpriteSetup(); JS_SpriteSetup();
TRAVERSE_SPRITE_STAT(headspritestat[0], SpriteNum, NextSprite) StatIterator it(STAT_DEFAULT);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];
@ -4752,7 +4755,8 @@ getzrangepoint(int x, int y, int z, short sectnum,
*florhit = sectnum + 16384; *florhit = sectnum + 16384;
// Go through sprites of only the current sector // Go through sprites of only the current sector
for (j = headspritesect[sectnum]; j >= 0; j = nextspritesect[j]) SectIterator it(sectnum);
while ((j = it.NextIndex()) >= 0)
{ {
spr = &sprite[j]; spr = &sprite[j];
cstat = spr->cstat; cstat = spr->cstat;

View file

@ -351,14 +351,15 @@ TrackClonePoint(short SpriteNum)
void QuickJumpSetup(short stat, short lotag, short type) void QuickJumpSetup(short stat, short lotag, short type)
{ {
short SpriteNum = 0, NextSprite, ndx; int SpriteNum = 0, ndx;
TRACK_POINTp tp; TRACK_POINTp tp;
TRACKp t; TRACKp t;
SPRITEp nsp; SPRITEp nsp;
short start_sprite, end_sprite; short start_sprite, end_sprite;
// make short quick jump tracks // make short quick jump tracks
TRAVERSE_SPRITE_STAT(headspritestat[stat], SpriteNum, NextSprite) StatIterator it(stat);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
// find an open track // find an open track
@ -416,14 +417,15 @@ void QuickJumpSetup(short stat, short lotag, short type)
void QuickScanSetup(short stat, short lotag, short type) void QuickScanSetup(short stat, short lotag, short type)
{ {
short SpriteNum = 0, NextSprite, ndx; int SpriteNum = 0, ndx;
TRACK_POINTp tp; TRACK_POINTp tp;
TRACKp t; TRACKp t;
SPRITEp nsp; SPRITEp nsp;
short start_sprite, end_sprite; short start_sprite, end_sprite;
// make short quick jump tracks // make short quick jump tracks
TRAVERSE_SPRITE_STAT(headspritestat[stat], SpriteNum, NextSprite) StatIterator it(stat);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
// find an open track // find an open track
@ -477,13 +479,14 @@ void QuickScanSetup(short stat, short lotag, short type)
void QuickExitSetup(short stat, short type) void QuickExitSetup(short stat, short type)
{ {
short SpriteNum = 0, NextSprite, ndx; int SpriteNum = 0, ndx;
TRACK_POINTp tp; TRACK_POINTp tp;
TRACKp t; TRACKp t;
SPRITEp nsp; SPRITEp nsp;
short start_sprite, end_sprite; short start_sprite, end_sprite;
TRAVERSE_SPRITE_STAT(headspritestat[stat], SpriteNum, NextSprite) StatIterator it(stat);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
// find an open track // find an open track
@ -532,13 +535,14 @@ void QuickExitSetup(short stat, short type)
void QuickLadderSetup(short stat, short lotag, short type) void QuickLadderSetup(short stat, short lotag, short type)
{ {
short SpriteNum = 0, NextSprite, ndx; int SpriteNum = 0, ndx;
TRACK_POINTp tp; TRACK_POINTp tp;
TRACKp t; TRACKp t;
SPRITEp nsp; SPRITEp nsp;
short start_sprite, end_sprite; short start_sprite, end_sprite;
TRAVERSE_SPRITE_STAT(headspritestat[stat], SpriteNum, NextSprite) StatIterator it(stat);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
// find an open track // find an open track
@ -594,7 +598,7 @@ void QuickLadderSetup(short stat, short lotag, short type)
void void
TrackSetup(void) TrackSetup(void)
{ {
short SpriteNum = 0, NextSprite, ndx; int SpriteNum = 0, ndx;
TRACK_POINTp tp; TRACK_POINTp tp;
TRACKp t; TRACKp t;
TRACK_POINTp New; TRACK_POINTp New;
@ -623,7 +627,8 @@ TrackSetup(void)
t = &Track[ndx]; t = &Track[ndx];
// find the first point and save it // find the first point and save it
TRAVERSE_SPRITE_STAT(headspritestat[STAT_TRACK + ndx], SpriteNum, NextSprite) StatIterator it(STAT_TRACK + ndx);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
if (LOW_TAG_SPRITE(SpriteNum) == TRACK_START) if (LOW_TAG_SPRITE(SpriteNum) == TRACK_START)
{ {
@ -660,7 +665,8 @@ TrackSetup(void)
int dist, low_dist = 999999; int dist, low_dist = 999999;
// find the closest point to the last point // find the closest point to the last point
TRAVERSE_SPRITE_STAT(headspritestat[STAT_TRACK + ndx], SpriteNum, NextSprite) StatIterator it(STAT_TRACK + ndx);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
dist = Distance((tp + t->NumPoints - 1)->x, (tp + t->NumPoints - 1)->y, sprite[SpriteNum].x, sprite[SpriteNum].y); dist = Distance((tp + t->NumPoints - 1)->x, (tp + t->NumPoints - 1)->y, sprite[SpriteNum].x, sprite[SpriteNum].y);
@ -705,9 +711,10 @@ TrackSetup(void)
SPRITEp SPRITEp
FindBoundSprite(short tag) FindBoundSprite(short tag)
{ {
short sn, next_sn; short sn;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ST1], sn, next_sn) StatIterator it(STAT_ST1);
while ((sn = it.NextIndex()) >= 0)
{ {
if (sprite[sn].hitag == tag) if (sprite[sn].hitag == tag)
{ {
@ -1037,7 +1044,7 @@ SetupSectorObject(short sectnum, short tag)
{ {
SPRITEp sp; SPRITEp sp;
SECTOR_OBJECTp sop; SECTOR_OBJECTp sop;
short object_num, SpriteNum, NextSprite; int object_num, SpriteNum;
short j; short j;
short New; short New;
USERp u; USERp u;
@ -1131,7 +1138,8 @@ SetupSectorObject(short sectnum, short tag)
SET(u->Flags2, SPR2_SPRITE_FAKE_BLOCK); // for damage test SET(u->Flags2, SPR2_SPRITE_FAKE_BLOCK); // for damage test
// check for any ST1 sprites laying on the center sector // check for any ST1 sprites laying on the center sector
TRAVERSE_SPRITE_SECT(headspritesect[sectnum], SpriteNum, NextSprite) SectIterator it(sectnum);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];
@ -2831,14 +2839,15 @@ PlaceSectorObject(SECTOR_OBJECTp sop, int newx, int newy)
void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator) void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator)
{ {
short SpriteNum, NextSprite; short SpriteNum;
SECTORp *sectp; SECTORp *sectp;
SPRITEp sp; SPRITEp sp;
USERp u; USERp u;
for (sectp = sop->sectp; *sectp; sectp++) for (sectp = sop->sectp; *sectp; sectp++)
{ {
TRAVERSE_SPRITE_SECT(headspritesect[*sectp - sector], SpriteNum, NextSprite) SectIterator it(*sectp - sector);
while ((SpriteNum = it.NextIndex()) >= 0)
{ {
sp = &sprite[SpriteNum]; sp = &sprite[SpriteNum];
u = User[SpriteNum]; u = User[SpriteNum];