From 16e0f79fd7c31ab5a3b942c2899adaa2827e7fe3 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Tue, 11 Nov 2014 02:18:52 +1300 Subject: [PATCH] Fix alt-tabbed desync with demos - Fixed: Stop the game timer if the window looses focus --- src/d_net.cpp | 2 +- src/doomstat.h | 1 + src/g_game.cpp | 5 +++-- src/s_sound.cpp | 26 +++++++++----------------- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4fcd66bd4..02ca8c0c4 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -939,7 +939,7 @@ void NetUpdate (void) newtics = nowtime - gametime; gametime = nowtime; - if (newtics <= 0) // nothing new to update + if (newtics <= 0 || pauseext) // nothing new to update or window paused { GetPackets (); return; diff --git a/src/doomstat.h b/src/doomstat.h index 1559609f1..565d15bd6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -109,6 +109,7 @@ enum EMenuState extern bool automapactive; // In AutoMap mode? extern EMenuState menuactive; // Menu overlayed? extern int paused; // Game Pause? +extern bool pauseext; extern bool viewactive; diff --git a/src/g_game.cpp b/src/g_game.cpp index af4a5411e..e419e09fc 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -141,6 +141,7 @@ gameaction_t gameaction; gamestate_t gamestate = GS_STARTUP; int paused; +bool pauseext; bool sendpause; // send a pause event next tic bool sendsave; // send a save event next tic bool sendturn180; // [RH] send a 180 degree turn next tic @@ -1152,13 +1153,13 @@ void G_Ticker () // If the user alt-tabbed away, paused gets set to -1. In this case, // we do not want to read more demo commands until paused is no // longer negative. - if (demoplayback && paused >= 0) + if (demoplayback) { G_ReadDemoTiccmd (cmd, i); } else { - memcpy (cmd, newcmd, sizeof(ticcmd_t)); + memcpy(cmd, newcmd, sizeof(ticcmd_t)); } // check for turbo cheats diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 75bd33d47..ccaebf610 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1783,21 +1783,13 @@ void S_SetSoundPaused (int state) { if (state) { - if (paused <= 0) + if (paused == 0) { S_ResumeSound(true); if (GSnd != NULL) { GSnd->SetInactive(SoundRenderer::INACTIVE_Active); } - if (!netgame -#ifdef _DEBUG - && !demoplayback -#endif - ) - { - paused = 0; - } } } else @@ -1811,16 +1803,16 @@ void S_SetSoundPaused (int state) SoundRenderer::INACTIVE_Complete : SoundRenderer::INACTIVE_Mute); } - if (!netgame -#ifdef _DEBUG - && !demoplayback -#endif - ) - { - paused = -1; - } } } + if (!netgame +#ifdef _DEBUG + && !demoplayback +#endif + ) + { + pauseext = !state; + } } //==========================================================================