- added new CHANF_SINGULAR flag plus a handler for CHANF_LOCAL in Duke.

This commit is contained in:
Christoph Oelckers 2022-12-28 22:57:31 +01:00
parent a3da3a4c43
commit 5da28bf5ad
4 changed files with 7 additions and 1 deletions

View file

@ -32,6 +32,7 @@ enum EChanFlag
CHANF_LOCAL = 16384, // only plays locally for the calling actor
CHANF_TRANSIENT = 32768, // Do not record in savegames - used for sounds that get restarted outside the sound system (e.g. ambients in SW and Blood)
CHANF_FORCE = 65536, // Start, even if sound is paused.
CHANF_SINGULAR = 0x20000, // Only start if no sound of this name is already playing.
};
typedef TFlags<EChanFlag> EChanFlags;

View file

@ -488,7 +488,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
}
// If this is a singular sound, don't play it if it's already playing.
if (sfx->bSingular && CheckSingular(sound_id))
if ((sfx->bSingular || (flags & CHANF_SINGULAR)) && CheckSingular(sound_id))
{
chanflags |= CHANF_EVICTED;
}

View file

@ -448,6 +448,8 @@ int S_PlaySound3D(FSoundID soundid, DDukeActor* actor, const DVector3& pos, int
if (!soundEngine->isValidSoundId(soundid) || !SoundEnabled() || actor == nullptr || !playrunning() ||
(pl->timebeforeexit > 0 && pl->timebeforeexit <= REALGAMETICSPERSEC * 3)) return -1;
if (flags & CHANF_LOCAL && actor != ps[screenpeek].actor && !ud.coop) return -1; // makes no sense...
soundid = GetReplacementSound(soundid);
int userflags = S_GetUserFlags(soundid);

View file

@ -32,6 +32,9 @@ enum ESoundFlags
CHANF_NOSTOP = 4096,
CHANF_OVERLAP = 8192,
CHANF_LOCAL = 16384,
CHANF_TRANSIENT = 32768, // Do not record in savegames - used for sounds that get restarted outside the sound system (e.g. ambients in SW and Blood)
CHANF_FORCE = 65536, // Start, even if sound is paused.
CHANF_SINGULAR = 0x20000, // Only start if no sound of this name is already playing.
CHANF_LOOPING = CHANF_LOOP | CHANF_NOSTOP, // convenience value for replicating the old 'looping' boolean.