[Scummvm-cvs-logs] CVS: scummvm/scumm object.cpp,1.138,1.139

Max Horn fingolfin at users.sourceforge.net
Thu Sep 11 16:38:49 CEST 2003


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

Modified Files:
	object.cpp 
Log Message:
let getObjActToObjActDist round up when dividing the distance by 8 for V1/V2 games. This helps in fixing bug #774529, but might cause regressions...

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -d -r1.138 -r1.139
--- object.cpp	9 Sep 2003 20:54:18 -0000	1.138
+++ object.cpp	11 Sep 2003 23:23:40 -0000	1.139
@@ -265,8 +265,14 @@
 		dir = oldDirToNewDir(od.actordir & 3);
 }
 
+static int getDist(int x, int y, int x2, int y2) {
+	int a = ABS(y - y2);
+	int b = ABS(x - x2);
+	return MAX(a, b);
+}
+
 int Scumm::getObjActToObjActDist(int a, int b) {
-	int x, y, x2, y2;
+	int x, y, x2, y2, dist;
 	Actor *acta = NULL;
 	Actor *actb = NULL;
 
@@ -291,12 +297,13 @@
 		y2 = r.y;
 	}
 
-	y = abs(y - y2);
-	x = abs(x - x2);
-
-	if (y > x)
-		x = y;
-	return (_version <= 2) ? x / 8 : x;
+	// Now compute the distance between the two points
+	dist = getDist(x, y, x2, y2);
+	// For V1/V2 games, distances are measured in "charactes" instead of pixels,
+	// so we divide by 8, rounding up.
+	if (_version <= 2)
+		dist = (dist + 7) / 8;
+	return dist;
 }
 
 int Scumm::findObject(int x, int y) {
@@ -1290,14 +1297,6 @@
 
 	addObjectToDrawQue(i);
 	putState(obj, state);
-}
-
-static int getDist(int x, int y, int x2, int y2) {
-	int a = abs(y - y2);
-	int b = abs(x - x2);
-	if (a > b)
-		return a;
-	return b;
 }
 
 int Scumm::getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f) {





More information about the Scummvm-git-logs mailing list