diff --git a/src/lang/english.txt b/src/lang/english.txt index af027e3b9b..e6c6a3d291 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -5264,6 +5264,7 @@ STR_ERROR_BRIDGE_TOO_LONG :{WHITE}... brid STR_ERROR_BRIDGE_THROUGH_MAP_BORDER :{WHITE}Bridge would end out of the map STR_ERROR_BRIDGE_TOO_LOW_FOR_STATION :{WHITE}Bridge is too low for station STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP :{WHITE}Bridge is too low for road stop +STR_ERROR_BRIDGE_TOO_LOW_FOR_DOCK :{WHITE}Bridge is too low for dock STR_ERROR_BRIDGE_TOO_LOW_FOR_BUOY :{WHITE}Bridge is too low for buoy STR_ERROR_BRIDGE_TOO_LOW_FOR_RAIL_WAYPOINT :{WHITE}Bridge is too low for rail waypoint STR_ERROR_BRIDGE_TOO_LOW_FOR_ROAD_WAYPOINT :{WHITE}Bridge is too low for road waypoint diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index ca2d16841f..2dfb49dc32 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -409,6 +409,8 @@ enum SaveLoadVersion : uint16_t { SLV_TOWN_SUPPLY_HISTORY, ///< 358 PR#14461 Town supply history. SLV_STATIONS_UNDER_BRIDGES, ///< 359 PR#14477 Allow stations under bridges. + SLV_DOCKS_UNDER_BRIDGES, ///< 360 PR#14594 Allow docks under bridges. + SL_MAX_VERSION, ///< Highest possible saveload version }; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index cd59fed02d..333460b53b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -864,7 +864,7 @@ static StringID GetBridgeTooLowMessageForStationType(StationType type) STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP, // Truck STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP, // Bus INVALID_STRING_ID, // Oilrig - INVALID_STRING_ID, // Dock + STR_ERROR_BRIDGE_TOO_LOW_FOR_DOCK, // Dock STR_ERROR_BRIDGE_TOO_LOW_FOR_BUOY, // Buoy STR_ERROR_BRIDGE_TOO_LOW_FOR_RAIL_WAYPOINT, // RailWaypoint STR_ERROR_BRIDGE_TOO_LOW_FOR_ROAD_WAYPOINT, // RoadWaypoint @@ -940,6 +940,21 @@ CommandCost IsRoadStationBridgeAboveOk(TileIndex tile, const RoadStopSpec *spec, return IsStationBridgeAboveOk(tile, bridgeable_info, type, layout, GetBridgeHeight(rampsouth), STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); } +/** + * Test if a dock can be built below a bridge. + * @param tile Tile to test. + * @param layout Layout piece of station to test. + * @return Command result. + */ +static CommandCost IsDockBridgeAboveOk(TileIndex tile, StationGfx layout) +{ + if (!IsBridgeAbove(tile)) return CommandCost(); + + TileIndex rampsouth = GetSouthernBridgeEnd(tile); + auto bridgeable_info = GetStationBridgeableTileInfo(StationType::Dock); + return IsStationBridgeAboveOk(tile, bridgeable_info, StationType::Dock, layout, GetBridgeHeight(rampsouth), STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); +} + /** * Checks if a rail station can be built at the given tile. * @param tile_cur Tile to check. @@ -2872,7 +2887,8 @@ CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags); if (ret.Failed()) return ret; - if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); + ret = IsDockBridgeAboveOk(tile, to_underlying(direction)); + if (ret.Failed()) return ret; CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_STATION_DOCK]); ret = Command::Do(flags, tile); @@ -2885,7 +2901,8 @@ CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station return CommandCost(STR_ERROR_SITE_UNSUITABLE); } - if (IsBridgeAbove(tile_cur)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); + ret = IsDockBridgeAboveOk(tile_cur, GFX_DOCK_BASE_WATER_PART + to_underlying(DiagDirToAxis(direction))); + if (ret.Failed()) return ret; /* Get the water class of the water tile before it is cleared.*/ WaterClass wc = GetWaterClass(tile_cur); diff --git a/src/table/station_land.h b/src/table/station_land.h index b33bf8ff4e..2552e6f761 100644 --- a/src/table/station_land.h +++ b/src/table/station_land.h @@ -919,6 +919,15 @@ static const BridgeableTileInfo _station_bridgeable_info_waypoint[] = { {2, {BridgePillarFlag::EdgeNW, BridgePillarFlag::EdgeSE}}, // Y-axis waypoint. }; +static const BridgeableTileInfo _station_bridgeable_info_dock[] = { + {2, {}}, // Northeast slope. + {2, {}}, // Southeast slope. + {2, {}}, // Southwest slope. + {2, {}}, // Northwest slope. + {3, {}}, // X-axis part on water. + {3, {}}, // Y-axis part on water. +}; + static const BridgeableTileInfo _station_bridgeable_info_buoy[] = { {1, {}}, }; @@ -947,7 +956,7 @@ static const std::array, to_underlying(Stati _station_bridgeable_info_roadstop, // Truck _station_bridgeable_info_roadstop, // Bus {}, // Oilrig - {}, // Dock + _station_bridgeable_info_dock, // Dock _station_bridgeable_info_buoy, // Buoy _station_bridgeable_info_waypoint, // RailWaypoint _station_bridgeable_info_road_waypoint, // RoadWaypoint