- the rest for SW.

This commit is contained in:
Christoph Oelckers 2020-10-15 18:59:11 +02:00
parent 6eb6938bbe
commit a8e7d1ef74
6 changed files with 29 additions and 39 deletions

View file

@ -253,8 +253,6 @@ inline int32_t FIXED(int32_t msw, int32_t lsw)
#define SectorIsDiveArea(sect) (TEST(sector[sect].extra, SECTFX_DIVE_AREA) ? true : false) #define SectorIsDiveArea(sect) (TEST(sector[sect].extra, SECTFX_DIVE_AREA) ? true : false)
#define SectorIsUnderwaterArea(sect) (TEST(sector[sect].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? true : false) #define SectorIsUnderwaterArea(sect) (TEST(sector[sect].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? true : false)
#define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritesect[o], (o) != -1; (o) = (n))
#define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = (o) == -1 ? -1 : nextspritestat[o], (o) != -1; (o) = (n))
#define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i]) #define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i])

View file

@ -337,11 +337,13 @@ void JS_InitMirrors(void)
mirror[mirrorcnt].ismagic = false; mirror[mirrorcnt].ismagic = false;
do if (wall[i].lotag == TAG_WALL_MAGIC_MIRROR) do if (wall[i].lotag == TAG_WALL_MAGIC_MIRROR)
{ {
short ii, nextii; int ii;
SPRITEp sp; SPRITEp sp;
Found_Cam = false; Found_Cam = false;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ST1], ii, nextii)
StatIterator it(STAT_ST1);
while ((ii = it.NextIndex()) >= 0)
{ {
sp = &sprite[ii]; sp = &sprite[ii];
// if correct type and matches // if correct type and matches
@ -355,10 +357,9 @@ void JS_InitMirrors(void)
} }
} }
ii = nextii = 0; it.Reset(STAT_SPAWN_SPOT);
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPAWN_SPOT], ii, nextii) while ((ii = it.NextIndex()) >= 0)
{ {
sp = &sprite[ii]; sp = &sprite[ii];
// if correct type and matches // if correct type and matches

View file

@ -2740,7 +2740,7 @@ DriveCrush(PLAYERp pp, int *x, int *y)
// all players // all players
for (stat = 0; stat < MAX_SW_PLAYERS; stat++) for (stat = 0; stat < MAX_SW_PLAYERS; stat++)
{ {
i = headspritestat[STAT_PLAYER0 + stat]; i = StatIterator::First(STAT_PLAYER0 + stat);
if (i < 0) if (i < 0)
continue; continue;
@ -4007,12 +4007,13 @@ DoPlayerFly(PLAYERp pp)
SPRITEp SPRITEp
FindNearSprite(SPRITEp sp, short stat) FindNearSprite(SPRITEp sp, short stat)
{ {
short fs, next_fs; int fs;
int dist, near_dist = 15000; int dist, near_dist = 15000;
SPRITEp fp, near_fp = NULL; SPRITEp fp, near_fp = NULL;
TRAVERSE_SPRITE_STAT(headspritestat[stat], fs, next_fs) StatIterator it(stat);
while ((fs = it.NextIndex()) >= 0)
{ {
fp = &sprite[fs]; fp = &sprite[fs];
@ -7423,7 +7424,7 @@ int SearchSpawnPosition(PLAYERp pp)
{ {
// get a spawn position // get a spawn position
pos_num = RANDOM_RANGE(MAX_SW_PLAYERS); pos_num = RANDOM_RANGE(MAX_SW_PLAYERS);
spawn_sprite = headspritestat[STAT_MULTI_START + pos_num]; spawn_sprite = StatIterator::First(STAT_MULTI_START + pos_num);
if (spawn_sprite <= -1) if (spawn_sprite <= -1)
return 0; return 0;
@ -7481,7 +7482,7 @@ PlayerSpawnPosition(PLAYERp pp)
{ {
case MULTI_GAME_NONE: case MULTI_GAME_NONE:
// start from the beginning // start from the beginning
spawn_sprite = headspritestat[STAT_MULTI_START + 0]; spawn_sprite = StatIterator::First(STAT_MULTI_START + 0);
break; break;
case MULTI_GAME_COMMBAT: case MULTI_GAME_COMMBAT:
case MULTI_GAME_AI_BOTS: case MULTI_GAME_AI_BOTS:
@ -7491,11 +7492,11 @@ PlayerSpawnPosition(PLAYERp pp)
pos_num = SearchSpawnPosition(pp); pos_num = SearchSpawnPosition(pp);
} }
spawn_sprite = headspritestat[STAT_MULTI_START + pos_num]; spawn_sprite = StatIterator::First(STAT_MULTI_START + pos_num);
break; break;
case MULTI_GAME_COOPERATIVE: case MULTI_GAME_COOPERATIVE:
// start your assigned spot // start your assigned spot
spawn_sprite = headspritestat[STAT_CO_OP_START + pos_num]; spawn_sprite = StatIterator::First(STAT_MULTI_START + pos_num);
break; break;
} }
@ -7503,7 +7504,7 @@ PlayerSpawnPosition(PLAYERp pp)
if (spawn_sprite < 0) if (spawn_sprite < 0)
{ {
spawn_sprite = headspritestat[STAT_MULTI_START + 0]; spawn_sprite = StatIterator::First(STAT_MULTI_START + 0);
} }
ASSERT(spawn_sprite >= 0); ASSERT(spawn_sprite >= 0);
@ -7570,7 +7571,7 @@ InitMultiPlayerInfo(void)
if (gNet.MultiGameType != MULTI_GAME_NONE) if (gNet.MultiGameType != MULTI_GAME_NONE)
{ {
// if start position is physically set then don't spawn a new one // if start position is physically set then don't spawn a new one
if (headspritestat[MultiStatList[stat] + 0] >= 0) if (StatIterator::First(MultiStatList[stat] + 0) >= 0)
continue; continue;
} }

View file

@ -1067,14 +1067,15 @@ DoExplodeSector(short match)
{ {
short orig_ang; short orig_ang;
int zh; int zh;
short cf,nextcf; int cf;
SPRITEp esp; SPRITEp esp;
SECTORp sectp; SECTORp sectp;
orig_ang = 0; //sp->ang; orig_ang = 0; //sp->ang;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_EXPLODING_CEIL_FLOOR], cf, nextcf) StatIterator it(STAT_EXPLODING_CEIL_FLOOR);
while ((cf = it.NextIndex()) >= 0)
{ {
esp = &sprite[cf]; esp = &sprite[cf];

View file

@ -4156,11 +4156,12 @@ int ActorCoughItem(short SpriteNum)
int SpawnItemsMatch(short match) int SpawnItemsMatch(short match)
{ {
short SpriteNum; int SpriteNum;
short si, nextsi; int si;
SPRITEp sp,sip; SPRITEp sp,sip;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_SPAWN_ITEMS],si,nextsi) StatIterator it(STAT_SPAWN_ITEMS);
while ((si = it.NextIndex()) >= 0)
{ {
sip = &sprite[si]; sip = &sprite[si];

View file

@ -607,7 +607,7 @@ TrackSetup(void)
// put points on track // put points on track
for (ndx = 0; ndx < MAX_TRACKS; ndx++) for (ndx = 0; ndx < MAX_TRACKS; ndx++)
{ {
if (headspritestat[STAT_TRACK + ndx] == -1) if (StatIterator::First(STAT_TRACK + ndx) == -1)
{ {
// for some reason I need at least one record allocated // for some reason I need at least one record allocated
// can't remember why at this point // can't remember why at this point
@ -643,7 +643,7 @@ TrackSetup(void)
if (t->NumPoints == 0) if (t->NumPoints == 0)
{ {
int i; int i;
auto const sp = (uspritetype const *)&sprite[headspritestat[STAT_TRACK+ndx]]; auto const sp = (uspritetype const *)&sprite[StatIterator::First(STAT_TRACK+ndx)];
Printf("WARNING: Did not find first point of Track Number %d, x %d, y %d\n", ndx, sp->x, sp->y); Printf("WARNING: Did not find first point of Track Number %d, x %d, y %d\n", ndx, sp->x, sp->y);
StatIterator it(STAT_TRACK + ndx); StatIterator it(STAT_TRACK + ndx);
while ((i = it.NextIndex()) >= 0) while ((i = it.NextIndex()) >= 0)
@ -659,7 +659,7 @@ TrackSetup(void)
SET(t->ttflags, BIT(tp->tag_high)); SET(t->ttflags, BIT(tp->tag_high));
// while there are still sprites on this status list // while there are still sprites on this status list
while (headspritestat[STAT_TRACK + ndx] != -1) while (StatIterator::First(STAT_TRACK + ndx) != -1)
{ {
short next_sprite = -1; short next_sprite = -1;
int dist, low_dist = 999999; int dist, low_dist = 999999;
@ -730,7 +730,7 @@ void
SectorObjectSetupBounds(SECTOR_OBJECTp sop) SectorObjectSetupBounds(SECTOR_OBJECTp sop)
{ {
int xlow, ylow, xhigh, yhigh; int xlow, ylow, xhigh, yhigh;
short sp_num, next_sp_num, startwall, endwall; int sp_num, startwall, endwall;
int i, k, j; int i, k, j;
SPRITEp BoundSprite; SPRITEp BoundSprite;
bool FoundOutsideLoop = false; bool FoundOutsideLoop = false;
@ -891,7 +891,8 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
for (i = 0; i < (int)SIZ(StatList); i++) for (i = 0; i < (int)SIZ(StatList); i++)
{ {
TRAVERSE_SPRITE_STAT(headspritestat[StatList[i]], sp_num, next_sp_num) StatIterator it(StatList[i]);
while ((sp_num = it.NextIndex()) >= 0)
{ {
SPRITEp sp = &sprite[sp_num]; SPRITEp sp = &sprite[sp_num];
USERp u; USERp u;
@ -1790,19 +1791,6 @@ PlayerPart:
if (TEST(sector[pp->lo_sectp - sector].extra, SECTFX_NO_RIDE)) if (TEST(sector[pp->lo_sectp - sector].extra, SECTFX_NO_RIDE))
{ {
#if 0
short nr, nextnr;
bool skip = true;
TRAVERSE_SPRITE_STAT(headspritestat[STAT_NO_RIDE], nr, nextnr)
{
if (sprite[nr].lotag == sop - SectorObject)
skip = true;
else
skip = false;
}
if (skip)
#endif
continue; continue;
} }