aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven_scripts.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2017-08-11 19:05:28 +0200
committerBastien Bouclet2017-08-11 19:05:55 +0200
commitee588a8c33b3f75c9ee64ca28ef5010e292b2458 (patch)
treed2061c30bc238291d9144f36be3bf53a634e6f43 /engines/mohawk/riven_scripts.cpp
parentc28d246cb0d8ad7773eef8008fd18dae53abbdbf (diff)
downloadscummvm-rg350-ee588a8c33b3f75c9ee64ca28ef5010e292b2458.tar.gz
scummvm-rg350-ee588a8c33b3f75c9ee64ca28ef5010e292b2458.tar.bz2
scummvm-rg350-ee588a8c33b3f75c9ee64ca28ef5010e292b2458.zip
MOHAWK: Riven: Patch an invalid card change when entering Gehn's office
Fixes #10118.
Diffstat (limited to 'engines/mohawk/riven_scripts.cpp')
-rw-r--r--engines/mohawk/riven_scripts.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 21c18fa468..cb040ee4a0 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -179,6 +179,16 @@ RivenScriptPtr RivenScriptManager::createScriptFromData(uint16 commandCount, ...
return readScript(&readStream);
}
+RivenScriptPtr RivenScriptManager::readScriptFromData(uint16 *data, uint16 size) {
+ // Script data is expected to be in big endian
+ for (uint i = 0; i < size; i++) {
+ data[i] = TO_BE_16(data[i]);
+ }
+
+ Common::MemoryReadStream patchStream((const byte *)(data), size * sizeof(uint16));
+ return _vm->_scriptMan->readScript(&patchStream);
+}
+
RivenScriptPtr RivenScriptManager::createScriptWithCommand(RivenCommand *command) {
assert(command);
@@ -312,6 +322,29 @@ void RivenScript::applyCardPatches(MohawkEngine_Riven *vm, uint32 cardGlobalId,
debugC(kRivenDebugPatches, "Applied missing closing sound patch to card %x", cardGlobalId);
}
+ // Second part of the patch to fix the invalid card change when entering Gehn's office
+ // The first part is in the card patches.
+ if (cardGlobalId == 0x2E76 && scriptType == kCardUpdateScript && !(vm->getFeatures() & GF_DVD)) {
+ shouldApplyPatches = true;
+
+ for (uint i = 0; i < _commands.size(); i++) {
+ int transitionIndex = -1;
+ if (_commands[i]->getType() == kRivenCommandTransition) {
+ transitionIndex = i;
+ }
+ if (transitionIndex >= 0) {
+ _commands.remove_at(transitionIndex + 1);
+ _commands.remove_at(transitionIndex);
+
+ RivenSimpleCommand::ArgumentArray arguments;
+ arguments.push_back(6);
+ _commands.push_back(RivenCommandPtr(new RivenSimpleCommand(vm, kRivenCommandActivatePLST, arguments)));
+ }
+ }
+
+ debugC(kRivenDebugPatches, "Applied invalid card change during screen update (2/2) to card %x", cardGlobalId);
+ }
+
if (shouldApplyPatches) {
for (uint i = 0; i < _commands.size(); i++) {
_commands[i]->applyCardPatches(cardGlobalId, scriptType, hotspotId);