From be3292d29bcf83f01a4c116c5dd2fc5aae39ae0d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 15 Oct 2020 16:59:43 +0200 Subject: [PATCH] - removed the mostly unused macros for sprite iteration. --- source/blood/src/actor.cpp | 4 +++- source/blood/src/aicult.cpp | 4 +++- source/blood/src/callback.cpp | 5 ++++- source/build/include/build.h | 24 ------------------------ source/sw/src/interpso.cpp | 4 +++- 5 files changed, 13 insertions(+), 28 deletions(-) diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 9e9d3025f..e11c79f02 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -2418,7 +2418,9 @@ int actOwnerIdToSpriteId(int nSprite) bool actTypeInSector(int nSector, int nType) { - for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritestat[nSprite]) + int nSprite; + SectIterator it(nSector); + while ((nSprite = it.NextIndex()) >= 0) { if (sprite[nSprite].index == nType) return 1; diff --git a/source/blood/src/aicult.cpp b/source/blood/src/aicult.cpp index 68a03e65e..4dfc70f80 100644 --- a/source/blood/src/aicult.cpp +++ b/source/blood/src/aicult.cpp @@ -219,7 +219,9 @@ static void sub_68230(int, int nXSprite) static char TargetNearExplosion(spritetype *pSprite) { - for (short nSprite = headspritesect[pSprite->sectnum]; nSprite >= 0; nSprite = nextspritesect[nSprite]) + int nSprite; + SectIterator it(pSprite->sectnum); + while ((nSprite = it.NextIndex()) >= 0) { if (sprite[nSprite].type == kThingArmedTNTStick || sprite[nSprite].statnum == kStatExplosion) return 1; diff --git a/source/blood/src/callback.cpp b/source/blood/src/callback.cpp index 49fb15e8b..18e7d5a19 100644 --- a/source/blood/src/callback.cpp +++ b/source/blood/src/callback.cpp @@ -363,7 +363,10 @@ void CounterCheck(int nSector) // 12 int nReq = pXSector->waitTimeA; int nType = pXSector->data; int nCount = 0; if (!nType || !nReq) return; - for (int nSprite = headspritesect[nSector]; nSprite >= 0; nSprite = nextspritesect[nSprite]) { + int nSprite; + SectIterator it(nSector); + while ((nSprite = it.NextIndex()) >= 0) + { if (sprite[nSprite].type == nType) nCount++; } diff --git a/source/build/include/build.h b/source/build/include/build.h index 199155854..5909fe80a 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -81,33 +81,9 @@ enum rendmode_t { #define PR_LIGHT_PRIO_LOW 4 #define PR_LIGHT_PRIO_LOW_GAME 5 -// Convenient sprite iterators, must not be used if any sprites inside the loop -// are potentially deleted or their sector changed... -#define SPRITES_OF(Statnum, Iter) Iter=headspritestat[Statnum]; Iter>=0; Iter=nextspritestat[Iter] #define SPRITES_OF_SECT(Sectnum, Iter) Iter=headspritesect[Sectnum]; Iter>=0; Iter=nextspritesect[Iter] -// ... in which case this iterator may be used: -#define SPRITES_OF_SECT_SAFE(Sectnum, Iter, Next) Iter=headspritesect[Sectnum]; \ - Iter>=0 && (Next=nextspritesect[Iter], 1); Iter=Next -#define SPRITES_OF_STAT_SAFE(Statnum, Iter, Next) Iter=headspritestat[Statnum]; \ - Iter>=0 && (Next=nextspritestat[Iter], 1); Iter=Next -////////// yax defs ////////// -#define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld))) - -#define YAX_CEILING 0 // don't change! -#define YAX_FLOOR 1 // don't change! - - -# define YAX_MAXBUNCHES 256 -# define YAX_BIT 1024 - // "has next wall when constrained"-bit (1<<10: ceiling, 1<<11: floor) -# define YAX_NEXTWALLBIT(Cf) (1<<(10+Cf)) -# define YAX_NEXTWALLBITS (YAX_NEXTWALLBIT(0)|YAX_NEXTWALLBIT(1)) - -# define yax_preparedrawrooms() -# define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr) - #define CLIPMASK0 (IntToFixed(1)+1) #define CLIPMASK1 (IntToFixed(256)+64) diff --git a/source/sw/src/interpso.cpp b/source/sw/src/interpso.cpp index 0926f7ce5..4bb70c9ca 100644 --- a/source/sw/src/interpso.cpp +++ b/source/sw/src/interpso.cpp @@ -139,7 +139,9 @@ void so_addinterpolation(SECTOR_OBJECTp sop) } } - for (SPRITES_OF_SECT(*sectp - sector, i)) + int i; + SectIterator it(*sectp - sector); + while ((i = it.NextIndex()) >= 0) if (sprite[i].statnum == STAT_VATOR && SP_TAG1(sprite+i) == SECT_VATOR) break; interp->hasvator |= (i >= 0);