* Check the slope of a tile of a new station. * @param north_tile Norther tile of the station rect. * @param cur_tile Tile to check. * @param statspec Station spec. * @param axis Axis of the new station. * @param plat_len Platform length. * @param numtracks Number of platforms. * @return Succeeded or failed command. */
| 674 | * @return Succeeded or failed command. |
| 675 | */ |
| 676 | CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, uint8_t plat_len, uint8_t numtracks) |
| 677 | { |
| 678 | TileIndex diff = cur_tile - north_tile; |
| 679 | Slope slope = GetTileSlope(cur_tile); |
| 680 | |
| 681 | StationResolverObject object(statspec, nullptr, cur_tile, CBID_STATION_LAND_SLOPE_CHECK, |
| 682 | (slope << 4) | (slope ^ (axis == AXIS_Y && HasBit(slope, CORNER_W) != HasBit(slope, CORNER_E) ? SLOPE_EW : 0)), |
| 683 | (numtracks << 24) | (plat_len << 16) | (axis == AXIS_Y ? TileX(diff) << 8 | TileY(diff) : TileY(diff) << 8 | TileX(diff))); |
| 684 | object.station_scope.axis = axis; |
| 685 | |
| 686 | std::array<int32_t, 16> regs100; |
| 687 | uint16_t cb_res = object.ResolveCallback(regs100); |
| 688 | |
| 689 | /* Failed callback means success. */ |
| 690 | if (cb_res == CALLBACK_FAILED) return CommandCost(); |
| 691 | |
| 692 | /* The meaning of bit 10 is inverted for a grf version < 8. */ |
| 693 | if (statspec->grf_prop.grffile->grf_version < 8) ToggleBit(cb_res, 10); |
| 694 | return GetErrorMessageFromLocationCallbackResult(cb_res, regs100, statspec->grf_prop.grffile, STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); |
| 695 | } |
| 696 | |
| 697 | |
| 698 | /** |
no test coverage detected