From 94176c7463d64d12bc74232058f445f367456ee5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Feb 2013 23:18:43 +0100 Subject: [PATCH] HOPKINS: Some renaming in ScripManager --- engines/hopkins/script.cpp | 41 ++++++++++++++++++-------------------- engines/hopkins/script.h | 2 +- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 09555bd2362..440b4a4d2b7 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -2437,44 +2437,41 @@ int ScriptManager::handleGoto(const byte *dataP) { return READ_LE_INT16(dataP + 5); } -int ScriptManager::handleIf(const byte *dataP, int a2) { - int v20; - int v2 = a2; +int ScriptManager::handleIf(const byte *dataP, int offset) { + int newOffset; + int curOffset = offset; bool loopFl; do { loopFl = false; - int v3 = v2; + int tmpOffset = curOffset; int opcodeType; do { if (_vm->shouldQuit()) return 0; // Exiting game - ++v3; - opcodeType = checkOpcode(dataP + 20 * v3); - if (v3 > 400) + ++tmpOffset; + if (tmpOffset > 400) error("Control if failed"); + opcodeType = checkOpcode(dataP + 20 * tmpOffset); } while (opcodeType != 4); // EIF - v20 = v3; - int v6 = v2; - bool v7 = false; + newOffset = tmpOffset; + tmpOffset = curOffset; do { if (_vm->shouldQuit()) return 0; // Exiting game - ++v6; - if (checkOpcode(dataP + 20 * v6) == 3) // IIF - v7 = true; - if (v6 > 400) + ++tmpOffset; + if (tmpOffset > 400) error("Control if failed "); - if (v7) { - v2 = v20; + if (checkOpcode(dataP + 20 * tmpOffset) == 3) { // IIF + curOffset = newOffset; loopFl = true; break; } - } while (v20 != v6); + } while (newOffset != tmpOffset); } while (loopFl); - const byte *buf = dataP + 20 * a2; + const byte *buf = dataP + 20 * offset; byte oper = buf[13]; byte oper2 = buf[14]; byte operType = buf[15]; @@ -2503,14 +2500,14 @@ int ScriptManager::handleIf(const byte *dataP, int a2) { } if ((operType == 3) && check1Fl) { - return (a2 + 1); + return (offset + 1); } else if ((operType == 1) && check1Fl && check2Fl) { - return (a2 + 1); + return (offset + 1); } else if ((operType == 2) && (check1Fl || check2Fl)) { - return (a2 + 1); + return (offset + 1); } - return (v20 + 1); + return (newOffset + 1); } int ScriptManager::checkOpcode(const byte *dataP) { diff --git a/engines/hopkins/script.h b/engines/hopkins/script.h index cf719f52ceb..3eba8d5167a 100644 --- a/engines/hopkins/script.h +++ b/engines/hopkins/script.h @@ -42,7 +42,7 @@ public: void setParent(HopkinsEngine *vm); int handleOpcode(byte *dataP); - int handleIf(const byte *dataP, int a2); + int handleIf(const byte *dataP, int offset); int handleGoto(const byte *dataP); };