Codechange: Simplify test for bridges above bridge ramps. (#14421)
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user