- replaced all stat iterators in actors_r.cpp.

This commit is contained in:
Christoph Oelckers 2020-10-14 20:24:31 +02:00
parent db8b454df1
commit 060b66b96b
2 changed files with 72 additions and 72 deletions

View file

@ -558,14 +558,14 @@ void gutsdir_r(spritetype* s, short gtype, short n, short p)
void movefta_r(void) void movefta_r(void)
{ {
int x, px, py, sx, sy; int x, px, py, sx, sy;
short i, j, p, psect, ssect, nexti; short j, p, psect, ssect;
spritetype* s; spritetype* s;
i = headspritestat[STAT_ZOMBIEACTOR];
while (i >= 0)
{
nexti = nextspritestat[i];
StatIterator it(STAT_ZOMBIEACTOR);
int i;
while((i = it.NextIndex()) >= 0)
{
s = &sprite[i]; s = &sprite[i];
p = findplayer(s, &x); p = findplayer(s, &x);
j = 0; j = 0;
@ -586,7 +586,6 @@ void movefta_r(void)
updatesector(px, py, &psect); updatesector(px, py, &psect);
if (psect == -1) if (psect == -1)
{ {
i = nexti;
continue; continue;
} }
sx = s->x + 64 - (krand() & 127); sx = s->x + 64 - (krand() & 127);
@ -594,7 +593,6 @@ void movefta_r(void)
updatesector(px, py, &ssect); updatesector(px, py, &ssect);
if (ssect == -1) if (ssect == -1)
{ {
i = nexti;
continue; continue;
} }
@ -666,7 +664,6 @@ void movefta_r(void)
} }
} }
} }
i = nexti;
} }
} }
@ -678,12 +675,12 @@ void movefta_r(void)
int ifhitsectors_r(int sectnum) int ifhitsectors_r(int sectnum)
{ {
int i = headspritestat[STAT_MISC]; StatIterator it(STAT_MISC);
while (i >= 0) int i;
while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].picnum == EXPLOSION2 || (sprite[i].picnum == EXPLOSION3 && sectnum == sprite[i].sectnum)) if (sprite[i].picnum == EXPLOSION2 || (sprite[i].picnum == EXPLOSION3 && sectnum == sprite[i].sectnum))
return i; return i;
i = nextspritestat[i];
} }
return -1; return -1;
} }
@ -844,14 +841,14 @@ void respawn_rrra(int i, int j)
void movefallers_r(void) void movefallers_r(void)
{ {
short i, nexti, sect, j; short sect, j;
spritetype* s; spritetype* s;
int x; int x;
i = headspritestat[STAT_FALLER]; StatIterator it(STAT_FALLER);
while (i >= 0) int i;
while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
s = &sprite[i]; s = &sprite[i];
sect = s->sectnum; sect = s->sectnum;
@ -869,17 +866,17 @@ void movefallers_r(void)
if (s->extra <= 0) if (s->extra <= 0)
{ {
hittype[i].temp_data[0] = 1; hittype[i].temp_data[0] = 1;
j = headspritestat[STAT_FALLER]; StatIterator it(STAT_FALLER);
while (j >= 0) while ((j = it.NextIndex()) >= 0)
{ {
if (sprite[j].hitag == sprite[i].hitag) auto sj = &sprite[j];
if (sj->hitag == sprite[i].hitag)
{ {
hittype[j].temp_data[0] = 1; hittype[j].temp_data[0] = 1;
sprite[j].cstat &= (65535 - 64); sj->cstat &= (65535 - 64);
if (sprite[j].picnum == CEILINGSTEAM || sprite[j].picnum == STEAM) if (sj->picnum == CEILINGSTEAM || sj->picnum == STEAM)
sprite[j].cstat |= 32768; sj->cstat |= 32768;
} }
j = nextspritestat[j];
} }
} }
} }
@ -932,8 +929,6 @@ void movefallers_r(void)
} }
} }
} }
i = nexti;
} }
} }
@ -960,13 +955,13 @@ static void movecrack(int i)
int j = ifhitbyweapon_r(i); int j = ifhitbyweapon_r(i);
if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
{ {
j = headspritestat[STAT_STANDABLE]; StatIterator it(STAT_STANDABLE);
while (j >= 0) while ((j = it.NextIndex()) >= 0)
{ {
if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE)) auto sj = &sprite[j];
if (sprite[j].shade != -32) if (s->hitag == sj->hitag && (sj->picnum == OOZFILTER || sj->picnum == SEENINE))
sprite[j].shade = -32; if (sj->shade != -32)
j = nextspritestat[j]; sj->shade = -32;
} }
detonate(i, EXPLOSION2); detonate(i, EXPLOSION2);
} }
@ -1051,12 +1046,10 @@ CLEAR_THE_BOLT:
void movestandables_r(void) void movestandables_r(void)
{ {
int nexti; StatIterator it(STAT_STANDABLE);
int i;
for (int i = headspritestat[STAT_STANDABLE]; i >= 0; i = nexti) while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
auto s = &sprite[i]; auto s = &sprite[i];
int picnum = s->picnum; int picnum = s->picnum;
@ -1161,14 +1154,15 @@ void movestandables_r(void)
void moveweapons_r(void) void moveweapons_r(void)
{ {
int j, k, nexti, p; int j, k, p;
int dax, day, daz, x, ll; int dax, day, daz, x, ll;
unsigned int qq; unsigned int qq;
spritetype* s; spritetype* s;
for (int i = headspritestat[STAT_PROJECTILE]; i >= 0; i = nexti) StatIterator it(STAT_PROJECTILE);
int i;
while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
s = &sprite[i]; s = &sprite[i];
if (s->sectnum < 0) if (s->sectnum < 0)
@ -2453,7 +2447,7 @@ static void rrra_specialstats()
void rr_specialstats() void rr_specialstats()
{ {
int x; int x;
int i, j, nextj, p, pi; int i, j, p, pi;
unsigned short pst; unsigned short pst;
StatIterator it(107); StatIterator it(107);
@ -2978,7 +2972,7 @@ static int henstand(int i)
void moveactors_r(void) void moveactors_r(void)
{ {
int x, nexti; int x;
int j, sect, p; int j, sect, p;
spritetype *s; spritetype *s;
@ -2991,9 +2985,10 @@ void moveactors_r(void)
} }
rr_specialstats(); rr_specialstats();
for (int i = headspritestat[STAT_ACTOR]; i >= 0; i = nexti) StatIterator it(STAT_ACTOR);
int i;
while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites. bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites.
s = &sprite[i]; s = &sprite[i];
@ -3262,15 +3257,15 @@ void moveactors_r(void)
void moveexplosions_r(void) // STATNUM 5 void moveexplosions_r(void) // STATNUM 5
{ {
int nexti, sect, p; int sect, p;
int x, * t; int x, * t;
spritetype* s; spritetype* s;
for (int i = headspritestat[STAT_MISC]; i >= 0; i = nexti) StatIterator it(STAT_MISC);
int i;
while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
t = &hittype[i].temp_data[0]; t = &hittype[i].temp_data[0];
s = &sprite[i]; s = &sprite[i];
sect = s->sectnum; sect = s->sectnum;
@ -3502,7 +3497,7 @@ void moveexplosions_r(void) // STATNUM 5
void moveeffectors_r(void) //STATNUM 3 void moveeffectors_r(void) //STATNUM 3
{ {
int l, x, st, j, * t; int l, x, st, j, * t;
int nexti, p, sh, nextj, ns, pn; int p, sh, nextj, ns, pn;
short k; short k;
spritetype* s; spritetype* s;
sectortype* sc; sectortype* sc;
@ -3511,9 +3506,10 @@ void moveeffectors_r(void) //STATNUM 3
clearfriction(); clearfriction();
for (int i = headspritestat[STAT_EFFECTOR]; i >= 0; i = nexti) StatIterator it(STAT_EFFECTOR);
int i;
while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
s = &sprite[i]; s = &sprite[i];
sc = &sector[s->sectnum]; sc = &sector[s->sectnum];
@ -3533,6 +3529,7 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case SE_6_SUBWAY: case SE_6_SUBWAY:
{
k = sc->extra; k = sc->extra;
if (t[4] > 0) if (t[4] > 0)
@ -3611,27 +3608,29 @@ void moveeffectors_r(void) //STATNUM 3
} }
} }
j = headspritestat[STAT_EFFECTOR]; StatIterator it(STAT_EFFECTOR);
while (j >= 0) while ((j = it.NextIndex()) >= 0)
{ {
if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0])) auto sj = &sprite[j];
auto htj = &hittype[j];
if ((sj->lotag == 14) && (sh == sj->hitag) && (htj->temp_data[0] == t[0]))
{ {
sprite[j].xvel = s->xvel; sj->xvel = s->xvel;
// if( t[4] == 1 ) // if( t[4] == 1 )
{ {
if (hittype[j].temp_data[5] == 0) if (htj->temp_data[5] == 0)
hittype[j].temp_data[5] = dist(&sprite[j], s); htj->temp_data[5] = dist(&sprite[j], s);
x = sgn(dist(&sprite[j], s) - hittype[j].temp_data[5]); x = sgn(dist(&sprite[j], s) - htj->temp_data[5]);
if (sprite[j].extra) if (sj->extra)
x = -x; x = -x;
s->xvel += x; s->xvel += x;
} }
hittype[j].temp_data[4] = t[4]; htj->temp_data[4] = t[4];
} }
j = nextspritestat[j]; j = nextspritestat[j];
} }
x = 0; x = 0;
}
case SE_14_SUBWAY_CAR: case SE_14_SUBWAY_CAR:
handle_se14(i, false, RPG, JIBS6); handle_se14(i, false, RPG, JIBS6);
@ -4015,7 +4014,8 @@ void moveeffectors_r(void) //STATNUM 3
} }
//Sloped sin-wave floors! //Sloped sin-wave floors!
for (int i = headspritestat[STAT_EFFECTOR]; i >= 0; i = nextspritestat[i]) it.Reset(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0)
{ {
s = &sprite[i]; s = &sprite[i];
if (s->lotag != 29) continue; if (s->lotag != 29) continue;
@ -4488,14 +4488,14 @@ void destroyit(int g_i)
{ {
auto g_sp = &sprite[g_i]; auto g_sp = &sprite[g_i];
spritetype* js; spritetype* js;
short lotag, hitag; int lotag, hitag;
short k, jj; int k, jj;
short wi, wj; int wi, wj;
short spr; int spr;
short nextk, nextjj; int nextk;
short wallstart2, wallend2; int wallstart2, wallend2;
short sectnum; int sectnum;
short wallstart, wallend; int wallstart, wallend;
hitag = 0; hitag = 0;
k = headspritesect[g_sp->sectnum]; k = headspritesect[g_sp->sectnum];
@ -4511,10 +4511,9 @@ void destroyit(int g_i)
} }
k = nextk; k = nextk;
} }
jj = headspritestat[100]; StatIterator it(STAT_DESTRUCT);
while (jj >= 0) while ((jj = it.NextIndex()) >= 0)
{ {
nextjj = nextspritestat[jj];
js = &sprite[jj]; js = &sprite[jj];
if (hitag) if (hitag)
if (hitag == js->hitag) if (hitag == js->hitag)
@ -4576,7 +4575,6 @@ void destroyit(int g_i)
sector[sectnum].hitag = sector[js->sectnum].hitag; sector[sectnum].hitag = sector[js->sectnum].hitag;
sector[sectnum].extra = sector[js->sectnum].extra; sector[sectnum].extra = sector[js->sectnum].extra;
} }
jj = nextjj;
} }
k = headspritesect[g_sp->sectnum]; k = headspritesect[g_sp->sectnum];
while (k != -1) while (k != -1)

View file

@ -253,6 +253,8 @@ enum
STAT_DUMMYPLAYER = 13, STAT_DUMMYPLAYER = 13,
STAT_LIGHT = 14, STAT_LIGHT = 14,
STAT_RAROR = 15, STAT_RAROR = 15,
STAT_DESTRUCT = 100,
STAT_NETALLOC = MAXSTATUS-1 STAT_NETALLOC = MAXSTATUS-1
}; };