mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-18 07:39:08 +00:00
KYRA: Simplify getMoveTableSize.
This also removes two FIXME comments. The original did the same checks as we had before, but as PVS-Studio noticed the expression was excessive. I changed it to a simpler expression now and removed the FIXMEs.
This commit is contained in:
parent
4232610c20
commit
4410e61238
@ -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;
|
||||
}
|
||||
} else {
|
||||
tempPosition = oldPosition;
|
||||
oldPosition = curPosition;
|
||||
++tableSize;
|
||||
|
||||
tempPosition = oldPosition;
|
||||
oldPosition = curPosition;
|
||||
++retValue;
|
||||
|
||||
while (true) {
|
||||
++curPosition;
|
||||
if (*curPosition != 9)
|
||||
break;
|
||||
do {
|
||||
++curPosition;
|
||||
} while (*curPosition == 9);
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
return tableSize;
|
||||
}
|
||||
|
||||
} // End of namespace Kyra
|
||||
|
Loading…
Reference in New Issue
Block a user