diff options
author | Strangerke | 2012-11-17 11:57:02 +0100 |
---|---|---|
committer | Strangerke | 2012-11-17 11:57:41 +0100 |
commit | 2f116e01c76bf8c208451b670d29e6ef3f05b9a8 (patch) | |
tree | b1c9bbd6f39f7e57da22030ea2dd12445e29bc60 | |
parent | 928b1ae0d02daee9362f111d51ae81f0fc3b86f8 (diff) | |
download | scummvm-rg350-2f116e01c76bf8c208451b670d29e6ef3f05b9a8.tar.gz scummvm-rg350-2f116e01c76bf8c208451b670d29e6ef3f05b9a8.tar.bz2 scummvm-rg350-2f116e01c76bf8c208451b670d29e6ef3f05b9a8.zip |
HOPKINS: Fix original bug in chapter 2, when searching the box.
Add a safeguard to the sequence parser
-rw-r--r-- | engines/hopkins/objects.cpp | 24 | ||||
-rw-r--r-- | engines/hopkins/objects.h | 2 |
2 files changed, 14 insertions, 12 deletions
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 04464f5e28..1aaed5a997 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -4555,7 +4555,7 @@ void ObjectsManager::Q_GAUCHE(int idx) { if (idx == 6) SPACTION1(_vm->_globals.GESTE, "17,16,15,-1,", 0, 0, 8); if (idx == 7) - SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20-1,", 0, 0, 8, 1); + SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20,-1,", 0, 0, 8, 1); if (idx == 8) SPACTION1(_vm->_globals.GESTE, "19,18,17,16,15,-1,", 0, 0, 8); if (idx == 9) @@ -5331,19 +5331,16 @@ void ObjectsManager::ACTION(const byte *spriteData, const Common::String &a2, in } } -void ObjectsManager::SPACTION(byte *a1, const Common::String &a2, int a3, int a4, int a5, int a6) { +void ObjectsManager::SPACTION(byte *a1, const Common::String &animationSeq, int a3, int a4, int a5, int a6) { int v6; - int16 v7; char v8; int v9; int16 v10; int v11; int spriteIndex; char v14; - int16 v15; Common::String v16; - v15 = 0; v6 = 0; spriteIndex = 0; v16 = " "; @@ -5358,23 +5355,28 @@ void ObjectsManager::SPACTION(byte *a1, const Common::String &a2, int a3, int a4 Sprite[0].field12 += a3; Sprite[0].field14 += a4; Sprite[0].fieldE = a6; + + uint strPos = 0; do { + bool loopCond = false; do { - v7 = 0; - v8 = a2[v15]; - if (v8 == ',') { + v8 = animationSeq[strPos]; + if ((animationSeq[strPos] == ',') || (strPos == animationSeq.size() - 1)) { + // Safeguard: if the sequence doesn't end with a coma, simulate it's present. + if (animationSeq[strPos] != ',') + v16.setChar(v8, v6); v9 = atoi(v16.c_str()); spriteIndex = v9; v6 = 0; v16 = " "; - v7 = 1; + loopCond = true; } else { v9 = v6; v16.setChar(v8, v6); v6 = v6 + 1; } - ++v15; - } while (v7 != 1); + ++strPos; + } while (!loopCond); if (spriteIndex != -1) { Sprite[0].spriteData = a1; Sprite[0].spriteIndex = spriteIndex; diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h index 60ace316da..0af22a8483 100644 --- a/engines/hopkins/objects.h +++ b/engines/hopkins/objects.h @@ -233,7 +233,7 @@ public: int colision(int xp, int yp); void ACTION(const byte *spriteData, const Common::String &a2, int a3, int a4, int a5, int a6); - void SPACTION(byte *a1, const Common::String &a2, int a3, int a4, int a5, int a6); + void SPACTION(byte *a1, const Common::String &animationSeq, int a3, int a4, int a5, int a6); void SPACTION1(byte *a1, const Common::String &a2, int a3, int a4, int a5); void TEST_FORET(int a1, int a2, int a3, int a4, int a5, int a6); void BLOQUE_ANIMX(int idx, int a2); |