diff --git a/src/lang/english.txt b/src/lang/english.txt index 295bf6d39b..b7736a13f0 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -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... diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 0dfb0a34d0..55490bf170 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -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::Do(flags, tile); - return Command::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. */