* Test if a bridge can be built above a station. * @param tile Tile to test. * @param spec Custom station spec to test. * @param type Type of station. * @param layout Layout piece of road station to test. * @param bridge_height Height of bridge to test. * @param disallowed_msg Error message if bridge is disallowed. * @return Command result. */
| 885 | * @return Command result. |
| 886 | */ |
| 887 | static CommandCost IsStationBridgeAboveOk(TileIndex tile, std::span<const BridgeableTileInfo> bridgeable_info, StationType type, StationGfx layout, int bridge_height, StringID disallowed_msg = INVALID_STRING_ID) |
| 888 | { |
| 889 | int height = layout < std::size(bridgeable_info) ? bridgeable_info[layout].height : 0; |
| 890 | |
| 891 | if (height == 0) { |
| 892 | if (disallowed_msg != INVALID_STRING_ID) return CommandCost{disallowed_msg}; |
| 893 | /* Get normal error message associated with clearing the tile. */ |
| 894 | return Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::Auto, tile); |
| 895 | } |
| 896 | if (GetTileMaxZ(tile) + height > bridge_height) { |
| 897 | int height_diff = (GetTileMaxZ(tile) + height - bridge_height) * TILE_HEIGHT_STEP; |
| 898 | return CommandCostWithParam(GetBridgeTooLowMessageForStationType(type), height_diff); |
| 899 | } |
| 900 | |
| 901 | return CommandCost{}; |
| 902 | } |
| 903 | |
| 904 | /** |
| 905 | * Get bridgeable tile information for a station type. |
no test coverage detected