aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1
diff options
context:
space:
mode:
authorMax Horn2009-10-20 19:11:22 +0000
committerMax Horn2009-10-20 19:11:22 +0000
commit08fb97ee59db67c8d1a5e8281fd4c9c11ffd9bc9 (patch)
tree48650a36746ae8a4ac727e0170117ca4d7a0e49e /engines/sword1
parent4f69e0a753fe22236e88c3cbebcf910d41f90a27 (diff)
downloadscummvm-rg350-08fb97ee59db67c8d1a5e8281fd4c9c11ffd9bc9.tar.gz
scummvm-rg350-08fb97ee59db67c8d1a5e8281fd4c9c11ffd9bc9.tar.bz2
scummvm-rg350-08fb97ee59db67c8d1a5e8281fd4c9c11ffd9bc9.zip
SWORD1: Resolve FIXME about weird static var 'k' in Router::smoothCheck
svn-id: r45279
Diffstat (limited to 'engines/sword1')
-rw-r--r--engines/sword1/router.cpp24
-rw-r--r--engines/sword1/router.h14
2 files changed, 13 insertions, 25 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() {
diff --git a/engines/sword1/router.h b/engines/sword1/router.h
index 0c04562f7f..15ad989ae3 100644
--- a/engines/sword1/router.h
+++ b/engines/sword1/router.h
@@ -118,14 +118,10 @@ private:
int32 megaId;
- /*RouteData _route[O_ROUTE_SIZE];
- //int32 _routeLength;
- PathData _smoothPath[O_ROUTE_SIZE];
- PathData _modularPath[O_ROUTE_SIZE];*/
- RouteData _route[O_ROUTE_SIZE];
- PathData _smoothPath[O_ROUTE_SIZE];
- PathData _modularPath[O_ROUTE_SIZE];
- int32 _routeLength;
+ RouteData _route[O_ROUTE_SIZE];
+ PathData _smoothPath[O_ROUTE_SIZE];
+ PathData _modularPath[O_ROUTE_SIZE];
+ int32 _routeLength;
int32 _framesPerStep, _framesPerChar;
uint8 _nWalkFrames, _nTurnFrames;
@@ -157,7 +153,7 @@ private:
void slidyWalkAnimator(WalkData *walkAnim);
int32 smoothestPath();
- int32 smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
+ void smoothCheck(int32 &steps, int32 best, int32 p, int32 dirS, int32 dirD);
void solidPath();
int32 solidWalkAnimator(WalkData *walkAnim);