|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
42 static_assert(
sizeof(
TileBase) == 8);
80 debug_inline constexpr
operator uint()
const {
return tile.base(); }
113 debug_inline
byte &
m1()
125 debug_inline uint16_t &
m2()
137 debug_inline
byte &
m3()
149 debug_inline
byte &
m4()
161 debug_inline
byte &
m5()
173 debug_inline
byte &
m6()
185 debug_inline
byte &
m7()
197 debug_inline uint16_t &
m8()
215 typedef size_t difference_type;
216 typedef std::forward_iterator_tag iterator_category;
219 bool operator==(
const Iterator &other)
const {
return this->index == other.index; }
220 bool operator!=(
const Iterator &other)
const {
return !(*
this == other); }
221 Tile operator*()
const {
return this->index; }
222 Iterator & operator++() { this->index++;
return *
this; }
233 bool empty() {
return false; }
251 debug_inline
static uint
LogX()
288 debug_inline
static uint
Size()
297 debug_inline
static uint
MaxX()
418 return (y >> 4 <<
Map::LogX()) + (x >> 4);
466 # define TILE_ADD(x, y) ((x) + (y))
469 const char *exp,
const char *file,
int line);
470 # define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
480 #define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
524 int x =
TileX(tile) + diff.
x;
525 int y =
TileY(tile) + diff.
y;
618 int dx = (int)
TileX(tile_to) - (int)
TileX(tile_from);
619 int dy = (int)
TileY(tile_to) - (int)
TileY(tile_from);
657 #define RandomTile() RandomTileSeed(Random())
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
Returns the TileIndexDiffC offset from a DiagDirection.
TileIndexDiff TileOffsByDir(Direction dir)
Convert a Direction to a TileIndexDiff.
uint16_t m8
General purpose.
Data that is stored per tile.
static uint size_y
Size of the map along the Y.
#define TILE_ADD(x, y)
Adds two tiles together.
const TileIndexDiffC _tileoffs_by_dir[]
'Lookup table' for tile offsets given a Direction
Direction
Defines the 8 directions on the map.
Tile(uint tile)
Create the tile wrapper for the given tile.
Size related data of the map.
TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
Add a TileIndexDiffC to a TileIndex and returns the new one.
bool TestTileOnSearchProc(TileIndex tile, void *user_data)
A callback function type for searching tiles.
byte type
The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
static debug_inline uint LogX()
Logarithm of the map size along the X side.
static uint size_x
Size of the map along the X.
@ DIAGDIR_END
Used for iterations.
static uint ScaleBySize1D(uint n)
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map.
static void Allocate(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
debug_inline uint16_t & m8()
General purpose.
static TileIndex WrapToMap(TileIndex tile)
'Wraps' the given "tile" so it is within the map.
uint16_t m2
Primarily used for indices to towns, industries and stations.
static bool IsInitialized()
Check whether the map has been initialized, as to not try to save the map during crashlog when the ma...
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
debug_inline byte & m6()
General purpose.
debug_inline Tile(TileIndex tile)
Create the tile wrapper for the given tile.
Wrapper class to abstract away the way the tiles are stored.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
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.
debug_inline byte & m5()
General purpose.
static uint ScaleBySize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
const TileIndexDiffC _tileoffs_by_diagdir[]
'Lookup table' for tile offsets given a DiagDirection
debug_inline byte & m1()
Primarily used for ownership information.
debug_inline byte & m4()
General purpose.
debug_inline byte & m7()
Primarily used for newgrf support.
uint DistanceSquare(TileIndex, TileIndex)
euclidian- or L2-Norm squared
uint DistanceFromEdgeDir(TileIndex, DiagDirection)
distance from the map edge in given direction
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
uint DistanceManhattan(TileIndex, TileIndex)
also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads)
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
bool IsValidDirection(Direction d)
Checks if an integer value is a valid Direction.
byte m7
Primarily used for newgrf support.
static TileExtended * extended_tiles
Pointer to the extended tile-array.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Iterator to iterate all Tiles.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
int32_t TileIndexDiff
An offset value between two tiles.
byte height
The height of the northern corner.
uint DistanceFromEdge(TileIndex)
shortest distance from any edge of the map
DiagDirection
Enumeration for diagonal directions.
TileIndex TileAddByDir(TileIndex tile, Direction dir)
Adds a Direction to a tile.
static uint log_x
2^_map_log_x == _map_size_x
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
static uint log_y
2^_map_log_y == _map_size_y
A pair-construct of a TileIndexDiff.
static debug_inline uint SizeX()
Get the size of the map along the X.
TileIndexDiffC TileIndexDiffCByDir(Direction dir)
Returns the TileIndexDiffC offset from a Direction.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
debug_inline byte & height()
The height of the northern corner.
DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
Determines the DiagDirection to get from one tile to another.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
uint DistanceMaxPlusManhattan(TileIndex, TileIndex)
Max + Manhattan.
@ DIR_END
Used to iterate.
static debug_inline uint Size()
Get the size of the map.
static uint tile_mask
_map_size - 1 (to mask the mapsize)
TileIndex tile
The tile to access the map data for.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
int16_t y
The y value of the coordinate.
static uint LogY()
Logarithm of the map size along the y side.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static TileBase * base_tiles
Pointer to the tile-array.
uint DistanceMax(TileIndex, TileIndex)
also known as L-Infinity-Norm
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
Returns the diff between two tiles.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Data that is stored per tile.
byte m1
Primarily used for ownership information.
debug_inline byte & m3()
General purpose.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
uint GetClosestWaterDistance(TileIndex tile, bool water)
Finds the distance for the closest tile with water/land given a tile.
int16_t x
The x value of the coordinate.
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.
static uint size
The number of tiles on the map.
TileIndex RandomTileSeed(uint32_t r)
Get a random tile out of a given seed.
static uint SizeY()
Get the size of the map along the Y.
debug_inline byte & type()
The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)