diff options
author | frosch <frosch@openttd.org> | 2008-01-22 16:08:17 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-01-22 16:08:17 +0000 |
commit | b99c83246b4029f91579712ae9044fa9e1f6b2c9 (patch) | |
tree | 78534c41444e96dbc9179ae15b7f8cbdddcaa1c4 /src/tunnelbridge_cmd.cpp | |
parent | 7d1e3086b8dfb7ffdf75478e159ce90543a1ee6e (diff) | |
download | openttd-b99c83246b4029f91579712ae9044fa9e1f6b2c9.tar.xz |
(svn r11946) -Fix: slope detection of bridge ramps.
YAPF failed for steep slopes.
Trolly failed for a lot.
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index c79f272ab..52762f9f5 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -90,6 +90,20 @@ Foundation GetBridgeFoundation(Slope tileh, Axis axis) return (HasSlopeHighestCorner(tileh) ? InclinedFoundation(axis) : FlatteningFoundation(tileh)); } +/** + * Determines if the track on a bridge ramp is flat or goes up/down. + * + * @param tileh Slope of the tile under the bridge head + * @param axis Orientation of bridge + * @return true iff the track is flat. + */ +bool HasBridgeFlatRamp(Slope tileh, Axis axis) +{ + ApplyFoundationToSlope(GetBridgeFoundation(tileh, axis), &tileh); + /* If the foundation slope is flat the bridge has a non-flat ramp and vice versa. */ + return (tileh != SLOPE_FLAT); +} + static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table) { const Bridge *bridge = &_bridge[index]; @@ -1084,7 +1098,6 @@ void DrawBridgeMiddle(const TileInfo* ti) static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) { - static const uint32 BRIDGE_HORZ_RAMP = (1 << SLOPE_SW) | (1 << SLOPE_SE) | (1 << SLOPE_NW) | (1 << SLOPE_NE); uint z; Slope tileh = GetTileSlope(tile, &z); @@ -1106,7 +1119,7 @@ static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) if (5 <= pos && pos <= 10) { uint delta; - if (HasBit(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT; + if (tileh != SLOPE_FLAT) return z + TILE_HEIGHT; switch (dir) { default: NOT_REACHED(); |