[Scummvm-cvs-logs] SF.net SVN: scummvm:[45282] scummvm/trunk/engines/sword2

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Oct 20 21:12:32 CEST 2009


Revision: 45282
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45282&view=rev
Author:   fingolfin
Date:     2009-10-20 19:12:31 +0000 (Tue, 20 Oct 2009)

Log Message:
-----------
SWORD2: Resolve FIXME about weird static var 'k' in Router::smoothCheck

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/router.cpp
    scummvm/trunk/engines/sword2/router.h

Modified: scummvm/trunk/engines/sword2/router.cpp
===================================================================
--- scummvm/trunk/engines/sword2/router.cpp	2009-10-20 19:12:08 UTC (rev 45281)
+++ scummvm/trunk/engines/sword2/router.cpp	2009-10-20 19:12:31 UTC (rev 45282)
@@ -462,17 +462,15 @@
 
 		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 @@
 	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 @@
 	 * 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 @@
 
 		break;
 	}
-
-	return k;
 }
 
 void Router::slidyPath() {
@@ -1364,7 +1357,7 @@
 	 * returns 0 if solid route not found
 	 *********************************************************************/
 
-	bool leftLeg;
+	int32 left;
 	int32 turnDir;
 	int32 scale;
 	int32 step;

Modified: scummvm/trunk/engines/sword2/router.h
===================================================================
--- scummvm/trunk/engines/sword2/router.h	2009-10-20 19:12:08 UTC (rev 45281)
+++ scummvm/trunk/engines/sword2/router.h	2009-10-20 19:12:31 UTC (rev 45282)
@@ -182,7 +182,7 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list