summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-07-18 19:25:00 +0000
committerfrosch <frosch@openttd.org>2012-07-18 19:25:00 +0000
commitab2ce64b6b547f6e7e184593697227daceec82f2 (patch)
tree472bbffa7c6e690b8558a6290cb4fd948c9a005b
parent25203976f0605eef25ae0ac9b9a594b951957be2 (diff)
downloadopenttd-ab2ce64b6b547f6e7e184593697227daceec82f2.tar.xz
(svn r24414) -Fix [FS#5221]: Disallow removing roadtypes from bridges when not dragging in bridge direction.
-rw-r--r--src/road_cmd.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 0930d2ace..6f91e20be 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -216,6 +216,9 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
CommandCost cost(EXPENSES_CONSTRUCTION);
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+ /* Removing any roadbit in the bridge axis removes the roadtype (that's the behaviour remove-long-roads needs) */
+ if ((AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) & pieces) == ROAD_NONE) return_cmd_error(rt == ROADTYPE_TRAM ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD);
+
TileIndex other_end = GetOtherTunnelBridgeEnd(tile);
/* Pay for *every* tile of the bridge or tunnel */
uint len = GetTunnelBridgeLength(other_end, tile) + 2;
@@ -651,6 +654,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
case MP_TUNNELBRIDGE: {
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) goto do_clear;
+ /* Only allow building the outern roadbit, so building long roads stops at existing bridges */
if (MirrorRoadBits(DiagDirToRoadBits(GetTunnelBridgeDirection(tile))) != pieces) goto do_clear;
if (HasTileRoadType(tile, rt)) return_cmd_error(STR_ERROR_ALREADY_BUILT);
/* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */