- iterators in CollectPortals

This commit is contained in:
Christoph Oelckers 2021-11-06 00:48:28 +01:00
parent 8df851c3e3
commit 79dcd2c178

View file

@ -1049,13 +1049,12 @@ void CollectPortals()
// pick one sprite out of the sectors, repeat until we get a valid connection // pick one sprite out of the sectors, repeat until we get a valid connection
for (auto sec : fp.sectors) for (auto sec : fp.sectors)
{ {
SectIterator it(sec); SWSectIterator it(sec);
int spr; while (auto actor = it.Next())
while ((spr = it.NextIndex()) >= 0)
{ {
int tx = sprite[spr].x; int tx = actor->s().x;
int ty = sprite[spr].y; int ty = actor->s().y;
int tz = sprite[spr].z; int tz = actor->s().z;
int16_t tsectnum = sec; int16_t tsectnum = sec;
int match = FindViewSectorInScene(tsectnum, VIEW_LEVEL1); int match = FindViewSectorInScene(tsectnum, VIEW_LEVEL1);
@ -1067,7 +1066,7 @@ void CollectPortals()
// got something! // got something!
fp.othersector = tsectnum; fp.othersector = tsectnum;
fp.offset = { tx, ty, tz }; fp.offset = { tx, ty, tz };
fp.offset -= sprite[spr].pos; fp.offset -= actor->s().pos;
goto nextfg; goto nextfg;
} }
} }
@ -1080,13 +1079,12 @@ void CollectPortals()
{ {
for (auto sec : fp.sectors) for (auto sec : fp.sectors)
{ {
SectIterator it(sec); SWSectIterator it(sec);
int spr; while (auto actor = it.Next())
while ((spr = it.NextIndex()) >= 0)
{ {
int tx = sprite[spr].x; int tx = actor->s().x;
int ty = sprite[spr].y; int ty = actor->s().y;
int tz = sprite[spr].z; int tz = actor->s().z;
int16_t tsectnum = sec; int16_t tsectnum = sec;
int match = FindViewSectorInScene(tsectnum, VIEW_LEVEL2); int match = FindViewSectorInScene(tsectnum, VIEW_LEVEL2);
@ -1098,7 +1096,7 @@ void CollectPortals()
// got something! // got something!
fp.othersector = tsectnum; fp.othersector = tsectnum;
fp.offset = { tx, ty, tz }; fp.offset = { tx, ty, tz };
fp.offset -= sprite[spr].pos; fp.offset -= actor->s().pos;
goto nextcg; goto nextcg;
} }
} }