- converted all stat iterators outside sector*.cpp.

This commit is contained in:
Christoph Oelckers 2020-10-14 22:18:10 +02:00
parent 760a557f73
commit 3d36381752
13 changed files with 107 additions and 141 deletions

View file

@ -2571,7 +2571,7 @@ void rr_specialstats()
}
}
it.Reset(105);
it.Reset(STAT_BOWLING);
while ((i = it.NextIndex()) >= 0)
{
auto s = &sprite[i];

View file

@ -37,34 +37,26 @@ short pinsectorresetdown(short sect);
void ballreturn(short spr)
{
short j, i, nexti, nextj;
i = headspritestat[105];
while (i >= 0)
int j, i;
StatIterator it(STAT_BOWLING);
while ((i = it.NextIndex()) >= 0)
{
nexti = nextspritestat[i];
if (sprite[i].picnum == RRTILE281)
if (sprite[spr].sectnum == sprite[i].sectnum)
auto si = &sprite[i];
if (si->picnum == RRTILE281 && sprite[spr].sectnum == si->sectnum)
{
j = headspritestat[105];
while (j >= 0)
StatIterator it2(STAT_BOWLING);
while ((j = it2.NextIndex()) >= 0)
{
nextj = nextspritestat[j];
if (sprite[j].picnum == RRTILE282)
if (sprite[i].hitag == sprite[j].hitag)
auto sj = &sprite[j];
if (sj->picnum == RRTILE282 && si->hitag == sj->hitag)
fi.spawn(j, BOWLINGBALLSPRITE);
if (sprite[j].picnum == RRTILE280)
if (sprite[i].hitag == sprite[j].hitag)
if (sprite[j].lotag == 0)
if (sj->picnum == RRTILE280 && si->hitag == sj->hitag && sj->lotag == 0)
{
sprite[j].lotag = 100;
sprite[j].extra++;
pinsectorresetdown(sprite[j].sectnum);
}
j = nextj;
sj->lotag = 100;
sj->extra++;
}
}
}
i = nexti;
}
}

View file

@ -255,6 +255,7 @@ enum
STAT_RAROR = 15,
STAT_DESTRUCT = 100,
STAT_BOWLING = 105,
STAT_NETALLOC = MAXSTATUS-1
};

View file

@ -2070,12 +2070,11 @@ int ParseState::parse(void)
updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum);
setpal(&ps[g_p]);
j = headspritestat[1];
while (j >= 0)
StatIterator it(STAT_ACTOR);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].picnum == TILE_CAMERA1)
sprite[j].yvel = 0;
j = nextspritestat[j];
}
}
@ -2934,8 +2933,8 @@ int ParseState::parse(void)
lFound = -1;
lDist = 32767; // big number
j = headspritestat[1]; // all sprites
while (j >= 0)
StatIterator it(STAT_ACTOR);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].picnum == lType)
{
@ -2949,7 +2948,6 @@ int ParseState::parse(void)
}
}
j = nextspritestat[j];
}
SetGameVarID(lVarID, lFound, g_i, g_p);
@ -2980,8 +2978,8 @@ int ParseState::parse(void)
lFound = -1;
lDist = 32767; // big number
j = headspritestat[1]; // all sprites
while (j >= 0)
StatIterator it(STAT_ACTOR);
while ((j = it.NextIndex()) >= 0)
{
if (sprite[j].picnum == lType)
{
@ -2995,7 +2993,6 @@ int ParseState::parse(void)
}
}
j = nextspritestat[j];
}
SetGameVarID(lVarID, lFound, g_i, g_p);

View file

@ -346,22 +346,25 @@ int aim(spritetype* s, int aang)
{
if (j >= 0)
break;
for (i = headspritestat[aimstats[k]]; i >= 0; i = nextspritestat[i])
if (sprite[i].xrepeat > 0 && sprite[i].extra >= 0 && (sprite[i].cstat & (257 + 32768)) == 257)
if (badguy(&sprite[i]) || k < 2)
StatIterator it(aimstats[k]);
while ((i = it.NextIndex()) >= 0)
{
auto sp = &sprite[i];
if (badguy(&sprite[i]) || sp->picnum == TILE_APLAYER)
if (sp->xrepeat > 0 && sp->extra >= 0 && (sp->cstat & (257 + 32768)) == 257)
if (badguy(sp) || k < 2)
{
if (badguy(sp) || sp->picnum == TILE_APLAYER)
{
if (sp->picnum == TILE_APLAYER &&
(isRR() && ud.ffire == 0) &&
ud.coop == 1 &&
s->picnum == TILE_APLAYER &&
s != &sprite[i])
s != sp)
continue;
if (gotshrinker && sprite[i].xrepeat < 30 && !(actorinfo[sp->picnum].flags & SFLAG_SHRINKAUTOAIM)) continue;
if (gotfreezer && sprite[i].pal == 1) continue;
if (gotshrinker && sp->xrepeat < 30 && !(actorinfo[sp->picnum].flags & SFLAG_SHRINKAUTOAIM)) continue;
if (gotfreezer && sp->pal == 1) continue;
}
xv = (sp->x - s->x);
@ -388,6 +391,7 @@ int aim(spritetype* s, int aang)
}
}
}
}
return j;
}

View file

@ -594,13 +594,12 @@ void shoot_d(int i, int atwith)
}
}
l = headspritestat[5];
while (l >= 0)
StatIterator it(STAT_MISC);
while ((l = it.NextIndex()) >= 0)
{
if (sprite[l].picnum == BULLETHOLE)
if (dist(&sprite[l], &sprite[k]) < (12 + (krand() & 7)))
goto SKIPBULLETHOLE;
l = nextspritestat[l];
}
l = fi.spawn(k, BULLETHOLE);
sprite[l].xvel = -1;
@ -1232,8 +1231,8 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
if (j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0)
{
k = headspritestat[1];
while (k >= 0)
StatIterator it(STAT_ACTOR);
while ((k = it.NextIndex()) >= 0)
{
if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i)
{
@ -1241,7 +1240,6 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
j = HANDREMOTE_WEAPON;
break;
}
k = nextspritestat[k];
}
}

View file

@ -507,13 +507,12 @@ void shoot_r(int i, int atwith)
}
}
l = headspritestat[5];
while (l >= 0)
StatIterator it(STAT_MISC);
while ((l = it.NextIndex()) >= 0)
{
if (sprite[l].picnum == BULLETHOLE)
if (dist(&sprite[l], &sprite[k]) < (12 + (krand() & 7)))
goto SKIPBULLETHOLE;
l = nextspritestat[l];
}
l = fi.spawn(k, BULLETHOLE);
sprite[l].xvel = -1;
@ -1032,8 +1031,8 @@ void selectweapon_r(int snum, int weap)
if (j == DYNAMITE_WEAPON && p->ammo_amount[DYNAMITE_WEAPON] == 0)
{
k = headspritestat[1];
while (k >= 0)
StatIterator it(STAT_ACTOR);
while ((k = it.NextIndex()) >= 0)
{
if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i)
{
@ -1041,7 +1040,6 @@ void selectweapon_r(int snum, int weap)
j = THROWINGDYNAMITE_WEAPON;
break;
}
k = nextspritestat[k];
}
}
else if (j == KNEE_WEAPON && isRRRA())

View file

@ -501,7 +501,7 @@ void resetprestat(int snum,int g)
void resetpspritevars(int g)
{
int i, j;
short nexti, circ;
short circ;
int firstx, firsty;
spritetype* s;
int aimmode[MAXPLAYERS], autoaim[MAXPLAYERS];
@ -571,10 +571,9 @@ void resetpspritevars(int g)
which_palookup = 9;
j = connecthead;
i = headspritestat[STAT_PLAYER];
while (i >= 0)
StatIterator it(STAT_PLAYER);
while ((i = it.NextIndex()) >= 0)
{
nexti = nextspritestat[i];
s = &sprite[i];
if (numplayersprites == MAXPLAYERS)
@ -641,7 +640,6 @@ void resetpspritevars(int g)
}
else deletesprite(i);
i = nexti;
}
}

View file

@ -270,43 +270,42 @@ void cacheit_d(void)
void prelevel_d(int g)
{
short i, nexti, j, startwall, endwall, lotaglist;
short i, j, startwall, endwall, lotaglist;
short lotags[65];
prelevel_common(g);
i = headspritestat[0];
while (i >= 0)
StatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
{
nexti = nextspritestat[i];
auto si = &sprite[i];
LoadActor(i, -1, -1);
if (sprite[i].lotag == -1 && (sprite[i].cstat & 16))
if (si->lotag == -1 && (si->cstat & 16))
{
ps[0].exitx = sprite[i].x;
ps[0].exity = sprite[i].y;
ps[0].exitx = si->x;
ps[0].exity = si->y;
}
else switch (sprite[i].picnum)
else switch (si->picnum)
{
case GPSPEED:
sector[sprite[i].sectnum].extra = sprite[i].lotag;
sector[si->sectnum].extra = si->lotag;
deletesprite(i);
break;
case CYCLER:
if (numcyclers >= MAXCYCLERS)
I_Error("Too many cycling sectors.");
cyclers[numcyclers][0] = sprite[i].sectnum;
cyclers[numcyclers][1] = sprite[i].lotag;
cyclers[numcyclers][2] = sprite[i].shade;
cyclers[numcyclers][3] = sector[sprite[i].sectnum].floorshade;
cyclers[numcyclers][4] = sprite[i].hitag;
cyclers[numcyclers][5] = (sprite[i].ang == 1536);
cyclers[numcyclers][0] = si->sectnum;
cyclers[numcyclers][1] = si->lotag;
cyclers[numcyclers][2] = si->shade;
cyclers[numcyclers][3] = sector[si->sectnum].floorshade;
cyclers[numcyclers][4] = si->hitag;
cyclers[numcyclers][5] = (si->ang == 1536);
numcyclers++;
deletesprite(i);
break;
}
i = nexti;
}
for (i = 0; i < MAXSPRITES; i++)
@ -328,8 +327,8 @@ void prelevel_d(int g)
lotaglist = 0;
i = headspritestat[0];
while (i >= 0)
it.Reset(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
{
switch (sprite[i].picnum)
{
@ -357,17 +356,15 @@ void prelevel_d(int g)
if (lotaglist > 64)
I_Error("Too many switches (64 max).");
j = headspritestat[3];
while (j >= 0)
StatIterator it1(STAT_EFFECTOR);
while ((j = it1.NextIndex()) >= 0)
{
if (sprite[j].lotag == 12 && sprite[j].hitag == sprite[i].lotag)
hittype[j].temp_data[0] = 1;
j = nextspritestat[j];
}
}
break;
}
i = nextspritestat[i];
}
mirrorcnt = 0;

View file

@ -446,7 +446,6 @@ void prelevel_r(int g)
{
struct player_struct* p;
short i;
short nexti;
short j;
short startwall;
short endwall;
@ -554,37 +553,37 @@ void prelevel_r(int g)
}
}
i = headspritestat[0];
while (i >= 0)
StatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
{
nexti = nextspritestat[i];
auto si = &sprite[i];
LoadActor(i, -1, -1);
if (sprite[i].lotag == -1 && (sprite[i].cstat & 16))
if (si->lotag == -1 && (si->cstat & 16))
{
ps[0].exitx = sprite[i].x;
ps[0].exity = sprite[i].y;
ps[0].exitx = si->x;
ps[0].exity = si->y;
}
else switch (sprite[i].picnum)
else switch (si->picnum)
{
case NUKEBUTTON:
chickenplant = 1;
break;
case GPSPEED:
sector[sprite[i].sectnum].extra = sprite[i].lotag;
sector[si->sectnum].extra = si->lotag;
deletesprite(i);
break;
case CYCLER:
if (numcyclers >= MAXCYCLERS)
I_Error("Too many cycling sectors.");
cyclers[numcyclers][0] = sprite[i].sectnum;
cyclers[numcyclers][1] = sprite[i].lotag;
cyclers[numcyclers][2] = sprite[i].shade;
cyclers[numcyclers][3] = sector[sprite[i].sectnum].floorshade;
cyclers[numcyclers][4] = sprite[i].hitag;
cyclers[numcyclers][5] = (sprite[i].ang == 1536);
cyclers[numcyclers][0] = si->sectnum;
cyclers[numcyclers][1] = si->lotag;
cyclers[numcyclers][2] = si->shade;
cyclers[numcyclers][3] = sector[si->sectnum].floorshade;
cyclers[numcyclers][4] = si->hitag;
cyclers[numcyclers][5] = (si->ang == 1536);
numcyclers++;
deletesprite(i);
break;
@ -600,12 +599,12 @@ void prelevel_r(int g)
break;
case RRTILE68:
shadedsector[sprite[i].sectnum] = 1;
shadedsector[si->sectnum] = 1;
deletesprite(i);
break;
case RRTILE67:
sprite[i].cstat |= 32768;
si->cstat |= 32768;
break;
case SOUNDFX:
@ -613,16 +612,15 @@ void prelevel_r(int g)
I_Error("Too many ambient effects");
else
{
ambienthitag[ambientfx] = sprite[i].hitag;
ambientlotag[ambientfx] = sprite[i].lotag;
sprite[i].ang = ambientfx;
ambienthitag[ambientfx] = si->hitag;
ambientlotag[ambientfx] = si->lotag;
si->ang = ambientfx;
ambientfx++;
sprite[i].lotag = 0;
sprite[i].hitag = 0;
si->lotag = 0;
si->hitag = 0;
}
break;
}
i = nexti;
}
for (i = 0; i < MAXSPRITES; i++)
@ -687,8 +685,8 @@ void prelevel_r(int g)
lotaglist = 0;
i = headspritestat[0];
while (i >= 0)
it.Reset(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
{
switch (sprite[i].picnum)
{
@ -721,17 +719,15 @@ void prelevel_r(int g)
if (lotaglist > 64)
I_Error("Too many switches (64 max).");
j = headspritestat[3];
while (j >= 0)
StatIterator it1(STAT_EFFECTOR);
while ((j = it1.NextIndex()) >= 0)
{
if (sprite[j].lotag == 12 && sprite[j].hitag == sprite[i].lotag)
hittype[j].temp_data[0] = 1;
j = nextspritestat[j];
}
}
break;
}
i = nextspritestat[i];
}
mirrorcnt = 0;

