diff options
Diffstat (limited to 'engines/sword1/router.cpp')
-rw-r--r-- | engines/sword1/router.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/engines/sword1/router.cpp b/engines/sword1/router.cpp index b8347abd32..6968a5bd23 100644 --- a/engines/sword1/router.cpp +++ b/engines/sword1/router.cpp @@ -327,7 +327,6 @@ int32 Router::smoothestPath() { lastDir = _startDir; // for each section of the route - for (int p = 0; p < _routeLength; p++) { int32 dirS = _route[p].dirS; int32 dirD = _route[p].dirD; @@ -402,17 +401,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 } @@ -425,7 +422,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 @@ -434,9 +431,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; @@ -568,8 +562,6 @@ int32 Router::smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD) { break; } - - return k; } void Router::slidyPath() { |