- SW: when an actor is killed, all attached ambient sounds must be deleted.

Not only did the sound not stop but what happened here was very much undefined behavior as the ambient sound retained its pointer to now undefined memory.
This commit is contained in:
Christoph Oelckers 2022-10-19 00:02:36 +02:00
parent 11735c2963
commit 0cef35c345

View file

@ -733,6 +733,17 @@ void DeleteNoSoundOwner(DSWActor* actor)
}
return false;
});
// also delete all ambients attached to this actor.
for (int i = ambients.Size() - 1; i >= 0; i--)
{
auto amb = ambients[i];
if (amb->spot == actor)
{
soundEngine->StopSound(SOURCE_Ambient, amb, -1);
ambients.Delete(i);
}
}
}
//==========================================================================