Introduce two convenient sprite iteration macros in build.h, add a few uses.

Defines SPRITES_OF(Statnum, Iter) and SPRITES_OF_SECT(Sectnum, Iter)
[The first is so that STAT_* can be substituted for Iter and it reads nicely.]

Usage should be self-explanatory, but one thing to keep in mind is that
the sprites that are iterated over MUST NOT be deleted.

git-svn-id: https://svn.eduke32.com/eduke32@2707 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-05-29 20:01:48 +00:00
parent cea07d0125
commit 5b387f7a08
3 changed files with 10 additions and 14 deletions

View file

@ -76,6 +76,11 @@ extern "C" {
#define PR_LIGHT_PRIO_LOW 4
#define PR_LIGHT_PRIO_LOW_GAME 5
// Convenient sprite iterators, must not be used if any sprites are potentially deleted!
#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]
////////// True Room over Room (YAX == rot -17 of "PRO") //////////
#define YAX_ENABLE
//#define YAX_DEBUG

View file

@ -5664,8 +5664,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
p = headspritesect[s->sectnum];
while (p >= 0)
for (SPRITES_OF_SECT(s->sectnum, p))
{
// that hardcoded SE light behavior here should be considered temporary at best...
// really need some more general system for handling them!
@ -5674,10 +5673,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (sprite[p].picnum != LASERLINE)
{
if (sprite[p].picnum == APLAYER && sprite[p].owner >= 0)
{
p = nextspritesect[p];
continue;
}
sprite[p].ang += (l*q);
sprite[p].ang &= 2047;
@ -5691,7 +5687,6 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (move_fixed_sprite(p, j, t[2]))
rotatepoint(sprite[j].x,sprite[j].y,sprite[p].x,sprite[p].y,(q*l),&sprite[p].x,&sprite[p].y);
}
p = nextspritesect[p];
}
}
@ -7391,13 +7386,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
A_PlaySound(LIGHTNING_SLAP,i);
else if (T3 == (T2>>2))
{
j = headspritestat[STAT_DEFAULT];
while (j >= 0)
{
for (SPRITES_OF(STAT_DEFAULT, j))
if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag)
sprite[j].cstat |= 32768;
j = nextspritestat[j];
}
}
else if (T3 > (T2>>3) && T3 < (T2>>2))
{

View file

@ -35,13 +35,14 @@ static int32_t g_haltSoundHack = 0;
int32_t A_CallSound(int32_t sn,int32_t whatsprite)
{
int32_t i;
if (g_haltSoundHack)
{
g_haltSoundHack = 0;
return -1;
}
i = headspritesect[sn];
while (i >= 0)
for (SPRITES_OF_SECT(sn, i))
{
if (PN == MUSICANDSFX && SLT < 1000)
{
@ -73,7 +74,6 @@ int32_t A_CallSound(int32_t sn,int32_t whatsprite)
}
return SLT;
}
i = nextspritesect[i];
}
return -1;
}