aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/console.cpp6
-rw-r--r--engines/mohawk/riven.cpp8
-rw-r--r--engines/mohawk/riven_scripts.cpp23
-rw-r--r--engines/mohawk/riven_scripts.h20
4 files changed, 27 insertions, 30 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 82173c2670..4d30008b4f 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -619,7 +619,8 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
cardStream->seek(4);
RivenScriptList scriptList = _vm->_scriptMan->readScripts(cardStream);
for (uint32 i = 0; i < scriptList.size(); i++) {
- scriptList[i]->dumpScript(varNames, xNames, 0);
+ debugN("Stream Type %d:\n", scriptList[i].type);
+ scriptList[i].script->dumpScript(varNames, xNames, 0);
}
delete cardStream;
} else if (!scumm_stricmp(argv[2], "HSPT")) {
@@ -636,7 +637,8 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
hsptStream->seek(22, SEEK_CUR); // Skip non-script related stuff
RivenScriptList scriptList = _vm->_scriptMan->readScripts(hsptStream);
for (uint32 j = 0; j < scriptList.size(); j++) {
- scriptList[j]->dumpScript(varNames, xNames, 1);
+ debugN("\tStream Type %d:\n", scriptList[i].type);
+ scriptList[j].script->dumpScript(varNames, xNames, 1);
}
}
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 61ceb4130c..4d6c6feeb1 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -696,8 +696,8 @@ uint32 MohawkEngine_Riven::getCurCardRMAP() {
void MohawkEngine_Riven::runCardScript(uint16 scriptType) {
assert(_cardData.hasData);
for (uint16 i = 0; i < _cardData.scripts.size(); i++)
- if (_cardData.scripts[i]->getScriptType() == scriptType) {
- RivenScriptPtr script = _cardData.scripts[i];
+ if (_cardData.scripts[i].type == scriptType) {
+ RivenScriptPtr script = _cardData.scripts[i].script;
script->runScript();
break;
}
@@ -706,8 +706,8 @@ void MohawkEngine_Riven::runCardScript(uint16 scriptType) {
void MohawkEngine_Riven::runHotspotScript(uint16 hotspot, uint16 scriptType) {
assert(hotspot < _hotspotCount);
for (uint16 i = 0; i < _hotspots[hotspot].scripts.size(); i++)
- if (_hotspots[hotspot].scripts[i]->getScriptType() == scriptType) {
- RivenScriptPtr script = _hotspots[hotspot].scripts[i];
+ if (_hotspots[hotspot].scripts[i].type == scriptType) {
+ RivenScriptPtr script = _hotspots[hotspot].scripts[i].script;
script->runScript();
break;
}
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 8e5207f90e..6e5b811c78 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -49,8 +49,8 @@ RivenScriptManager::~RivenScriptManager() {
clearStoredMovieOpcode();
}
-RivenScriptPtr RivenScriptManager::readScript(Common::ReadStream *stream, uint16 scriptType) {
- RivenScriptPtr script = RivenScriptPtr(new RivenScript(_vm, scriptType));
+RivenScriptPtr RivenScriptManager::readScript(Common::ReadStream *stream) {
+ RivenScriptPtr script = RivenScriptPtr(new RivenScript(_vm));
uint16 commandCount = stream->readUint16BE();
@@ -77,8 +77,9 @@ RivenScriptList RivenScriptManager::readScripts(Common::ReadStream *stream) {
uint16 scriptCount = stream->readUint16BE();
for (uint16 i = 0; i < scriptCount; i++) {
- uint16 scriptType = stream->readUint16BE();
- RivenScriptPtr script = readScript(stream, scriptType);
+ RivenTypedScript script;
+ script.type = stream->readUint16BE();
+ script.script = readScript(stream);
scriptList.push_back(script);
}
@@ -111,9 +112,8 @@ void RivenScriptManager::clearStoredMovieOpcode() {
_storedMovieOpcode.id = 0;
}
-RivenScript::RivenScript(MohawkEngine_Riven *vm, uint16 scriptType) :
- _vm(vm),
- _scriptType(scriptType) {
+RivenScript::RivenScript(MohawkEngine_Riven *vm) :
+ _vm(vm) {
_continueRunning = true;
}
@@ -124,11 +124,6 @@ RivenScript::~RivenScript() {
}
void RivenScript::dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs) {
- printTabs(tabs); debugN("Stream Type %d:\n", _scriptType);
- dumpCommands(varNames, xNames, tabs + 1);
-}
-
-void RivenScript::dumpCommands(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs) {
for (uint16 i = 0; i < _commands.size(); i++) {
_commands[i]->dump(varNames, xNames, tabs);
}
@@ -512,7 +507,7 @@ void RivenSimpleCommand::storeMovieOpcode(uint16 op, uint16 argc, uint16 *argv)
// Build a script out of 'er
Common::SeekableReadStream *scriptStream = new Common::MemoryReadStream(scriptBuf, scriptSize, DisposeAfterUse::YES);
- RivenScriptPtr script = _vm->_scriptMan->readScript(scriptStream, kStoredOpcodeScript);
+ RivenScriptPtr script = _vm->_scriptMan->readScript(scriptStream);
uint32 delayTime = (argv[1] << 16) + argv[2];
@@ -691,7 +686,7 @@ RivenSwitchCommand *RivenSwitchCommand::createFromStream(MohawkEngine_Riven *vm,
// Value for this logic block
branch.value = stream->readUint16BE();
- branch.script = vm->_scriptMan->readScript(stream, kStoredOpcodeScript);
+ branch.script = vm->_scriptMan->readScript(stream);
}
return command;
diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h
index 9163345a64..95b62b66b3 100644
--- a/engines/mohawk/riven_scripts.h
+++ b/engines/mohawk/riven_scripts.h
@@ -43,9 +43,7 @@ enum {
kCardLoadScript = 6,
kCardLeaveScript = 7,
kCardOpenScript = 9,
- kCardUpdateScript = 10,
-
- kStoredOpcodeScript // This is ScummVM-only to denote the script from a storeMovieOpcode() call
+ kCardUpdateScript = 10
};
class MohawkEngine_Riven;
@@ -53,35 +51,37 @@ class RivenCommand;
class RivenScript {
public:
- RivenScript(MohawkEngine_Riven *vm, uint16 scriptType);
+ RivenScript(MohawkEngine_Riven *vm);
~RivenScript();
void addCommand(RivenCommand *command);
void runScript();
void dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs);
- uint16 getScriptType() { return _scriptType; }
void stopRunning() { _continueRunning = false; }
private:
MohawkEngine_Riven *_vm;
Common::Array<RivenCommand *> _commands;
- uint16 _scriptType;
bool _continueRunning;
-
- void dumpCommands(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs);
};
typedef Common::SharedPtr<RivenScript> RivenScriptPtr;
-typedef Common::Array<RivenScriptPtr> RivenScriptList;
+
+struct RivenTypedScript {
+ uint16 type;
+ RivenScriptPtr script;
+};
+
+typedef Common::Array<RivenTypedScript> RivenScriptList;
class RivenScriptManager {
public:
RivenScriptManager(MohawkEngine_Riven *vm);
~RivenScriptManager();
- RivenScriptPtr readScript(Common::ReadStream *stream, uint16 scriptType);
+ RivenScriptPtr readScript(Common::ReadStream *stream);
RivenScriptList readScripts(Common::ReadStream *stream);
void stopAllScripts();