1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 04:15:33 +00:00

Don't increase simulationTime while the game is minimized (Fixes #4211)

This commit is contained in:
scrawl 2017-11-16 17:56:44 +01:00
parent cf40d19d7d
commit 36f4f0ef85
2 changed files with 12 additions and 13 deletions

View file

@ -79,12 +79,14 @@ void OMW::Engine::executeLocalScripts()
} }
} }
void OMW::Engine::frame(float frametime) bool OMW::Engine::frame(float frametime)
{ {
try try
{ {
mStartTick = mViewer->getStartTick(); mStartTick = mViewer->getStartTick();
mEnvironment.setFrameDuration(frametime);
// update input // update input
mEnvironment.getInputManager()->update(frametime, false); mEnvironment.getInputManager()->update(frametime, false);
@ -92,7 +94,7 @@ void OMW::Engine::frame(float frametime)
// If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures (fixed in MyGUI 3.3.2), // If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures (fixed in MyGUI 3.3.2),
// and destroyed widgets will not be deleted (not fixed yet, https://github.com/MyGUI/mygui/issues/21) // and destroyed widgets will not be deleted (not fixed yet, https://github.com/MyGUI/mygui/issues/21)
if (!mEnvironment.getInputManager()->isWindowVisible()) if (!mEnvironment.getInputManager()->isWindowVisible())
return; return false;
// sound // sound
if (mUseSound) if (mUseSound)
@ -187,8 +189,9 @@ void OMW::Engine::frame(float frametime)
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
std::cerr << "Error in framelistener: " << e.what() << std::endl; std::cerr << "Error in frame: " << e.what() << std::endl;
} }
return true;
} }
OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
@ -686,17 +689,9 @@ void OMW::Engine::go()
frameTimer.setStartTick(); frameTimer.setStartTick();
dt = std::min(dt, 0.2); dt = std::min(dt, 0.2);
bool guiActive = mEnvironment.getWindowManager()->isGuiMode();
if (!guiActive)
simulationTime += dt;
mViewer->advance(simulationTime); mViewer->advance(simulationTime);
mEnvironment.setFrameDuration(dt); if (!frame(dt))
frame(dt);
if (!mEnvironment.getInputManager()->isWindowVisible())
{ {
OpenThreads::Thread::microSleep(5000); OpenThreads::Thread::microSleep(5000);
continue; continue;
@ -709,6 +704,10 @@ void OMW::Engine::go()
mEnvironment.getWorld()->updateWindowManager(); mEnvironment.getWorld()->updateWindowManager();
mViewer->renderingTraversals(); mViewer->renderingTraversals();
bool guiActive = mEnvironment.getWindowManager()->isGuiMode();
if (!guiActive)
simulationTime += dt;
} }
mEnvironment.limitFrameRate(frameTimer.time_s()); mEnvironment.limitFrameRate(frameTimer.time_s());

View file

@ -118,7 +118,7 @@ namespace OMW
void executeLocalScripts(); void executeLocalScripts();
void frame (float dt); bool frame (float dt);
/// Load settings from various files, returns the path to the user settings file /// Load settings from various files, returns the path to the user settings file
std::string loadSettings (Settings::Manager & settings); std::string loadSettings (Settings::Manager & settings);