aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2
diff options
context:
space:
mode:
authorMax Horn2009-10-20 19:12:08 +0000
committerMax Horn2009-10-20 19:12:08 +0000
commit774eefe6882f9c123535872d17434d7d6dd20dd5 (patch)
tree52a76b567880c895e52d981f36bd7beb91c369b6 /engines/sword2
parentb935f0119ac1542f099c806a4af75494f0b99f5c (diff)
downloadscummvm-rg350-774eefe6882f9c123535872d17434d7d6dd20dd5.tar.gz
scummvm-rg350-774eefe6882f9c123535872d17434d7d6dd20dd5.tar.bz2
scummvm-rg350-774eefe6882f9c123535872d17434d7d6dd20dd5.zip
SWORD2: Resolve FIXME about static var 'left' in Router::slidyWalkAnimator
svn-id: r45281
Diffstat (limited to 'engines/sword2')
-rw-r--r--engines/sword2/router.cpp39
1 files changed, 11 insertions, 28 deletions
diff --git a/engines/sword2/router.cpp b/engines/sword2/router.cpp
index d8789d00fb..fcccc3cbe4 100644
--- a/engines/sword2/router.cpp
+++ b/engines/sword2/router.cpp
@@ -857,9 +857,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
* produce a module list from the line data
*********************************************************************/
- // FIXME: Using 'static' vars in a method is evil -- they should almost
- // always be turned into member variables instead.
- static int32 left = 0;
+ int32 left;
int32 p;
int32 lastDir;
int32 lastRealDir;
@@ -991,7 +989,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
} else {
// start the walk on the right leg (ie. at beginning of the
// second step of the walk cycle)
- left = _framesPerStep;
+ left = 1;
}
_lastCount = _stepCount;
@@ -1018,12 +1016,9 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
_currentDir = _modularPath[p].dir;
if (_currentDir < NO_DIRECTIONS) {
- module = _currentDir * _framesPerStep * 2 + left;
+ module = _currentDir * _framesPerStep * 2 + left * _framesPerStep;
- if (left == 0)
- left = _framesPerStep;
- else
- left = 0;
+ left = !left;
moduleEnd = module + _framesPerStep;
step = 0;
@@ -1070,20 +1065,14 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// the last stop was
// closest
_stepCount -= _framesPerStep;
- if (left == 0)
- left = _framesPerStep;
- else
- left = 0;
+ left = !left;
}
} else {
if (3 * ABS(lastErrorX) < ABS(errorX)) {
//the last stop was
// closest
_stepCount -= _framesPerStep;
- if (left == 0)
- left = _framesPerStep;
- else
- left = 0;
+ left = !left;
}
}
}
@@ -1375,7 +1364,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
* returns 0 if solid route not found
*********************************************************************/
- int32 left;
+ bool leftLeg;
int32 turnDir;
int32 scale;
int32 step;
@@ -1493,7 +1482,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
} else {
// start the walk on the right leg (ie. at beginning of the
// second step of the walk cycle)
- left = _framesPerStep;
+ left = 1;
}
_lastCount = _stepCount;
@@ -1510,12 +1499,9 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
while (_modularPath[p].num > 0) {
_currentDir = _modularPath[p].dir;
if (_currentDir < NO_DIRECTIONS) {
- module = _currentDir * _framesPerStep * 2 + left;
+ module = _currentDir * _framesPerStep * 2 + left * _framesPerStep;
- if (left == 0)
- left = _framesPerStep;
- else
- left = 0;
+ left = !left;
moduleEnd = module + _framesPerStep;
step = 0;
@@ -1545,10 +1531,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
_modularPath[p].num = 0;
_stepCount -= _framesPerStep;
- if (left == 0)
- left = _framesPerStep;
- else
- left = 0;
+ left = !left;
// Okay this is the end of a section