OpenTTD Source: src/map_func.h File Reference

OpenTTD Source 14.0-beta3

Data Structures | Macros | Typedefs | Functions
map_func.h File Reference
`#include "core/math_func.hpp"`
`#include "tile_type.h"`
`#include "map_type.h"`
`#include "direction_func.h"`

Go to the source code of this file.

## Data Structures
class | Tile
| Wrapper class to abstract away the way the tiles are stored. More...
struct | Tile::TileBase
| Data that is stored per tile. More...
struct | Tile::TileExtended
| Data that is stored per tile. More...
struct | Map
| Size related data of the map. More...
struct | Map::Iterator
| Iterator to iterate all Tiles. More...
struct | Map::IterateWrapper

## Macros
#define | TILE_ADD(x, y) ((x) + (y))
| Adds two tiles together. More...
#define | TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
| Adds a given offset to a tile. More...
#define | RandomTile() RandomTileSeed(Random())
| Get a valid random tile. More...

## Typedefs
typedef int32_t | TileIndexDiff
| An offset value between two tiles. More...
typedef bool | TestTileOnSearchProc(TileIndex tile, void *user_data)
| A callback function type for searching tiles. More...

## Functions
static debug_inline TileIndex | TileXY (uint x, uint y)
| Returns the TileIndex of a coordinate. More...
TileIndexDiff | TileDiffXY (int x, int y)
| Calculates an offset for the given coordinate(-offset). More...
static debug_inline TileIndex | TileVirtXY (uint x, uint y)
| Get a tile from the virtual XY-coordinate. More...
static debug_inline uint | TileX (TileIndex tile)
| Get the X component of a tile. More...
static debug_inline uint | TileY (TileIndex tile)
| Get the Y component of a tile. More...
TileIndexDiff | ToTileIndexDiff (TileIndexDiffC tidc)
| Return the offset between two tiles from a TileIndexDiffC struct. More...
TileIndex | TileAddWrap (TileIndex tile, int addx, int addy)
| This function checks if we add addx/addy to tile, if we do wrap around the edges. More...
TileIndexDiffC | TileIndexDiffCByDiagDir (DiagDirection dir)
| Returns the TileIndexDiffC offset from a DiagDirection. More...
TileIndexDiffC | TileIndexDiffCByDir (Direction dir)
| Returns the TileIndexDiffC offset from a Direction. More...
TileIndex | AddTileIndexDiffCWrap (TileIndex tile, TileIndexDiffC diff)
| Add a TileIndexDiffC to a TileIndex and returns the new one. More...
TileIndexDiffC | TileIndexToTileIndexDiffC (TileIndex tile_a, TileIndex tile_b)
| Returns the diff between two tiles. More...
uint | DistanceManhattan (TileIndex, TileIndex)
| also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads) More...
uint | DistanceSquare (TileIndex, TileIndex)
| euclidian- or L2-Norm squared More...
uint | DistanceMax (TileIndex, TileIndex)
| also known as L-Infinity-Norm More...
uint | DistanceMaxPlusManhattan (TileIndex, TileIndex)
| Max + Manhattan. More...
uint | DistanceFromEdge (TileIndex)
| shortest distance from any edge of the map More...
uint | DistanceFromEdgeDir (TileIndex, DiagDirection)
| distance from the map edge in given direction More...
TileIndexDiff | TileOffsByDiagDir (DiagDirection dir)
| Convert a DiagDirection to a TileIndexDiff. More...
TileIndexDiff | TileOffsByDir (Direction dir)
| Convert a Direction to a TileIndexDiff. More...
TileIndex | TileAddByDir (TileIndex tile, Direction dir)
| Adds a Direction to a tile. More...
TileIndex | TileAddByDiagDir (TileIndex tile, DiagDirection dir)
| Adds a DiagDir to a tile. More...
DiagDirection | DiagdirBetweenTiles (TileIndex tile_from, TileIndex tile_to)
| Determines the DiagDirection to get from one tile to another. More...
bool | CircularTileSearch (TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
| Function performing a search around a center tile and going outward, thus in circle. More...
bool | CircularTileSearch (TileIndex *tile, uint radius, uint w, uint h, TestTileOnSearchProc proc, void *user_data)
| Generalized circular search allowing for rectangles and a hole. More...
TileIndex | RandomTileSeed (uint32_t r)
| Get a random tile out of a given seed. More...
uint | GetClosestWaterDistance (TileIndex tile, bool water)
| Finds the distance for the closest tile with water/land given a tile. More...

## Detailed Description

Functions related to maps.

Definition in file map_func.h.

## Macro Definition Documentation

## ◆ RandomTile

#define RandomTile | ( |  | ) | RandomTileSeed(Random())

Get a valid random tile.

Note
  a define so 'random' gets inserted in the place where it is actually called, thus making the random traces more explicit.

Returns
  a valid tile

Definition at line 657 of file map_func.h.

## ◆ TILE_ADD

#define TILE_ADD | ( |  | x,
|  |  | y
| ) |  | ((x) + (y))

