- do not allow playing sounds during PlayerFinishLevel.

This gets called right before the level ends, any sound in here would play during the intermission or at the start of the next level.

# Conflicts:
#	src/sound/s_soundinternal.h
This commit is contained in:
Christoph Oelckers 2020-06-09 21:01:14 +02:00 committed by drfrag
parent d4dba5ed3f
commit 555dea3c8a
3 changed files with 10 additions and 1 deletions

View file

@ -852,6 +852,8 @@ void G_DoCompleted (void)
// Intermission stats for entire hubs
G_LeavingHub(mode, thiscluster, &wminfo);
// Do not allow playing sounds in here - they'd never be able to play properly.
soundEngine->BlockNewSounds(true);
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
@ -859,6 +861,7 @@ void G_DoCompleted (void)
G_PlayerFinishLevel (i, mode, changeflags);
}
}
soundEngine->BlockNewSounds(false);
if (mode == FINISH_SameHub)
{ // Remember the level's state for re-entry.

View file

@ -384,7 +384,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
FVector3 pos, vel;
FRolloffInfo *rolloff;
if (sound_id <= 0 || volume <= 0 || nosfx || nosound )
if (sound_id <= 0 || volume <= 0 || nosfx || nosound || blockNewSounds)
return NULL;
// prevent crashes.

View file

@ -246,6 +246,7 @@ protected:
TArray<uint8_t> S_SoundCurve;
TMap<int, int> ResIdMap;
TArray<FRandomSoundList> S_rnd;
bool blockNewSounds = false;
private:
void LinkChannel(FSoundChan* chan, FSoundChan** head);
@ -273,6 +274,11 @@ public:
virtual ~SoundEngine() = default;
void EvictAllChannels();
void BlockNewSounds(bool on)
{
blockNewSounds = on;
}
void StopChannel(FSoundChan* chan);
sfxinfo_t* LoadSound(sfxinfo_t* sfx);