* Tests if a track can be build on a tile. * * @param tileh Tile slope. * @param rail_bits Tracks to build. * @param existing Tracks already built. * @param tile Tile (used for water test) * @return Error message or cost for foundation building. */
| 387 | * @return Error message or cost for foundation building. |
| 388 | */ |
| 389 | static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) |
| 390 | { |
| 391 | /* don't allow building on the lower side of a coast */ |
| 392 | if (GetFloodingBehaviour(tile) != FLOOD_NONE) { |
| 393 | if (!IsSteepSlope(tileh) && ((~_valid_tracks_on_leveled_foundation[tileh] & (rail_bits | existing)) != 0)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER); |
| 394 | } |
| 395 | |
| 396 | Foundation f_new = GetRailFoundation(tileh, rail_bits | existing); |
| 397 | |
| 398 | /* check track/slope combination */ |
| 399 | if ((f_new == FOUNDATION_INVALID) || |
| 400 | ((f_new != FOUNDATION_NONE) && (!_settings_game.construction.build_on_slopes))) { |
| 401 | return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); |
| 402 | } |
| 403 | |
| 404 | Foundation f_old = GetRailFoundation(tileh, existing); |
| 405 | return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price[PR_BUILD_FOUNDATION] : (Money)0); |
| 406 | } |
| 407 | |
| 408 | /* Validate functions for rail building */ |
| 409 | static inline bool ValParamTrackOrientation(Track track) |