Skip to content

Commit

Permalink
- do not allow playing sounds during PlayerFinishLevel.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coelckers committed Jun 9, 2020
1 parent c9833a8 commit b41ae2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/audio/sound/s_sound.cpp
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/common/audio/sound/s_soundinternal.h
Expand Up @@ -238,6 +238,7 @@ class SoundEngine
TArray<uint8_t> S_SoundCurve;
TMap<int, int> ResIdMap;
TArray<FRandomSoundList> S_rnd;
bool blockNewSounds = false;

private:
void LinkChannel(FSoundChan* chan, FSoundChan** head);
Expand Down Expand Up @@ -268,6 +269,11 @@ class SoundEngine
}
void EvictAllChannels();

void BlockNewSounds(bool on)
{
blockNewSounds = on;
}

virtual int SoundSourceIndex(FSoundChan* chan) { return 0; }
virtual void SetSource(FSoundChan* chan, int index) {}

Expand Down
3 changes: 3 additions & 0 deletions src/g_level.cpp
Expand Up @@ -954,13 +954,16 @@ 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])
{ // take away appropriate inventory
G_PlayerFinishLevel (i, mode, changeflags);
}
}
soundEngine->BlockNewSounds(false);

if (mode == FINISH_SameHub)
{ // Remember the level's state for re-entry.
Expand Down

0 comments on commit b41ae2d

Please sign in to comment.