Update to 14.0-beta1
This commit is contained in:
488
src/map_func.h
488
src/map_func.h
@@ -15,131 +15,353 @@
|
||||
#include "map_type.h"
|
||||
#include "direction_func.h"
|
||||
|
||||
extern uint _map_tile_mask;
|
||||
|
||||
/**
|
||||
* 'Wraps' the given tile to it is within the map. It does
|
||||
* this by masking the 'high' bits of.
|
||||
* @param x the tile to 'wrap'
|
||||
*/
|
||||
|
||||
#define TILE_MASK(x) ((x) & _map_tile_mask)
|
||||
|
||||
/**
|
||||
* Pointer to the tile-array.
|
||||
* Wrapper class to abstract away the way the tiles are stored. It is
|
||||
* intended to be used to access the "map" data of a single tile.
|
||||
*
|
||||
* This variable points to the tile-array which contains the tiles of
|
||||
* the map.
|
||||
* The wrapper is expected to be fully optimized away by the compiler, even
|
||||
* with low optimization levels except when completely disabling it.
|
||||
*/
|
||||
extern Tile *_m;
|
||||
class Tile {
|
||||
private:
|
||||
friend struct Map;
|
||||
/**
|
||||
* Data that is stored per tile. Also used TileExtended for this.
|
||||
* Look at docs/landscape.html for the exact meaning of the members.
|
||||
*/
|
||||
struct TileBase {
|
||||
byte type; ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
|
||||
byte height; ///< The height of the northern corner.
|
||||
uint16_t m2; ///< Primarily used for indices to towns, industries and stations
|
||||
byte m1; ///< Primarily used for ownership information
|
||||
byte m3; ///< General purpose
|
||||
byte m4; ///< General purpose
|
||||
byte m5; ///< General purpose
|
||||
};
|
||||
|
||||
static_assert(sizeof(TileBase) == 8);
|
||||
|
||||
/**
|
||||
* Data that is stored per tile. Also used TileBase for this.
|
||||
* Look at docs/landscape.html for the exact meaning of the members.
|
||||
*/
|
||||
struct TileExtended {
|
||||
byte m6; ///< General purpose
|
||||
byte m7; ///< Primarily used for newgrf support
|
||||
uint16_t m8; ///< General purpose
|
||||
};
|
||||
|
||||
static TileBase *base_tiles; ///< Pointer to the tile-array.
|
||||
static TileExtended *extended_tiles; ///< Pointer to the extended tile-array.
|
||||
|
||||
TileIndex tile; ///< The tile to access the map data for.
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create the tile wrapper for the given tile.
|
||||
* @param tile The tile to access the map for.
|
||||
*/
|
||||
debug_inline Tile(TileIndex tile) : tile(tile) {}
|
||||
|
||||
/**
|
||||
* Create the tile wrapper for the given tile.
|
||||
* @param tile The tile to access the map for.
|
||||
*/
|
||||
Tile(uint tile) : tile(tile) {}
|
||||
|
||||
/**
|
||||
* Implicit conversion to the TileIndex.
|
||||
*/
|
||||
debug_inline constexpr operator TileIndex() const { return tile; }
|
||||
|
||||
/**
|
||||
* Implicit conversion to the uint for bounds checking.
|
||||
*/
|
||||
debug_inline constexpr operator uint() const { return tile.base(); }
|
||||
|
||||
/**
|
||||
* The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &type()
|
||||
{
|
||||
return base_tiles[tile.base()].type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The height of the northern corner
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the height for.
|
||||
* @return reference to the byte holding the height.
|
||||
*/
|
||||
debug_inline byte &height()
|
||||
{
|
||||
return base_tiles[tile.base()].height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primarily used for ownership information
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &m1()
|
||||
{
|
||||
return base_tiles[tile.base()].m1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primarily used for indices to towns, industries and stations
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the uint16_t holding the data.
|
||||
*/
|
||||
debug_inline uint16_t &m2()
|
||||
{
|
||||
return base_tiles[tile.base()].m2;
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &m3()
|
||||
{
|
||||
return base_tiles[tile.base()].m3;
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &m4()
|
||||
{
|
||||
return base_tiles[tile.base()].m4;
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &m5()
|
||||
{
|
||||
return base_tiles[tile.base()].m5;
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &m6()
|
||||
{
|
||||
return extended_tiles[tile.base()].m6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primarily used for newgrf support
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the byte holding the data.
|
||||
*/
|
||||
debug_inline byte &m7()
|
||||
{
|
||||
return extended_tiles[tile.base()].m7;
|
||||
}
|
||||
|
||||
/**
|
||||
* General purpose
|
||||
*
|
||||
* Look at docs/landscape.html for the exact meaning of the data.
|
||||
* @param tile The tile to get the data for.
|
||||
* @return reference to the uint16_t holding the data.
|
||||
*/
|
||||
debug_inline uint16_t &m8()
|
||||
{
|
||||
return extended_tiles[tile.base()].m8;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pointer to the extended tile-array.
|
||||
*
|
||||
* This variable points to the extended tile-array which contains the tiles
|
||||
* of the map.
|
||||
* Size related data of the map.
|
||||
*/
|
||||
extern TileExtended *_me;
|
||||
struct Map {
|
||||
private:
|
||||
/**
|
||||
* Iterator to iterate all Tiles
|
||||
*/
|
||||
struct Iterator {
|
||||
typedef Tile value_type;
|
||||
typedef Tile *pointer;
|
||||
typedef Tile &reference;
|
||||
typedef size_t difference_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
void AllocateMap(uint size_x, uint size_y);
|
||||
explicit Iterator(TileIndex index) : index(index) {}
|
||||
bool operator==(const Iterator &other) const { return this->index == other.index; }
|
||||
bool operator!=(const Iterator &other) const { return !(*this == other); }
|
||||
Tile operator*() const { return this->index; }
|
||||
Iterator & operator++() { this->index++; return *this; }
|
||||
private:
|
||||
TileIndex index;
|
||||
};
|
||||
|
||||
/**
|
||||
* Logarithm of the map size along the X side.
|
||||
* @note try to avoid using this one
|
||||
* @return 2^"return value" == MapSizeX()
|
||||
*/
|
||||
static inline uint MapLogX()
|
||||
{
|
||||
extern uint _map_log_x;
|
||||
return _map_log_x;
|
||||
}
|
||||
/*
|
||||
* Iterable ensemble of all Tiles
|
||||
*/
|
||||
struct IterateWrapper {
|
||||
Iterator begin() { return Iterator(0); }
|
||||
Iterator end() { return Iterator(Map::Size()); }
|
||||
bool empty() { return false; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Logarithm of the map size along the y side.
|
||||
* @note try to avoid using this one
|
||||
* @return 2^"return value" == MapSizeY()
|
||||
*/
|
||||
static inline uint MapLogY()
|
||||
{
|
||||
extern uint _map_log_y;
|
||||
return _map_log_y;
|
||||
}
|
||||
static uint log_x; ///< 2^_map_log_x == _map_size_x
|
||||
static uint log_y; ///< 2^_map_log_y == _map_size_y
|
||||
static uint size_x; ///< Size of the map along the X
|
||||
static uint size_y; ///< Size of the map along the Y
|
||||
static uint size; ///< The number of tiles on the map
|
||||
static uint tile_mask; ///< _map_size - 1 (to mask the mapsize)
|
||||
|
||||
/**
|
||||
* Get the size of the map along the X
|
||||
* @return the number of tiles along the X of the map
|
||||
*/
|
||||
static inline uint MapSizeX()
|
||||
{
|
||||
extern uint _map_size_x;
|
||||
return _map_size_x;
|
||||
}
|
||||
public:
|
||||
static void Allocate(uint size_x, uint size_y);
|
||||
|
||||
/**
|
||||
* Get the size of the map along the Y
|
||||
* @return the number of tiles along the Y of the map
|
||||
*/
|
||||
static inline uint MapSizeY()
|
||||
{
|
||||
extern uint _map_size_y;
|
||||
return _map_size_y;
|
||||
}
|
||||
/**
|
||||
* Logarithm of the map size along the X side.
|
||||
* @note try to avoid using this one
|
||||
* @return 2^"return value" == Map::SizeX()
|
||||
*/
|
||||
debug_inline static uint LogX()
|
||||
{
|
||||
return Map::log_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the map
|
||||
* @return the number of tiles of the map
|
||||
*/
|
||||
static inline uint MapSize()
|
||||
{
|
||||
extern uint _map_size;
|
||||
return _map_size;
|
||||
}
|
||||
/**
|
||||
* Logarithm of the map size along the y side.
|
||||
* @note try to avoid using this one
|
||||
* @return 2^"return value" == Map::SizeY()
|
||||
*/
|
||||
static inline uint LogY()
|
||||
{
|
||||
return Map::log_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum X coordinate within the map, including MP_VOID
|
||||
* @return the maximum X coordinate
|
||||
*/
|
||||
static inline uint MapMaxX()
|
||||
{
|
||||
return MapSizeX() - 1;
|
||||
}
|
||||
/**
|
||||
* Get the size of the map along the X
|
||||
* @return the number of tiles along the X of the map
|
||||
*/
|
||||
debug_inline static uint SizeX()
|
||||
{
|
||||
return Map::size_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum Y coordinate within the map, including MP_VOID
|
||||
* @return the maximum Y coordinate
|
||||
*/
|
||||
static inline uint MapMaxY()
|
||||
{
|
||||
return MapSizeY() - 1;
|
||||
}
|
||||
/**
|
||||
* Get the size of the map along the Y
|
||||
* @return the number of tiles along the Y of the map
|
||||
*/
|
||||
static inline uint SizeY()
|
||||
{
|
||||
return Map::size_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the given value by the map size, where the given value is
|
||||
* for a 256 by 256 map.
|
||||
* @param n the value to scale
|
||||
* @return the scaled size
|
||||
*/
|
||||
static inline uint ScaleByMapSize(uint n)
|
||||
{
|
||||
/* Subtract 12 from shift in order to prevent integer overflow
|
||||
* for large values of n. It's safe since the min mapsize is 64x64. */
|
||||
return CeilDiv(n << (MapLogX() + MapLogY() - 12), 1 << 4);
|
||||
}
|
||||
/**
|
||||
* Get the size of the map
|
||||
* @return the number of tiles of the map
|
||||
*/
|
||||
debug_inline static uint Size()
|
||||
{
|
||||
return Map::size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum X coordinate within the map, including MP_VOID
|
||||
* @return the maximum X coordinate
|
||||
*/
|
||||
debug_inline static uint MaxX()
|
||||
{
|
||||
return Map::SizeX() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum Y coordinate within the map, including MP_VOID
|
||||
* @return the maximum Y coordinate
|
||||
*/
|
||||
static inline uint MaxY()
|
||||
{
|
||||
return Map::SizeY() - 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scales the given value by the maps circumference, where the given
|
||||
* value is for a 256 by 256 map
|
||||
* @param n the value to scale
|
||||
* @return the scaled size
|
||||
*/
|
||||
static inline uint ScaleByMapSize1D(uint n)
|
||||
{
|
||||
/* Normal circumference for the X+Y is 256+256 = 1<<9
|
||||
* Note, not actually taking the full circumference into account,
|
||||
* just half of it. */
|
||||
return CeilDiv((n << MapLogX()) + (n << MapLogY()), 1 << 9);
|
||||
}
|
||||
/**
|
||||
* 'Wraps' the given "tile" so it is within the map.
|
||||
* It does this by masking the 'high' bits of.
|
||||
* @param tile the tile to 'wrap'
|
||||
*/
|
||||
static inline TileIndex WrapToMap(TileIndex tile)
|
||||
{
|
||||
return tile.base() & Map::tile_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the given value by the map size, where the given value is
|
||||
* for a 256 by 256 map.
|
||||
* @param n the value to scale
|
||||
* @return the scaled size
|
||||
*/
|
||||
static inline uint ScaleBySize(uint n)
|
||||
{
|
||||
/* Subtract 12 from shift in order to prevent integer overflow
|
||||
* for large values of n. It's safe since the min mapsize is 64x64. */
|
||||
return CeilDiv(n << (Map::LogX() + Map::LogY() - 12), 1 << 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the given value by the maps circumference, where the given
|
||||
* value is for a 256 by 256 map
|
||||
* @param n the value to scale
|
||||
* @return the scaled size
|
||||
*/
|
||||
static inline uint ScaleBySize1D(uint n)
|
||||
{
|
||||
/* Normal circumference for the X+Y is 256+256 = 1<<9
|
||||
* Note, not actually taking the full circumference into account,
|
||||
* just half of it. */
|
||||
return CeilDiv((n << Map::LogX()) + (n << Map::LogY()), 1 << 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the map has been initialized, as to not try to save the map
|
||||
* during crashlog when the map is not there yet.
|
||||
* @return true when the map has been allocated/initialized.
|
||||
*/
|
||||
static bool IsInitialized()
|
||||
{
|
||||
return Tile::base_tiles != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterable ensemble of all Tiles
|
||||
* @return an iterable ensemble of all Tiles
|
||||
*/
|
||||
static IterateWrapper Iterate() { return IterateWrapper(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* An offset value between two tiles.
|
||||
@@ -151,7 +373,7 @@ static inline uint ScaleByMapSize1D(uint n)
|
||||
*
|
||||
* @see TileDiffXY(int, int)
|
||||
*/
|
||||
typedef int32 TileIndexDiff;
|
||||
typedef int32_t TileIndexDiff;
|
||||
|
||||
/**
|
||||
* Returns the TileIndex of a coordinate.
|
||||
@@ -160,9 +382,9 @@ typedef int32 TileIndexDiff;
|
||||
* @param y The y coordinate of the tile
|
||||
* @return The TileIndex calculated by the coordinate
|
||||
*/
|
||||
static inline TileIndex TileXY(uint x, uint y)
|
||||
debug_inline static TileIndex TileXY(uint x, uint y)
|
||||
{
|
||||
return (y << MapLogX()) + x;
|
||||
return (y << Map::LogX()) + x;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,13 +398,13 @@ static inline TileIndex TileXY(uint x, uint y)
|
||||
* @return The resulting offset value of the given coordinate
|
||||
* @see ToTileIndexDiff(TileIndexDiffC)
|
||||
*/
|
||||
static inline TileIndexDiff TileDiffXY(int x, int y)
|
||||
inline TileIndexDiff TileDiffXY(int x, int y)
|
||||
{
|
||||
/* Multiplication gives much better optimization on MSVC than shifting.
|
||||
* 0 << shift isn't optimized to 0 properly.
|
||||
* Typically x and y are constants, and then this doesn't result
|
||||
* in any actual multiplication in the assembly code.. */
|
||||
return (y * MapSizeX()) + x;
|
||||
return (y * Map::SizeX()) + x;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,9 +413,9 @@ static inline TileIndexDiff TileDiffXY(int x, int y)
|
||||
* @param y The virtual y coordinate of the tile.
|
||||
* @return The TileIndex calculated by the coordinate.
|
||||
*/
|
||||
static inline TileIndex TileVirtXY(uint x, uint y)
|
||||
debug_inline static TileIndex TileVirtXY(uint x, uint y)
|
||||
{
|
||||
return (y >> 4 << MapLogX()) + (x >> 4);
|
||||
return (y >> 4 << Map::LogX()) + (x >> 4);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,9 +424,9 @@ static inline TileIndex TileVirtXY(uint x, uint y)
|
||||
* @param tile the tile to get the X component of
|
||||
* @return the X component
|
||||
*/
|
||||
static inline uint TileX(TileIndex tile)
|
||||
debug_inline static uint TileX(TileIndex tile)
|
||||
{
|
||||
return tile.value & MapMaxX();
|
||||
return tile.base() & Map::MaxX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,9 +434,9 @@ static inline uint TileX(TileIndex tile)
|
||||
* @param tile the tile to get the Y component of
|
||||
* @return the Y component
|
||||
*/
|
||||
static inline uint TileY(TileIndex tile)
|
||||
debug_inline static uint TileY(TileIndex tile)
|
||||
{
|
||||
return tile.value >> MapLogX();
|
||||
return tile.base() >> Map::LogX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,9 +449,9 @@ static inline uint TileY(TileIndex tile)
|
||||
* @return The difference between two tiles.
|
||||
* @see TileDiffXY(int, int)
|
||||
*/
|
||||
static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
|
||||
inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
|
||||
{
|
||||
return (tidc.y << MapLogX()) + tidc.x;
|
||||
return (tidc.y << Map::LogX()) + tidc.x;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +487,7 @@ TileIndex TileAddWrap(TileIndex tile, int addx, int addy);
|
||||
* @param dir The given direction
|
||||
* @return The offset as TileIndexDiffC value
|
||||
*/
|
||||
static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
|
||||
inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
|
||||
{
|
||||
extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
|
||||
|
||||
@@ -279,7 +501,7 @@ static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
|
||||
* @param dir The given direction
|
||||
* @return The offset as TileIndexDiffC value
|
||||
*/
|
||||
static inline TileIndexDiffC TileIndexDiffCByDir(Direction dir)
|
||||
inline TileIndexDiffC TileIndexDiffCByDir(Direction dir)
|
||||
{
|
||||
extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
|
||||
|
||||
@@ -297,12 +519,12 @@ static inline TileIndexDiffC TileIndexDiffCByDir(Direction dir)
|
||||
* @param diff The offset to add on the tile
|
||||
* @return The resulting TileIndex
|
||||
*/
|
||||
static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
|
||||
inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
|
||||
{
|
||||
int x = TileX(tile) + diff.x;
|
||||
int y = TileY(tile) + diff.y;
|
||||
/* Negative value will become big positive value after cast */
|
||||
if ((uint)x >= MapSizeX() || (uint)y >= MapSizeY()) return INVALID_TILE;
|
||||
if ((uint)x >= Map::SizeX() || (uint)y >= Map::SizeY()) return INVALID_TILE;
|
||||
return TileXY(x, y);
|
||||
}
|
||||
|
||||
@@ -313,7 +535,7 @@ static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC dif
|
||||
* @param tile_b to tile
|
||||
* @return the difference between tila_a and tile_b
|
||||
*/
|
||||
static inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
|
||||
inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
|
||||
{
|
||||
TileIndexDiffC difference;
|
||||
|
||||
@@ -338,7 +560,7 @@ uint DistanceFromEdgeDir(TileIndex, DiagDirection); ///< distance from the map e
|
||||
* @return The resulting TileIndexDiff
|
||||
* @see TileIndexDiffCByDiagDir
|
||||
*/
|
||||
static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
|
||||
inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
|
||||
{
|
||||
extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
|
||||
|
||||
@@ -352,7 +574,7 @@ static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
|
||||
* @param dir The direction to convert from
|
||||
* @return The resulting TileIndexDiff
|
||||
*/
|
||||
static inline TileIndexDiff TileOffsByDir(Direction dir)
|
||||
inline TileIndexDiff TileOffsByDir(Direction dir)
|
||||
{
|
||||
extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
|
||||
|
||||
@@ -367,7 +589,7 @@ static inline TileIndexDiff TileOffsByDir(Direction dir)
|
||||
* @param dir The direction in which we want to step
|
||||
* @return the moved tile
|
||||
*/
|
||||
static inline TileIndex TileAddByDir(TileIndex tile, Direction dir)
|
||||
inline TileIndex TileAddByDir(TileIndex tile, Direction dir)
|
||||
{
|
||||
return TILE_ADD(tile, TileOffsByDir(dir));
|
||||
}
|
||||
@@ -379,7 +601,7 @@ static inline TileIndex TileAddByDir(TileIndex tile, Direction dir)
|
||||
* @param dir The direction in which we want to step
|
||||
* @return the moved tile
|
||||
*/
|
||||
static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
|
||||
inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
|
||||
{
|
||||
return TILE_ADD(tile, TileOffsByDiagDir(dir));
|
||||
}
|
||||
@@ -391,7 +613,7 @@ static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
|
||||
* @param tile_to Destination tile
|
||||
* @return DiagDirection from tile_from towards tile_to, or INVALID_DIAGDIR if the tiles are not on an axis
|
||||
*/
|
||||
static inline DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
|
||||
inline DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
|
||||
{
|
||||
int dx = (int)TileX(tile_to) - (int)TileX(tile_from);
|
||||
int dy = (int)TileY(tile_to) - (int)TileY(tile_from);
|
||||
@@ -421,9 +643,9 @@ bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOn
|
||||
* @param r the random 'seed'
|
||||
* @return a valid tile
|
||||
*/
|
||||
static inline TileIndex RandomTileSeed(uint32 r)
|
||||
inline TileIndex RandomTileSeed(uint32_t r)
|
||||
{
|
||||
return TILE_MASK(r);
|
||||
return Map::WrapToMap(r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user