* 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 */
| 211 | * @return Error or cost for bridge foundation |
| 212 | */ |
| 213 | static 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? |
no test coverage detected