MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsStationBridgeAboveOk

Function IsStationBridgeAboveOk

src/station_cmd.cpp:887–902  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

885 * @return Command result.
886 */
887static 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.

Callers 5

IsDockBridgeAboveOkFunction · 0.85
IsBuoyBridgeAboveOkFunction · 0.85
CheckBuildAbove_StationFunction · 0.85

Calls 4

GetTileMaxZFunction · 0.85
CommandCostWithParamFunction · 0.70
sizeFunction · 0.50

Tested by

no test coverage detected