Skip to content

Commit

Permalink
Disallow sound to be played on destroyed actors
Browse files Browse the repository at this point in the history
It's possible for an actor to call Destroy() in a ZScript method (such
as Tick()) and then subsequently call A_StartSound() to play a sound.
Generally speaking this doesn't happen within a given class, but with a
class hierarchy, Destroy() may be called unbeknownst to a mod developer.
Even though checking bDestroyed is likely good practice, this ensures
that sounds won't be started on actors flagged for cleanup.
  • Loading branch information
KyleJ61782 authored and coelckers committed Sep 12, 2020
1 parent e9af7e7 commit e281f99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sound/s_doomsound.cpp
Expand Up @@ -471,7 +471,8 @@ FSoundID DoomSoundEngine::ResolveSound(const void * ent, int type, FSoundID soun

static bool VerifyActorSound(AActor* ent, FSoundID& sound_id, int& channel, EChanFlags flags)
{
if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != primaryLevel)
if (ent == nullptr || ent->ObjectFlags & OF_EuthanizeMe || ent->Sector->Flags & SECF_SILENT ||
ent->Level != primaryLevel)
return false;

if ((flags & CHANF_MAYBE_LOCAL) && (compatflags & COMPATF_SILENTPICKUP))
Expand Down

0 comments on commit e281f99

Please sign in to comment.