OpenTTD Source 20260206-master-g4d4e37dbf1
map_func.h File Reference

Functions related to maps. More...

#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 RandomTile()
 Get a valid random tile.

Functions

static TileIndex TileXY (uint x, uint y)
 Returns the TileIndex of a coordinate.
TileIndexDiff TileDiffXY (int x, int y)
 Calculates an offset for the given coordinate(-offset).
static TileIndex TileVirtXY (uint x, uint y)
 Get a tile from the virtual XY-coordinate.
static uint TileX (TileIndex tile)
 Get the X component of a tile.
static uint TileY (TileIndex tile)
 Get the Y component of a tile.
TileIndexDiff ToTileIndexDiff (TileIndexDiffC tidc)
 Return the offset between two tiles from a TileIndexDiffC struct.
constexpr TileIndexoperator+= (TileIndex &tile, TileIndexDiff offset)
constexpr TileIndexoperator-= (TileIndex &tile, TileIndexDiff offset)
constexpr TileIndex TileAdd (TileIndex tile, TileIndexDiff offset)
 Adds a given offset to a tile.
TileIndex TileAddXY (TileIndex tile, int x, int y)
 Adds a given offset to a tile.
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.
TileIndexDiffC TileIndexDiffCByDiagDir (DiagDirection dir)
 Returns the TileIndexDiffC offset from a DiagDirection.
TileIndexDiffC TileIndexDiffCByDir (Direction dir)
 Returns the TileIndexDiffC offset from a Direction.
TileIndex AddTileIndexDiffCWrap (TileIndex tile, TileIndexDiffC diff)
 Add a TileIndexDiffC to a TileIndex and returns the new one.
TileIndexDiffC TileIndexToTileIndexDiffC (TileIndex tile_a, TileIndex tile_b)
 Returns the diff between two tiles.
uint DistanceManhattan (TileIndex, TileIndex)
 also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
uint DistanceSquare (TileIndex, TileIndex)
 Euclidean- or L2-Norm squared.
uint DistanceMax (TileIndex, TileIndex)
 also known as L-Infinity-Norm
uint DistanceMaxPlusManhattan (TileIndex, TileIndex)
 Max + Manhattan.
uint DistanceFromEdge (TileIndex)
 shortest distance from any edge of the map
uint DistanceFromEdgeDir (TileIndex, DiagDirection)
 distance from the map edge in given direction
TileIndexDiff TileOffsByAxis (Axis axis)
 Convert an Axis to a TileIndexDiff.
TileIndexDiff TileOffsByDiagDir (DiagDirection dir)
 Convert a DiagDirection to a TileIndexDiff.
TileIndexDiff TileOffsByDir (Direction dir)
 Convert a Direction to a TileIndexDiff.
TileIndex TileAddByDir (TileIndex tile, Direction dir)
 Adds a Direction to a tile.
TileIndex TileAddByDiagDir (TileIndex tile, DiagDirection dir)
 Adds a DiagDir to a tile.
DiagDirection DiagdirBetweenTiles (TileIndex tile_from, TileIndex tile_to)
 Determines the DiagDirection to get from one tile to another.
TileIndex RandomTileSeed (uint32_t r)
 Get a random tile out of a given seed.
uint GetClosestWaterDistance (TileIndex tile, bool water)
 Finds the distance for the closest tile with water/land given a tile.

Detailed Description

Functions related to maps.

Definition in file map_func.h.

Macro Definition Documentation

◆ RandomTile

#define RandomTile ( )
Value:
RandomTileSeed(Random())
TileIndex RandomTileSeed(uint32_t r)
Get a random tile out of a given seed.
Definition map_func.h:643

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 654 of file map_func.h.

Referenced by CmdBuildIndustry(), CreateRandomTown(), CreateRivers(), Disaster_Small_Ufo_Init(), Disaster_Zeppeliner_Init(), DisasterTick_Big_Ufo(), DisasterTick_Ufo(), PlaceIndustry(), PlaceTreeGroups(), ReleaseDisasterVehicle(), and TryBuildTransmitter().

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
tileThe base tile to add the offset on
diffThe offset to add on the tile
Returns
The resulting TileIndex

