tunnelbridge_cmd.c
changeset 4156 0292b2b52e03
parent 4087 5ae6c880d66c
child 4158 a8f7265a6fd0
--- a/tunnelbridge_cmd.c	Fri Jul 21 06:37:09 2006 +0000
+++ b/tunnelbridge_cmd.c	Sat Jul 22 07:28:04 2006 +0000
@@ -597,13 +597,12 @@
 
 static uint GetBridgeHeightRamp(TileIndex t)
 {
-	/* Return the height there (the height of the NORTH CORNER)
-	 * If the end of the bridge is on a tile with all corners except the north corner raised,
-	 * the z coordinate is 1 height level too low. Compensate for that */
-	return
-		TilePixelHeight(t) +
-		(GetTileSlope(t, NULL) == SLOPE_WSE ? TILE_HEIGHT : 0) +
-		TILE_HEIGHT;
+	uint h;
+	uint tileh = GetTileSlope(t, &h);
+	uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
+
+	// one height level extra if the ramp is on a flat foundation
+	return h + TILE_HEIGHT + (IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0);
 }