diff --git a/source/games/exhumed/src/anims.cpp b/source/games/exhumed/src/anims.cpp index ac6340735..892412e1f 100644 --- a/source/games/exhumed/src/anims.cpp +++ b/source/games/exhumed/src/anims.cpp @@ -139,7 +139,7 @@ void AIAnim::Tick(RunListEvent* ev) if (!(pActor->spr.cstat & CSTAT_SPRITE_INVISIBLE)) { - playFrameSound(pActor, animSeq.frames[nFrame]); + animSeq.frames[nFrame].playSound(pActor); } if (pActor->spr.statnum == kStatIgnited) diff --git a/source/games/exhumed/src/anubis.cpp b/source/games/exhumed/src/anubis.cpp index 5486a371c..e2a89d06e 100644 --- a/source/games/exhumed/src/anubis.cpp +++ b/source/games/exhumed/src/anubis.cpp @@ -130,7 +130,7 @@ void AIAnubis::Tick(RunListEvent* ev) if (nAction < 11) Gravity(ap); - playFrameSound(ap, seqFrame); + seqFrame.playSound(ap); ap->spr.picnum = seqFrame.getFirstPicnum(); ap->nFrame++; diff --git a/source/games/exhumed/src/bubbles.cpp b/source/games/exhumed/src/bubbles.cpp index 65c136f51..25b590050 100644 --- a/source/games/exhumed/src/bubbles.cpp +++ b/source/games/exhumed/src/bubbles.cpp @@ -98,7 +98,7 @@ void AIBubble::Tick(RunListEvent* ev) const auto& bubbSeq = getSequence(pActor->nSeqFile, pActor->nSeqIndex); - playFrameSound(pActor, bubbSeq.frames[pActor->nFrame]); + bubbSeq.frames[pActor->nFrame].playSound(pActor); pActor->nFrame++; diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index dbf0eaf2a..ac0b07cb0 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -806,7 +806,7 @@ void AIBullet::Tick(RunListEvent* ev) const auto& seqFrame = bulletSeq.frames[pBullet->nFrame]; DExhumedActor* pActor = BulletList[nBullet].pActor; - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); if (seqFrame.flags & 0x80) { diff --git a/source/games/exhumed/src/fish.cpp b/source/games/exhumed/src/fish.cpp index d0f555ba7..5bc162b39 100644 --- a/source/games/exhumed/src/fish.cpp +++ b/source/games/exhumed/src/fish.cpp @@ -363,7 +363,7 @@ void AIFish::Tick(RunListEvent* ev) pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= fishSeq.frames.Size()) { diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index 1b6e71545..5b06f9503 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -261,7 +261,7 @@ void AIGrenade::Tick(RunListEvent* ev) const auto& grenadeSeq = pActor->nFrame ? getSequence("grenboom") : getSequence("grenroll", pActor->nIndex); const auto& seqFrame = grenadeSeq.frames[pActor->nHealth >> 8]; - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->spr.picnum = seqFrame.getFirstPicnum(); pActor->nIndex2--; diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index aa7c09556..9c868fcf0 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -381,7 +381,7 @@ void MoveWeapons(int nPlayer) for (frames = var_1C; frames > 0; frames--) { - playFrameSound(pPlayerActor, seqFrame.get()); + seqFrame.get().playSound(pPlayerActor); pPlayer->nWeapFrame++; diff --git a/source/games/exhumed/src/lavadude.cpp b/source/games/exhumed/src/lavadude.cpp index e12f58dc7..03bad402a 100644 --- a/source/games/exhumed/src/lavadude.cpp +++ b/source/games/exhumed/src/lavadude.cpp @@ -224,7 +224,7 @@ void AILavaDude::Tick(RunListEvent* ev) if (nAction) { - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= lavadudeSeq.frames.Size()) diff --git a/source/games/exhumed/src/lion.cpp b/source/games/exhumed/src/lion.cpp index 85c04f7fd..35bb9896e 100644 --- a/source/games/exhumed/src/lion.cpp +++ b/source/games/exhumed/src/lion.cpp @@ -205,7 +205,7 @@ void AILion::Tick(RunListEvent* ev) pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= lionSeq.frames.Size()) diff --git a/source/games/exhumed/src/mummy.cpp b/source/games/exhumed/src/mummy.cpp index 43694bfa9..f74bce165 100644 --- a/source/games/exhumed/src/mummy.cpp +++ b/source/games/exhumed/src/mummy.cpp @@ -146,7 +146,7 @@ void AIMummy::Tick(RunListEvent* ev) pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); bool bVal = false; diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 7df648ece..03a3153e3 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -2180,7 +2180,7 @@ void DoDrips() if (!pActor) continue; const auto& dripSeq = getSequence("drips", !(pActor->sector()->Flag & kSectLava)); - playFrameSound(pActor, dripSeq.frames[RandomSize(2) % dripSeq.frames.Size()]); + dripSeq.frames[RandomSize(2) % dripSeq.frames.Size()].playSound(pActor); sDrip[i].nCount = RandomSize(8) + 90; } diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 93d7c7eab..ad65ef48c 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1918,7 +1918,7 @@ static void doPlayerActionSequence(Player* const pPlayer) const auto& seqFrame = playerSeq.frames[pPlayerActor->nFrame]; const auto seqSize = playerSeq.frames.Size(); - playFrameSound(pPlayerActor, seqFrame); + seqFrame.playSound(pPlayerActor); pPlayerActor->nFrame++; if (pPlayerActor->nFrame < seqSize) diff --git a/source/games/exhumed/src/queen.cpp b/source/games/exhumed/src/queen.cpp index a05a0ea2c..308f709d5 100644 --- a/source/games/exhumed/src/queen.cpp +++ b/source/games/exhumed/src/queen.cpp @@ -550,7 +550,7 @@ void AIQueenEgg::Tick(RunListEvent* ev) if (nAction != 4) { - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pEgg->nFrame++; if (pEgg->nFrame >= eggSeq.frames.Size()) @@ -805,7 +805,7 @@ void AIQueenHead::Tick(RunListEvent* ev) const auto& queenSeq = getSequence(pActor->nSeqFile, HeadSeq[QueenHead.nAction].nSeqId); const auto& seqFrame = queenSeq.frames[QueenHead.nFrame]; - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->spr.picnum = seqFrame.getFirstPicnum(); @@ -1240,7 +1240,7 @@ void AIQueen::Tick(RunListEvent* ev) pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); QueenList[nQueen].nFrame++; if (QueenList[nQueen].nFrame >= queenSeq.frames.Size()) diff --git a/source/games/exhumed/src/ra.cpp b/source/games/exhumed/src/ra.cpp index 4d382fcad..390243c7b 100644 --- a/source/games/exhumed/src/ra.cpp +++ b/source/games/exhumed/src/ra.cpp @@ -223,7 +223,7 @@ void AIRa::Tick(RunListEvent* ev) if (Ra[nPlayer].nAction) { - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); Ra[nPlayer].nFrame++; if (Ra[nPlayer].nFrame >= raSeq.frames.Size()) diff --git a/source/games/exhumed/src/rat.cpp b/source/games/exhumed/src/rat.cpp index efa48e561..f6858eda7 100644 --- a/source/games/exhumed/src/rat.cpp +++ b/source/games/exhumed/src/rat.cpp @@ -251,7 +251,7 @@ void AIRat::Tick(RunListEvent* ev) pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= ratSeq.frames.Size()) diff --git a/source/games/exhumed/src/rex.cpp b/source/games/exhumed/src/rex.cpp index 7e3bfb799..6311e549c 100644 --- a/source/games/exhumed/src/rex.cpp +++ b/source/games/exhumed/src/rex.cpp @@ -206,7 +206,7 @@ void AIRex::Tick(RunListEvent* ev) // moves the mouth open and closed as it's idle? while (--ecx != -1) { - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= rexSeq.frames.Size()) diff --git a/source/games/exhumed/src/roach.cpp b/source/games/exhumed/src/roach.cpp index 127ea7e38..9fa4bbdd2 100644 --- a/source/games/exhumed/src/roach.cpp +++ b/source/games/exhumed/src/roach.cpp @@ -216,7 +216,7 @@ void AIRoach::Tick(RunListEvent* ev) const auto& seqFrame = roachSeq.frames[pActor->nFrame]; pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= roachSeq.frames.Size()) diff --git a/source/games/exhumed/src/scorp.cpp b/source/games/exhumed/src/scorp.cpp index d452f0b06..648ef24ff 100644 --- a/source/games/exhumed/src/scorp.cpp +++ b/source/games/exhumed/src/scorp.cpp @@ -211,7 +211,7 @@ void AIScorp::Tick(RunListEvent* ev) const auto& seqFrame = scorpSeq.frames[pActor->nFrame]; pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index 251e00667..c6af873fe 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -742,29 +742,6 @@ void seq_MoveSequence(DExhumedActor* actor, int16_t nSeq, int16_t nFrame) // //--------------------------------------------------------------------------- -void playFrameSound(DExhumedActor* actor, const SeqFrame& seqFrame) -{ - const int nSound = seqFrame.sound; - - if (nSound == -1) - return; - - if (actor) - { - D3PlayFX(nSound, actor); - } - else - { - PlayLocalSound(nSound, 0); - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void seq_PlotArrowSequence(const int nSprite, const FName seqFile, const int16_t seqIndex, const int frameIndex) { tspritetype* pTSprite = mytspriteArray->get(nSprite); diff --git a/source/games/exhumed/src/sequence.h b/source/games/exhumed/src/sequence.h index ea6854b9b..f0c1a5ea2 100644 --- a/source/games/exhumed/src/sequence.h +++ b/source/games/exhumed/src/sequence.h @@ -126,6 +126,21 @@ struct SeqFrame { return chunks[0].picnum; } + + const void playSound(DExhumedActor* const pActor) const + { + if (sound == -1) + return; + + if (pActor) + { + D3PlayFX(sound, pActor); + } + else + { + PlayLocalSound(sound, 0); + } + } }; struct Seq @@ -164,7 +179,6 @@ int getSeqFrameChunkPicnum(const int nChunk); int getSeqFrameChunkFlags(const int nChunk); TArray* getFileSeqs(const FName nSeqFile); -void playFrameSound(DExhumedActor* actor, const SeqFrame& seqFrame); inline const Seq& getSequence(const FName nSeqFile, const unsigned nSeqIndex = 0) { diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index 73f93a07e..d5c8e317b 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -145,7 +145,7 @@ void AISoul::Tick(RunListEvent* ev) auto pActor = ev->pObjActor; if (!pActor) return; - playFrameSound(pActor, getSequence("set", 75).frames[0]); + getSequence("set", 75).frames[0].playSound(pActor); if (pActor->spr.scale.X < 0.5) { @@ -275,7 +275,7 @@ void AISet::Tick(RunListEvent* ev) const auto& seqFrame = setSeq.frames[pActor->nFrame]; pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); if (nAction == 3) { diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index 858280c62..45f09751b 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -339,7 +339,7 @@ void AISnake::Tick(RunListEvent* ev) DExhumedActor* pActor = SnakeList[nSnake].pSprites[0]; if (!pActor) return; - playFrameSound(pActor, getSequence("snakehed").frames[0]); + getSequence("snakehed").frames[0].playSound(pActor); DExhumedActor* pEnemySprite = SnakeList[nSnake].pEnemy; diff --git a/source/games/exhumed/src/spider.cpp b/source/games/exhumed/src/spider.cpp index 3a9dcf26f..57d213677 100644 --- a/source/games/exhumed/src/spider.cpp +++ b/source/games/exhumed/src/spider.cpp @@ -124,7 +124,7 @@ void AISpider::Tick(RunListEvent* ev) spp->spr.picnum = spp->nFrame < 9 ? seqFrame.getFirstPicnum() : -1; - playFrameSound(spp, seqFrame); + seqFrame.playSound(spp); spp->nFrame++; if (spp->nFrame >= spiderSeq.frames.Size()) { diff --git a/source/games/exhumed/src/wasp.cpp b/source/games/exhumed/src/wasp.cpp index a10ec90ac..e544ee0f1 100644 --- a/source/games/exhumed/src/wasp.cpp +++ b/source/games/exhumed/src/wasp.cpp @@ -220,7 +220,7 @@ void AIWasp::Tick(RunListEvent* ev) pActor->spr.picnum = seqFrame.getFirstPicnum(); - playFrameSound(pActor, seqFrame); + seqFrame.playSound(pActor); pActor->nFrame++; if (pActor->nFrame >= waspSeq.frames.Size())