diff options
author | Max Horn | 2009-10-20 19:12:31 +0000 |
---|---|---|
committer | Max Horn | 2009-10-20 19:12:31 +0000 |
commit | c5c12130f5b88e69f5ee7e6f0f1d58d65fbbbd27 (patch) | |
tree | b7fe5e64e5652bae2f407979f61fac107d0da007 /engines | |
parent | 774eefe6882f9c123535872d17434d7d6dd20dd5 (diff) | |
download | scummvm-rg350-c5c12130f5b88e69f5ee7e6f0f1d58d65fbbbd27.tar.gz scummvm-rg350-c5c12130f5b88e69f5ee7e6f0f1d58d65fbbbd27.tar.bz2 scummvm-rg350-c5c12130f5b88e69f5ee7e6f0f1d58d65fbbbd27.zip |
SWORD2: Resolve FIXME about weird static var 'k' in Router::smoothCheck
svn-id: r45282
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sword2/router.cpp | 25 | ||||
-rw-r--r-- | engines/sword2/router.h | 2 |
2 files changed, 10 insertions, 17 deletions
diff --git a/engines/sword2/router.cpp b/engines/sword2/router.cpp index fcccc3cbe4..9c79f1f9cb 100644 --- a/engines/sword2/router.cpp +++ b/engines/sword2/router.cpp @@ -462,17 +462,15 @@ int32 Router::smoothestPath() { assert(options); - i = 0; - steps = 0; - - do { + for (i = 0; i < 4; ++i) { int32 opt = 1 << turns[i]; - if (options & opt) - steps = smoothCheck(turns[i], p, dirS, dirD); - i++; - } while (steps == 0 && i < 4); + if (options & opt) { + smoothCheck(steps, turns[i], p, dirS, dirD); + break; + } + } - assert(steps); + assert(i < 4); // route.X route.Y route.dir and bestTurns start at far end } @@ -485,7 +483,7 @@ int32 Router::smoothestPath() { return 1; } -int32 Router::smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD) { +void Router::smoothCheck(int32 &k, int32 best, int32 p, int32 dirS, int32 dirD) { /********************************************************************* * Slip sliding away * This path checker checks to see if a walk that exactly follows the @@ -494,9 +492,6 @@ int32 Router::smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD) { * No longer checks the data it only creates the smoothPath array JPS *********************************************************************/ - // FIXME: Using 'static' vars in a method is evil -- they should almost - // always be turned into member variables instead. - static int32 k; int32 dsx, dsy; int32 ddx, ddy; int32 ss0, ss1, ss2; @@ -628,8 +623,6 @@ int32 Router::smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD) { break; } - - return k; } void Router::slidyPath() { @@ -1364,7 +1357,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) { * returns 0 if solid route not found *********************************************************************/ - bool leftLeg; + int32 left; int32 turnDir; int32 scale; int32 step; diff --git a/engines/sword2/router.h b/engines/sword2/router.h index c75bea6131..f556850797 100644 --- a/engines/sword2/router.h +++ b/engines/sword2/router.h @@ -182,7 +182,7 @@ private: int32 smoothestPath(); void slidyPath(); - int32 smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD); + void smoothCheck(int32 &steps, int32 best, int32 p, int32 dirS, int32 dirD); bool addSlowInFrames(WalkData *walkAnim); void addSlowOutFrames(WalkData *walkAnim); |