diff options
-rw-r--r-- | engines/kyra/scene_v1.cpp | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/engines/kyra/scene_v1.cpp b/engines/kyra/scene_v1.cpp index 059c42ec5e..cef472682e 100644 --- a/engines/kyra/scene_v1.cpp +++ b/engines/kyra/scene_v1.cpp @@ -277,7 +277,7 @@ void KyraEngine_v1::changePosTowardsFacing(int &x, int &y, int facing) { } int KyraEngine_v1::getMoveTableSize(int *moveTable) { - int retValue = 0; + int tableSize = 0; if (moveTable[0] == 8) return 0; @@ -298,11 +298,11 @@ int KyraEngine_v1::getMoveTableSize(int *moveTable) { int *oldPosition = moveTable; int *tempPosition = moveTable; int *curPosition = moveTable + 1; - retValue = 1; + tableSize = 1; while (*curPosition != 8) { if (*oldPosition == facingTable[*curPosition]) { - retValue -= 2; + tableSize -= 2; *oldPosition = 9; *curPosition = 9; @@ -314,7 +314,7 @@ int KyraEngine_v1::getMoveTableSize(int *moveTable) { if (tempPosition == moveTable && *tempPosition == 9) { // FIXME: This check is odd. Perhaps it should check if *tempPosition == 9 ? - while (*tempPosition != 8 && *tempPosition == 9) + while (*tempPosition == 9) ++tempPosition; if (*tempPosition == 8) @@ -322,54 +322,40 @@ int KyraEngine_v1::getMoveTableSize(int *moveTable) { } oldPosition = tempPosition; - curPosition = oldPosition+1; + curPosition = oldPosition + 1; - // FIXME: This check is odd. Perhaps it should check if *tempPosition == 9 ? - while (*curPosition != 8 && *curPosition == 9) + while (*curPosition == 9) ++curPosition; - - continue; - } - - if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { - --retValue; - *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; + } else if (unkTable[*curPosition + *oldPosition * 8] != -1) { + --tableSize; + *oldPosition = unkTable[*curPosition + *oldPosition * 8]; *curPosition = 9; if (tempPosition != oldPosition) { curPosition = oldPosition; oldPosition = tempPosition; - while (true) { - if (tempPosition == moveTable) - break; - + while (tempPosition != moveTable) { --tempPosition; if (*tempPosition != 9) break; - } } else { - while (true) { + do { ++curPosition; - if (*curPosition != 9) - break; - } + } while (*curPosition == 9); } - continue; - } - - tempPosition = oldPosition; - oldPosition = curPosition; - ++retValue; + } else { + tempPosition = oldPosition; + oldPosition = curPosition; + ++tableSize; - while (true) { - ++curPosition; - if (*curPosition != 9) - break; + do { + ++curPosition; + } while (*curPosition == 9); } } - return retValue; + return tableSize; } } // End of namespace Kyra |