[Scummvm-cvs-logs] CVS: scummvm/scumm logic_he.cpp,2.17,2.18

Max Horn fingolfin at users.sourceforge.net
Tue May 17 17:03:47 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28301

Modified Files:
	logic_he.cpp 
Log Message:
Some cleanup (note: for some (negative value) corner cases, round does not 100% match the original code. However, that should probably not matter...)

Index: logic_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/logic_he.cpp,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -d -r2.17 -r2.18
--- logic_he.cpp	17 May 2005 23:27:50 -0000	2.17
+++ logic_he.cpp	18 May 2005 00:02:29 -0000	2.18
@@ -415,11 +415,11 @@
 		data[i + 1] -= (double)y;
 	}
 
-	double a1 = (double)args[1] * PI / 180;
+	double a1 = (double)args[1] * DEG2RAD;
 
 	for (int i = 0; i <= 6; i += 2) {
 		at = atan2(data[i + 1], data[i]);
-		sq = sqrt(fabs(data[i]) * fabs(data[i]) + fabs(data[i + 1]) * fabs(data[i + 1]));
+		sq = hypot(data[i + 1], data[i]);
 
 		if (at <= 0)
 			at += 2 * PI;
@@ -442,26 +442,14 @@
 		data[i] -= data[minx];
 		data[i + 1] -= data[miny];
 
-		if (floor(data[i]) + 0.5 > data[i])
-			data[i] = floor(data[i]);
-		else
-			data[i] = ceil(data[i]);
-
-		putInArray(args[0], 0, 519 + i, (int32)data[i]);
-
-		if (floor(data[i + 1]) + 0.5 > data[i + 1])
-			data[i + 1] = floor(data[i + 1]);
-		else
-			data[i + 1] = ceil(data[i + 1]);
-
-		putInArray(args[0], 0, 519 + i + 1, (int32)data[i + 1]);
+		putInArray(args[0], 0, 519 + i, (int32)round(data[i]));
+		putInArray(args[0], 0, 519 + i + 1, (int32)round(data[i + 1]));
 	}
 }
 
 void LogicHEfunshop::op_1005(int32 *args) {
 	double data[8];
 	double args1, args2;
-	double temp;
 
 	for (int i = 520; i <= 526; i += 2) {
 		data[i - 520] = getFromArray(args[0], 0, i - 1);
@@ -477,19 +465,8 @@
 	}
 	
 	for (int i = 520; i <= 526; i += 2) {
-		if (floor(data[i - 520]) + 0.5 > data[i - 520]) {
-			temp = ceil(data[i - 520]);
-		} else {
-			temp = floor(data[i - 520]);
-		}
-		putInArray(args[0], 0, i - 1, (int32)temp);
-
-		if (floor(data[i - 520 + 1]) + 0.5 <= data[i - 520 + 1]) {
-			temp = ceil(data[i - 520 + 1]);
-		} else {
-			temp = floor(data[i - 520 + 1]);
-		}
-		putInArray(args[0], 0, i, (int32)temp);
+		putInArray(args[0], 0, i - 1, (int32)round(data[i - 520]));
+		putInArray(args[0], 0, i, (int32)round(data[i - 520 + 1]));
 	}
 }
 





More information about the Scummvm-git-logs mailing list