From 3055d42fc4c0e58deb6b37ff712d754384b9c174 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 14 Sep 2007 22:27:40 +0000 Subject: (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. --- src/tunnelbridge_cmd.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/tunnelbridge_cmd.cpp') 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); } -- cgit v1.2.3-54-g00ecf