From 9c17cedd406d5a05cbb4c544eeb426c45d93f004 Mon Sep 17 00:00:00 2001 From: Sylvain Dupont Date: Sat, 29 Jan 2011 23:03:08 +0000 Subject: 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 --- engines/toon/character.cpp | 12 ++++++++++-- engines/toon/character.h | 1 + 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 -- cgit v1.2.3