diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 8908a86b7..3d376e94c 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -572,10 +572,10 @@ void resetpspritevars(int g) which_palookup = 9; j = connecthead; - StatIterator it(STAT_PLAYER); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_PLAYER); + while (auto act = it.Next()) { - s = &sprite[i]; + s = &act->s; if (numplayersprites == MAXPLAYERS) I_Error("Too many player sprites (max 16.)"); @@ -595,7 +595,7 @@ void resetpspritevars(int g) numplayersprites++; if (j >= 0) { - s->owner = i; + act->SetOwner(act); s->shade = 0; s->xrepeat = isRR() ? 24 : 42; s->yrepeat = isRR() ? 17 : 36; @@ -626,13 +626,13 @@ void resetpspritevars(int g) else s->pal = ps[j].palookup = ud.user_pals[j]; - ps[j].i = i; + ps[j].i = act->GetIndex(); 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; - hittype[i].bposy = ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y; - hittype[i].bposz = ps[j].oposz = ps[j].posz = s->z; + act->bposx = ps[j].bobposx = ps[j].oposx = ps[j].posx = s->x; + act->bposy = ps[j].bobposy = ps[j].oposy = ps[j].posy = s->y; + act->bposz = ps[j].oposz = ps[j].posz = s->z; ps[j].angle.oang = ps[j].angle.ang = buildang(s->ang); updatesector(s->x, s->y, &ps[j].cursectnum); diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index b6a47a293..d4eb575e5 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -276,10 +276,9 @@ void prelevel_d(int g) prelevel_common(g); - StatIterator it(STAT_DEFAULT); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_DEFAULT); + while (auto ac = it.Next()) { - auto ac = &hittype[i]; auto si = &ac->s; LoadActor(ac, -1, -1); @@ -292,7 +291,7 @@ void prelevel_d(int g) { case GPSPEED: sector[si->sectnum].extra = si->lotag; - deletesprite(i); + deletesprite(ac); break; case CYCLER: @@ -305,7 +304,7 @@ void prelevel_d(int g) cyclers[numcyclers][4] = si->hitag; cyclers[numcyclers][5] = (si->ang == 1536); numcyclers++; - deletesprite(i); + deletesprite(ac); break; } } @@ -363,11 +362,11 @@ void prelevel_d(int g) if (lotaglist > 64) I_Error("Too many switches (64 max)."); - StatIterator it1(STAT_EFFECTOR); - while ((j = it1.NextIndex()) >= 0) + DukeStatIterator it1(STAT_EFFECTOR); + while (auto ac = it1.Next()) { - if (sprite[j].lotag == 12 && sprite[j].hitag == spr->lotag) - hittype[j].temp_data[0] = 1; + if (ac->s.lotag == 12 && ac->s.hitag == spr->lotag) + ac->temp_data[0] = 1; } } break; diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index fffffaf49..c35d00339 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -557,10 +557,9 @@ void prelevel_r(int g) } } - StatIterator it(STAT_DEFAULT); - while ((i = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_DEFAULT); + while (auto ac = it.Next()) { - auto ac = &hittype[i]; auto si = &ac->s; LoadActor(ac, -1, -1); @@ -577,7 +576,7 @@ void prelevel_r(int g) case GPSPEED: sector[si->sectnum].extra = si->lotag; - deletesprite(i); + deletesprite(ac); break; case CYCLER: @@ -590,22 +589,22 @@ void prelevel_r(int g) cyclers[numcyclers][4] = si->hitag; cyclers[numcyclers][5] = (si->ang == 1536); numcyclers++; - deletesprite(i); + deletesprite(ac); break; case RRTILE18: addtorch(si); - deletesprite(i); + deletesprite(ac); break; case RRTILE35: addlightning(si); - deletesprite(i); + deletesprite(ac); break; case RRTILE68: shadedsector[si->sectnum] = 1; - deletesprite(i); + deletesprite(ac); break; case RRTILE67: @@ -695,9 +694,9 @@ void prelevel_r(int g) lotaglist = 0; 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) { case RRTILE8464 + 1: