From ccc7412c57e3d88476a3ba9682c2d97b66f5c690 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Thu, 19 Aug 2021 21:32:57 +0200 Subject: [PATCH] SCUMM: MONKEY-VGA fix bug #346, Object stopped with active cutscene Also occurs in original. In script 204 room 25 (Cannibal Village) a crash can occur when you are expected to give something to the cannibals, but instead look at certain items like the compass or kidnap note. Those inventory items contain little cutscenes and are abrubtly stopped by the cutscene in script 204 at 0x0060. This workaround changes the result of isScriptRunning(164) to also wait for any inventory scripts that are in a cutscene state, preventing the crash. Script #204 [0000] (1A) Bit[354] = 1; [0005] (1A) Var[249] = 0; [000A] (5D) setClass(303,[32]); [0011] (DD) setClass(VAR_EGO,[5]); [0018] (2E) delay(1200); [001C] (80) breakHere(); [001D] (68) VAR_RESULT = isScriptRunning(164); [0021] (A8) if (VAR_RESULT) { [0026] (18) goto 001C; [0029] (**) } [0029] (58) endOverride(); [002B] (91) animateCostume(VAR_EGO,3); [002F] (5D) setClass(303,[160]); [0036] (40) cutscene([]); [0038] (AE) WaitForMessage(); [003A] (14) print(5,[Text("Obviously you have nothing for us.")]); [0060] (C0) endCutscene(); [0061] (2A) startScript(105,[],F); [0064] (A0) stopObjectCode(); END --- engines/scumm/script_v5.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp index cb5d3ddbd76..bfc8e7b3da7 100644 --- a/engines/scumm/script_v5.cpp +++ b/engines/scumm/script_v5.cpp @@ -1215,6 +1215,23 @@ void ScummEngine_v5::o5_getRandomNr() { void ScummEngine_v5::o5_isScriptRunning() { getResultPos(); setResult(isScriptRunning(getVarOrDirectByte(PARAM_1))); + + // WORKAROUND bug #346 (also occurs in original): Object stopped with active cutscene + // In script 204 room 25 (Cannibal Village) a crash can occur when you are + // expected to give something to the cannibals, but instead look at certain + // items like the compass or kidnap note. Those inventory items contain little + // cutscenes and are abrubtly stopped by the endcutscene in script 204 at 0x0060. + // This patch changes the the result of isScriptRunning(164) to also wait for + // any inventory scripts that are in a cutscene state, preventing the crash. + if (_game.id == GID_MONKEY && vm.slot[_currentScript].number == 204 && _currentRoom == 25) { + ScriptSlot *ss = vm.slot; + for (int i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) { + if (ss->status != ssDead && ss->where == WIO_INVENTORY && ss->cutsceneOverride) { + setResult(1); + return; + } + } + } } void ScummEngine_v5::o5_getVerbEntrypoint() {