- actor iterators for movefx and its RRRA subfunction.

This commit is contained in:
Christoph Oelckers 2020-10-24 10:30:17 +02:00
parent 801e94ca54
commit d95131cb4d
3 changed files with 18 additions and 20 deletions

View file

@ -552,28 +552,26 @@ void moveplayers(void)
void movefx(void) void movefx(void)
{ {
int i, j, p; int p;
int x, ht; int x, ht;
StatIterator iti(STAT_FX); DukeStatIterator iti(STAT_FX);
while ((i = iti.NextIndex()) >= 0) while (auto act = iti.Next())
{ {
auto spri = &sprite[i]; auto spri = &act->s;
auto act = &hittype[i];
switch (spri->picnum) switch (spri->picnum)
{ {
case RESPAWN: case RESPAWN:
if (spri->extra == 66) if (spri->extra == 66)
{ {
j = fi.spawn(i, spri->hitag); auto j = spawn(act, spri->hitag);
if (isRRRA()) if (isRRRA())
{ {
respawn_rrra(i, j); respawn_rrra(act, j);
} }
else else
{ {
deletesprite(i); deletesprite(act);
} }
} }
else if (spri->extra > (66 - 13)) else if (spri->extra > (66 - 13))
@ -592,7 +590,7 @@ void movefx(void)
if (spri->lotag >= 1000 && spri->lotag < 2000) if (spri->lotag >= 1000 && spri->lotag < 2000)
{ {
x = ldist(&sprite[ps[screenpeek].i], spri); x = ldist(ps[screenpeek].GetActor(), act);
if (x < ht && act->temp_data[0] == 0) if (x < ht && act->temp_data[0] == 0)
{ {
FX_SetReverb(spri->lotag - 1000); FX_SetReverb(spri->lotag - 1000);
@ -607,21 +605,21 @@ void movefx(void)
} }
else if (spri->lotag < 999 && (unsigned)sector[spri->sectnum].lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && sector[spri->sectnum].floorz != sector[spri->sectnum].ceilingz) else if (spri->lotag < 999 && (unsigned)sector[spri->sectnum].lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && sector[spri->sectnum].floorz != sector[spri->sectnum].ceilingz)
{ {
auto flags = S_GetUserFlags(spri->lotag); int flags = S_GetUserFlags(spri->lotag);
if (flags & SF_MSFX) if (flags & SF_MSFX)
{ {
int x = dist(&sprite[ps[screenpeek].i], spri); int x = dist(ps[screenpeek].GetActor(), act);
if (x < ht && act->temp_data[0] == 0) if (x < ht && act->temp_data[0] == 0)
{ {
// Start playing an ambience sound. // Start playing an ambience sound.
S_PlayActorSound(spri->lotag, i, CHAN_AUTO, CHANF_LOOP); S_PlayActorSound(spri->lotag, act, CHAN_AUTO, CHANF_LOOP);
act->temp_data[0] = 1; // AMBIENT_SFX_PLAYING act->temp_data[0] = 1; // AMBIENT_SFX_PLAYING
} }
else if (x >= ht && act->temp_data[0] == 1) else if (x >= ht && act->temp_data[0] == 1)
{ {
// Stop playing ambience sound because we're out of its range. // Stop playing ambience sound because we're out of its range.
S_StopSound(spri->lotag, i); S_StopSound(spri->lotag, act);
} }
} }

View file

@ -784,10 +784,10 @@ int ifhitbyweapon_r(int sn)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void respawn_rrra(int i, int j) void respawn_rrra(DDukeActor* oldact, DDukeActor* newact)
{ {
auto newspr = &sprite[j]; auto newspr = &newact->s;
newspr->pal = sprite[i].pal; newspr->pal = oldact->s.pal;
if (newspr->picnum == MAMA) if (newspr->picnum == MAMA)
{ {
if (newspr->pal == 30) if (newspr->pal == 30)
@ -823,10 +823,10 @@ void respawn_rrra(int i, int j)
if (newspr->pal != 6) if (newspr->pal != 6)
{ {
deletesprite(i); deletesprite(oldact);
return; return;
} }
sprite[i].extra = (66 - 13); oldact->s.extra = (66 - 13);
newspr->pal = 0; newspr->pal = 0;
} }

View file

@ -91,7 +91,7 @@ void handle_se35(int i, int SMALLSMOKE, int EXPLOSION2);
void handle_se128(int i); void handle_se128(int i);
void handle_se130(int i, int countmax, int EXPLOSION2); void handle_se130(int i, int countmax, int EXPLOSION2);
void respawn_rrra(int i, int j); void respawn_rrra(DDukeActor* oldact, DDukeActor* newact);
int dodge(spritetype*); int dodge(spritetype*);
void alterang(int a, int g_i, int g_p); void alterang(int a, int g_i, int g_p);