Adds two tiles together.

Parameters

  x | One tile
  y | Another tile to add

Returns
  The resulting tile(index)

Definition at line 466 of file map_func.h.

## ◆ TILE_ADDXY

#define TILE_ADDXY | ( |  | tile,
|  |  | x,
|  |  | y
| ) |  | TILE_ADD(tile, TileDiffXY(x, y))

Adds a given offset to a tile.

Parameters

  tile | The tile to add an offset on it
  x | The x offset to add to the tile
  y | The y offset to add to the tile

Definition at line 480 of file map_func.h.

## Typedef Documentation

## ◆ TestTileOnSearchProc

typedef bool TestTileOnSearchProc(TileIndex tile, void *user_data)

A callback function type for searching tiles.

Parameters

  tile | The tile to test
  user_data | additional data for the callback function to use

Returns
  A boolean value, depend on the definition of the function.

Definition at line 636 of file map_func.h.

## ◆ TileIndexDiff

typedef int32_t TileIndexDiff

An offset value between two tiles.

This value is used for the difference between two tiles. It can be added to a TileIndex to get the resulting TileIndex of the start tile applied with this saved difference.

See also
  TileDiffXY(int, int)

Definition at line 376 of file map_func.h.

## Function Documentation

## ◆ AddTileIndexDiffCWrap()

TileIndex AddTileIndexDiffCWrap | ( | TileIndex | tile,
|  | TileIndexDiffC | diff
| ) |  |
| inline

Add a TileIndexDiffC to a TileIndex and returns the new one.

Returns tile + the diff given in diff. If the result tile would end up outside of the map, INVALID_TILE is returned instead.

Parameters

  tile | The base tile to add the offset on
  diff | The offset to add on the tile

Returns
  The resulting TileIndex

Definition at line 522 of file map_func.h.

Referenced by CalculateCoverageLine().

## ◆ CircularTileSearch() [1/2]

bool CircularTileSearch | ( | TileIndex * | tile,
|  | uint | radius,
|  | uint | w,
|  | uint | h,
|  | TestTileOnSearchProc | proc,
|  | void * | user_data
| ) |  |

Generalized circular search allowing for rectangles and a hole.

Function performing a search around a center rectangle and going outward. The center rectangle is left out from the search. To do a rectangular search without a hole, set either h or w to zero. Every tile will be tested by means of the callback function proc, which will determine if yes or no the given tile meets criteria of search.

Parameters

  tile | to start the search from. Upon completion, it will return the tile matching the search. This tile should be directly north of the hole (if any).
  radius | How many tiles to search outwards. Note: This is a radius and thus different from the size parameter of the other CircularTileSearch function, which is a diameter.
  w | the width of the inner rectangle
  h | the height of the inner rectangle
  proc | callback testing function pointer.
  user_data | to be passed to the callback function. Depends on the implementation

Returns
  result of the search

Precondition
  proc != nullptr
  radius > 0

Definition at line 298 of file map.cpp.

## ◆ CircularTileSearch() [2/2]

