diff options
author | Robert Špalek | 2009-11-08 06:30:10 +0000 |
---|---|---|
committer | Robert Špalek | 2009-11-08 06:30:10 +0000 |
commit | a4393d46b203c183d26f931e247f30d760b6ad0b (patch) | |
tree | 6a0782f19ab54ffad29e29533dfe2c6767f2384b | |
parent | 5c8aa6ee91ed9342b991827d0a93bbc32f1bbb38 (diff) | |
download | scummvm-rg350-a4393d46b203c183d26f931e247f30d760b6ad0b.tar.gz scummvm-rg350-a4393d46b203c183d26f931e247f30d760b6ad0b.tar.bz2 scummvm-rg350-a4393d46b203c183d26f931e247f30d760b6ad0b.zip |
Do not immediately clear the path when it has just 1 vertex.
This fixes the previous bugfix, which causes that I could not re-run the same
program (e.g., by repeatedly clicking on the hollow tree) if the hero did not
move at least one pixel.
svn-id: r45747
-rw-r--r-- | engines/draci/game.cpp | 2 | ||||
-rw-r--r-- | engines/draci/walking.cpp | 10 | ||||
-rw-r--r-- | engines/draci/walking.h | 6 |
3 files changed, 13 insertions, 5 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index c87034bdea..daad892b6c 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -443,7 +443,7 @@ void Game::advanceAnimationsAndTestLoopExit() { // proper timing. bool walkingFinished = false; if (_walkingState.isActive()) { - walkingFinished = !_walkingState.continueWalking(); + walkingFinished = !_walkingState.continueWalkingOrClearPath(); } // Advance animations (this may also call setExitLoop(true) in the diff --git a/engines/draci/walking.cpp b/engines/draci/walking.cpp index f9e29da881..6f2e295000 100644 --- a/engines/draci/walking.cpp +++ b/engines/draci/walking.cpp @@ -493,6 +493,14 @@ void WalkingState::callback() { _vm->_mouse->cursorOn(); } +bool WalkingState::continueWalkingOrClearPath() { + const bool stillWalking = continueWalking(); + if (!stillWalking) { + _path.clear(); + } + return stillWalking; +} + bool WalkingState::continueWalking() { const GameObject *dragon = _vm->_game->getObject(kDragonObject); const Movement movement = static_cast<Movement> (_vm->_game->playingObjectAnimation(dragon)); @@ -513,7 +521,6 @@ bool WalkingState::continueWalking() { // has just 1 vertex and startWalking() leaves the path open. // Finishing and nontrivial path will get caught earlier. if (_segment >= _path.size()) { - _path.clear(); return false; } @@ -650,7 +657,6 @@ bool WalkingState::walkOnNextEdge() { } else { // Otherwise we are done. continueWalking() will return false next time. debugC(2, kDraciWalkingDebugLevel, "We have walked the whole path"); - _path.clear(); return false; } } diff --git a/engines/draci/walking.h b/engines/draci/walking.h index 4c0f31d116..eb165b2c6f 100644 --- a/engines/draci/walking.h +++ b/engines/draci/walking.h @@ -120,9 +120,11 @@ public: // Advances the hero along the path and changes animation accordingly. // Walking MUST be active when calling this method. When the hero has - // arrived to the target, clears the path and returns false, but leaves - // the callback untouched (the caller must call it). + // arrived to the target, returns false, but leaves the callback + // untouched (the caller must call it). + // The second variant also clears the path when returning false. bool continueWalking(); + bool continueWalkingOrClearPath(); // Called when the hero's turning animation has finished. void heroAnimationFinished(); |