mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use TileOffsByAxis(...) in more places (#13026)
parent
c9819f8957
commit
d5a13fb9f4
|
@ -1013,7 +1013,7 @@ static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields)
|
|||
*/
|
||||
static void SetupFarmFieldFence(TileIndex tile, int size, uint8_t type, DiagDirection side)
|
||||
{
|
||||
TileIndexDiff diff = (DiagDirToAxis(side) == AXIS_Y ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
TileIndexDiff diff = TileOffsByAxis(OtherAxis(DiagDirToAxis(side)));
|
||||
TileIndexDiff neighbour_diff = TileOffsByDiagDir(side);
|
||||
|
||||
do {
|
||||
|
|
|
@ -1129,7 +1129,7 @@ std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlag flags, TileIndex
|
|||
|
||||
if (tile == end_tile) break;
|
||||
|
||||
tile += (axis == AXIS_Y) ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
||||
tile += TileOffsByAxis(axis);
|
||||
}
|
||||
|
||||
return { had_success ? cost : last_error, 0 };
|
||||
|
|
|
@ -264,7 +264,7 @@ void Station::MarkTilesDirty(bool cargo_change) const
|
|||
{
|
||||
assert(this->TileBelongsToRailStation(tile));
|
||||
|
||||
TileIndexDiff delta = (GetRailStationAxis(tile) == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
TileIndexDiff delta = TileOffsByAxis(GetRailStationAxis(tile));
|
||||
|
||||
TileIndex t = tile;
|
||||
uint len = 0;
|
||||
|
|
|
@ -1430,8 +1430,8 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
|
|||
st->cached_anim_triggers |= statspec->animation.triggers;
|
||||
}
|
||||
|
||||
TileIndexDiff tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); // offset to go to the next platform tile
|
||||
TileIndexDiff track_delta = (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); // offset to go to the next track
|
||||
TileIndexDiff tile_delta = TileOffsByAxis(axis); // offset to go to the next platform tile
|
||||
TileIndexDiff track_delta = TileOffsByAxis(OtherAxis(axis)); // offset to go to the next track
|
||||
Track track = AxisToTrack(axis);
|
||||
|
||||
std::vector<uint8_t> layouts(numtracks * plat_len);
|
||||
|
|
|
@ -3620,7 +3620,7 @@ static Vehicle *CollectTrackbitsFromCrashedVehiclesEnum(Vehicle *v, void *data)
|
|||
|
||||
static bool IsRailStationPlatformOccupied(TileIndex tile)
|
||||
{
|
||||
TileIndexDiff delta = (GetRailStationAxis(tile) == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
TileIndexDiff delta = TileOffsByAxis(GetRailStationAxis(tile));
|
||||
|
||||
for (TileIndex t = tile; IsCompatibleTrainStationTile(t, tile); t -= delta) {
|
||||
if (HasVehicleOnPos(t, nullptr, &TrainOnTileEnum)) return true;
|
||||
|
|
|
@ -439,7 +439,7 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti
|
|||
}
|
||||
}
|
||||
|
||||
TileIndexDiff delta = (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
TileIndexDiff delta = TileOffsByAxis(direction);
|
||||
for (TileIndex tile = tile_start + delta; tile != tile_end; tile += delta) {
|
||||
if (GetTileMaxZ(tile) > z_start) return_cmd_error(STR_ERROR_BRIDGE_TOO_LOW_FOR_TERRAIN);
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ static void MarkCanalsAndRiversAroundDirty(TileIndex tile)
|
|||
CommandCost CmdBuildShipDepot(DoCommandFlag flags, TileIndex tile, Axis axis)
|
||||
{
|
||||
if (!IsValidAxis(axis)) return CMD_ERROR;
|
||||
TileIndex tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
TileIndex tile2 = tile + TileOffsByAxis(axis);
|
||||
|
||||
if (!HasTileWaterGround(tile) || !HasTileWaterGround(tile2)) {
|
||||
return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
|
||||
|
|
|
@ -280,7 +280,7 @@ inline DiagDirection GetShipDepotDirection(Tile t)
|
|||
*/
|
||||
inline TileIndex GetOtherShipDepotTile(Tile t)
|
||||
{
|
||||
return TileIndex(t) + (GetShipDepotPart(t) != DEPOT_PART_NORTH ? -1 : 1) * (GetShipDepotAxis(t) != AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
|
||||
return TileIndex(t) + (GetShipDepotPart(t) != DEPOT_PART_NORTH ? -1 : 1) * TileOffsByAxis(GetShipDepotAxis(t));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue