- handled the last remaining stat iterators in Duke.

This commit is contained in:
Christoph Oelckers 2020-10-15 00:09:48 +02:00
parent 53414afbe5
commit 0b80ad8fb1
2 changed files with 70 additions and 90 deletions

View file

@ -186,12 +186,11 @@ void animatewalls_d(void)
void operaterespawns_d(int low) void operaterespawns_d(int low)
{ {
short i, j, nexti; int i, j;
i = headspritestat[11]; StatIterator it(STAT_FX);
while (i >= 0) while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
if (sprite[i].lotag == low) switch (sprite[i].picnum) if (sprite[i].lotag == low) switch (sprite[i].picnum)
{ {
case RESPAWN: case RESPAWN:
@ -203,7 +202,6 @@ void operaterespawns_d(int low)
sprite[i].extra = 66 - 12; // Just a way to killit sprite[i].extra = 66 - 12; // Just a way to killit
break; break;
} }
i = nexti;
} }
} }
@ -352,32 +350,33 @@ bool checkhitswitch_d(int snum, int w, int switchtype)
break; break;
} }
i = headspritestat[0]; StatIterator it(STAT_DEFAULT);
while (i >= 0) while ((i = it.NextIndex()) >= 0)
{ {
if (lotag == sprite[i].lotag) switch (sprite[i].picnum) auto si = &sprite[i];
if (lotag == si->lotag) switch (si->picnum)
{ {
case DIPSWITCH: case DIPSWITCH:
case TECHSWITCH: case TECHSWITCH:
case ALIENSWITCH: case ALIENSWITCH:
if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum++; if (switchtype == SWITCH_SPRITE && w == i) si->picnum++;
else if (sprite[i].hitag == 0) correctdips++; else if (si->hitag == 0) correctdips++;
numdips++; numdips++;
break; break;
case TECHSWITCH + 1: case TECHSWITCH + 1:
case DIPSWITCH + 1: case DIPSWITCH + 1:
case ALIENSWITCH + 1: case ALIENSWITCH + 1:
if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum--; if (switchtype == SWITCH_SPRITE && w == i) si->picnum--;
else if (sprite[i].hitag == 1) correctdips++; else if (si->hitag == 1) correctdips++;
numdips++; numdips++;
break; break;
case MULTISWITCH: case MULTISWITCH:
case MULTISWITCH + 1: case MULTISWITCH + 1:
case MULTISWITCH + 2: case MULTISWITCH + 2:
case MULTISWITCH + 3: case MULTISWITCH + 3:
sprite[i].picnum++; si->picnum++;
if (sprite[i].picnum > (MULTISWITCH + 3)) if (si->picnum > (MULTISWITCH + 3))
sprite[i].picnum = MULTISWITCH; si->picnum = MULTISWITCH;
break; break;
case ACCESSSWITCH: case ACCESSSWITCH:
case ACCESSSWITCH2: case ACCESSSWITCH2:
@ -394,7 +393,7 @@ bool checkhitswitch_d(int snum, int w, int switchtype)
case PULLSWITCH: case PULLSWITCH:
case DIPSWITCH2: case DIPSWITCH2:
case DIPSWITCH3: case DIPSWITCH3:
sprite[i].picnum++; si->picnum++;
break; break;
case PULLSWITCH + 1: case PULLSWITCH + 1:
case HANDSWITCH + 1: case HANDSWITCH + 1:
@ -409,10 +408,9 @@ bool checkhitswitch_d(int snum, int w, int switchtype)
case FRANKENSTINESWITCH + 1: case FRANKENSTINESWITCH + 1:
case DIPSWITCH2 + 1: case DIPSWITCH2 + 1:
case DIPSWITCH3 + 1: case DIPSWITCH3 + 1:
sprite[i].picnum--; si->picnum--;
break; break;
} }
i = nextspritestat[i];
} }
for (i = 0; i < numwalls; i++) for (i = 0; i < numwalls; i++)
@ -549,8 +547,8 @@ bool checkhitswitch_d(int snum, int w, int switchtype)
picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3)) picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3))
lotag += picnum - MULTISWITCH; lotag += picnum - MULTISWITCH;
x = headspritestat[3]; StatIterator it(STAT_EFFECTOR);
while (x >= 0) while ((x = it.NextIndex()) >= 0)
{ {
if (sprite[x].hitag == lotag) if (sprite[x].hitag == lotag)
{ {
@ -576,7 +574,6 @@ bool checkhitswitch_d(int snum, int w, int switchtype)
break; break;
} }
} }
x = nextspritestat[x];
} }
operateactivators(lotag, snum); operateactivators(lotag, snum);
@ -864,8 +861,8 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith)
darkestwall = wal->shade; darkestwall = wal->shade;
j = krand() & 1; j = krand() & 1;
i = headspritestat[3]; StatIterator it(STAT_EFFECTOR);
while (i >= 0) while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3)
{ {
@ -873,7 +870,6 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith)
hittype[i].temp_data[3] = darkestwall; hittype[i].temp_data[3] = darkestwall;
hittype[i].temp_data[4] = 1; hittype[i].temp_data[4] = 1;
} }
i = nextspritestat[i];
} }
break; break;
} }
@ -990,28 +986,26 @@ bool checkhitceiling_d(int sn)
{ {
if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 12) if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 12)
{ {
j = headspritestat[3]; StatIterator it1(STAT_EFFECTOR);
while (j >= 0) while ((j = it1.NextIndex()) >= 0)
{ {
if (sprite[j].hitag == sprite[i].hitag) if (sprite[j].hitag == sprite[i].hitag)
hittype[j].temp_data[3] = 1; hittype[j].temp_data[3] = 1;
j = nextspritestat[j];
} }
break; break;
} }
} }
} }
i = headspritestat[3];
j = krand() & 1; j = krand() & 1;
while (i >= 0) StatIterator it(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3)
{ {
hittype[i].temp_data[2] = j; hittype[i].temp_data[2] = j;
hittype[i].temp_data[4] = 1; hittype[i].temp_data[4] = 1;
} }
i = nextspritestat[i];
} }
return 1; return 1;
@ -1463,11 +1457,10 @@ void checkhitsprite_d(int i, int sn)
updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum);
setpal(&ps[p]); setpal(&ps[p]);
j = headspritestat[1]; StatIterator it(STAT_ACTOR);
while (j >= 0) while ((j = it.NextIndex()) >= 0)
{ {
if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0;
j = nextspritestat[j];
} }
} }
@ -1697,9 +1690,8 @@ void checksectors_d(int snum)
case VIEWSCREEN: case VIEWSCREEN:
case VIEWSCREEN2: case VIEWSCREEN2:
{ {
i = headspritestat[1]; StatIterator it(STAT_ACTOR);
while ((i = it.NextIndex()) >= 0)
while (i >= 0)
{ {
if (sprite[i].picnum == CAMERA1 && sprite[i].yvel == 0 && sprite[neartagsprite].hitag == sprite[i].lotag) if (sprite[i].picnum == CAMERA1 && sprite[i].yvel == 0 && sprite[neartagsprite].hitag == sprite[i].lotag)
{ {
@ -1720,7 +1712,6 @@ void checksectors_d(int snum)
p->newowner = i; p->newowner = i;
return; return;
} }
i = nextspritestat[i];
} }
} }
@ -1736,12 +1727,10 @@ void checksectors_d(int snum)
updatesector(p->posx, p->posy, &p->cursectnum); updatesector(p->posx, p->posy, &p->cursectnum);
setpal(p); setpal(p);
StatIterator it(STAT_ACTOR);
i = headspritestat[1]; while ((i = it.NextIndex()) >= 0)
while (i >= 0)
{ {
if (sprite[i].picnum == CAMERA1) sprite[i].yvel = 0; if (sprite[i].picnum == CAMERA1) sprite[i].yvel = 0;
i = nextspritestat[i];
} }
} }
else if (p->newowner >= 0) else if (p->newowner >= 0)

