(svn r5883) -Fix [FS#272]: use the height of the edge of the map for shadows of aircrafts that are outside the map; similar to r5841, caused by r5794.
authorrubidium
Sun, 13 Aug 2006 14:46:16 +0000
changeset 4259 71b8dba85ce1
parent 4258 3ac20963213d
child 4260 8a9824f6e501
(svn r5883) -Fix [FS#272]: use the height of the edge of the map for shadows of aircrafts that are outside the map; similar to r5841, caused by r5794.
aircraft_cmd.c
--- a/aircraft_cmd.c	Sun Aug 13 10:22:34 2006 +0000
+++ b/aircraft_cmd.c	Sun Aug 13 14:46:16 2006 +0000
@@ -764,7 +764,8 @@
 static void SetAircraftPosition(Vehicle *v, int x, int y, int z)
 {
 	Vehicle *u;
-	int yt;
+	int safe_x;
+	int safe_y;
 
 	v->x_pos = x;
 	v->y_pos = y;
@@ -779,10 +780,13 @@
 
 	u = v->next;
 
-	yt = y - ((v->z_pos-GetSlopeZ(x, y-1)) >> 3);
+	safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
+	safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
 	u->x_pos = x;
-	u->y_pos = yt;
-	u->z_pos = GetSlopeZ(x,yt);
+	u->y_pos = y - ((v->z_pos-GetSlopeZ(safe_x, safe_y)) >> 3);;
+
+	safe_y = clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
+	u->z_pos = GetSlopeZ(safe_x, safe_y);
 	u->cur_image = v->cur_image;
 
 	BeginVehicleMove(u);