(svn r4790) Remove slope magic from EnsureNoVehicleZ() and rename it to EnsureNoVehicleOnGround() to make more clear what it does
authortron
Tue, 09 May 2006 09:56:09 +0000
changeset 3794 ac26a7b4615d
parent 3793 33cdb5bf7b21
child 3795 52398950b042
(svn r4790) Remove slope magic from EnsureNoVehicleZ() and rename it to EnsureNoVehicleOnGround() to make more clear what it does
functions.h
rail_cmd.c
road_cmd.c
tile.h
tunnelbridge_cmd.c
vehicle.c
--- a/functions.h	Tue May 09 08:25:31 2006 +0000
+++ b/functions.h	Tue May 09 09:56:09 2006 +0000
@@ -193,9 +193,8 @@
 bool ScrollMainWindowToTile(TileIndex tile);
 bool ScrollMainWindowTo(int x, int y);
 void DrawSprite(uint32 img, int x, int y);
-uint GetCorrectTileHeight(TileIndex tile);
 bool EnsureNoVehicle(TileIndex tile);
-bool EnsureNoVehicleZ(TileIndex tile, byte z);
+bool EnsureNoVehicleOnGround(TileIndex tile);
 void MarkAllViewportsDirty(int left, int top, int right, int bottom);
 void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost);
 void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost);
--- a/rail_cmd.c	Tue May 09 08:25:31 2006 +0000
+++ b/rail_cmd.c	Tue May 09 09:56:09 2006 +0000
@@ -349,7 +349,7 @@
 					GetTransportTypeUnderBridge(tile) != TRANSPORT_RAIL ||
 					GetRailBitsUnderBridge(tile) != trackbit ||
 					(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
-					!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) {
+					!EnsureNoVehicleOnGround(tile)) {
 				return CMD_ERROR;
 			}
 
--- a/road_cmd.c	Tue May 09 08:25:31 2006 +0000
+++ b/road_cmd.c	Tue May 09 09:56:09 2006 +0000
@@ -125,7 +125,7 @@
 
 	switch (GetTileType(tile)) {
 		case MP_TUNNELBRIDGE:
-			if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR;
+			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
 			if (!IsBridge(tile) ||
 					!IsBridgeMiddle(tile) ||
--- a/tile.h	Tue May 09 08:25:31 2006 +0000
+++ b/tile.h	Tue May 09 09:56:09 2006 +0000
@@ -32,13 +32,6 @@
 uint GetTileZ(TileIndex tile);
 uint GetTileMaxZ(TileIndex tile);
 
-static inline bool CorrectZ(Slope tileh)
-{
-	/* tile height must be corrected if the north corner is not raised, but
-	 * any other corner is. These are the cases 1 till 7 */
-	return IS_INT_INSIDE(tileh, 1, 8);
-}
-
 static inline uint TileHeight(TileIndex tile)
 {
 	assert(tile < MapSize());
--- a/tunnelbridge_cmd.c	Tue May 09 08:25:31 2006 +0000
+++ b/tunnelbridge_cmd.c	Tue May 09 09:56:09 2006 +0000
@@ -608,7 +608,7 @@
 			int32 cost;
 
 			// check if we own the tile below the bridge..
-			if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile))))
+			if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile)))
 				return CMD_ERROR;
 
 			if (GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) {
@@ -626,7 +626,7 @@
 			/* delete canal under bridge */
 
 			// check for vehicles under bridge
-			if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR;
+			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 
 			if (flags & DC_EXEC) {
 				SetClearUnderBridge(tile);
@@ -752,7 +752,7 @@
 			IsTransportUnderBridge(tile) &&
 			GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) {
 		// only check for train under bridge
-		if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile)))
+		if (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile))
 			return CMD_ERROR;
 
 		if (GetRailType(tile) == totype) return CMD_ERROR;
--- a/vehicle.c	Tue May 09 08:25:31 2006 +0000
+++ b/vehicle.c	Tue May 09 09:56:09 2006 +0000
@@ -131,30 +131,19 @@
 	const TileInfo *ti = data;
 
 	if (v->tile != ti->tile || v->type == VEH_Disaster) return NULL;
-	if (!IS_INT_INSIDE(ti->z - v->z_pos, 0, TILE_HEIGHT + 1)) return NULL;
+	if (v->z_pos > ti->z) return NULL;
 
 	VehicleInTheWayErrMsg(v);
 	return v;
 }
 
-static inline uint Correct_Z(Slope tileh)
-{
-	// needs z correction for slope-type graphics that have the NORTHERN tile lowered
-	return CorrectZ(tileh) ? TILE_HEIGHT : 0;
-}
 
-uint GetCorrectTileHeight(TileIndex tile)
-{
-	return Correct_Z(GetTileSlope(tile, NULL));
-}
-
-bool EnsureNoVehicleZ(TileIndex tile, byte z)
+bool EnsureNoVehicleOnGround(TileIndex tile)
 {
 	TileInfo ti;
 
 	ti.tile = tile;
-	ti.z = z + GetCorrectTileHeight(tile);
-
+	ti.z = GetTileMaxZ(tile);
 	return VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ) == NULL;
 }