Fix alt-tabbed desync with demos

- Fixed: Stop the game timer if the window looses focus
This commit is contained in:
Edward Richardson 2014-11-11 02:18:52 +13:00
parent b08fcbf6b3
commit 16e0f79fd7
4 changed files with 14 additions and 20 deletions

View file

@ -939,7 +939,7 @@ void NetUpdate (void)
newtics = nowtime - gametime; newtics = nowtime - gametime;
gametime = nowtime; gametime = nowtime;
if (newtics <= 0) // nothing new to update if (newtics <= 0 || pauseext) // nothing new to update or window paused
{ {
GetPackets (); GetPackets ();
return; return;

View file

@ -109,6 +109,7 @@ enum EMenuState
extern bool automapactive; // In AutoMap mode? extern bool automapactive; // In AutoMap mode?
extern EMenuState menuactive; // Menu overlayed? extern EMenuState menuactive; // Menu overlayed?
extern int paused; // Game Pause? extern int paused; // Game Pause?
extern bool pauseext;
extern bool viewactive; extern bool viewactive;

View file

@ -141,6 +141,7 @@ gameaction_t gameaction;
gamestate_t gamestate = GS_STARTUP; gamestate_t gamestate = GS_STARTUP;
int paused; int paused;
bool pauseext;
bool sendpause; // send a pause event next tic bool sendpause; // send a pause event next tic
bool sendsave; // send a save event next tic bool sendsave; // send a save event next tic
bool sendturn180; // [RH] send a 180 degree turn 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, // 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 // we do not want to read more demo commands until paused is no
// longer negative. // longer negative.
if (demoplayback && paused >= 0) if (demoplayback)
{ {
G_ReadDemoTiccmd (cmd, i); G_ReadDemoTiccmd (cmd, i);
} }
else else
{ {
memcpy (cmd, newcmd, sizeof(ticcmd_t)); memcpy(cmd, newcmd, sizeof(ticcmd_t));
} }
// check for turbo cheats // check for turbo cheats

View file

@ -1783,21 +1783,13 @@ void S_SetSoundPaused (int state)
{ {
if (state) if (state)
{ {
if (paused <= 0) if (paused == 0)
{ {
S_ResumeSound(true); S_ResumeSound(true);
if (GSnd != NULL) if (GSnd != NULL)
{ {
GSnd->SetInactive(SoundRenderer::INACTIVE_Active); GSnd->SetInactive(SoundRenderer::INACTIVE_Active);
} }
if (!netgame
#ifdef _DEBUG
&& !demoplayback
#endif
)
{
paused = 0;
}
} }
} }
else else
@ -1811,16 +1803,16 @@ void S_SetSoundPaused (int state)
SoundRenderer::INACTIVE_Complete : SoundRenderer::INACTIVE_Complete :
SoundRenderer::INACTIVE_Mute); SoundRenderer::INACTIVE_Mute);
} }
if (!netgame
#ifdef _DEBUG
&& !demoplayback
#endif
)
{
paused = -1;
}
} }
} }
if (!netgame
#ifdef _DEBUG
&& !demoplayback
#endif
)
{
pauseext = !state;
}
} }
//========================================================================== //==========================================================================