Definition at line 517 of file map_func.h.

References INVALID_TILE, Map::SizeX(), Map::SizeY(), TileX(), TileXY(), TileY(), TileIndexDiffC::x, and TileIndexDiffC::y.

Referenced by CalculateCoverageLine(), InvalidateWaterRegion(), TerraformTileHeight(), and TileLoop_Water().

◆ 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_fromOrigin tile
tile_toDestination tile
Returns
DiagDirection from tile_from towards tile_to, or INVALID_DIAGDIR if the tiles are not on an axis

Definition at line 625 of file map_func.h.

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

Referenced by WaterRegion::ForceUpdate(), and TrainController().

◆ DistanceFromEdge()

uint DistanceFromEdge ( TileIndex tile)

shortest distance from any edge of the map

shortest distance from any edge of the map

Parameters
tilethe tile to get the distance from
Returns
the distance from the edge in tiles

Definition at line 218 of file map.cpp.

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

Referenced by CountConnectedSeaTiles(), GenerateStationName(), GreyscaleToMapHeights(), 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
tilethe tile to get the distance from
dirthe direction of interest
Returns
the distance from the edge in tiles

Definition at line 235 of file map.cpp.

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

Referenced by CheckScaledDistanceFromEdge(), and GetOtherAqueductEnd().

◆ DistanceManhattan()

uint DistanceManhattan ( TileIndex t0,
TileIndex t1 )

◆ 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
t0the start tile
t1the end tile
Returns
the distance

Definition at line 190 of file map.cpp.

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

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

◆ DistanceMaxPlusManhattan()

uint DistanceMaxPlusManhattan ( TileIndex t0,
TileIndex t1 )

Max + Manhattan.

Max + Manhattan.

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

Parameters
t0the start tile
t1the end tile
Returns
the distance

Definition at line 206 of file map.cpp.

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

Referenced by DemandCalculator::CalcDemand(), DemandCalculator::DemandCalculator(), and MultiCommodityFlow::Dijkstra().

◆ DistanceSquare()

uint DistanceSquare ( TileIndex t0,
TileIndex t1 )

Euclidean- or L2-Norm squared.

Euclidean- or L2-Norm squared.

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

Parameters
t0the start tile
t1the end tile
Returns
the distance

Definition at line 175 of file map.cpp.

References TileX(), and TileY().

Referenced by CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), FindNearestHangar(), GetOrderDistance(), GetTownRadiusGroup(), IndustriesScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), RoadStopScopeResolver::GetVariable(), MakeWetlands(), and PlaceTreeGroupAroundTile().

◆ GetClosestWaterDistance()

uint GetClosestWaterDistance ( TileIndex tile,
bool water )

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

Parameters
tilethe tile to find the distance too
waterwhether to find water or land
Returns
distance to nearest water (max 0x7F) / land (max 0x1FF; 0x200 if there is no land)

Definition at line 252 of file map.cpp.

References _settings_game, DIAGDIR_BEGIN, DIAGDIR_END, HasTileWaterGround(), IsInsideMM(), IsTileType(), Map::Iterate(), Map::MaxX(), Map::MaxY(), TileX(), TileXY(), TileY(), Void, and Water.

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

◆ operator+=()

TileIndex & operator+= ( TileIndex & tile,
TileIndexDiff offset )
constexpr

Definition at line 448 of file map_func.h.

◆ operator-=()

TileIndex & operator-= ( TileIndex & tile,
TileIndexDiff offset )
constexpr

Definition at line 449 of file map_func.h.

◆ RandomTileSeed()

TileIndex RandomTileSeed ( uint32_t r)
inline

Get a random tile out of a given seed.

Parameters
rthe random 'seed'
Returns
a valid tile

Definition at line 643 of file map_func.h.

References Map::WrapToMap().

