mirror of https://github.com/OpenTTD/OpenTTD
(svn r20230) -Fix [FS#3961]: road vehicles could be dead locked with one way roads. This allows one wayness to be removed if there are vehicles on a tile; it does not allow you to add one wayness to roads that have vehicles on them as it makes turning vehicles jump
parent
8df78e7a7b
commit
cfdcb6cbee
|
@ -499,12 +499,21 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandCost ret = EnsureNoVehicleOnGround(tile);
|
DisallowedRoadDirections dis_existing = GetDisallowedRoadDirections(tile);
|
||||||
if (ret.Failed()) return ret;
|
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 */
|
/* Ignore half built tiles */
|
||||||
if ((flags & DC_EXEC) && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
|
if ((flags & DC_EXEC) && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
|
||||||
SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd);
|
SetDisallowedRoadDirections(tile, dis_new);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
|
Loading…
Reference in New Issue