bool CircularTileSearch | ( | TileIndex * | tile,
|  | uint | size,
|  | TestTileOnSearchProc | proc,
|  | void * | user_data
| ) |  |

Function performing a search around a center tile and going outward, thus in circle.

Although it really is a square search... Every tile will be tested by means of the callback function proc, which will determine if yes or no the given tile meets criteria of search.

Parameters

  tile | to start the search from. Upon completion, it will return the tile matching the search
  size | number of tiles per side of the desired search area
  proc | callback testing function pointer.
  user_data | to be passed to the callback function. Depends on the implementation

Returns
  result of the search

Precondition
  proc != nullptr
  size > 0

Definition at line 260 of file map.cpp.

References CircularTileSearch(), DIR_N, and TileAddByDir().

Referenced by ChopLumberMillTrees(), CircularTileSearch(), CreateRivers(), FindNearestGoodCoastalTownSpot(), GetDistanceFromNearbyHouse(), GrowTownWithBridge(), TownActionBuildStatue(), and TryBuildTransmitter().

## ◆ DiagdirBetweenTiles()

DiagDirection DiagdirBetweenTiles | ( | TileIndex | tile_from,
|  | TileIndex | tile_to
| ) |  |
| inline

Determines the DiagDirection to get from one tile to another.

The tiles do not necessarily have to be adjacent.

Parameters

  tile_from | Origin tile
  tile_to | Destination tile

Returns
  DiagDirection from tile_from towards tile_to, or INVALID_DIAGDIR if the tiles are not on an axis

Definition at line 616 of file map_func.h.

References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, INVALID_DIAGDIR, TileX(), and TileY().

Referenced by TrainController().

## ◆ DistanceFromEdge()

uint DistanceFromEdge | ( | TileIndex | tile | ) |

shortest distance from any edge of the map

shortest distance from any edge of the map

Parameters

  tile | the tile to get the distance from

Returns
  the distance from the edge in tiles

Definition at line 219 of file map.cpp.

References Map::SizeX(), Map::SizeY(), TileX(), and TileY().

Referenced by GrowTownWithExtraHouse(), IsRoadAllowedHere(), and TownCanBePlacedHere().

## ◆ DistanceFromEdgeDir()

uint DistanceFromEdgeDir | ( | TileIndex | tile,
|  | DiagDirection | dir
| ) |  |

distance from the map edge in given direction

distance from the map edge in given direction

Parameters

  tile | the tile to get the distance from
  dir | the direction of interest

Returns
  the distance from the edge in tiles

Definition at line 236 of file map.cpp.

References _settings_game, GameSettings::construction, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, ConstructionSettings::freeform_edges, Map::MaxX(), Map::MaxY(), TileX(), and TileY().

Referenced by CheckScaledDistanceFromEdge(), and GetOtherAqueductEnd().

## ◆ DistanceManhattan()

uint DistanceManhattan | ( | TileIndex | t0,
|  | TileIndex | t1
| ) |  |

also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)

also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)

The Manhattan distance is the sum of the delta of both the X and Y component. Also known as L1-Norm

Parameters

  t0 | the start tile
  t1 | the end tile

Returns
  the distance

Definition at line 159 of file map.cpp.

References Delta(), TileX(), and TileY().

Referenced by AirportGetNearestTown(), CheckSubsidyDistance(), DeleteStaleLinks(), FindDeletedWaypointCloseTo(), FindSubsidyPassengerRoute(), FlowRiver(), FlowsDown(), GetClosestObject(), CargoPacket::GetDistance(), GetDistanceFromNearbyHouse(), IndustriesScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), VpSetPresizeRange(), and YapfTrainCheckReverse().

## ◆ DistanceMax()

uint DistanceMax | ( | TileIndex | t0,
|  | TileIndex | t1
| ) |  |

also known as L-Infinity-Norm

also known as L-Infinity-Norm

Also known as L-Infinity-Norm.

Parameters

  t0 | the start tile
  t1 | the end tile

Returns
  the distance

Definition at line 191 of file map.cpp.

References Delta(), TileX(), and TileY().

Referenced by Station::AddIndustryToDeliver(), CheckIfFarEnoughFromConflictingIndustry(), and CheckIfIndustryIsAllowed().

## ◆ DistanceMaxPlusManhattan()

uint DistanceMaxPlusManhattan | ( | TileIndex | t0,
|  | TileIndex | t1
| ) |  |

Max + Manhattan.

Max + Manhattan.

two times the biggest distance component and once the smallest component.

Parameters

  t0 | the start tile
  t1 | the end tile

Returns
  the distance

Definition at line 207 of file map.cpp.

References Delta(), TileX(), and TileY().

Referenced by DemandCalculator::CalcDemand().

## ◆ DistanceSquare()

uint DistanceSquare | ( | TileIndex | t0,
|  | TileIndex | t1
| ) |  |

euclidian- or L2-Norm squared

euclidian- or L2-Norm squared

The 'Square' distance is the square of the shortest (straight line) distance between the two tiles. Also known as euclidian- or L2-Norm squared.

Parameters

  t0 | the start tile
  t1 | the end tile

Returns
  the distance

Definition at line 176 of file map.cpp.

References TileX(), and TileY().

Referenced by CmdBuildBridge(), CmdBuildTunnel(), GetTownRadiusGroup(), IndustriesScopeResolver::GetVariable(), and ObjectScopeResolver::GetVariable().

## ◆ GetClosestWaterDistance()

uint GetClosestWaterDistance | ( | TileIndex | tile,
|  | bool | water
| ) |  |

Finds the distance for the closest tile with water/land given a tile.

Parameters

  tile | the tile to find the distance too
  water | whether to find water or land

Returns
  distance to nearest water (max 0x7F) / land (max 0x1FF; 0x200 if there is no land)

Definition at line 342 of file map.cpp.

References HasTileWaterGround().

Referenced by FindFurthestFromWater(), and IndustriesScopeResolver::GetVariable().

## ◆ RandomTileSeed()

TileIndex RandomTileSeed | ( | uint32_t | r | ) |
| inline

Get a random tile out of a given seed.

Parameters

  r | the random 'seed'

Returns
  a valid tile

Definition at line 646 of file map_func.h.

References Map::WrapToMap().

## ◆ TileAddByDiagDir()

TileIndex TileAddByDiagDir | ( | TileIndex | tile,
|  | DiagDirection | dir
| ) |  |
| inline

Adds a DiagDir to a tile.

Parameters

  tile | The current tile
  dir | The direction in which we want to step

Returns
  the moved tile

Definition at line 604 of file map_func.h.

References TILE_ADD, and TileOffsByDiagDir().

Referenced by CleanUpRoadBits(), ClearPathReservation(), DrawRoadTypeCatenary(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), GrowTownWithBridge(), GrowTownWithExtraHouse(), GrowTownWithTunnel(), MarkDirtyAdjacentLevelCrossingTiles(), MaskWireBits(), RiverMakeWider(), SetWaterClassDependingOnSurroundings(), TryPathReserve(), and UpdateLevelCrossing().

## ◆ TileAddByDir()

TileIndex TileAddByDir | ( | TileIndex | tile,
|  | Direction | dir
| ) |  |
| inline

Adds a Direction to a tile.

Parameters

  tile | The current tile
  dir | The direction in which we want to step

Returns
  the moved tile

Definition at line 592 of file map_func.h.

References TILE_ADD, and TileOffsByDir().

Referenced by CircularTileSearch().

## ◆ TileAddWrap()

TileIndex TileAddWrap | ( | TileIndex | tile,
|  | int | addx,
|  | int | addy
| ) |  |

This function checks if we add addx/addy to tile, if we do wrap around the edges.

For example, tile = (10,2) and addx = +3 and addy = -4. This function will now return INVALID_TILE, because the y is wrapped. This is needed in for example, farmland. When the tile is not wrapped, the result will be tile + TileDiffXY(addx, addy)

Parameters

  tile | the 'starting' point of the adding
  addx | the amount of tiles in the X direction to add
  addy | the amount of tiles in the Y direction to add

Returns
  translated tile, or INVALID_TILE when it would've wrapped.