View file

@ -301,12 +301,11 @@ void animatewalls_r(void)
void operaterespawns_r(int low) void operaterespawns_r(int low)
{ {
short i, j, nexti; int i, j;
i = headspritestat[11]; StatIterator it(STAT_FX);
while (i >= 0) while ((i = it.NextIndex()) >= 0)
{ {
nexti = nextspritestat[i];
if (sprite[i].lotag == low) switch (sprite[i].picnum) if (sprite[i].lotag == low) switch (sprite[i].picnum)
{ {
case RESPAWN: case RESPAWN:
@ -323,7 +322,6 @@ void operaterespawns_r(int low)
break; break;
} }
i = nexti;
} }
} }
@ -483,46 +481,47 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
break; break;
} }
i = headspritestat[0]; StatIterator it(STAT_DEFAULT);
while (i >= 0) while ((i = it.NextIndex()) >= 0)
{ {
if (lotag == sprite[i].lotag) switch (sprite[i].picnum) auto si = &sprite[i];
if (lotag == si->lotag) switch (si->picnum)
{ {
case DIPSWITCH: case DIPSWITCH:
case TECHSWITCH: case TECHSWITCH:
case ALIENSWITCH: case ALIENSWITCH:
if (switchtype == 1 && w == i) sprite[i].picnum++; if (switchtype == 1 && w == i) si->picnum++;
else if (sprite[i].hitag == 0) correctdips++; else if (si->hitag == 0) correctdips++;
numdips++; numdips++;
break; break;
case TECHSWITCH + 1: case TECHSWITCH + 1:
case DIPSWITCH + 1: case DIPSWITCH + 1:
case ALIENSWITCH + 1: case ALIENSWITCH + 1:
if (switchtype == 1 && w == i) sprite[i].picnum--; if (switchtype == 1 && w == i) si->picnum--;
else if (sprite[i].hitag == 1) correctdips++; else if (si->hitag == 1) correctdips++;
numdips++; numdips++;
break; break;
case MULTISWITCH: case MULTISWITCH:
case MULTISWITCH + 1: case MULTISWITCH + 1:
case MULTISWITCH + 2: case MULTISWITCH + 2:
case MULTISWITCH + 3: case MULTISWITCH + 3:
sprite[i].picnum++; si->picnum++;
if (sprite[i].picnum > (MULTISWITCH + 3)) if (si->picnum > (MULTISWITCH + 3))
sprite[i].picnum = MULTISWITCH; si->picnum = MULTISWITCH;
break; break;
case MULTISWITCH2: case MULTISWITCH2:
case MULTISWITCH2 + 1: case MULTISWITCH2 + 1:
case MULTISWITCH2 + 2: case MULTISWITCH2 + 2:
case MULTISWITCH2 + 3: case MULTISWITCH2 + 3:
if (!isRRRA()) break; if (!isRRRA()) break;
sprite[i].picnum++; si->picnum++;
if (sprite[i].picnum > (MULTISWITCH2 + 3)) if (si->picnum > (MULTISWITCH2 + 3))
sprite[i].picnum = MULTISWITCH2; si->picnum = MULTISWITCH2;
break; break;
case RRTILE2214: case RRTILE2214:
//if (ud.level_numbe r > 6) ud.level_numbe r = 0; ??? Looks like some leftover garbage. //if (ud.level_numbe r > 6) ud.level_numbe r = 0; ??? Looks like some leftover garbage.
sprite[i].picnum++; si->picnum++;
break; break;
case RRTILE8660: case RRTILE8660:
if (!isRRRA()) break; if (!isRRRA()) break;
@ -544,14 +543,13 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
case NUKEBUTTON: case NUKEBUTTON:
case RRTILE2697: case RRTILE2697:
case RRTILE2707: case RRTILE2707:
if (sprite[i].picnum == DIPSWITCH3) if (si->picnum == DIPSWITCH3)
if (sprite[i].hitag == 999) if (si->hitag == 999)
{ {
short j, nextj; int j;
j = headspritestat[107]; StatIterator it1(107);
while (j >= 0) while ((j = it1.NextIndex()) >= 0)
{ {
nextj = nextspritestat[j];
if (sprite[j].picnum == RRTILE3410) if (sprite[j].picnum == RRTILE3410)
{ {
sprite[j].picnum++; sprite[j].picnum++;
@ -561,19 +559,18 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
} }
else if (sprite[j].picnum == RRTILE295) else if (sprite[j].picnum == RRTILE295)
deletesprite(j); deletesprite(j);
j = nextj;
} }
sprite[i].picnum++; si->picnum++;
break; break;
} }
if (sprite[i].picnum == NUKEBUTTON) if (si->picnum == NUKEBUTTON)
chickenplant = 0; chickenplant = 0;
if (sprite[i].picnum == RRTILE8660) if (si->picnum == RRTILE8660)
{ {
BellTime = 132; BellTime = 132;
BellSprite = i; BellSprite = i;
} }
sprite[i].picnum++; si->picnum++;
break; break;
case PULLSWITCH + 1: case PULLSWITCH + 1:
case HANDSWITCH + 1: case HANDSWITCH + 1:
@ -591,13 +588,12 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
case NUKEBUTTON + 1: case NUKEBUTTON + 1:
case RRTILE2697 + 1: case RRTILE2697 + 1:
case RRTILE2707 + 1: case RRTILE2707 + 1:
if (sprite[i].picnum == NUKEBUTTON + 1) if (si->picnum == NUKEBUTTON + 1)
chickenplant = 1; chickenplant = 1;
if (sprite[i].hitag != 999) if (si->hitag != 999)
sprite[i].picnum--; si->picnum--;
break; break;
} }
i = nextspritestat[i];
} }
for (i = 0; i < numwalls; i++) for (i = 0; i < numwalls; i++)
@ -828,8 +824,8 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
lotag += picnum - MULTISWITCH2; lotag += picnum - MULTISWITCH2;
} }
x = headspritestat[STAT_EFFECTOR]; StatIterator itx(STAT_EFFECTOR);
while (x >= 0) while ((x = itx.NextIndex()) >= 0)
{ {
if (sprite[x].hitag == lotag) if (sprite[x].hitag == lotag)
{ {
@ -859,7 +855,6 @@ bool checkhitswitch_r(int snum, int w, int switchtype)
break; break;
} }
} }
x = nextspritestat[x];
} }
operateactivators(lotag, snum); operateactivators(lotag, snum);
@ -1349,8 +1344,8 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith)
darkestwall = wal->shade; darkestwall = wal->shade;
j = krand() & 1; j = krand() & 1;
i = headspritestat[3]; StatIterator it(STAT_EFFECTOR);
while (i >= 0) while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3)
{ {
@ -1358,7 +1353,6 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith)
hittype[i].temp_data[3] = darkestwall; hittype[i].temp_data[3] = darkestwall;
hittype[i].temp_data[4] = 1; hittype[i].temp_data[4] = 1;
} }
i = nextspritestat[i];
} }
break; break;
} }
@ -1496,28 +1490,26 @@ bool checkhitceiling_r(int sn)
{ {
if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || (isRRRA() && (sprite[i].lotag == 47 || sprite[i].lotag == 48)))) if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || (isRRRA() && (sprite[i].lotag == 47 || sprite[i].lotag == 48))))
{ {
j = headspritestat[3]; StatIterator it(STAT_EFFECTOR);
while (j >= 0) while ((j = it.NextIndex()) >= 0)
{ {
if (sprite[j].hitag == sprite[i].hitag) if (sprite[j].hitag == sprite[i].hitag)
hittype[j].temp_data[3] = 1; hittype[j].temp_data[3] = 1;
j = nextspritestat[j];
} }
break; break;
} }
} }
} }
i = headspritestat[3];
j = krand() & 1; j = krand() & 1;
while (i >= 0) StatIterator it(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0)
{ {
if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3)
{ {
hittype[i].temp_data[2] = j; hittype[i].temp_data[2] = j;
hittype[i].temp_data[4] = 1; hittype[i].temp_data[4] = 1;
} }
i = nextspritestat[i];
} }
return 1; return 1;
@ -2408,11 +2400,10 @@ void checkhitsprite_r(int i, int sn)
updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum);
setpal(&ps[p]); setpal(&ps[p]);
j = headspritestat[1]; StatIterator it(STAT_EFFECTOR);
while (j >= 0) while ((j = it.NextIndex()) >= 0)
{ {
if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0;
j = nextspritestat[j];
} }
} }