(svn r5352) -Fix: Return accurate slope information for tunnels and bridges to fix several foundation graphics glitches
authortron
Sat, 24 Jun 2006 22:52:24 +0000
changeset 4062 e4a3faed6fe4
parent 4061 219f9d065a28
child 4063 f45785a1b41e
(svn r5352) -Fix: Return accurate slope information for tunnels and bridges to fix several foundation graphics glitches
tunnelbridge_cmd.c
--- a/tunnelbridge_cmd.c	Sat Jun 24 22:19:28 2006 +0000
+++ b/tunnelbridge_cmd.c	Sat Jun 24 22:52:24 2006 +0000
@@ -1146,8 +1146,29 @@
 
 static Slope GetSlopeTileh_TunnelBridge(TileIndex tile, Slope tileh)
 {
-	// not accurate, but good enough for slope graphics drawing
-	return SLOPE_FLAT;
+	uint f;
+
+	if (IsTunnel(tile)) {
+		return tileh;
+	} else {
+		if (IsBridgeRamp(tile)) {
+			if (HASBIT(BRIDGE_NO_FOUNDATION, tileh)) {
+				return tileh;
+			} else {
+				f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
+			}
+		} else {
+			if (IsTransportUnderBridge(tile)) {
+				f = _bridge_foundations[GetBridgeAxis(tile)][tileh];
+			} else {
+				return tileh;
+			}
+		}
+	}
+
+	if (f == 0) return tileh;
+	if (f < 15) return SLOPE_FLAT;
+	return _inclined_tileh[f - 15];
 }