aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorRobert Špalek2009-11-04 04:27:31 +0000
committerRobert Špalek2009-11-04 04:27:31 +0000
commitf147fbb93672b3490b6265cf5f912ef23799c907 (patch)
tree865516ade676ca2c421c97fc6eb130a515e864f1 /engines/draci
parent14f268513487f0eafbe1cbf7c9b7b928d77a6148 (diff)
downloadscummvm-rg350-f147fbb93672b3490b6265cf5f912ef23799c907.tar.gz
scummvm-rg350-f147fbb93672b3490b6265cf5f912ef23799c907.tar.bz2
scummvm-rg350-f147fbb93672b3490b6265cf5f912ef23799c907.zip
Properly animate the last phase of the walk before running callbacks
svn-id: r45649
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/game.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index c404b50618..11e9546b39 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -441,25 +441,9 @@ void Game::advanceAnimationsAndTestLoopExit() {
// Walk the hero. The WalkingState class handles everything including
// proper timing.
+ bool walkingFinished = false;
if (_walkingState.isActive()) {
- if (!_walkingState.continueWalking()) {
- // Walking has finished.
- bool exitLoop = false;
- if (_loopSubstatus == kInnerUntilExit) {
- // The callback may run another inner loop (for
- // example, a dialogue). Reset the loop
- // substatus temporarily to the outer one.
- exitLoop = true;
- setLoopSubstatus(kOuterLoop);
- }
- debugC(2, kDraciWalkingDebugLevel, "Finished walking");
- _walkingState.callback(); // clears callback pointer first
- if (exitLoop) {
- debugC(3, kDraciWalkingDebugLevel, "Exiting from the inner loop");
- setExitLoop(true);
- setLoopSubstatus(kInnerUntilExit);
- }
- }
+ walkingFinished = !_walkingState.continueWalking();
}
// Advance animations (this may also call setExitLoop(true) in the
@@ -467,6 +451,26 @@ void Game::advanceAnimationsAndTestLoopExit() {
_vm->_anims->drawScene(_vm->_screen->getSurface());
_vm->_screen->copyToScreen();
_vm->_system->delayMillis(20);
+
+ // If the hero has arrived at his destination, after even the last
+ // phase was correctly animated, run the callback.
+ if (walkingFinished) {
+ bool exitLoop = false;
+ if (_loopSubstatus == kInnerUntilExit) {
+ // The callback may run another inner loop (for
+ // example, a dialogue). Reset the loop
+ // substatus temporarily to the outer one.
+ exitLoop = true;
+ setLoopSubstatus(kOuterLoop);
+ }
+ debugC(2, kDraciWalkingDebugLevel, "Finished walking");
+ _walkingState.callback(); // clears callback pointer first
+ if (exitLoop) {
+ debugC(3, kDraciWalkingDebugLevel, "Exiting from the inner loop");
+ setExitLoop(true);
+ setLoopSubstatus(kInnerUntilExit);
+ }
+ }
}
void Game::loop(LoopSubstatus substatus, bool shouldExit) {