diff options
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 25 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.h | 9 |
2 files changed, 20 insertions, 14 deletions
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index a9b64d6ce7..761de1d703 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -43,7 +43,8 @@ static void printTabs(byte tabs) { RivenScriptManager::RivenScriptManager(MohawkEngine_Riven *vm) : _vm(vm), - _runningQueuedScripts(false) { + _runningQueuedScripts(false), + _stoppingAllScripts(false) { _storedMovieOpcode.time = 0; _storedMovieOpcode.id = 0; @@ -94,9 +95,7 @@ RivenScriptList RivenScriptManager::readScripts(Common::ReadStream *stream) { } void RivenScriptManager::stopAllScripts() { -// TODO: Restore -// for (uint32 i = 0; i < _currentScripts.size(); i++) -// _currentScripts[i]->stopRunning(); + _stoppingAllScripts = true; } void RivenScriptManager::setStoredMovieOpcode(const StoredMovieOpcode &op) { @@ -125,7 +124,7 @@ void RivenScriptManager::runScript(const RivenScriptPtr &script, bool queue) { } if (!queue) { - script->run(); + script->run(this); } else { _queue.push_back(script); } @@ -139,11 +138,12 @@ void RivenScriptManager::runQueuedScripts() { _runningQueuedScripts = true; for (uint i = 0; i < _queue.size(); i++) { - _queue[i]->run(); + _queue[i]->run(this); } _queue.clear(); + _stoppingAllScripts = false; // Once the queue is empty, all scripts have been stopped _runningQueuedScripts = false; } @@ -191,8 +191,11 @@ bool RivenScriptManager::runningQueuedScripts() const { return _runningQueuedScripts; } +bool RivenScriptManager::stoppingAllScripts() const { + return _stoppingAllScripts; +} + RivenScript::RivenScript() { - _continueRunning = true; } RivenScript::~RivenScript() { @@ -204,8 +207,12 @@ void RivenScript::dumpScript(byte tabs) { } } -void RivenScript::run() { - for (uint i = 0; i < _commands.size() && _continueRunning; i++) { +void RivenScript::run(RivenScriptManager *scriptManager) { + for (uint i = 0; i < _commands.size(); i++) { + if (scriptManager->stoppingAllScripts()) { + return; + } + _commands[i]->execute(); } } diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h index 37bdc062d4..6d422b858d 100644 --- a/engines/mohawk/riven_scripts.h +++ b/engines/mohawk/riven_scripts.h @@ -122,14 +122,11 @@ public: * Script execution must go through the ScriptManager, * this method should not be called directly. */ - void run(); + void run(RivenScriptManager *scriptManager); /** Print script details to the standard output */ void dumpScript(byte tabs); - /** Stop the script after the current command */ - void stopRunning() { _continueRunning = false; } - /** Append the commands of the other script to this script */ RivenScript &operator+=(const RivenScript &other); @@ -138,7 +135,6 @@ public: private: Common::Array<RivenCommandPtr> _commands; - bool _continueRunning; }; /** Append the commands of the rhs Script to those of the lhs Script */ @@ -196,6 +192,8 @@ public: void stopAllScripts(); + bool stoppingAllScripts() const; + struct StoredMovieOpcode { RivenScriptPtr script; uint32 time; @@ -213,6 +211,7 @@ private: Common::Array<RivenScriptPtr> _queue; bool _runningQueuedScripts; + bool _stoppingAllScripts; StoredMovieOpcode _storedMovieOpcode; |