Definition at line 116 of file map.cpp.

Referenced by CheckIfIndustryTilesAreFree(), CmdRemoveRoadStop(), and CountMapSquareAround().

## ◆ TileDiffXY()

TileIndexDiff TileDiffXY | ( | int | x,
|  | int | y
| ) |  |
| inline

Calculates an offset for the given coordinate(-offset).

This function calculate an offset value which can be added to a TileIndex. The coordinates can be negative.

Parameters

  x | The offset in x direction
  y | The offset in y direction

Returns
  The resulting offset value of the given coordinate

See also
  ToTileIndexDiff(TileIndexDiffC)

Definition at line 401 of file map_func.h.

Referenced by CheckIfCanLevelIndustryPlatform(), CmdBuildShipDepot(), CmdTerraformLand(), GetOtherShipDepotTile(), Station::GetPlatformLength(), GetReferenceTile(), Airport::GetRotatedTileFromOffset(), GUIPlaceProcDragXY(), Station::MarkTilesDirty(), OrthogonalTileIterator::operator++(), SetupFarmFieldFence(), and TerraformAddDirtyTileAround().

## ◆ TileIndexDiffCByDiagDir()

TileIndexDiffC TileIndexDiffCByDiagDir | ( | DiagDirection | dir | ) |
| inline

Returns the TileIndexDiffC offset from a DiagDirection.

Parameters

  dir | The given direction

Returns
  The offset as TileIndexDiffC value

Definition at line 490 of file map_func.h.

References _tileoffs_by_diagdir, DIAGDIR_END, and IsValidDiagDirection().

Referenced by CalculateCoverageLine().

## ◆ TileIndexDiffCByDir()

TileIndexDiffC TileIndexDiffCByDir | ( | Direction | dir | ) |
| inline

Returns the TileIndexDiffC offset from a Direction.

Parameters

  dir | The given direction

Returns
  The offset as TileIndexDiffC value

Definition at line 504 of file map_func.h.

References _tileoffs_by_dir, DIR_END, and IsValidDirection().

## ◆ TileIndexToTileIndexDiffC()

TileIndexDiffC TileIndexToTileIndexDiffC | ( | TileIndex | tile_a,
|  | TileIndex | tile_b
| ) |  |
| inline

Returns the diff between two tiles.

Parameters

  tile_a | from tile
  tile_b | to tile

Returns
  the difference between tila_a and tile_b

Definition at line 538 of file map_func.h.

References TileX(), TileY(), TileIndexDiffC::x, and TileIndexDiffC::y.

Referenced by GetTownRoadGridElement(), TownLayoutAllows2x2HouseHere(), and TownLayoutAllowsHouseHere().

## ◆ TileOffsByDiagDir()

TileIndexDiff TileOffsByDiagDir | ( | DiagDirection | dir | ) |
| inline

Convert a DiagDirection to a TileIndexDiff.

Parameters

  dir | The DiagDirection

Returns
  The resulting TileIndexDiff

See also
  TileIndexDiffCByDiagDir

Definition at line 563 of file map_func.h.

References _tileoffs_by_diagdir, DIAGDIR_END, IsValidDiagDirection(), and ToTileIndexDiff().

Referenced by CanConnectToRoad(), CanFollowRoad(), CanRoadContinueIntoNextTile(), CheckForDockingTile(), CheckFree2x2Area(), RoadStop::Entry::CheckIntegrity(), CheckTownBuild2House(), CheckTownBuild2x2House(), ClearDockingTilesCheckingNeighbours(), RoadStop::ClearDriveThrough(), CmdBuildLongRoad(), ConnectRoadToStructure(), DisasterTick_Submarine(), DoBuildLock(), DoClearBridge(), ExtendTrainReservation(), FindDockLandPart(), FixOwnerOfRailTrack(), FollowReservation(), FollowTrainReservation(), GetBridgeEnd(), GetOtherAqueductEnd(), GetOtherTunnelEnd(), Station::GetPlatformLength(), GetTrainForReservation(), GrowTownWithBridge(), GrowTownWithTunnel(), CYapfCostRailT< Types >::IsAnyStationTileReserved(), IsNeighborRoadTile(), IsShipDestinationTile(), IsTunnelInWayDir(), RoadStop::MakeDriveThrough(), MakeLock(), MarkBridgeDirty(), NeighbourIsNormal(), NPFSaveTargetData(), CYapfCostRoadT< Types >::OneTileCost(), RoadStop::Entry::Rebuild(), RemoveDock(), RemoveLock(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), SetRailStationPlatformReservation(), TestTownOwnsBridge(), TileAddByDiagDir(), TrainApproachingCrossing(), TrainApproachingCrossingTile(), CYapfReserveTrack< Types >::UnreserveSingleTrack(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), and UpdateSignalsInBuffer().

