From 35e8a6651864dd8dc6c4607b0aefa32a571f29be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Andersson?= Date: Sun, 16 Dec 2007 00:41:30 +0000 Subject: [PATCH] Workaround for bug #1487382 ("SWORD2: Game freezes"). It appears to be a script bug. svn-id: r29866 --- engines/sword2/interpreter.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/engines/sword2/interpreter.cpp b/engines/sword2/interpreter.cpp index d3f202211d9..17b7cbe92f6 100644 --- a/engines/sword2/interpreter.cpp +++ b/engines/sword2/interpreter.cpp @@ -312,6 +312,7 @@ int Logic::runScript2(byte *scriptData, byte *objectData, byte *offsetPtr) { bool checkMopBug = false; bool checkPyramidBug = false; bool checkElevatorBug = false; + bool checkPearlBug = false; if (scriptNumber == 2) { if (strcmp((char *)header.name, "mop_73") == 0) @@ -320,6 +321,8 @@ int Logic::runScript2(byte *scriptData, byte *objectData, byte *offsetPtr) { checkPyramidBug = true; else if (strcmp((char *)header.name, "lift_82") == 0) checkElevatorBug = true; + else if (strcmp((char *)header.name, "pearl_31") == 0) + checkPearlBug = true; } code += noScripts * 4; @@ -633,6 +636,15 @@ int Logic::runScript2(byte *scriptData, byte *objectData, byte *offsetPtr) { // Continue as normal break; case IR_TERMINATE: + if (checkPearlBug && readVar(1290) == 0) { + // Pearl's interaction script will wait + // until global(1290) is no longer 0 + // before doing anything. But if the + // script was terminated prematurely, + // that never happens. + warning("Working around Pearl bug: Resetting Pearl's state"); + writeVar(1290, 1); + } // Return without updating the offset return 2; case IR_REPEAT: