1
0
Fork 0

Codechange: Simplify test for bridges above bridge ramps. (#14421)

pull/14188/merge
Peter Nelson 2025-07-08 13:55:36 +01:00 committed by GitHub
parent 6d86c760c6
commit b21c8a3450
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 9 deletions

View File

@ -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);