viewport.c
changeset 4231 2823b3643862
parent 4189 fcc29d7b6722
child 4238 4b58d6ea4e5b
--- a/viewport.c	Sun Aug 06 08:23:19 2006 +0000
+++ b/viewport.c	Sun Aug 06 16:32:49 2006 +0000
@@ -294,7 +294,6 @@
 
 static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y)
 {
-	int z;
 	Point pt;
 	int a,b;
 
@@ -314,16 +313,19 @@
 	a = x+y;
 	b = x-y;
 #endif
-	z = GetSlopeZ(a, b) >> 1;
-	z = GetSlopeZ(a+z, b+z) >> 1;
-	z = GetSlopeZ(a+z, b+z) >> 1;
-	z = GetSlopeZ(a+z, b+z) >> 1;
-	z = GetSlopeZ(a+z, b+z) >> 1;
 
-	pt.x = a+z;
-	pt.y = b+z;
+	if ((uint)a < MapMaxX() * TILE_SIZE && (uint)b < MapMaxY() * TILE_SIZE) {
+		uint z;
 
-	if ((uint)pt.x >= MapMaxX() * TILE_SIZE || (uint)pt.y >= MapMaxY() * TILE_SIZE) {
+		z = GetSlopeZ(a,     b    ) / 2;
+		z = GetSlopeZ(a + z, b + z) / 2;
+		z = GetSlopeZ(a + z, b + z) / 2;
+		z = GetSlopeZ(a + z, b + z) / 2;
+		z = GetSlopeZ(a + z, b + z) / 2;
+
+		pt.x = a + z;
+		pt.y = b + z;
+	} else {
 		pt.x = pt.y = -1;
 	}