mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- Fixed: Sound limiting applied even to sounds that were already playing on the same
actor+channel. Since in this case, it's really just restarting the sound, it shouldn't limit it. (Since it's already playing, we know the limit wasn't exceeded when it started playing, so it shouldn't be exceeded if we restart it now.) SVN r3355 (trunk)
This commit is contained in:
parent
033b3964f1
commit
540473cbe0
1 changed files with 19 additions and 6 deletions
|
@ -101,7 +101,7 @@ extern float S_GetMusicVolume (const char *music);
|
|||
|
||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||
|
||||
static bool S_CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, float limit_range);
|
||||
static bool S_CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, float limit_range, AActor *actor, int channel);
|
||||
static bool S_IsChannelUsed(AActor *actor, int channel, int *seen);
|
||||
static void S_ActivatePlayList(bool goBack);
|
||||
static void CalcPosVel(FSoundChan *chan, FVector3 *pos, FVector3 *vel);
|
||||
|
@ -952,7 +952,7 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
|
|||
|
||||
// If this sound doesn't like playing near itself, don't play it if
|
||||
// that's what would happen.
|
||||
if (near_limit > 0 && S_CheckSoundLimit(sfx, pos, near_limit, limit_range))
|
||||
if (near_limit > 0 && S_CheckSoundLimit(sfx, pos, near_limit, limit_range, actor, channel))
|
||||
{
|
||||
chanflags |= CHAN_EVICTED;
|
||||
}
|
||||
|
@ -1157,7 +1157,7 @@ void S_RestartSound(FSoundChan *chan)
|
|||
|
||||
// If this sound doesn't like playing near itself, don't play it if
|
||||
// that's what would happen.
|
||||
if (chan->NearLimit > 0 && S_CheckSoundLimit(&S_sfx[chan->SoundID], pos, chan->NearLimit, chan->LimitRange))
|
||||
if (chan->NearLimit > 0 && S_CheckSoundLimit(&S_sfx[chan->SoundID], pos, chan->NearLimit, chan->LimitRange, NULL, 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1389,12 +1389,19 @@ bool S_CheckSingular(int sound_id)
|
|||
//
|
||||
// Limits the number of nearby copies of a sound that can play near
|
||||
// each other. If there are NearLimit instances of this sound already
|
||||
// playing within 256 units of the new sound, the new sound will not
|
||||
// start.
|
||||
// playing within sqrt(limit_range) (typically 256 units) of the new sound, the
|
||||
// new sound will not start.
|
||||
//
|
||||
// If an actor is specified, and it is already playing the same sound on
|
||||
// the same channel, this sound will not be limited. In this case, we're
|
||||
// restarting an already playing sound, so there's no need to limit it.
|
||||
//
|
||||
// Returns true if the sound should not play.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool S_CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, float limit_range)
|
||||
bool S_CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, float limit_range,
|
||||
AActor *actor, int channel)
|
||||
{
|
||||
FSoundChan *chan;
|
||||
int count;
|
||||
|
@ -1405,6 +1412,12 @@ bool S_CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_limit, floa
|
|||
{
|
||||
FVector3 chanorigin;
|
||||
|
||||
if (actor != NULL && chan->EntChannel == channel &&
|
||||
chan->SourceType == SOURCE_Actor && chan->Actor == actor)
|
||||
{ // We are restarting a playing sound. Always let it play.
|
||||
return false;
|
||||
}
|
||||
|
||||
CalcPosVel(chan, &chanorigin, NULL);
|
||||
if ((chanorigin - pos).LengthSquared() <= limit_range)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue