diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index 04a5649133..81bdf047a3 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -378,7 +378,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. diff --git a/src/common/audio/sound/s_soundinternal.h b/src/common/audio/sound/s_soundinternal.h index 5ecb6ee482..7778338953 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -238,6 +238,7 @@ protected: TArray S_SoundCurve; TMap ResIdMap; TArray S_rnd; + bool blockNewSounds = false; private: void LinkChannel(FSoundChan* chan, FSoundChan** head); @@ -268,6 +269,11 @@ public: } void EvictAllChannels(); + void BlockNewSounds(bool on) + { + blockNewSounds = on; + } + virtual int SoundSourceIndex(FSoundChan* chan) { return 0; } virtual void SetSource(FSoundChan* chan, int index) {} diff --git a/src/g_level.cpp b/src/g_level.cpp index 21010137ed..85be99467f 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -954,6 +954,8 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) // Intermission stats for entire hubs G_LeavingHub(this, 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]) @@ -961,6 +963,7 @@ bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) G_PlayerFinishLevel (i, mode, changeflags); } } + soundEngine->BlockNewSounds(false); if (mode == FINISH_SameHub) { // Remember the level's state for re-entry.