Change: Use "bridge ... too low" message for bridgeable objects (#15838)

This commit is contained in:
Peter Nelson
2026-07-09 19:56:06 +01:00
committed by GitHub
parent 83ce49f6cb
commit 85e6f020f9
2 changed files with 10 additions and 8 deletions
+1
View File
@@ -5364,6 +5364,7 @@ STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK :bridge is {HEIG
STR_ERROR_BRIDGE_TOO_LOW_FOR_TRAIN_DEPOT :bridge is {HEIGHT} too low for train depot
STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADVEH_DEPOT :bridge is {HEIGHT} too low for road vehicle depot
STR_ERROR_BRIDGE_TOO_LOW_FOR_SHIP_DEPOT :bridge is {HEIGHT} too low for ship depot
STR_ERROR_BRIDGE_TOO_LOW_FOR_OBJECT :bridge is {HEIGHT} too low for object
# Tunnel related errors
STR_ERROR_CAN_T_BUILD_TUNNEL_HERE :Can't build tunnel here...
+9 -8
View File
@@ -313,10 +313,11 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type
/* Finally do a check for bridges. */
for (TileIndex t : ta) {
if (IsBridgeAbove(t) && (
!spec->flags.Test(ObjectFlag::AllowUnderBridge) ||
(GetTileMaxZ(t) + spec->height >= GetBridgeHeight(GetSouthernBridgeEnd(t))))) {
return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
if (IsBridgeAbove(t)) {
if (!spec->flags.Test(ObjectFlag::AllowUnderBridge)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
int height_diff = GetTileMaxZ(t) + spec->height - GetBridgeHeight(GetSouthernBridgeEnd(t));
if (height_diff > 0) return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_OBJECT, height_diff * TILE_HEIGHT_STEP);
}
}
@@ -1011,11 +1012,11 @@ static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlags flags, in
static CommandCost CheckBuildAbove_Object(TileIndex tile, DoCommandFlags flags, [[maybe_unused]] Axis axis, int height)
{
const ObjectSpec *spec = ObjectSpec::GetByTile(tile);
if (spec->flags.Test(ObjectFlag::AllowUnderBridge) && GetTileMaxZ(tile) + spec->height <= height) {
return CommandCost();
}
if (!spec->flags.Test(ObjectFlag::AllowUnderBridge)) return Command<Commands::LandscapeClear>::Do(flags, tile);
return Command<Commands::LandscapeClear>::Do(flags, tile);
int height_diff = GetTileMaxZ(tile) + spec->height - height;
if (height_diff > 0) return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_OBJECT, height_diff * TILE_HEIGHT_STEP);
return CommandCost();
}
/** TileTypeProcs definitions for TileType::Object tiles. */