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

Function PerformStationTileSlopeCheck

src/newgrf_station.cpp:676–695  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

674 * @return Succeeded or failed command.
675 */
676CommandCost 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/**

Callers 1

CheckFlatLandRailStationFunction · 0.85

Calls 8

GetTileSlopeFunction · 0.85
HasBitFunction · 0.85
TileXFunction · 0.85
TileYFunction · 0.85
CommandCostClass · 0.85
ToggleBitFunction · 0.85
ResolveCallbackMethod · 0.80

Tested by

no test coverage detected