(svn r10910) [NewGRF_ports] -Fix: take foundations into account when determining the height of the 0,0 position of the airport. NewGRF_ports
authorrubidium
Wed, 15 Aug 2007 22:33:37 +0000
branchNewGRF_ports
changeset 6827 3274ed92c5d5
parent 6826 5d1265dc2a73
child 6828 8de7a4609b33
(svn r10910) [NewGRF_ports] -Fix: take foundations into account when determining the height of the 0,0 position of the airport.
src/aircraft_cmd.cpp
--- a/src/aircraft_cmd.cpp	Wed Aug 15 21:09:34 2007 +0000
+++ b/src/aircraft_cmd.cpp	Wed Aug 15 22:33:37 2007 +0000
@@ -431,7 +431,7 @@
 											 st->fsmportsspeclist[1].spec->size_y[st->FSMport_layout_set], st->FSMport_orientation);
 				v->x_pos = u->x_pos = TileX(st->airport_tile) * TILE_SIZE + amd.x;
 				v->y_pos = u->y_pos = TileY(st->airport_tile) * TILE_SIZE + amd.y;
-				u->z_pos = GetTileZ(st->airport_tile) + amd.z;
+				u->z_pos = GetTileMaxZ(st->airport_tile) + amd.z;
 				v->z_pos = u->z_pos + 1;
 				v->u.air.pos = apc->layout[i].position;
 				v->direction = amd.direction;
@@ -878,7 +878,7 @@
 	int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
 	int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
 	u->x_pos = x;
-	u->y_pos = y - ((v->z_pos-GetSlopeZ(safe_x, safe_y)) >> 3);;
+	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);
@@ -1094,7 +1094,7 @@
 	int y = TileY(tile) * TILE_SIZE;
 
 	/* Helicopter raise */
-	if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileZ(st->airport_tile))-1 ) < amd.z)) {
+	if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileMaxZ(st->airport_tile)) - 1) < amd.z)) {
 		Vehicle *u = v->next->next;
 
 		/* Make sure the rotors don't rotate too fast */
@@ -1117,7 +1117,7 @@
 	}
 
 	/* Helicopter landing. */
-	if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileZ(st->airport_tile))-1 ) > amd.z)) {
+	if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileMaxZ(st->airport_tile)) - 1) > amd.z)) {
 		count = UpdateAircraftSpeed(v);
 		if (count > 0) {
 			if (st->airport_tile == 0) {
@@ -1134,7 +1134,7 @@
 			v->tile = st->airport_tile;
 
 			/* Find altitude of landing position. */
-			int z = GetSlopeZ(x, y) + 1 + afc->delta_z;
+			int z = GetTileMaxZ(v->tile) + 1 + afc->delta_z;
 
 			if (z == v->z_pos) {
 				Vehicle *u = v->next->next;
@@ -1230,13 +1230,13 @@
 		/* Adjust Z for land or takeoff? */
 		int z = v->z_pos;
 
-		if ((int)v->z_pos < (amd.z + TilePixelHeight(st->airport_tile))) { //target position is higher, so increase altitude
-			z = min(z + 2, (v->u.air.state == ENDTAKEOFF)? GetAircraftFlyingAltitude(v) : amd.z + TilePixelHeight(st->airport_tile) );
+		if ((int)v->z_pos < (amd.z + GetTileMaxZ(st->airport_tile))) { //target position is higher, so increase altitude
+			z = min(z + 2, (v->u.air.state == ENDTAKEOFF)? GetAircraftFlyingAltitude(v) : amd.z + GetTileMaxZ(st->airport_tile) );
 		}
 
 		if ((amd.flag & AMED_HOLD) && (z > 150)) z--;
 
-		if ((amd.z + TilePixelHeight(st->airport_tile) + 1) < (int)v->z_pos) { //target position is lower, so decrease altitude
+		if ((amd.z + GetTileMaxZ(st->airport_tile) + 1) < (int)v->z_pos) { //target position is lower, so decrease altitude
 			if (st->airport_tile == 0) {
 				/* Airport has been removed, abort the landing procedure */
 				v->u.air.state = FLYING;
@@ -1247,14 +1247,14 @@
 				continue;
 			}
 
-			int curz = amd.z + TilePixelHeight(st->airport_tile) + 1;
+			int curz = amd.z + GetTileMaxZ(st->airport_tile) + 1;
 
 			if (curz > z) {
 				z++;
 			} else {
 				int t = max(1U, dist - 4);
 
-					z = ((((z * t - (z - curz))*2) / t) + 1)/2;
+				z = ((((z * t - (z - curz)) * 2) / t) + 1) / 2;
 				if (z < curz) z = curz;
 			}
 		}
@@ -1268,7 +1268,6 @@
 			} else if (z < curz) {
 				z++;
 			}
-
 		}
 
 		SetAircraftPosition(v, gp.x, gp.y, z);
@@ -2194,7 +2193,7 @@
 			if (IsAircraftInHangar(v_oldstyle)) {
 				/* airplane in hangar, ensure stopped, and safe state */
 				v_oldstyle->u.air.pos = 0;
-				z_offset =  (int)TilePixelHeight(v_oldstyle->tile) + 1;
+				z_offset =  (int)GetTileMaxZ(v_oldstyle->tile) + 1;
 				v_oldstyle->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
 				v_oldstyle->u.air.state = HANGAR;
 			} else {