OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
44 FatalError(
"Invalid map size");
73 uint32_t x =
TileX(tile) + dx;
74 uint32_t y =
TileY(tile) + dy;
99 uint x =
TileX(tile) + addx;
100 uint y =
TileY(tile) + addy;
161 return dx * dx + dy * dy;
176 return std::max(dx, dy);
192 return dx > dy ? 2 * dx + dy : 2 * dy + dx;
202 const uint xl =
TileX(tile);
203 const uint yl =
TileY(tile);
206 const uint minl = std::min(xl, yl);
207 const uint minh = std::min(xh, yh);
208 return std::min(minl, minh);
224 default: NOT_REACHED();
243 assert(proc !=
nullptr);
249 if (proc(*tile, user_data))
return true;
281 assert(proc !=
nullptr);
284 uint x =
TileX(*tile) + w + 1;
285 uint y =
TileY(*tile);
289 for (uint n = 0; n < radius; n++) {
292 for (uint j = extent[dir] + n * 2 + 1; j != 0; j--) {
296 if (proc(t, user_data)) {
327 uint max_dist = water ? 0x7F : 0x200;
337 for (uint dist = 1; dist < max_dist; dist++) {
343 static const int8_t ddx[
DIAGDIR_END] = { -1, 1, 1, -1};
344 static const int8_t ddy[
DIAGDIR_END] = { 1, 1, -1, -1};
350 for (uint a = 0; a < dist; a++) {
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
Data that is stored per tile.
static uint size_y
Size of the map along the Y.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
const TileIndexDiffC _tileoffs_by_dir[]
'Lookup table' for tile offsets given a Direction
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
static const uint MIN_MAP_SIZE
Minimal map size = 64.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
bool TestTileOnSearchProc(TileIndex tile, void *user_data)
A callback function type for searching tiles.
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
static uint size_x
Size of the map along the X.
uint GetClosestWaterDistance(TileIndex tile, bool water)
Finds the distance for the closest tile with water/land given a tile.
static void Allocate(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
static TileIndex WrapToMap(TileIndex tile)
'Wraps' the given "tile" so it is within the map.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
DiagDirection
Enumeration for diagonal directions.
const TileIndexDiffC _tileoffs_by_diagdir[]
'Lookup table' for tile offsets given a DiagDirection
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
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.
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.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
@ DIAGDIR_BEGIN
Used for iterations.
static TileExtended * extended_tiles
Pointer to the extended tile-array.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
Gets the distance to the edge of the map in given direction.
bool freeform_edges
allow terraforming the tiles at the map edges
int32_t TileIndexDiff
An offset value between two tiles.
TileIndex TileAddByDir(TileIndex tile, Direction dir)
Adds a Direction to a tile.
static uint log_x
2^_map_log_x == _map_size_x
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
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.
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
@ MP_VOID
Invisible tiles at the SW and SE border.
static debug_inline uint Size()
Get the size of the map.
@ DIAGDIR_END
Used for iterations.
static uint tile_mask
_map_size - 1 (to mask the mapsize)
void AllocateWaterRegions()
Allocates the appropriate amount of water regions for the current map size.
int16_t y
The y value of the coordinate.
constexpr T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static TileBase * base_tiles
Pointer to the tile-array.
ConstructionSettings construction
construction of things in-game
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
uint DistanceMaxPlusManhattan(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles plus the Manhattan distance,...
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
Data that is stored per tile.
bool HasTileWaterGround(Tile t)
Checks whether the tile has water at the ground.
int16_t x
The x value of the coordinate.
static uint size
The number of tiles on the map.
static uint SizeY()
Get the size of the map along the Y.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.