From 1897329071bc417a3d93e008955817f44b2aa9f0 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Mon, 24 Jun 2013 03:39:48 +0200 Subject: [PATCH] Allow downloading data while the game is minimized. With this change, downloads should no longer abort when the game is minimized for more than a few seconds. --- Aquaria/DSQ.cpp | 13 +++---------- Aquaria/DSQ.h | 3 +++ Aquaria/Network.cpp | 3 +++ BBGE/Core.cpp | 9 ++++++++- BBGE/Core.h | 2 ++ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 838259c..f9bd757 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -5133,16 +5133,9 @@ void DSQ::cutsceneEffects(bool on) } } -void pauseSound() +void DSQ::onBackgroundUpdate() { - if (dsq && dsq->sound) { - dsq->sound->pause(); - } + Network::update(); + Core::onBackgroundUpdate(); } -void resumeSound() -{ - if (dsq && dsq->sound) { - dsq->sound->resume(); - } -} diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index a1db87e..68533b9 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -1563,6 +1563,9 @@ public: void pauseCutscene(bool on); bool canSkipCutscene(); bool isSkippingCutscene(); + + virtual void onBackgroundUpdate(); + protected: Quad *cutscene_bg; diff --git a/Aquaria/Network.cpp b/Aquaria/Network.cpp index cbd2a84..e1358f5 100644 --- a/Aquaria/Network.cpp +++ b/Aquaria/Network.cpp @@ -244,6 +244,9 @@ void download(RequestData *rq) void update() { + if(!netUp) + return; + RequestDataHolder h; while(notifyRequests.pop(h)) h.rq->notify(h.ev, h.recvd, h.total); diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index c659d2e..f514807 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -2727,6 +2727,13 @@ bool Core::isWindowFocus() return true; } +void Core::onBackgroundUpdate() +{ +#if BBGE_BUILD_SDL + SDL_Delay(200); +#endif +} + void Core::main(float runTime) { bool verbose = coreVerboseDebug; @@ -2911,7 +2918,7 @@ void Core::main(float runTime) { pollEvents(); //debugLog("app not in input focus"); - SDL_Delay(200); + onBackgroundUpdate(); resetTimer(); } diff --git a/BBGE/Core.h b/BBGE/Core.h index fbdc4ed..e265dda 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -1310,6 +1310,8 @@ public: volatile int dbg_numThreadDecoders; static unsigned int dbg_numRenderCalls; + virtual void onBackgroundUpdate(); + protected: std::string fpsDebugString;