diff options
author | Strangerke | 2016-05-08 01:19:40 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 12:14:55 +0200 |
commit | 1f7eeb24a0622a44a4b4582b51950fae4a80fcb7 (patch) | |
tree | d557c3759d98f94c74fd1b2cc9679dd39b4135e5 | |
parent | 81c5f8651d7b78986a5487c0b6b67a3ea1bea19c (diff) | |
download | scummvm-rg350-1f7eeb24a0622a44a4b4582b51950fae4a80fcb7.tar.gz scummvm-rg350-1f7eeb24a0622a44a4b4582b51950fae4a80fcb7.tar.bz2 scummvm-rg350-1f7eeb24a0622a44a4b4582b51950fae4a80fcb7.zip |
GNAP: Simplify some checks
-rw-r--r-- | engines/gnap/character.cpp | 49 | ||||
-rw-r--r-- | engines/gnap/scenes/group1.cpp | 53 |
2 files changed, 53 insertions, 49 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; diff --git a/engines/gnap/scenes/group1.cpp b/engines/gnap/scenes/group1.cpp index 0122a08109..aa55e1dcf5 100644 --- a/engines/gnap/scenes/group1.cpp +++ b/engines/gnap/scenes/group1.cpp @@ -410,20 +410,25 @@ void Scene10::updateAnimations() { } switch (_currCookSequenceId) { - case 0x106: { - // TODO: Refactor into a if + a switch - int rnd = _vm->getRandom(7); + case 0x106: if (_vm->_gnap->_actionStatus >= 0 || _vm->_plat->_actionStatus >= 0) _nextCookSequenceId = 0x106; - else if (rnd == 0) - _nextCookSequenceId = 0x104; - else if (rnd == 1) - _nextCookSequenceId = 0x103; - else if (rnd == 2) { - _nextCookSequenceId = 0x106; - gameSys.insertSequence(0x10D, 1, 0, 0, kSeqNone, 0, 0, 0); - } else - _nextCookSequenceId = 0x106; + else { + int rnd = _vm->getRandom(7); + switch (rnd) { + case 0: + _nextCookSequenceId = 0x104; + break; + case 1: + _nextCookSequenceId = 0x103; + break; + case 2: + _nextCookSequenceId = 0x106; + gameSys.insertSequence(0x10D, 1, 0, 0, kSeqNone, 0, 0, 0); + break; + default: + _nextCookSequenceId = 0x106; + } } break; case 0x103: @@ -442,17 +447,22 @@ void Scene10::updateAnimations() { else _nextCookSequenceId = 0x106; break; - case 0x105: { - // TODO: Refactor into a if + a switch - int rnd = _vm->getRandom(7); + case 0x105: if (_vm->_gnap->_actionStatus >= 0 || _vm->_plat->_actionStatus >= 0) _nextCookSequenceId = 0x106; - else if (rnd == 0) - _nextCookSequenceId = 0x104; - else if (rnd == 1) - _nextCookSequenceId = 0x103; - else - _nextCookSequenceId = 0x106; + else { + int rnd = _vm->getRandom(7); + switch (rnd) { + case 0: + _nextCookSequenceId = 0x104; + break; + case 1: + _nextCookSequenceId = 0x103; + break; + default: + _nextCookSequenceId = 0x106; + } + } _vm->_timers[2] = _vm->getRandom(30) + 20; _vm->_timers[3] = 300; gameSys.insertSequence(0x10C, _vm->_gnap->_id, makeRid(_vm->_gnap->_sequenceDatNum, _vm->_gnap->_sequenceId), _vm->_gnap->_id, kSeqSyncWait, 0, 0, 0); @@ -461,7 +471,6 @@ void Scene10::updateAnimations() { _vm->_gnap->_sequenceDatNum = 0; _vm->_gnap->_actionStatus = -1; _vm->_plat->_actionStatus = -1; - } break; } if (_currCookSequenceId == 0x843) |