- fixed sounds disappearing when the owning actor was deleted.

These sounds now get unlinked so that they can play out normally.

Fixes #119.
This commit is contained in:
Christoph Oelckers 2020-08-12 20:15:02 +02:00
parent 81f85ee480
commit 80d1b71899
3 changed files with 9 additions and 0 deletions

View file

@ -73,6 +73,8 @@ void deletesprite(int num)
{
if (sprite[num].picnum == MUSICANDSFX && hittype[num].temp_data[0] == 1)
S_StopSound(sprite[num].lotag, num);
else
S_RelinkActorSound(num, -1);
::deletesprite(num);
}

View file

@ -482,6 +482,12 @@ int S_PlayActorSound(int soundNum, int spriteNum, int channel, EChanFlags flags)
S_PlaySound3D(soundNum, spriteNum, &sprite[spriteNum].pos, channel, flags);
}
void S_RelinkActorSound(int from, int to)
{
FVector3 pos = GetSoundPos(&sprite[from].pos);
soundEngine->RelinkSound(SOURCE_Actor, &sprite[from], to == -1 ? nullptr : &sprite[to], &pos);
}
void S_StopSound(int sndNum, int sprNum, int channel)
{
if (sprNum < -1 || sprNum >= MAXSPRITES) return;

View file

@ -43,6 +43,7 @@ int S_DefineSound(unsigned index, const char* filename, int ps, int pe, int pr,
int S_PlaySound(int num, int channel = CHAN_AUTO, EChanFlags flags = 0, float vol =0.8f);
int S_PlaySound3D(int num, int spriteNum, const vec3_t* pos, int channel = CHAN_AUTO, EChanFlags flags = 0);
int S_PlayActorSound(int soundNum, int spriteNum, int channel = CHAN_AUTO, EChanFlags flags = 0);
void S_RelinkActorSound(int from, int to);
void S_MenuSound(void);
void S_StopSound(int sndNum, int sprNum = -1, int flags = -1);