## ◆ TileOffsByDir()

TileIndexDiff TileOffsByDir | ( | Direction | dir | ) |
| inline

Convert a Direction to a TileIndexDiff.

Parameters

  dir | The direction to convert from

Returns
  The resulting TileIndexDiff

Definition at line 577 of file map_func.h.

References _tileoffs_by_dir, DIR_END, IsValidDirection(), and ToTileIndexDiff().

Referenced by MarkCanalsAndRiversAroundDirty(), TileAddByDir(), and TileLoop_Water().

## ◆ TileVirtXY()

static debug_inline TileIndex TileVirtXY | ( | uint | x,
|  | uint | y
| ) |  |
| static

Get a tile from the virtual XY-coordinate.

Parameters

  x | The virtual x coordinate of the tile.
  y | The virtual y coordinate of the tile.

Returns
  The TileIndex calculated by the coordinate.

Definition at line 416 of file map_func.h.

Referenced by AircraftLandAirplane(), CheckGroundVehiclesAtCorrectZ(), CheckTrainCollision(), CrashAirplane(), DrawStationCoverageAreaText(), FindStationsAroundSelection(), GetTileHeightBelowAircraft(), BuildRoadToolbarWindow::OnHotkey(), BuildRailToolbarWindow::OnHotkey(), UpdateStatusAfterSwap(), and YapfTrainCheckReverse().

## ◆ TileX()

static debug_inline uint TileX | ( | TileIndex | tile | ) |
| static

Get the X component of a tile.

Parameters

  tile | the tile to get the X component of

Returns
  the X component

Definition at line 427 of file map_func.h.

Referenced by OrthogonalTileArea::Add(), AyStar::AddStartNode(), AircraftGetEntryPoint(), AirportGetNearestTown(), AlignTileToGrid(), TileMatrix< T, N >::AllocateStorage(), CalcClosestStationTile(), CheckIfCanLevelIndustryPlatform(), OrthogonalTileArea::ClampToMap(), CmdBuildLongRoad(), CmdClearArea(), CmdRemoveLongRoad(), OrthogonalTileArea::Contains(), DiagonalTileArea::Contains(), DiagdirBetweenTiles(), DiagonalTileArea::DiagonalTileArea(), DistanceFromEdge(), DistanceFromEdgeDir(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DistanceSquare(), SmallMapWindow::DrawTowns(), TileMatrix< T, N >::GetAreaForTile(), CargoPacket::GetDistance(), WaterRegion::GetLocalIndex(), GetOtherAqueductEnd(), GetPCPElevation(), RailTypeScopeResolver::GetRandomBits(), RoadTypeScopeResolver::GetRandomBits(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GetTLG(), GetTunnelBridgeLength(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GUIPlaceProcDragXY(), Town::InitializeLayout(), CommandHelperBase::InternalPostBefore(), OrthogonalTileArea::Intersects(), IsTileAlignedToGrid(), IsTileFlat(), IsTunnelInWay(), AirportSpec::IsWithinMapBounds(), MarkTileDirtyByTile(), NPFDistanceTrack(), NPFHash(), OrthogonalTileArea::OrthogonalTileArea(), CYapfDestinationTileWaterT< Types >::PfCalcEstimate(), CYapfDestinationTileT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), River_Hash(), ScrollMainWindowToTile(), ScrollWindowToTile(), SetWaterClassDependingOnSurroundings(), SwapDirection(), TerraformAddDirtyTileAround(), TileIndexToTileIndexDiffC(), TileStr(), CargoPacket::UpdateLoadingTile(), CargoPacket::UpdateUnloadingTile(), Waypoint::UpdateVirtCoord(), Town::UpdateVirtCoord(), and Station::UpdateVirtCoord().

## ◆ TileXY()

static debug_inline TileIndex TileXY | ( | uint | x,
|  | uint | y
| ) |  |
| static

Returns the TileIndex of a coordinate.

Parameters

  x | The x coordinate of the tile
  y | The y coordinate of the tile

Returns
  The TileIndex calculated by the coordinate

Definition at line 385 of file map_func.h.

Referenced by OrthogonalTileArea::Add(), AlignTileToGrid(), FlatEmptyWorld(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GetWaterRegionCenterTile(), BitmapTileArea::Initialize(), IsTileFlat(), OrthogonalTileArea::OrthogonalTileArea(), Station::RecomputeCatchment(), and StationRect::ScanForStationTiles().

## ◆ TileY()

static debug_inline uint TileY | ( | TileIndex | tile | ) |
| static

Get the Y component of a tile.

Parameters

  tile | the tile to get the Y component of

Returns
  the Y component

Definition at line 437 of file map_func.h.

Referenced by OrthogonalTileArea::Add(), AyStar::AddStartNode(), AircraftGetEntryPoint(), AirportGetNearestTown(), AlignTileToGrid(), CalcClosestStationTile(), CheckIfCanLevelIndustryPlatform(), OrthogonalTileArea::ClampToMap(), CmdBuildLongRoad(), CmdClearArea(), CmdRemoveLongRoad(), OrthogonalTileArea::Contains(), DiagonalTileArea::Contains(), DiagdirBetweenTiles(), DiagonalTileArea::DiagonalTileArea(), DistanceFromEdge(), DistanceFromEdgeDir(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DistanceSquare(), SmallMapWindow::DrawTowns(), CargoPacket::GetDistance(), GetOtherAqueductEnd(), RailTypeScopeResolver::GetRandomBits(), RoadTypeScopeResolver::GetRandomBits(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), GetTLG(), GetTunnelBridgeLength(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GUIPlaceProcDragXY(), Town::InitializeLayout(), CommandHelperBase::InternalPostBefore(), OrthogonalTileArea::Intersects(), IsTileAlignedToGrid(), IsTileFlat(), IsTunnelInWay(), AirportSpec::IsWithinMapBounds(), MarkTileDirtyByTile(), NPFDistanceTrack(), OrthogonalTileArea::OrthogonalTileArea(), CYapfDestinationTileWaterT< Types >::PfCalcEstimate(), CYapfDestinationTileT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), River_Hash(), ScrollMainWindowToTile(), ScrollWindowToTile(), SetWaterClassDependingOnSurroundings(), SwapDirection(), TerraformAddDirtyTileAround(), TileIndexToTileIndexDiffC(), TileStr(), CargoPacket::UpdateLoadingTile(), CargoPacket::UpdateUnloadingTile(), Waypoint::UpdateVirtCoord(), Town::UpdateVirtCoord(), and Station::UpdateVirtCoord().

## ◆ ToTileIndexDiff()

TileIndexDiff ToTileIndexDiff | ( | TileIndexDiffC | tidc | ) |
| inline

Return the offset between two tiles from a TileIndexDiffC struct.

This function works like TileDiffXY(int, int) and returns the difference between two tiles.

Parameters

  tidc | The coordinate of the offset as TileIndexDiffC

Returns
  The difference between two tiles.

See also
  TileDiffXY(int, int)

Definition at line 452 of file map_func.h.

References Map::LogX(), TileIndexDiffC::x, and TileIndexDiffC::y.

Referenced by Airport::GetRotatedTileFromOffset(), AirportTileTableIterator::operator++(), RoadTypesAllowHouseHere(), TileOffsByDiagDir(), and TileOffsByDir().