mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Simplify test for bridges above bridge ramps. (#14421)
parent
6d86c760c6
commit
b21c8a3450
|
@ -413,17 +413,13 @@ CommandCost CmdBuildBridge(DoCommandFlags flags, TileIndex tile_end, TileIndex t
|
||||||
if (terraform_cost_south.Failed() || (terraform_cost_south.GetCost() != 0 && !allow_on_slopes)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
if (terraform_cost_south.Failed() || (terraform_cost_south.GetCost() != 0 && !allow_on_slopes)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
cost.AddCost(terraform_cost_south.GetCost());
|
cost.AddCost(terraform_cost_south.GetCost());
|
||||||
|
|
||||||
const TileIndex heads[] = {tile_start, tile_end};
|
/* Check for bridges above the bridge ramps. */
|
||||||
for (int i = 0; i < 2; i++) {
|
for (TileIndex tile : {tile_start, tile_end}) {
|
||||||
if (IsBridgeAbove(heads[i])) {
|
if (!IsBridgeAbove(tile)) continue;
|
||||||
TileIndex north_head = GetNorthernBridgeEnd(heads[i]);
|
|
||||||
|
|
||||||
if (direction == GetBridgeAxis(heads[i])) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
if (direction == GetBridgeAxis(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||||
|
|
||||||
if (z_start + 1 == GetBridgeHeight(north_head)) {
|
if (z_start + 1 == GetBridgeHeight(GetNorthernBridgeEnd(tile))) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||||
return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TileIndexDiff delta = TileOffsByAxis(direction);
|
TileIndexDiff delta = TileOffsByAxis(direction);
|
||||||
|
|
Loading…
Reference in New Issue