Changeset - r26788:0785302ccc5b
[Not reviewed]
master
0 5 0
Rubidium - 17 months ago 2023-01-21 10:05:19
rubidium@openttd.org
Codechange: move TILE_MASK to Map::WrapToMap
5 files changed with 17 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1010,7 +1010,7 @@ static void SetupFarmFieldFence(TileInde
 
	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;
src/map.cpp
Show inline comments
 
@@ -92,7 +92,7 @@ TileIndex TileAdd(TileIndex tile, TileIn
 
#endif
 
	}
 

	
 
	assert(TileXY(x, y) == TILE_MASK(tile + add));
 
	assert(TileXY(x, y) == Map::WrapToMap(tile + add));
 

	
 
	return TileXY(x, y);
 
}
src/map_func.h
Show inline comments
 
@@ -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,
 
 */
 
static inline TileIndex RandomTileSeed(uint32 r)
 
{
 
	return TILE_MASK(r);
 
	return Map::WrapToMap(r);
 
}
 

	
 
/**
src/newgrf_commons.cpp
Show inline comments
 
@@ -433,7 +433,7 @@ TileIndex GetNearbyTile(byte parameter, 
 
	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));
 
}
 

	
 
/**
src/newgrf_house.cpp
Show inline comments
 
@@ -346,7 +346,7 @@ static uint32 GetDistanceFromNearbyHouse
 
			/* 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();
0 comments (0 inline, 0 general)