aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Dupont2011-01-29 23:03:08 +0000
committerSylvain Dupont2011-01-29 23:03:08 +0000
commit9c17cedd406d5a05cbb4c544eeb426c45d93f004 (patch)
tree7f0fd9b7549a3401a1120cc45701c0f6aa7a0ef4
parent4e6628038850f423b8d9673f25c5b9a63a10b9e0 (diff)
downloadscummvm-rg350-9c17cedd406d5a05cbb4c544eeb426c45d93f004.tar.gz
scummvm-rg350-9c17cedd406d5a05cbb4c544eeb426c45d93f004.tar.bz2
scummvm-rg350-9c17cedd406d5a05cbb4c544eeb426c45d93f004.zip
TOON: Bug #3124518 with disappearing inventory items fixed
Bug #3124518: "TOON: loss of inventory items in Bricabrac's machine room" Was caused by recursive walkTo that were not canceling out. svn-id: r55641
-rw-r--r--engines/toon/character.cpp12
-rw-r--r--engines/toon/character.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp
index 523eac9eb9..dd057cca4a 100644
--- a/engines/toon/character.cpp
+++ b/engines/toon/character.cpp
@@ -58,6 +58,7 @@ Character::Character(ToonEngine *vm) : _vm(vm) {
_animSpecialDefaultId = 0;
_currentPathNodeCount = 0;
_currentPathNode = 0;
+ _currentWalkStamp = 0;
_visible = true;
_speed = 150; // 150 = nominal drew speed
_lastWalkTime = 0;
@@ -192,6 +193,10 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) {
_flags |= 0x1;
+ _currentWalkStamp++;
+
+ int32 localWalkStamp = _currentWalkStamp;
+
if (_blockingWalk) {
while ((_x != newPosX || _y != newPosY) && _currentPathNode < _currentPathNodeCount && !_vm->shouldQuitGame()) {
if (_currentPathNode < _currentPathNodeCount - 4) {
@@ -226,6 +231,11 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) {
setPosition(_x, _y);
_vm->doFrame();
+ if (_currentWalkStamp != localWalkStamp) {
+ // another walkTo was started in doFrame, we need to cancel this one.
+ return false;
+ }
+
}
playStandingAnim();
_flags &= ~0x1;
@@ -238,8 +248,6 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) {
}
}
- //_vm->getPathFinding()->findClosestWalkingPoint(newPosX, newPosY, &_x, &_y, _x, _y);
- //setPosition(_x,_y);
return true;
}
diff --git a/engines/toon/character.h b/engines/toon/character.h
index 4cd3813f73..d4079d82ef 100644
--- a/engines/toon/character.h
+++ b/engines/toon/character.h
@@ -146,6 +146,7 @@ protected:
int32 _currentPathY[4096];
int32 _currentPathNodeCount;
int32 _currentPathNode;
+ int32 _currentWalkStamp;
};
} // End of namespace Toon