View file

@ -175,8 +175,8 @@ void se40code(int x, int y, int z, binangle a, fixedhoriz h, int smoothratio)
else if (isRRRA()) tag = 150;
else return;
i = headspritestat[STAT_RAROR];
while (i >= 0)
StatIterator it(STAT_RAROR);
while ((i = it.NextIndex()) >= 0)
{
switch (sprite[i].lotag - tag + 40)
{
@ -192,7 +192,6 @@ void se40code(int x, int y, int z, binangle a, fixedhoriz h, int smoothratio)
SE40_Draw(tag, i, x, y, z, a, h, smoothratio);
break;
}
i = nextspritestat[i];
}
}

View file

@ -43,8 +43,9 @@ static void recreateinterpolations()
{
numinterpolations = 0;
int k = headspritestat[STAT_EFFECTOR];
while (k >= 0)
int k;
StatIterator it(STAT_EFFECTOR);
while ((k = it.NextIndex()) >= 0)
{
switch (sprite[k].lotag)
{
@ -71,8 +72,6 @@ static void recreateinterpolations()
setsectinterpolate(k);
break;
}
k = nextspritestat[k];
}
for (int i = numinterpolations - 1; i >= 0; i--) bakipos[i] = *curipos[i];
@ -500,20 +499,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
show_shareware = 0;
everyothertime = 0;
// should be unnecessary with the sounds getting serialized as well.
#if 0
if (ps[myconnectindex].jetpack_on)
spritesound(DUKE_JETPACK_IDLE, ps[myconnectindex].i);
// Update sound state in SFX sprites.
for (int i = headspritestat[STAT_FX]; i >= 0; i = nextspritestat[i])
if (sprite[i].picnum == MUSICANDSFX)
{
hittype[i].temp_data[1] = SoundEnabled();
hittype[i].temp_data[0] = 0;
}
#endif
FX_SetReverb(0);
}

View file

@ -491,30 +491,31 @@ void initcrane(int j, int i, int CRANEPOLE)
msy[tempwallptr] = sp->y;
msx[tempwallptr + 2] = sp->z;
int s = headspritestat[0];
while (s >= 0)
int s;
StatIterator it(STAT_DEFAULT);
while ((s = it.NextIndex()) >= 0)
{
if (sprite[s].picnum == CRANEPOLE && sp->hitag == (sprite[s].hitag))
auto ss = &sprite[s];
if (ss->picnum == CRANEPOLE && sp->hitag == (ss->hitag))
{
msy[tempwallptr + 2] = s;
t[1] = sprite[s].sectnum;
t[1] = ss->sectnum;
sprite[s].xrepeat = 48;
sprite[s].yrepeat = 128;
ss->xrepeat = 48;
ss->yrepeat = 128;
msx[tempwallptr + 1] = sprite[s].x;
msy[tempwallptr + 1] = sprite[s].y;
msx[tempwallptr + 1] = ss->x;
msy[tempwallptr + 1] = ss->y;
sprite[s].x = sp->x;
sprite[s].y = sp->y;
sprite[s].z = sp->z;
sprite[s].shade = sp->shade;
ss->x = sp->x;
ss->y = sp->y;
ss->z = sp->z;
ss->shade = sp->shade;
setsprite(s, sprite[s].x, sprite[s].y, sprite[s].z);
setsprite(s, ss->x, ss->y, ss->z);
break;
}
s = nextspritestat[s];
}
tempwallptr += 3;