mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-31 09:20:59 +00:00
- SW/Exhumed fixed sound relinking on actor destruction.
This still passed the sprites instead of the actors. Moved the relinking code to DCoreActor::Destroy because it is the same for all games. Also did a little bit of sound cleanup to ensure the sound backend does not hold stale actor pointers.
This commit is contained in:
parent
7c5080f654
commit
d1f088a858
8 changed files with 66 additions and 57 deletions
|
@ -35,6 +35,7 @@
|
|||
#include "build.h"
|
||||
#include "coreactor.h"
|
||||
#include "gamefuncs.h"
|
||||
#include "raze_sound.h"
|
||||
|
||||
// Doubly linked ring list of Actors
|
||||
|
||||
|
@ -367,6 +368,21 @@ DCoreActor* InsertActor(PClass* type, sectortype* sector, int stat, bool tail)
|
|||
|
||||
void DCoreActor::OnDestroy()
|
||||
{
|
||||
FVector3 pos = GetSoundPos(&spr.pos);
|
||||
soundEngine->RelinkSound(SOURCE_Actor, this, nullptr, &pos);
|
||||
|
||||
// also scan all other sounds if they have this actor as source. If so, null the source and stop looped sounds.
|
||||
soundEngine->EnumerateChannels([=](FSoundChan* chan)
|
||||
{
|
||||
if (chan->Source == this)
|
||||
{
|
||||
if (chan->ChanFlags & CHANF_LOOP) soundEngine->StopChannel(chan);
|
||||
else chan->Source = nullptr;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
||||
if(link_stat == INT_MAX) return;
|
||||
|
||||
int stat = link_stat;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue