summaryrefslogtreecommitdiff
path: root/tunnelbridge_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-01-27 12:52:20 +0000
committertron <tron@openttd.org>2005-01-27 12:52:20 +0000
commit63653bd6aff20948868d9d6cf01d00e3a8c31d8f (patch)
tree3d5f382fb85ba8444b4f6b8788fddbaa84031924 /tunnelbridge_cmd.c
parent6eec07257a86cb23f1b4efc11e184dff100a452e (diff)
downloadopenttd-63653bd6aff20948868d9d6cf01d00e3a8c31d8f.tar.xz
(svn r1696) Use GetTileSlope() instead of FindLandscapeHeightByTile() where it is sufficient. FindLandscapeHeightByTile() uses GetTileSlope() internally and adds some more info, which is discarded in these cases.
While touching the code make a bit more clear how GetBridgeHeight() works.
Diffstat (limited to 'tunnelbridge_cmd.c')
-rw-r--r--tunnelbridge_cmd.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 156ea8a23..62418e2d3 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -905,9 +905,7 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
static uint GetBridgeHeight(const TileInfo *ti)
{
uint delta;
- TileInfo ti_end;
- uint tile = ti->tile;
- uint z_correction = 0;
+ TileIndex tile = ti->tile;
// find the end tile of the bridge.
delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0);
@@ -916,14 +914,10 @@ static uint GetBridgeHeight(const TileInfo *ti)
tile += delta;
} while (_map5[tile] & 0x40); // while bridge middle parts
- // if the end of the bridge is on a tileh 7, the z coordinate is 1 tile too low
- // correct it.
- FindLandscapeHeightByTile(&ti_end, tile);
- if (HASBIT(1 << 7, ti_end.tileh))
- z_correction += 8;
-
- // return the height there (the height of the NORTH CORNER)
- return TilePixelHeight(tile) + z_correction;
+ /* Return the height there (the height of the NORTH CORNER)
+ * If the end of the bridge is on a tileh 7 (all raised, except north corner),
+ * the z coordinate is 1 height level too low. Compensate for that */
+ return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == 7 ? 8 : 0);
}
static const byte _bridge_foundations[2][16] = {