diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index 8d417db0b..5407dac46 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -289,9 +289,9 @@ inline void detonate(int i, int explosion) detonate(&hittype[i], explosion); } -inline void callsound(int sect, DDukeActor* a) +inline int callsound(int sect, int a) { - callsound(sect, a->GetIndex()); + return callsound(sect, a == -1? nullptr : &hittype[a]); } inline int hits(DDukeActor* snum) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 7e969724f..1acd81ada 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -140,8 +140,7 @@ int haskey(int sect, int snum); void shootbloodsplat(int i, int p, int sx, int sy, int sz, int sa, int atwith, int BIGFORCE, int OOZFILTER, int NEWBEAST); void breakwall(short newpn, short spr, short dawallnum); -void callsound2(int soundNum, int playerNum); -int callsound(int sectnum,int snum); +int callsound(int sectnum,DDukeActor* snum); int hitasprite(int snum,short *hitSprite); int findplayer(const spritetype* s, int* dist); void operatejaildoors(int hitag); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index f262f7b1c..feff3d22c 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -50,7 +50,7 @@ BEGIN_DUKE_NS //--------------------------------------------------------------------------- static bool haltsoundhack; -int callsound(int sn, int whatsprite) +int callsound(int sn, DDukeActor* whatsprite) { if (!isRRRA() && haltsoundhack) { @@ -58,49 +58,48 @@ int callsound(int sn, int whatsprite) return -1; } - int i; - SectIterator it(sn); - while ((i = it.NextIndex()) >= 0) + DukeSectIterator it(sn); + while (auto act = it.Next()) { - auto si = &sprite[i]; + auto si = &act->s; if (si->picnum == MUSICANDSFX && si->lotag < 1000) { - if (whatsprite == -1) whatsprite = i; + if (whatsprite == nullptr) whatsprite = act; int snum = si->lotag; auto flags = S_GetUserFlags(snum); // Reset if the desired actor isn't playing anything. bool hival = S_IsSoundValid(si->hitag); - if (hittype[i].temp_data[0] == 1 && !hival) + if (act->temp_data[0] == 1 && !hival) { - if (!S_CheckActorSoundPlaying(hittype[i].temp_data[5], snum)) - hittype[i].temp_data[0] = 0; + if (!S_CheckActorSoundPlaying(act->temp_actor, snum)) + act->temp_data[0] = 0; } - if (hittype[i].temp_data[0] == 0) + if (act->temp_data[0] == 0) { if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL) { if (snum) { if (si->hitag && snum != si->hitag) - S_StopSound(si->hitag, hittype[i].temp_data[5]); + S_StopSound(si->hitag, act->temp_actor); S_PlayActorSound(snum, whatsprite); - hittype[i].temp_data[5] = whatsprite; + act->temp_actor = whatsprite; } if ((sector[si->sectnum].lotag & 0xff) != ST_22_SPLITTING_DOOR) - hittype[i].temp_data[0] = 1; + act->temp_data[0] = 1; } } else if (si->hitag < 1000) { if ((flags & SF_LOOP) || (si->hitag && si->hitag != si->lotag)) - S_StopSound(si->lotag, hittype[i].temp_data[5]); + S_StopSound(si->lotag, act->temp_actor); if (si->hitag) S_PlayActorSound(si->hitag, whatsprite); - hittype[i].temp_data[0] = 0; - hittype[i].temp_data[5] = whatsprite; + act->temp_data[0] = 0; + act->temp_actor = whatsprite; } return si->lotag; } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 704fc205a..f4acaa142 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -172,6 +172,7 @@ int initspriteforspawn(int j, int pn, const std::initializer_list &excludes act->actorstayput = -1; t[0] = t[1] = t[2] = t[3] = t[4] = t[5] = 0; + hittype[i].temp_actor = nullptr; if (sp->cstat & 48) if (!isIn(sp->picnum, excludes) && (sp->cstat & 48))