diff options
author | rubidium <rubidium@openttd.org> | 2007-09-14 22:27:40 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-09-14 22:27:40 +0000 |
commit | fef64185b87e4517b7760e017171d646eaa1eb69 (patch) | |
tree | 66f89fc328e49813581c22632a0a9cb21d7c2eb8 /src/tunnelbridge_cmd.cpp | |
parent | 5647bd5157b623348feb202623057fd84eb9c3c5 (diff) | |
download | openttd-fef64185b87e4517b7760e017171d646eaa1eb69.tar.xz |
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 87abd7470..2ddefb554 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -32,6 +32,7 @@ #include "yapf/yapf.h" #include "date.h" #include "newgrf_sound.h" +#include "autoslope.h" #include "table/bridge_land.h" @@ -1416,6 +1417,30 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) { + if (_patches.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) { + DiagDirection direction = GetBridgeRampDirection(tile); + Axis axis = DiagDirToAxis(direction); + CommandCost res; + + /* Check if new slope is valid for bridges in general (so we can savely call GetBridgeFoundation()) */ + if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) { + res = CheckBridgeSlopeSouth(axis, tileh_new); + } else { + res = CheckBridgeSlopeNorth(axis, tileh_new); + } + + if (!CmdFailed(res)) { + uint z_old; + Slope tileh_old = GetTileSlope(tile, &z_old); + + z_old += ApplyFoundationToSlope(GetBridgeFoundation(tileh_old, axis), &tileh_old); + z_new += ApplyFoundationToSlope(GetBridgeFoundation(tileh_new, axis), &tileh_new); + + /* Surface slope remains unchanged? */ + if ((z_old == z_new) && (tileh_old == tileh_new)) return _price.terraform; + } + } + return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); } |