aboutsummaryrefslogtreecommitdiff
path: root/engines/gnap/character.cpp
diff options
context:
space:
mode:
authorStrangerke2016-05-08 01:19:40 +0200
committerEugene Sandulenko2016-05-10 12:14:55 +0200
commit1f7eeb24a0622a44a4b4582b51950fae4a80fcb7 (patch)
treed557c3759d98f94c74fd1b2cc9679dd39b4135e5 /engines/gnap/character.cpp
parent81c5f8651d7b78986a5487c0b6b67a3ea1bea19c (diff)
downloadscummvm-rg350-1f7eeb24a0622a44a4b4582b51950fae4a80fcb7.tar.gz
scummvm-rg350-1f7eeb24a0622a44a4b4582b51950fae4a80fcb7.tar.bz2
scummvm-rg350-1f7eeb24a0622a44a4b4582b51950fae4a80fcb7.zip
GNAP: Simplify some checks
Diffstat (limited to 'engines/gnap/character.cpp')
-rw-r--r--engines/gnap/character.cpp49
1 files changed, 22 insertions, 27 deletions
diff --git a/engines/gnap/character.cpp b/engines/gnap/character.cpp
index aa920fa0f8..114c2f4adf 100644
--- a/engines/gnap/character.cpp
+++ b/engines/gnap/character.cpp
@@ -676,7 +676,6 @@ int PlayerGnap::getWalkSequenceId(int deltaX, int deltaY) {
bool PlayerGnap::walkTo(Common::Point gridPos, int animationIndex, int sequenceId, int flags) {
int datNum = flags & 3;
- bool done = false;
_vm->_timers[2] = 200;
_vm->_timers[3] = 300;
@@ -695,17 +694,16 @@ bool PlayerGnap::walkTo(Common::Point gridPos, int animationIndex, int sequenceI
if (animationIndex >= 0 && _walkDestX == _vm->_plat->_pos.x && _walkDestY == _vm->_plat->_pos.y)
_vm->_plat->makeRoom();
- if (findPath1(_pos.x, _pos.y, 0))
- done = true;
+ bool done = findPath1(_pos.x, _pos.y, 0);
- if (!done && findPath2(_pos.x, _pos.y, 0))
- done = true;
+ if (!done)
+ done = findPath2(_pos.x, _pos.y, 0);
- if (!done && findPath3(_pos.x, _pos.y))
- done = true;
+ if (!done)
+ done = findPath3(_pos.x, _pos.y);
- if (!done && findPath4(_pos.x, _pos.y))
- done = true;
+ if (!done)
+ done = findPath4(_pos.x, _pos.y);
idle();
@@ -812,15 +810,14 @@ bool PlayerGnap::walkTo(Common::Point gridPos, int animationIndex, int sequenceI
break;
}
} else {
- //TODO: simplify the checks by using v10 and v11
- int v10 = _vm->_leftClickMouseX - (_vm->_gridMinX + 75 * _pos.x);
- int v11 = _vm->_leftClickMouseY - (_vm->_gridMinY + 48 * _pos.y);
- if (_vm->_leftClickMouseX == _vm->_gridMinX + 75 * _pos.x)
- ++v10;
- if (_vm->_leftClickMouseY == _vm->_gridMinY + 48 * _pos.y)
- v11 = 1;
- _sequenceId = getWalkStopSequenceId(v10 / abs(v10), v11 / abs(v11));
- _idleFacing = getWalkFacing(v10 / abs(v10), v11 / abs(v11));
+ int dirX = _vm->_leftClickMouseX - (_vm->_gridMinX + 75 * _pos.x);
+ int dirY = _vm->_leftClickMouseY - (_vm->_gridMinY + 48 * _pos.y);
+ if (dirX == 0)
+ dirX = 1;
+ if (dirY == 0)
+ dirY = 1;
+ _sequenceId = getWalkStopSequenceId(dirX / abs(dirX), dirY / abs(dirY));
+ _idleFacing = getWalkFacing(dirX / abs(dirX), dirY / abs(dirY));
}
_sequenceDatNum = datNum;
}
@@ -1271,7 +1268,6 @@ int PlayerPlat::getWalkSequenceId(int deltaX, int deltaY) {
bool PlayerPlat::walkTo(Common::Point gridPos, int animationIndex, int sequenceId, int flags) {
int datNum = flags & 3;
- bool done = false;
_vm->_timers[1] = 60;
@@ -1289,17 +1285,16 @@ bool PlayerPlat::walkTo(Common::Point gridPos, int animationIndex, int sequenceI
if (animationIndex >= 0 && _vm->_gnap->_pos == Common::Point(_walkDestX, _walkDestY))
_vm->_gnap->walkStep();
- if (findPath1(_pos.x, _pos.y, 0))
- done = true;
+ bool done = findPath1(_pos.x, _pos.y, 0);
- if (!done && findPath2(_pos.x, _pos.y, 0))
- done = true;
+ if (!done)
+ done = findPath2(_pos.x, _pos.y, 0);
- if (!done && findPath3(_pos.x, _pos.y))
- done = true;
+ if (!done)
+ done = findPath3(_pos.x, _pos.y);
- if (!done && findPath4(_pos.x, _pos.y))
- done = true;
+ if (!done)
+ done = findPath4(_pos.x, _pos.y);
int platSequenceId = _sequenceId;
int platId = _id;