diff options
-rw-r--r-- | engines/mohawk/myst.cpp | 20 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 8 |
2 files changed, 26 insertions, 2 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 5337a5e773..ad803cca7c 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -76,6 +76,7 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription _showResourceRects = false; _curCard = 0; _needsUpdate = false; + _canSafelySaveLoad = false; _curResource = -1; _hoverResource = nullptr; @@ -267,7 +268,7 @@ Common::Error MohawkEngine_Myst::run() { _needsUpdate = _video->updateMovies(); _scriptParser->runPersistentScripts(); - while (_eventMan->pollEvent(event)) { + while (pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: { _needsUpdate = true; @@ -312,7 +313,9 @@ Common::Error MohawkEngine_Myst::run() { _needsShowMap = false; _needsShowDemoMenu = false; + _canSafelySaveLoad = true; runDialog(*_optionsDialog); + _canSafelySaveLoad = false; if (_needsPageDrop) { dropPage(); @@ -350,6 +353,15 @@ Common::Error MohawkEngine_Myst::run() { return Common::kNoError; } +bool MohawkEngine_Myst::pollEvent(Common::Event &event) { + // Saving / Loading is allowed from the GMM only when the main event loop is running + _canSafelySaveLoad = true; + bool eventReturned = _eventMan->pollEvent(event); + _canSafelySaveLoad = false; + + return eventReturned; +} + bool MohawkEngine_Myst::skippableWait(uint32 duration) { uint32 end = _system->getMillis() + duration; bool skipped = false; @@ -1083,10 +1095,14 @@ Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &d bool MohawkEngine_Myst::canLoadGameStateCurrently() { // No loading in the demo/makingof - return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF; + return _canSafelySaveLoad && !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF; } bool MohawkEngine_Myst::canSaveGameStateCurrently() { + if (!_canSafelySaveLoad) { + return false; + } + // There's a limited number of stacks the game can save in switch (_curStack) { case kChannelwoodStack: diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index 4b4ceb4a5b..79bd0819cb 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -28,6 +28,7 @@ #include "mohawk/resource_cache.h" #include "mohawk/myst_scripts.h" +#include "common/events.h" #include "common/random.h" namespace Mohawk { @@ -240,6 +241,13 @@ private: bool _runExitScript; + /** + * Saving / Loading is only allowed from the main event loop + */ + bool _canSafelySaveLoad; + + bool pollEvent(Common::Event &event); + void dropPage(); void loadCard(); |