[Scummvm-cvs-logs] CVS: scummvm/scumm scummvm.cpp,2.57,2.58

Max Horn fingolfin at users.sourceforge.net
Fri Mar 7 13:57:06 CET 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv4881

Modified Files:
	scummvm.cpp 
Log Message:
cleanup toSimpleDir: should be easier to understand this way, and hopefully fixes the valgrind warnings

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.57
retrieving revision 2.58
diff -u -d -r2.57 -r2.58
--- scummvm.cpp	7 Mar 2003 15:37:59 -0000	2.57
+++ scummvm.cpp	7 Mar 2003 21:56:38 -0000	2.58
@@ -1447,16 +1447,18 @@
 // Convert an angle to a simple direction.
 //
 int toSimpleDir(int dirType, int dir) {
-	const int16 many_direction_tab[16] = {
-		71, 109, 251, 289,  -1,  -1,  -1,  -1,
-		22,  72, 107, 157, 202, 252, 287, 337
-	};
-	int num = dirType ? 8 : 4;
-	const int16 *dirtab = &many_direction_tab[dirType * 8];
-	for (int i = 1; i < num-1; i++, dirtab++) {
-		if (dir >= dirtab[0] && dir <= dirtab[1])
-			return i;
+	if (dirType) {
+		const int16 directions[] = { 22,  72, 107, 157, 202, 252, 287, 337 };
+		for (int i = 0; i < 7; i++)
+			if (dir >= directions[i] && dir <= directions[i+1])
+				return i;
+	} else {
+		const int16 directions[] = { 71, 109, 251, 289 };
+		for (int i = 0; i < 3; i++)
+			if (dir >= directions[i] && dir <= directions[i+1])
+				return i;
 	}
+
 	return 0;
 }
 





More information about the Scummvm-git-logs mailing list