From 4f7c0b696c5c87c4b0042b2c5ac7ea6efa875eb8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 Oct 2020 19:31:30 +0200 Subject: [PATCH] - and finally the iterators in the backend. --- source/build/src/clip.cpp | 43 +++++++---------------------------- source/build/src/engine.cpp | 6 +++-- source/build/src/polymost.cpp | 5 ++-- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 1b460f784..ec3038d16 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -606,7 +606,9 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int if (dasprclipmask==0) continue; - for (native_t j=headspritesect[dasect]; j>=0; j=nextspritesect[j]) + int j; + SectIterator it(dasect); + while ((j = it.NextIndex()) >= 0) { auto const spr = (uspriteptr_t)&sprite[j]; const int32_t cstat = spr->cstat; @@ -885,39 +887,7 @@ int pushmove(vec3_t *const vect, int16_t *const sectnum, { uwallptr_t wal; int32_t startwall, endwall; -#if 0 - // Push FACE sprites - for (i=headspritesect[clipsectorlist[clipsectcnt]]; i>=0; i=nextspritesect[i]) - { - spr = &sprite[i]; - if (((spr->cstat&48) != 0) && ((spr->cstat&48) != 48)) continue; - if ((spr->cstat&dasprclipmask) == 0) continue; - dax = (vect->x)-spr->x; day = (vect->y)-spr->y; - t = (spr->clipdist<<2)+walldist; - if ((klabs(dax) < t) && (klabs(day) < t)) - { - daz = spr->z + spriteheightofs(i, &t, 1); - if (((vect->z) < daz+ceildist) && ((vect->z) > daz-t-flordist)) - { - t = (spr->clipdist<<2)+walldist; - - j = getangle(dax, day); - dx = (sintable[(j+512)&2047]>>11); - dy = (sintable[(j)&2047]>>11); - bad2 = 16; - do - { - vect->x = (vect->x) + dx; vect->y = (vect->y) + dy; - bad2--; if (bad2 == 0) break; - } while ((klabs((vect->x)-spr->x) < t) && (klabs((vect->y)-spr->y) < t)); - bad = -1; - k--; if (k <= 0) return bad; - updatesector(vect->x, vect->y, sectnum); - } - } - } -#endif auto sec = (usectorptr_t)§or[clipsectorlist[clipsectcnt]]; if (dir > 0) startwall = sec->wallptr, endwall = startwall + sec->wallnum; @@ -1117,7 +1087,9 @@ void getzrange(const vec3_t *pos, int16_t sectnum, if (dasprclipmask) for (bssize_t i=0; i=0; j=nextspritesect[j]) + int j; + SectIterator it(clipsectorlist[i]); + while ((j = it.NextIndex()) >= 0) { const int32_t cstat = sprite[j].cstat; int32_t daz, daz2; @@ -1451,7 +1423,8 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 if (dasprclipmask==0) continue; - for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) + SectIterator it(dasector); + while ((z = it.NextIndex()) >= 0) { auto const spr = (uspriteptr_t)&sprite[z]; uint32_t const cstat = spr->cstat; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index d4e4226eb..7f6329d8f 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1742,7 +1742,8 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) //Collect floor sprites to draw - for (i=headspritesect[s]; i>=0; i=nextspritesect[i]) + SectIterator it(s); + while ((i = it.NextIndex()) >= 0) { if (sprite[i].cstat & 32768) continue; @@ -2525,7 +2526,8 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, if (tagsearch & 4) continue; // skip sprite search - for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) + SectIterator it(dasector); + while ((z = it.NextIndex()) >= 0) { auto const spr = (uspriteptr_t)&sprite[z]; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 43f503e7e..9d0bdd18a 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -2227,7 +2227,9 @@ void polymost_scansector(int32_t sectnum) { sectnum = sectorborder[--sectorbordercnt]; - for (bssize_t z=headspritesect[sectnum]; z>=0; z=nextspritesect[z]) + int z; + SectIterator it(sectnum); + while ((z = it.NextIndex()) >= 0) { auto const spr = (uspriteptr_t)&sprite[z]; @@ -2260,7 +2262,6 @@ void polymost_scansector(int32_t sectnum) vec2d_t p2 = { 0, 0 }; uwallptr_t wal; - int z; for (z=startwall,wal=(uwallptr_t)&wall[z]; z