From 79dcd2c17858b15dc397dab4d8f9811df8f4ac5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Nov 2021 00:48:28 +0100 Subject: [PATCH] - iterators in CollectPortals --- source/games/sw/src/rooms.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 65f2afb22..51cdd2225 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -1049,13 +1049,12 @@ void CollectPortals() // pick one sprite out of the sectors, repeat until we get a valid connection for (auto sec : fp.sectors) { - SectIterator it(sec); - int spr; - while ((spr = it.NextIndex()) >= 0) + SWSectIterator it(sec); + while (auto actor = it.Next()) { - int tx = sprite[spr].x; - int ty = sprite[spr].y; - int tz = sprite[spr].z; + int tx = actor->s().x; + int ty = actor->s().y; + int tz = actor->s().z; int16_t tsectnum = sec; int match = FindViewSectorInScene(tsectnum, VIEW_LEVEL1); @@ -1067,7 +1066,7 @@ void CollectPortals() // got something! fp.othersector = tsectnum; fp.offset = { tx, ty, tz }; - fp.offset -= sprite[spr].pos; + fp.offset -= actor->s().pos; goto nextfg; } } @@ -1080,13 +1079,12 @@ void CollectPortals() { for (auto sec : fp.sectors) { - SectIterator it(sec); - int spr; - while ((spr = it.NextIndex()) >= 0) + SWSectIterator it(sec); + while (auto actor = it.Next()) { - int tx = sprite[spr].x; - int ty = sprite[spr].y; - int tz = sprite[spr].z; + int tx = actor->s().x; + int ty = actor->s().y; + int tz = actor->s().z; int16_t tsectnum = sec; int match = FindViewSectorInScene(tsectnum, VIEW_LEVEL2); @@ -1098,7 +1096,7 @@ void CollectPortals() // got something! fp.othersector = tsectnum; fp.offset = { tx, ty, tz }; - fp.offset -= sprite[spr].pos; + fp.offset -= actor->s().pos; goto nextcg; } }