mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-07-12 07:14:01 +01:00
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
This commit is contained in:
parent
459fd42e1d
commit
35195bb2bc
@ -919,8 +919,3 @@ TileIndex AdjustTileCoordRandomly(TileIndex a, byte rng)
|
|||||||
TileY(a) + (GB(r, 8, 8) * rn * 2 >> 8) - rn
|
TileY(a) + (GB(r, 8, 8) * rn * 2 >> 8) - rn
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValidTile(TileIndex tile)
|
|
||||||
{
|
|
||||||
return (tile < MapSizeX() * MapMaxY() && TileX(tile) != MapMaxX());
|
|
||||||
}
|
|
||||||
|
@ -26,8 +26,6 @@ byte GetSnowLine(void);
|
|||||||
byte HighestSnowLine(void);
|
byte HighestSnowLine(void);
|
||||||
void ClearSnowLine(void);
|
void ClearSnowLine(void);
|
||||||
|
|
||||||
bool IsValidTile(TileIndex tile);
|
|
||||||
|
|
||||||
uint GetPartialZ(int x, int y, Slope corners);
|
uint GetPartialZ(int x, int y, Slope corners);
|
||||||
uint GetSlopeZ(int x, int y);
|
uint GetSlopeZ(int x, int y);
|
||||||
void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
|
void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
|
||||||
|
@ -106,6 +106,17 @@ static inline bool IsTileType(TileIndex tile, TileType type)
|
|||||||
return GetTileType(tile) == type;
|
return GetTileType(tile) == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a tile is valid
|
||||||
|
*
|
||||||
|
* @param tile The tile to check
|
||||||
|
* @return True if the tile is on the map and not one of MP_VOID.
|
||||||
|
*/
|
||||||
|
static inline bool IsValidTile(TileIndex tile)
|
||||||
|
{
|
||||||
|
return tile < MapSize() && !IsTileType(tile, MP_VOID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the owner of a tile
|
* Returns the owner of a tile
|
||||||
*
|
*
|
||||||
@ -115,14 +126,13 @@ static inline bool IsTileType(TileIndex tile, TileType type)
|
|||||||
*
|
*
|
||||||
* @param tile The tile to check
|
* @param tile The tile to check
|
||||||
* @return The owner of the tile
|
* @return The owner of the tile
|
||||||
* @pre tile < MapSize()
|
* @pre IsValidTile(tile)
|
||||||
* @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
|
* @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
|
||||||
*/
|
*/
|
||||||
static inline Owner GetTileOwner(TileIndex tile)
|
static inline Owner GetTileOwner(TileIndex tile)
|
||||||
{
|
{
|
||||||
assert(tile < MapSize());
|
assert(IsValidTile(tile));
|
||||||
assert(!IsTileType(tile, MP_HOUSE));
|
assert(!IsTileType(tile, MP_HOUSE));
|
||||||
assert(!IsTileType(tile, MP_VOID));
|
|
||||||
assert(!IsTileType(tile, MP_INDUSTRY));
|
assert(!IsTileType(tile, MP_INDUSTRY));
|
||||||
|
|
||||||
return (Owner)_m[tile].m1;
|
return (Owner)_m[tile].m1;
|
||||||
@ -136,14 +146,13 @@ static inline Owner GetTileOwner(TileIndex tile)
|
|||||||
*
|
*
|
||||||
* @param tile The tile to change the owner status.
|
* @param tile The tile to change the owner status.
|
||||||
* @param owner The new owner.
|
* @param owner The new owner.
|
||||||
* @pre tile < MapSize()
|
* @pre IsValidTile(tile)
|
||||||
* @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY
|
* @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
|
||||||
*/
|
*/
|
||||||
static inline void SetTileOwner(TileIndex tile, Owner owner)
|
static inline void SetTileOwner(TileIndex tile, Owner owner)
|
||||||
{
|
{
|
||||||
assert(tile < MapSize());
|
assert(IsValidTile(tile));
|
||||||
assert(!IsTileType(tile, MP_HOUSE));
|
assert(!IsTileType(tile, MP_HOUSE));
|
||||||
assert(!IsTileType(tile, MP_VOID));
|
|
||||||
assert(!IsTileType(tile, MP_INDUSTRY));
|
assert(!IsTileType(tile, MP_INDUSTRY));
|
||||||
|
|
||||||
_m[tile].m1 = owner;
|
_m[tile].m1 = owner;
|
||||||
@ -165,7 +174,7 @@ static inline bool IsTileOwner(TileIndex tile, Owner owner)
|
|||||||
* Set the tropic zone
|
* Set the tropic zone
|
||||||
* @param tile the tile to set the zone of
|
* @param tile the tile to set the zone of
|
||||||
* @param type the new type
|
* @param type the new type
|
||||||
* @pre assert(tile < MapSize());
|
* @pre tile < MapSize()
|
||||||
*/
|
*/
|
||||||
static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
||||||
{
|
{
|
||||||
@ -176,7 +185,7 @@ static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
|||||||
/**
|
/**
|
||||||
* Get the tropic zone
|
* Get the tropic zone
|
||||||
* @param tile the tile to get the zone of
|
* @param tile the tile to get the zone of
|
||||||
* @pre assert(tile < MapSize());
|
* @pre tile < MapSize()
|
||||||
* @return the zone type
|
* @return the zone type
|
||||||
*/
|
*/
|
||||||
static inline TropicZone GetTropicZone(TileIndex tile)
|
static inline TropicZone GetTropicZone(TileIndex tile)
|
||||||
|
Loading…
Reference in New Issue
Block a user