Fix bug with simulation pause state and backgrounding

This commit is contained in:
Nathan Fulton 2016-09-12 13:43:40 -04:00
parent b06b3db1d4
commit 31ca038021
3 changed files with 7 additions and 8 deletions

View File

@ -2687,9 +2687,4 @@ bool Game::SetVar(const char *pszName, const char *pszValue)
return m_dictPvars.Set(pszName, pszValue);
}
void Game::GamePause(bool fpause) {
if (!gfMultiplayer)
gsim.Pause(fpause);
}
} // namespace wi

View File

@ -2337,7 +2337,6 @@ public:
bool AskObserveGame() secGame;
bool CheckDatabaseVersion(const char *pszDir, char *pszPdb,
bool fUpwardCompatOK) secGame;
void GamePause(bool fpause);
// ModeMatch helpers

View File

@ -24,6 +24,7 @@ SurfaceProperties gprops;
SDL_FingerID gtouches[2];
wi::Point gaptLast[2];
bool gfWasBackgrounded;
bool gfSimWasPaused;
char *gpszUdid;
@ -402,7 +403,10 @@ bool ProcessSdlEvent(base::Message *pmsg, Event *pevt)
gpdisp->SetShouldRender(true);
// Unpause simulation
ggame.GamePause(false);
if (!gfSimWasPaused) {
gsim.Pause(false);
gfSimWasPaused = false;
}
// The client was disconected in SDL_APP_DIDENTERBACKGROUND.
// Notify the callbacks about this to present the user with a message.
@ -430,7 +434,8 @@ bool ProcessSdlEvent(base::Message *pmsg, Event *pevt)
gfWasBackgrounded = true;
// Pause simulation
ggame.GamePause(true);
gfSimWasPaused = gsim.IsPaused();
gsim.Pause(true);
// Close the connection to the server. If the user returns to the app,
// SDL_APP_DIDENTERFOREGROUND will notify gptra's callbacks.