- cleaned up a few more loops.

This commit is contained in:
Christoph Oelckers 2020-11-02 19:13:58 +01:00
parent 618c739318
commit d8a7821b4f
3 changed files with 26 additions and 28 deletions

View file

@ -572,10 +572,10 @@ void resetpspritevars(int g)
which_palookup = 9; which_palookup = 9;
j = connecthead; j = connecthead;
StatIterator it(STAT_PLAYER); DukeStatIterator it(STAT_PLAYER);
while ((i = it.NextIndex()) >= 0) while (auto act = it.Next())
{ {
s = &sprite[i]; s = &act->s;
if (numplayersprites == MAXPLAYERS) if (numplayersprites == MAXPLAYERS)
I_Error("Too many player sprites (max 16.)"); I_Error("Too many player sprites (max 16.)");
@ -595,7 +595,7 @@ void resetpspritevars(int g)
numplayersprites++; numplayersprites++;
if (j >= 0) if (j >= 0)
{ {
s->owner = i; act->SetOwner(act);
s->shade = 0; s->shade = 0;
s->xrepeat = isRR() ? 24 : 42; s->xrepeat = isRR() ? 24 : 42;
s->yrepeat = isRR() ? 17 : 36; s->yrepeat = isRR() ? 17 : 36;
@ -626,13 +626,13 @@ void resetpspritevars(int g)
else else
s->pal = ps[j].palookup = ud.user_pals[j]; s->pal = ps[j].palookup = ud.user_pals[j];
ps[j].i = i; ps[j].i = act->GetIndex();
ps[j].frag_ps = j; ps[j].frag_ps = j;
hittype[i].owner = i; act->SetOwner(act);
hittype[i].bposx = ps[j].bobposx = ps[j].oposx = ps[j].posx = s->x; act->bposx = ps[j].bobposx = ps[j].oposx = ps[j].posx = s->x;
hittype[i].bposy = ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y; act->bposy = ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y;
hittype[i].bposz = ps[j].oposz = ps[j].posz = s->z; act->bposz = ps[j].oposz = ps[j].posz = s->z;
ps[j].angle.oang = ps[j].angle.ang = buildang(s->ang); ps[j].angle.oang = ps[j].angle.ang = buildang(s->ang);
updatesector(s->x, s->y, &ps[j].cursectnum); updatesector(s->x, s->y, &ps[j].cursectnum);

View file

@ -276,10 +276,9 @@ void prelevel_d(int g)
prelevel_common(g); prelevel_common(g);
StatIterator it(STAT_DEFAULT); DukeStatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0) while (auto ac = it.Next())
{ {
auto ac = &hittype[i];
auto si = &ac->s; auto si = &ac->s;
LoadActor(ac, -1, -1); LoadActor(ac, -1, -1);
@ -292,7 +291,7 @@ void prelevel_d(int g)
{ {
case GPSPEED: case GPSPEED:
sector[si->sectnum].extra = si->lotag; sector[si->sectnum].extra = si->lotag;
deletesprite(i); deletesprite(ac);
break; break;
case CYCLER: case CYCLER:
@ -305,7 +304,7 @@ void prelevel_d(int g)
cyclers[numcyclers][4] = si->hitag; cyclers[numcyclers][4] = si->hitag;
cyclers[numcyclers][5] = (si->ang == 1536); cyclers[numcyclers][5] = (si->ang == 1536);
numcyclers++; numcyclers++;
deletesprite(i); deletesprite(ac);
break; break;
} }
} }
@ -363,11 +362,11 @@ void prelevel_d(int g)
if (lotaglist > 64) if (lotaglist > 64)
I_Error("Too many switches (64 max)."); I_Error("Too many switches (64 max).");
StatIterator it1(STAT_EFFECTOR); DukeStatIterator it1(STAT_EFFECTOR);
while ((j = it1.NextIndex()) >= 0) while (auto ac = it1.Next())
{ {
if (sprite[j].lotag == 12 && sprite[j].hitag == spr->lotag) if (ac->s.lotag == 12 && ac->s.hitag == spr->lotag)
hittype[j].temp_data[0] = 1; ac->temp_data[0] = 1;
} }
} }
break; break;

View file

@ -557,10 +557,9 @@ void prelevel_r(int g)
} }
} }
StatIterator it(STAT_DEFAULT); DukeStatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0) while (auto ac = it.Next())
{ {
auto ac = &hittype[i];
auto si = &ac->s; auto si = &ac->s;
LoadActor(ac, -1, -1); LoadActor(ac, -1, -1);
@ -577,7 +576,7 @@ void prelevel_r(int g)
case GPSPEED: case GPSPEED:
sector[si->sectnum].extra = si->lotag; sector[si->sectnum].extra = si->lotag;
deletesprite(i); deletesprite(ac);
break; break;
case CYCLER: case CYCLER:
@ -590,22 +589,22 @@ void prelevel_r(int g)
cyclers[numcyclers][4] = si->hitag; cyclers[numcyclers][4] = si->hitag;
cyclers[numcyclers][5] = (si->ang == 1536); cyclers[numcyclers][5] = (si->ang == 1536);
numcyclers++; numcyclers++;
deletesprite(i); deletesprite(ac);
break; break;
case RRTILE18: case RRTILE18:
addtorch(si); addtorch(si);
deletesprite(i); deletesprite(ac);
break; break;
case RRTILE35: case RRTILE35:
addlightning(si); addlightning(si);
deletesprite(i); deletesprite(ac);
break; break;
case RRTILE68: case RRTILE68:
shadedsector[si->sectnum] = 1; shadedsector[si->sectnum] = 1;
deletesprite(i); deletesprite(ac);
break; break;
case RRTILE67: case RRTILE67:
@ -695,9 +694,9 @@ void prelevel_r(int g)
lotaglist = 0; lotaglist = 0;
it.Reset(STAT_DEFAULT); it.Reset(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0) while (auto ac = it.Next())
{ {
auto spr = &sprite[i]; auto spr = &ac->s;
switch (spr->picnum) switch (spr->picnum)
{ {
case RRTILE8464 + 1: case RRTILE8464 + 1: