[Scummvm-cvs-logs] CVS: scummvm/sword2 interpreter.cpp,1.30,1.31 mouse.cpp,1.45,1.46

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sat Nov 29 09:06:03 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv19350

Modified Files:
	interpreter.cpp mouse.cpp 
Log Message:
Clarified comment about the elevator script bug and added a workaround for
the dreaded Pyramid Bug.


Index: interpreter.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/interpreter.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- interpreter.cpp	28 Nov 2003 07:55:25 -0000	1.30
+++ interpreter.cpp	29 Nov 2003 17:05:30 -0000	1.31
@@ -212,6 +212,8 @@
 }
 
 int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) {
+	bool checkPyramidBug = false;
+
 	#define STACK_SIZE		10
 
 	_standardHeader *header = (_standardHeader *) scriptData;
@@ -256,6 +258,27 @@
 		debug(5, "Start script with offset %d", ip);
 	}
 
+	// WORKAROUND: The dreaded pyramid makes the torch untakeable when you
+	// speak to Titipoco. This is because one of the conditions for the
+	// torch to be takeable is that Titipoco isn't doing anything out of
+	// the ordinary. Global variable 913 has to be 0 to signify that he is
+	// in his "idle" state.
+	//
+	// Unfortunately, simply the act of speaking to him sets variable 913
+	// to 1 (probably to stop him from turning around every now and then).
+	// The script may then go on to set the variable to different values
+	// to trigger various behaviours in him, but if you have run out of
+	// these cases the script won't ever set it back to 0 again.
+	//
+	// So if his click hander (action script number 2) finishes, and
+	// variable 913 is 1, we set it back to 0 manually.
+
+	if (strcmp((char *) header->name, "titipoco_81") == 0 &&
+	    ip >= (int32) READ_LE_UINT32((const int *) code + 3) &&
+	    ip < (int32) READ_LE_UINT32((const int *) code + 4)) {
+		checkPyramidBug = true;
+	}
+
 	code += noScripts * sizeof(int32) + sizeof(int32);
 
 #ifdef DONTPROCESSSCRIPTCHECKSUM
@@ -290,8 +313,16 @@
 		switch (curCommand) {
 		case CP_END_SCRIPT:
 			// End the script
-			debug(5, "End script",0);
+			debug(5, "End script");
 			runningScript = 0;
+
+			// WORKAROUND: Pyramid Bug. See explanation above.
+
+			if (checkPyramidBug && _globals[913] == 1) {
+				warning("Working around Titipoco script bug (the \"Pyramid Bug\")");
+				_globals[913] = 0;
+			}
+
 			break;
 		case CP_PUSH_LOCAL_VAR32:
 			// Push the contents of a local variable

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- mouse.cpp	23 Nov 2003 13:40:24 -0000	1.45
+++ mouse.cpp	29 Nov 2003 17:05:30 -0000	1.46
@@ -648,23 +648,18 @@
 		EXIT_FADING = 0;
 
 		// WORKAROUND: Examining the lift while at the top of the
-		// pyramid causes the game to hang. It looks like a script
-		// bug to me: the script hides the mouse cursor, checks if the
-		// player pressed the left mouse button and, if not, jumps to
-		// an end of script instruction.
+		// pyramid causes the game to hang.
 		//
-		// One idea would be to redirect the action to the elevator
-		// object at the bottom of the pyramid instead, but I don't
-		// know if that's a safe thing to do so for now I've disabled
-		// it. Maybe we could find a better workaround if we had a
-		// script decompiler...
+		// Actually, what happens is that the elevator's click handler
+		// (action script 2) disables the mouse cursor. Then it checks
+		// if the user clicked the left button, in which case it
+		// triggers the "going down" animation.
 		//
-		// I'm checking the status of the left button rather than the
-		// right button because that's what I think the script does.
+		// If the user didn't click the left button, the script will
+		// terminate. With the mouse cursor still disabled. Ouch!
 
 		if (_mouseTouching == 2773 && !LEFT_BUTTON) {
-			warning("Ignoring action to work around script bug at pyramid top");
-			// _logic->setPlayerActionEvent(CUR_PLAYER_ID, 2737);
+			warning("Working around elevator script bug");
 		} else
 			_logic->setPlayerActionEvent(CUR_PLAYER_ID, _mouseTouching);
 





More information about the Scummvm-git-logs mailing list