OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
26 #define TILE_MASK(x) ((x) & _map_tile_mask)
196 return (y >> 4 <<
MapLogX()) + (x >> 4);
244 # define TILE_ADD(x, y) ((x) + (y))
247 const char *exp,
const char *file,
int line);
248 # define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
258 #define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
302 int x =
TileX(tile) + diff.
x;
303 int y =
TileY(tile) + diff.
y;
396 int dx = (int)
TileX(tile_to) - (int)
TileX(tile_from);
397 int dy = (int)
TileY(tile_to) - (int)
TileY(tile_from);
435 #define RandomTile() RandomTileSeed(Random())
static uint MapLogX()
Logarithm of the map size along the X side.
uint _map_log_y
2^_map_log_y == _map_size_y
uint32 TileIndex
The index/ID of a Tile.
static TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
Add a TileIndexDiffC to a TileIndex and returns the new one.
#define TILE_ADD(x, y)
Adds to tiles together.
const TileIndexDiffC _tileoffs_by_dir[]
'Lookup table' for tile offsets given a Direction
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Direction
Defines the 8 directions on the map.
bool TestTileOnSearchProc(TileIndex tile, void *user_data)
A callback function type for searching tiles.
uint _map_size
The number of tiles on the map.
static TileIndex TileAddByDir(TileIndex tile, Direction dir)
Adds a Direction to a tile.
@ DIAGDIR_END
Used for iterations.
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
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.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
#define TILE_MASK(x)
'Wraps' the given tile to it is within the map.
const TileIndexDiffC _tileoffs_by_diagdir[]
'Lookup table' for tile offsets given a DiagDirection
static TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
Returns the diff between two tiles.
static uint TileX(TileIndex tile)
Get the X component of a tile.
static uint MapSizeX()
Get the size of the map along the X.
uint _map_size_x
Size of the map along the X.
uint _map_tile_mask
_map_size - 1 (to mask the mapsize)
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
int16 y
The y value of the coordinate.
uint DistanceSquare(TileIndex, TileIndex)
euclidian- or L2-Norm squared
uint DistanceFromEdgeDir(TileIndex, DiagDirection)
distance from the map edge in given direction
static uint MapSize()
Get the size of the map.
uint DistanceManhattan(TileIndex, TileIndex)
also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
int32 TileIndexDiff
An offset value between to tiles.
static TileIndexDiff TileOffsByDir(Direction dir)
Convert a Direction to a TileIndexDiff.
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
static bool IsValidDirection(Direction d)
Checks if an integer value is a valid Direction.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
uint DistanceFromEdge(TileIndex)
shortest distance from any edge of the map
DiagDirection
Enumeration for diagonal directions.
static uint MapSizeY()
Get the size of the map along the Y.
Tile * _m
Pointer to the tile-array.
uint _map_log_x
2^_map_log_x == _map_size_x
Data that is stored per tile.
A pair-construct of a TileIndexDiff.
void AllocateMap(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
static uint ScaleByMapSize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
Determines the DiagDirection to get from one tile to another.
uint DistanceMaxPlusManhattan(TileIndex, TileIndex)
Max + Manhattan.
@ DIR_END
Used to iterate.
Data that is stored per tile.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static uint ScaleByMapSize1D(uint n)
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
uint DistanceMax(TileIndex, TileIndex)
also known as L-Infinity-Norm
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
uint _map_size_y
Size of the map along the Y.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
static TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
Returns the TileIndexDiffC offset from a DiagDirection.
uint GetClosestWaterDistance(TileIndex tile, bool water)
Finds the distance for the closest tile with water/land given a tile.
static uint MapLogY()
Logarithm of the map size along the y side.
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.
TileExtended * _me
Pointer to the extended tile-array.
static TileIndex RandomTileSeed(uint32 r)
Get a random tile out of a given seed.
static TileIndexDiffC TileIndexDiffCByDir(Direction dir)
Returns the TileIndexDiffC offset from a Direction.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
int16 x
The x value of the coordinate.