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

Function CheckBridgeSlope

src/tunnelbridge_cmd.cpp:213–231  ·  view source on GitHub ↗

* Determines the foundation for the bridge head, and tests if the resulting slope is valid. * * @param bridge_piece Direction of the bridge head. * @param axis Axis of the bridge * @param tileh Slope of the tile under the north bridge head; returns slope on top of foundation * @param z TileZ corresponding to tileh, gets modified as well * @return Error or cost for bridge foundation */

Source from the content-addressed store, hash-verified

211 * @return Error or cost for bridge foundation
212 */
213static CommandCost CheckBridgeSlope(BridgePieces bridge_piece, Axis axis, Slope &tileh, int &z)
214{
215 assert(bridge_piece == BRIDGE_PIECE_NORTH || bridge_piece == BRIDGE_PIECE_SOUTH);
216
217 Foundation f = GetBridgeFoundation(tileh, axis);
218 z += ApplyFoundationToSlope(f, tileh);
219
220 Slope valid_inclined;
221 if (bridge_piece == BRIDGE_PIECE_NORTH) {
222 valid_inclined = (axis == AXIS_X ? SLOPE_NE : SLOPE_NW);
223 } else {
224 valid_inclined = (axis == AXIS_X ? SLOPE_SW : SLOPE_SE);
225 }
226 if ((tileh != SLOPE_FLAT) && (tileh != valid_inclined)) return CMD_ERROR;
227
228 if (f == FOUNDATION_NONE) return CommandCost();
229
230 return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
231}
232
233/**
234 * Is a bridge of the specified type and length available?

Callers 2

CmdBuildBridgeFunction · 0.85

Calls 3

GetBridgeFoundationFunction · 0.85
ApplyFoundationToSlopeFunction · 0.85
CommandCostClass · 0.85

Tested by

no test coverage detected