summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/road_cmd.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 0d286cb66..96f2b0b5c 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -499,12 +499,21 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (ret.Failed()) return ret;
}
- CommandCost ret = EnsureNoVehicleOnGround(tile);
- if (ret.Failed()) return ret;
+ DisallowedRoadDirections dis_existing = GetDisallowedRoadDirections(tile);
+ DisallowedRoadDirections dis_new = dis_existing ^ toggle_drd;
+
+ /* We allow removing disallowed directions to break up
+ * deadlocks, but adding them can break articulated
+ * vehicles. As such, only when less is disallowed,
+ * i.e. bits are removed, we skip the vehicle check. */
+ if (CountBits(dis_existing) <= CountBits(dis_new)) {
+ CommandCost ret = EnsureNoVehicleOnGround(tile);
+ if (ret.Failed()) return ret;
+ }
/* Ignore half built tiles */
if ((flags & DC_EXEC) && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
- SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd);
+ SetDisallowedRoadDirections(tile, dis_new);
MarkTileDirtyByTile(tile);
}
return CommandCost();