Referenced by PlaceTreesRandomly(), and PlantRandomTree().

◆ TileAdd()

◆ TileAddByDiagDir()

◆ TileAddByDir()

TileIndex TileAddByDir ( TileIndex tile,
Direction dir )
inline

Adds a Direction to a tile.

Parameters
tileThe current tile
dirThe direction in which we want to step
Returns
the moved tile

Definition at line 601 of file map_func.h.

References TileAdd(), and TileOffsByDir().

Referenced by CalcHeightdiff(), FindStationsNearby(), and GrowTownInTile().

◆ 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
tilethe 'starting' point of the adding
addxthe amount of tiles in the X direction to add
addythe amount of tiles in the Y direction to add
Returns
translated tile, or INVALID_TILE when it would've wrapped.

Definition at line 109 of file map.cpp.

References _settings_game, INVALID_TILE, Map::MaxX(), Map::MaxY(), TileX(), TileXY(), and TileY().

Referenced by CheckIfIndustryTilesAreFree(), CheckIfIndustryTileSlopes(), CmdBuildRailStation(), CmdBuildRoadStop(), CmdRemoveRoadStop(), CountMapSquareAround(), DisasterTick_Big_Ufo_Destroyer(), PlaceTreeAtSameHeight(), PlaceTreeGroupAroundTile(), and PlaceTreeGroups().

◆ TileAddXY()

TileIndex TileAddXY ( TileIndex tile,
int x,
int y )
inline

Adds a given offset to a tile.

Parameters
tileThe tile to add an offset to.
xThe x offset to add to the tile.
yThe y offset to add to the tile.
Returns
The resulting tile.

Definition at line 472 of file map_func.h.

References TileAdd(), and TileDiffXY().

Referenced by AdvanceHouseConstruction(), AfterLoadGame(), CheckAllowRemoveRoad(), CheckNewIndustry_OilRefinery(), CheckNewIndustry_OilRig(), CmdPlaceHouse(), DrawWaterEdges(), FindStationsNearby(), OrthogonalTileArea::GetCenterTile(), GetOtherAqueductEnd(), CanalScopeResolver::GetVariable(), HeightmapCallback(), TileLoop_Town(), and TriggerHouseAnimation_WatchedCargoAccepted().

◆ 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
xThe offset in x direction
yThe offset in y direction
Returns
The resulting offset value of the given coordinate
See also
ToTileIndexDiff(TileIndexDiffC)

Definition at line 391 of file map_func.h.

References Map::SizeX().

Referenced by AfterLoadGame(), BuildTownHouse(), ChangeIndustryProduction(), CheckIfCanLevelIndustryPlatform(), ClearTownHouse(), CmdBuildBridge(), CmdTerraformLand(), Disaster_CoalMine_Init(), GetHouseNorthPart(), GetNearbyTile(), GetReferenceTile(), Airport::GetRotatedTileFromOffset(), HouseScopeResolver::GetVariable(), GUIPlaceProcDragXY(), MakeTownHouse(), TerraformToolbarWindow::OnPlaceMouseUp(), OrthogonalTileIterator::operator++(), RebuildTownCaches(), RemoveNearbyStations(), TerraformAddDirtyTileAround(), TileAddXY(), ToTileIndexDiff(), and UpdateHousesAndTowns().

◆ TileIndexDiffCByDiagDir()

TileIndexDiffC TileIndexDiffCByDiagDir ( DiagDirection dir)
inline

Returns the TileIndexDiffC offset from a DiagDirection.

Parameters
dirThe given direction
Returns
The offset as TileIndexDiffC value

Definition at line 485 of file map_func.h.

References _tileoffs_by_diagdir, DIAGDIR_END, and IsValidDiagDirection().

Referenced by CalculateCoverageLine(), SpiralTileIterator::Increment(), InvalidateWaterRegion(), TerraformTileHeight(), and VisitAdjacentWaterRegionPatchNeighbours().

◆ TileIndexDiffCByDir()

TileIndexDiffC TileIndexDiffCByDir ( Direction dir)
inline

Returns the TileIndexDiffC offset from a Direction.

Parameters
dirThe given direction
Returns
The offset as TileIndexDiffC value

Definition at line 499 of file map_func.h.

References _tileoffs_by_dir, DIR_END, and IsValidDirection().

Referenced by SpiralTileIterator::Increment(), and TileLoop_Water().

◆ TileIndexToTileIndexDiffC()

TileIndexDiffC TileIndexToTileIndexDiffC ( TileIndex tile_a,
TileIndex tile_b )
inline

Returns the diff between two tiles.

Parameters
tile_afrom tile
tile_bto tile
Returns
the difference between tila_a and tile_b

Definition at line 533 of file map_func.h.

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

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

◆ TileOffsByAxis()

◆ TileOffsByDiagDir()

TileIndexDiff TileOffsByDiagDir ( DiagDirection dir)
inline

Convert a DiagDirection to a TileIndexDiff.

Parameters
dirThe DiagDirection
Returns
The resulting TileIndexDiff
See also
TileIndexDiffCByDiagDir

Definition at line 572 of file map_func.h.

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

Referenced by CanConnectToRoad(), CFollowTrackT< TRANSPORT_WATER, Ship, true >::CanEnterNewTile(), CanFollowRoad(), CanRoadContinueIntoNextTile(), CheckForDockingTile(), CheckFree2x2Area(), CheckTownBuild2House(), CheckTownBuild2x2House(), ClearDockingTilesCheckingNeighbours(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildRailStation(), CmdBuildTunnel(), ConnectRoadToStructure(), CountConnectedSeaTiles(), Disaster_CoalMine_Init(), DisasterTick_Submarine(), DoBuildLock(), DoClearBridge(), DrawRailCatenaryRailway(), DrawTile_TunnelBridge(), ExploreSegment(), ExtendTrainReservation(), FindDockLandPart(), FixOwnerOfRailTrack(), FlowRiver(), FollowReservation(), FollowTrainReservation(), GetBridgeEnd(), GetOtherAqueductEnd(), GetOtherTunnelEnd(), Station::GetPlatformLength(), GetTrainForReservation(), GrowTownWithBridge(), GrowTownWithTunnel(), CYapfCostRailT< Types >::IsAnyStationTileReserved(), IsNeighbourRoadTile(), IsShipDestinationTile(), IsTunnelInWayDir(), MakeDock(), MakeLake(), MakeLock(), MarkBridgeDirty(), NeighbourIsNormal(), CYapfCostRoadT< Types >::OneTileCost(), RemoveDock(), RemoveLock(), CYapfReserveTrack< Types >::ReserveRailStationPlatform(), SetRailStationPlatformReservation(), SetupFarmFieldFence(), TestTownOwnsBridge(), TileAddByDiagDir(), TrainApproachingCrossing(), TrainApproachingCrossingTile(), TrainCheckIfLineEnds(), TryBuildLightHouse(), CYapfReserveTrack< Types >::UnreserveSingleTrack(), UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(), and UpdateSignalsInBuffer().

◆ TileOffsByDir()

TileIndexDiff TileOffsByDir ( Direction dir)
inline

Convert a Direction to a TileIndexDiff.

Parameters
dirThe direction to convert from
Returns
The resulting TileIndexDiff

Definition at line 586 of file map_func.h.

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

Referenced by ClearNeighbourNonFloodingStates(), IsWateredTile(), MarkCanalsAndRiversAroundDirty(), and TileAddByDir().

◆ TileVirtXY()

◆ TileX()

uint TileX ( TileIndex tile)
inlinestatic

Get the X component of a tile.

Parameters
tilethe tile to get the X component of
Returns
the X component

Definition at line 417 of file map_func.h.

References Map::MaxX().

Referenced by OrthogonalTileArea::Add(), AddTileIndexDiffCWrap(), CargoPacket::AfterLoad(), AfterLoadGame(), AircraftController(), AircraftGetEntryPoint(), AirportGetNearestTown(), AlignTileToGrid(), CalcClosestStationTile(), CalcClosestTownFromTile(), CalcHeightdiff(), CanExpandRailStation(), CheckIfCanLevelIndustryPlatform(), OrthogonalTileArea::ClampToMap(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildLock(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildTunnel(), CmdChangeBankBalance(), CmdClearArea(), CmdMoveSign(), CmdMoveStationName(), CmdMoveWaypointName(), CmdPlaceSign(), CmdRemoveLongRoad(), DiagonalTileArea::Contains(), OrthogonalTileArea::Contains(), DiagdirBetweenTiles(), DiagonalTileArea::DiagonalTileArea(), DiagonalTileIterator::DiagonalTileIterator(), Disaster_Small_Ufo_Init(), Disaster_Zeppeliner_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Ufo(), DistanceFromEdge(), DistanceFromEdgeDir(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DistanceSquare(), SmallMapWindow::DrawIndustryNames(), DrawTileSelection(), SmallMapWindow::DrawTowns(), OrthogonalTileArea::Expand(), FindStationsAroundSelection(), FindStationsNearby(), ForAllStationsRadius(), WaterRegion::ForceUpdate(), GenerateStationName(), GetBridgeTilePillarFlags(), GetClosestWaterDistance(), CargoPacket::GetDistance(), WaterRegion::GetLocalIndex(), GetOtherAqueductEnd(), GetPCPElevation(), GetRailTileArea(), RailTypeScopeResolver::GetRandomBits(), RoadTypeScopeResolver::GetRandomBits(), GetRelativePosition(), GetTileHighlightType(), GetTileLocationGroup(), GetTileMaxZ(), GetTileSlopeZ(), GetTileZ(), GetTunnelBridgeLength(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GUIPlaceProcDragXY(), HighlightTownLocalAuthorityTiles(), Town::InitializeLayout(), InitializeWindowViewport(), CommandHelperBase::InternalPostBefore(), CommandHelperBase::InternalPostResult(), OrthogonalTileArea::Intersects(), IsCloseToTown(), IsInnerTile(), CYapfCostShipT< Types >::IsPreferredShipDirection(), IsTileAlignedToGrid(), IsTileFlat(), IsTunnelInWay(), AirportSpec::IsWithinMapBounds(), VehiclesOnTile::Iterator::Iterator(), MarkTileDirtyByTile(), OctileDistanceCost(), LandInfoWindow::OnInit(), TerraformToolbarWindow::OnPlaceMouseUp(), OrthogonalTileArea::OrthogonalTileArea(), PerformStationTileSlopeCheck(), ScrollMainWindowToTile(), ScrollWindowToTile(), SetupScreenshotViewport(), SetWaterClassDependingOnSurroundings(), ShowBuildBridgeWindow(), SpiralTileIterator::SpiralTileIterator(), SpiralTileIterator::SpiralTileIterator(), SwapDirection(), TerraformAddDirtyTileAround(), TerraformTileHeight(), TileAddWrap(), TileIndexToTileIndexDiffC(), TileStr(), CargoPacket::UpdateLoadingTile(), CargoPacket::UpdateUnloadingTile(), Station::UpdateVirtCoord(), Town::UpdateVirtCoord(), Waypoint::UpdateVirtCoord(), VpSelectTilesWithMethod(), VpSetPresizeRange(), and VpStartPlaceSizing().

◆ TileXY()

◆ TileY()

uint TileY ( TileIndex tile)
inlinestatic

Get the Y component of a tile.

Parameters
tilethe tile to get the Y component of
Returns
the Y component

Definition at line 427 of file map_func.h.

References Map::LogX().

Referenced by OrthogonalTileArea::Add(), AddTileIndexDiffCWrap(), CargoPacket::AfterLoad(), AfterLoadGame(), AircraftController(), AircraftGetEntryPoint(), AirportGetNearestTown(), AlignTileToGrid(), CalcClosestStationTile(), CalcClosestTownFromTile(), CanExpandRailStation(), CheckIfCanLevelIndustryPlatform(), OrthogonalTileArea::ClampToMap(), CmdBuildAircraft(), CmdBuildBridge(), CmdBuildLock(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdBuildTunnel(), CmdChangeBankBalance(), CmdClearArea(), CmdMoveSign(), CmdMoveStationName(), CmdMoveWaypointName(), CmdPlaceSign(), CmdRemoveLongRoad(), DiagonalTileArea::Contains(), OrthogonalTileArea::Contains(), DiagdirBetweenTiles(), DiagonalTileArea::DiagonalTileArea(), DiagonalTileIterator::DiagonalTileIterator(), Disaster_Helicopter_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Ufo(), DistanceFromEdge(), DistanceFromEdgeDir(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DistanceSquare(), SmallMapWindow::DrawIndustryNames(), DrawTileSelection(), SmallMapWindow::DrawTowns(), OrthogonalTileArea::Expand(), FindStationsAroundSelection(), FindStationsNearby(), ForAllStationsRadius(), WaterRegion::ForceUpdate(), GenerateStationName(), GetClosestWaterDistance(), CargoPacket::GetDistance(), WaterRegion::GetLocalIndex(), GetOtherAqueductEnd(), GetPCPElevation(), GetRailTileArea(), RailTypeScopeResolver::GetRandomBits(), RoadTypeScopeResolver::GetRandomBits(), GetRelativePosition(), GetTileHighlightType(), GetTileLocationGroup(), GetTileMaxZ(), GetTileSlopeZ(), GetTileZ(), GetTunnelBridgeLength(), HouseScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), GUIPlaceProcDragXY(), HighlightTownLocalAuthorityTiles(), Town::InitializeLayout(), InitializeWindowViewport(), CommandHelperBase::InternalPostBefore(), CommandHelperBase::InternalPostResult(), OrthogonalTileArea::Intersects(), IsCloseToTown(), IsInnerTile(), CYapfCostShipT< Types >::IsPreferredShipDirection(), IsTileAlignedToGrid(), IsTileFlat(), IsTunnelInWay(), AirportSpec::IsWithinMapBounds(), VehiclesOnTile::Iterator::Iterator(), MarkTileDirtyByTile(), OctileDistanceCost(), LandInfoWindow::OnInit(), TerraformToolbarWindow::OnPlaceMouseUp(), OrthogonalTileArea::OrthogonalTileArea(), PerformStationTileSlopeCheck(), ScrollMainWindowToTile(), ScrollWindowToTile(), SetupScreenshotViewport(), SetWaterClassDependingOnSurroundings(), ShowBuildBridgeWindow(), SpiralTileIterator::SpiralTileIterator(), SpiralTileIterator::SpiralTileIterator(), SwapDirection(), TerraformAddDirtyTileAround(), TerraformTileHeight(), TileAddWrap(), TileIndexToTileIndexDiffC(), TileStr(), CargoPacket::UpdateLoadingTile(), CargoPacket::UpdateUnloadingTile(), Station::UpdateVirtCoord(), Town::UpdateVirtCoord(), Waypoint::UpdateVirtCoord(), VpSelectTilesWithMethod(), VpSetPresizeRange(), and VpStartPlaceSizing().

◆ 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
tidcThe coordinate of the offset as TileIndexDiffC
Returns
The difference between two tiles.
See also
TileDiffXY(int, int)

Definition at line 442 of file map_func.h.

References TileDiffXY(), TileIndexDiffC::x, and TileIndexDiffC::y.

Referenced by AirportTileTableIterator::AirportTileTableIterator(), CalcHeightdiff(), CmdBuildDock(), CmdRailTrackHelper(), CmdSignalTrackHelper(), DoCreateNewIndustry(), Airport::GetRotatedTileFromOffset(), GrowTown(), AirportTileTableIterator::operator++(), RoadTypesAllowHouseHere(), TileOffsByAxis(), TileOffsByDiagDir(), and TileOffsByDir().