From 57218bb38dfd9804866927b73a71f55059469d10 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Fri, 8 Mar 2019 06:29:52 +0100 Subject: MOHAWK: RIVEN: Fix using the jundle ladder without lowering it It was possible to bypass lowering the ladder when using keyboard navigation. This is fixed using a game script patch to ensure the hotspot for getting down the ladder is disabled when appropriate. --- engines/mohawk/riven_card.cpp | 81 ++++++++++++++++++++++--------------------- engines/mohawk/riven_card.h | 2 +- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index 9026f2e8fb..db833052f8 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -73,7 +73,11 @@ void RivenCard::loadCardResource(uint16 id) { void RivenCard::applyPatches(uint16 id) { uint32 globalId = _vm->getStack()->getCardGlobalId(id); - applyPropertiesPatch8EB7(globalId); + if (globalId == 0x2A3BC) { + applyPropertiesPatch8EB7(globalId, "jladder", 3); + } else if (globalId == 0x8EB7) { + applyPropertiesPatch8EB7(globalId, "jgate", 3); + } applyPropertiesPatch2E76(globalId); // Apply script patches @@ -86,7 +90,7 @@ void RivenCard::applyPatches(uint16 id) { applyPropertiesPatch1518D(globalId); } -void RivenCard::applyPropertiesPatch8EB7(uint32 globalId) { +void RivenCard::applyPropertiesPatch8EB7(uint32 globalId, const Common::String &var, uint16 hotspotId) { // On Jungle Island on the back side of the "beetle" gate, the forward hotspot // is always enabled, preventing keyboard navigation from automatically opening // the gate. @@ -109,48 +113,47 @@ void RivenCard::applyPropertiesPatch8EB7(uint32 globalId) { // case 1: // activateBLST(5); // break; - if (globalId == 0x8EB7) { - HotspotEnableRecord forwardEnabled; - forwardEnabled.index = _hotspotEnableList.back().index + 1; - forwardEnabled.hotspotId = 3; - forwardEnabled.enabled = 1; - _hotspotEnableList.push_back(forwardEnabled); - - HotspotEnableRecord forwardDisabled; - forwardDisabled.index = _hotspotEnableList.back().index + 1; - forwardDisabled.hotspotId = 3; - forwardDisabled.enabled = 0; - _hotspotEnableList.push_back(forwardDisabled); - - uint16 jGateVariable = _vm->getStack()->getIdFromName(kVariableNames, "jgate"); - uint16 patchData[] = { - 1, // Command count in script - kRivenCommandSwitch, - 2, // Unused - jGateVariable, - 2, // Branches count - 0, // jgate == 0 branch (gate closed) - 1, // Command count in sub-script - kRivenCommandActivateBLST, - 1, // Argument count - forwardDisabled.index, + HotspotEnableRecord forwardEnabled; + forwardEnabled.index = _hotspotEnableList.back().index + 1; + forwardEnabled.hotspotId = hotspotId; + forwardEnabled.enabled = 1; + _hotspotEnableList.push_back(forwardEnabled); - 1, // jgate == 1 branch (gate open) - 1, // Command count in sub-script - kRivenCommandActivateBLST, - 1, // Argument count - forwardEnabled.index - }; + HotspotEnableRecord forwardDisabled; + forwardDisabled.index = _hotspotEnableList.back().index + 1; + forwardDisabled.hotspotId = hotspotId; + forwardDisabled.enabled = 0; + _hotspotEnableList.push_back(forwardDisabled); - RivenScriptPtr patchScript = _vm->_scriptMan->readScriptFromData(patchData, ARRAYSIZE(patchData)); + uint16 jGateVariable = _vm->getStack()->getIdFromName(kVariableNames, var); + uint16 patchData[] = { + 1, // Command count in script + kRivenCommandSwitch, + 2, // Unused + jGateVariable, + 2, // Branches count + + 0, // jgate == 0 branch (gate closed) + 1, // Command count in sub-script + kRivenCommandActivateBLST, + 1, // Argument count + forwardDisabled.index, + + 1, // jgate == 1 branch (gate open) + 1, // Command count in sub-script + kRivenCommandActivateBLST, + 1, // Argument count + forwardEnabled.index + }; - // Append the patch to the existing script - RivenScriptPtr loadScript = getScript(kCardLoadScript); - loadScript += patchScript; + RivenScriptPtr patchScript = _vm->_scriptMan->readScriptFromData(patchData, ARRAYSIZE(patchData)); - debugC(kRivenDebugPatches, "Applied fix always enabled forward hotspot in card %x", globalId); - } + // Append the patch to the existing script + RivenScriptPtr loadScript = getScript(kCardLoadScript); + loadScript += patchScript; + + debugC(kRivenDebugPatches, "Applied fix always enabled forward hotspot in card %x", globalId); } void RivenCard::applyPropertiesPatch2E76(uint32 globalId) { diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h index e12b127f39..c092f59713 100644 --- a/engines/mohawk/riven_card.h +++ b/engines/mohawk/riven_card.h @@ -154,7 +154,7 @@ private: void applyPatches(uint16 id); void applyPropertiesPatchE2E(uint32 globalId); void applyPropertiesPatch1518D(uint32 globalId); - void applyPropertiesPatch8EB7(uint32 globalId); + void applyPropertiesPatch8EB7(uint32 globalId, const Common::String &var, uint16 hotspotId); void applyPropertiesPatch2E76(uint32 globalId); void applyPropertiesPatch22118(uint32 globalId); void setCurrentCardVariable(); -- cgit v1.2.3