aboutsummaryrefslogtreecommitdiff
path: root/sword2/interpreter.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-11-29 17:05:30 +0000
committerTorbjörn Andersson2003-11-29 17:05:30 +0000
commit67c75a35c66a2535b6f9e9fcc89f0e1aa5fef49b (patch)
tree81790c9a57579c709bb7af108a9d49297f9ac5a2 /sword2/interpreter.cpp
parent9cca17b3beb681ac482e96331e7444ae851d1741 (diff)
downloadscummvm-rg350-67c75a35c66a2535b6f9e9fcc89f0e1aa5fef49b.tar.gz
scummvm-rg350-67c75a35c66a2535b6f9e9fcc89f0e1aa5fef49b.tar.bz2
scummvm-rg350-67c75a35c66a2535b6f9e9fcc89f0e1aa5fef49b.zip
Clarified comment about the elevator script bug and added a workaround for
the dreaded Pyramid Bug. svn-id: r11427
Diffstat (limited to 'sword2/interpreter.cpp')
-rw-r--r--sword2/interpreter.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/sword2/interpreter.cpp b/sword2/interpreter.cpp
index 92cf4bdbf4..d30ecee760 100644
--- a/sword2/interpreter.cpp
+++ b/sword2/interpreter.cpp
@@ -212,6 +212,8 @@ void Logic::setGlobalInterpreterVariables(int32 *vars) {
}
int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) {
+ bool checkPyramidBug = false;
+
#define STACK_SIZE 10
_standardHeader *header = (_standardHeader *) scriptData;
@@ -256,6 +258,27 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) {
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 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) {
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