diff options
author | Bastien Bouclet | 2016-08-02 21:43:22 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | 3c2ca0887766d54db5690e140d3fb2d9479bdc4d (patch) | |
tree | 5992f29e044e44061899336353cdae213902e40c /engines | |
parent | bc01a276f971f51ec435734155adadecf7cf1c2b (diff) | |
download | scummvm-rg350-3c2ca0887766d54db5690e140d3fb2d9479bdc4d.tar.gz scummvm-rg350-3c2ca0887766d54db5690e140d3fb2d9479bdc4d.tar.bz2 scummvm-rg350-3c2ca0887766d54db5690e140d3fb2d9479bdc4d.zip |
MOHAWK: Add a script queue to Riven's script manager
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/riven.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 18 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.h | 17 |
3 files changed, 29 insertions, 10 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 4d6c6feeb1..03a489884b 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -698,7 +698,7 @@ void MohawkEngine_Riven::runCardScript(uint16 scriptType) { for (uint16 i = 0; i < _cardData.scripts.size(); i++) if (_cardData.scripts[i].type == scriptType) { RivenScriptPtr script = _cardData.scripts[i].script; - script->runScript(); + _scriptMan->runScript(script, false); break; } } @@ -708,7 +708,7 @@ void MohawkEngine_Riven::runHotspotScript(uint16 hotspot, uint16 scriptType) { for (uint16 i = 0; i < _hotspots[hotspot].scripts.size(); i++) if (_hotspots[hotspot].scripts[i].type == scriptType) { RivenScriptPtr script = _hotspots[hotspot].scripts[i].script; - script->runScript(); + _scriptMan->runScript(script, false); break; } } diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index eec27a0b22..134c383c5a 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -101,7 +101,7 @@ void RivenScriptManager::setStoredMovieOpcode(const StoredMovieOpcode &op) { void RivenScriptManager::runStoredMovieOpcode() { if (_storedMovieOpcode.script) { - _storedMovieOpcode.script->runScript(); + runScript(_storedMovieOpcode.script, false); clearStoredMovieOpcode(); } } @@ -112,6 +112,14 @@ void RivenScriptManager::clearStoredMovieOpcode() { _storedMovieOpcode.id = 0; } +void RivenScriptManager::runScript(const RivenScriptPtr &script, bool queue) { + if (!queue) { + script->run(); + } else { + _queue.push_back(script); + } +} + RivenScript::RivenScript() { _continueRunning = true; } @@ -128,7 +136,7 @@ void RivenScript::dumpScript(const Common::StringArray &varNames, const Common:: } } -void RivenScript::runScript() { +void RivenScript::run() { for (uint16 i = 0; i < _commands.size() && _continueRunning; i++) { _commands[i]->execute(); } @@ -521,7 +529,7 @@ void RivenSimpleCommand::storeMovieOpcode(uint16 op, uint16 argc, uint16 *argv) _vm->_scriptMan->setStoredMovieOpcode(storedOp); } else { // Run immediately if we have no delay - script->runScript(); + _vm->_scriptMan->runScript(script, false); } delete scriptStream; @@ -712,7 +720,7 @@ void RivenSwitchCommand::execute() { // Look for a case matching the value for (uint i = 0; i < _branches.size(); i++) { if (_branches[i].value == value) { - _branches[i].script->runScript(); + _vm->_scriptMan->runScript(_branches[i].script, false); return; } } @@ -720,7 +728,7 @@ void RivenSwitchCommand::execute() { // Look for the default case if any for (uint i = 0; i < _branches.size(); i++) { if (_branches[i].value == 0Xffff) { - _branches[i].script->runScript(); + _vm->_scriptMan->runScript(_branches[i].script, false); return; } } diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h index 68b78074a3..394c046cae 100644 --- a/engines/mohawk/riven_scripts.h +++ b/engines/mohawk/riven_scripts.h @@ -63,8 +63,13 @@ public: /** Append a command to the script */ void addCommand(RivenCommand *command); - /** Run the script */ - void runScript(); + /** + * Run the script + * + * Script execution must go through the ScriptManager, + * this method should not be called directly. + */ + void run(); /** Print script details to the standard output */ void dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs); @@ -107,6 +112,10 @@ public: /** Read a list of typed scripts from a stream */ RivenScriptList readScripts(Common::ReadStream *stream); + + /** Run a script */ + void runScript(const RivenScriptPtr &script, bool queue); + void stopAllScripts(); struct StoredMovieOpcode { @@ -123,6 +132,8 @@ public: private: MohawkEngine_Riven *_vm; + + Common::Array<RivenScriptPtr> _queue; StoredMovieOpcode _storedMovieOpcode; RivenCommand *readCommand(Common::ReadStream *stream); @@ -178,7 +189,7 @@ private: DECLARE_OPCODE(empty) { warning ("Unknown Opcode %04x", op); } - //Opcodes + // Opcodes DECLARE_OPCODE(drawBitmap); DECLARE_OPCODE(switchCard); DECLARE_OPCODE(playScriptSLST); |