mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: move TILE_MASK to Map::WrapToMap
This commit is contained in:
parent
fe2bcd2a58
commit
de6bc8e692
|
@ -1010,7 +1010,7 @@ static void SetupFarmFieldFence(TileIndex tile, int size, byte type, DiagDirecti
|
|||
TileIndexDiff diff = (DiagDirToAxis(side) == AXIS_Y ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
|
||||
do {
|
||||
tile = TILE_MASK(tile);
|
||||
tile = Map::WrapToMap(tile);
|
||||
|
||||
if (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS)) {
|
||||
byte or_ = type;
|
||||
|
|
|
@ -92,7 +92,7 @@ TileIndex TileAdd(TileIndex tile, TileIndexDiff add,
|
|||
#endif
|
||||
}
|
||||
|
||||
assert(TileXY(x, y) == TILE_MASK(tile + add));
|
||||
assert(TileXY(x, y) == Map::WrapToMap(tile + add));
|
||||
|
||||
return TileXY(x, y);
|
||||
}
|
||||
|
|
|
@ -15,16 +15,6 @@
|
|||
#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.
|
||||
*
|
||||
|
@ -117,6 +107,18 @@ struct Map {
|
|||
return Map::SizeY() - 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* '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(uint tile)
|
||||
{
|
||||
extern uint _map_tile_mask;
|
||||
return tile & _map_tile_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the given value by the map size, where the given value is
|
||||
* for a 256 by 256 map.
|
||||
|
@ -429,7 +431,7 @@ bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOn
|
|||
*/
|
||||
static inline TileIndex RandomTileSeed(uint32 r)
|
||||
{
|
||||
return TILE_MASK(r);
|
||||
return Map::WrapToMap(r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -433,7 +433,7 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axi
|
|||
if (axis == AXIS_Y) Swap(x, y);
|
||||
|
||||
/* Make sure we never roam outside of the map, better wrap in that case */
|
||||
return TILE_MASK(tile + TileDiffXY(x, y));
|
||||
return Map::WrapToMap(tile + TileDiffXY(x, y));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -346,7 +346,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
|
|||
/* Extract tile offset. */
|
||||
int8 x_offs = GB(GetRegister(0x100), 0, 8);
|
||||
int8 y_offs = GB(GetRegister(0x100), 8, 8);
|
||||
TileIndex testtile = TILE_MASK(this->tile + TileDiffXY(x_offs, y_offs));
|
||||
TileIndex testtile = Map::WrapToMap(this->tile + TileDiffXY(x_offs, y_offs));
|
||||
|
||||
StationFinder stations(TileArea(testtile, 1, 1));
|
||||
const StationList *sl = stations.GetStations();
|
||||
|
|
Loading…
Reference in New Issue