Skip to content

Commit

Permalink
- fix sound and music pausing with tweaks to updatePauseStatus(). A…
Browse files Browse the repository at this point in the history
…lso removed unneeded game-side function. Fixes #11.
  • Loading branch information
mjr4077au committed Jul 26, 2020
1 parent c7a9b56 commit f67a53a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 34 deletions.
29 changes: 11 additions & 18 deletions source/core/gamecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,33 +1102,26 @@ bool CheckCheatmode(bool printmsg)

void updatePauseStatus()
{
bool GUICapture = System_WantGuiCapture();
if (M_Active() || ConsoleState != c_up)
if (M_Active() || System_WantGuiCapture())
{
paused = 1;
return;
}
else if (!pausedWithKey)
else if (!M_Active() || !System_WantGuiCapture())
{
paused = 0;
}

if (inputState.GetKeyStatus(sc_Pause))
{
inputState.ClearKeyStatus(sc_Pause);
paused = pausedWithKey ? 0 : 2;

if (paused)
if (!pausedWithKey)
{
S_PauseSound(!paused, !paused);
paused = 0;
}
else

if (inputState.GetKeyStatus(sc_Pause))
{
S_ResumeSound(!!paused);
inputState.ClearKeyStatus(sc_Pause);
paused = pausedWithKey ? 0 : 2;
pausedWithKey = !!paused;
}

pausedWithKey = !!paused;
}

paused ? S_PauseSound(!pausedWithKey, !paused) : S_ResumeSound(paused);
}

bool OkForLocalization(FTextureID texnum, const char* substitute)
Expand Down
3 changes: 0 additions & 3 deletions source/games/duke/src/d_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, double oxpos, dou

void GameInterface::MenuOpened()
{
S_PauseSounds(true);
if (ud.multimode < 2)
{
ready2send = 0;
Expand Down Expand Up @@ -263,8 +262,6 @@ void GameInterface::MenuClosed()
cameraclock = (int32_t)totalclock;
cameradist = 65536;
}

S_PauseSounds(false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/premap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ int enterlevel(MapRecord *mi, int gamemode)
OnEvent(EVENT_ENTERLEVEL);

// Stop all sounds
S_PauseSounds(false);
S_ResumeSound(false);
FX_StopAllSounds();
FX_SetReverb(0);

Expand Down
11 changes: 0 additions & 11 deletions source/games/duke/src/sounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ TArray<uint8_t> DukeSoundEngine::ReadSound(int lumpnum)
//
//==========================================================================

void S_PauseSounds(bool paused)
{
soundEngine->SetPaused(paused);
}

//==========================================================================
//
//
//
//==========================================================================

void S_CacheAllSounds(void)
{
auto& sfx = soundEngine->GetSounds();
Expand Down
1 change: 0 additions & 1 deletion source/games/duke/src/sounds.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ inline int S_CheckSoundPlaying(int sprnum, int soundNum) { return S_CheckSoundPl
int S_CheckActorSoundPlaying(int spriteNum, int soundNum, int channel = 0);
int S_CheckAnyActorSoundPlaying(int spriteNum);

void S_PauseSounds(bool paused);
void S_ChangeSoundPitch(int soundNum, int spriteNum, int pitchoffset);
int S_GetUserFlags(int sndnum);

Expand Down

0 comments on commit f67a53a

Please sign in to comment.