summaryrefslogtreecommitdiff
path: root/tile.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-05-22 07:12:09 +0000
committertron <tron@openttd.org>2005-05-22 07:12:09 +0000
commit870127fd307c1ac46c55cea2bd28a7301c54ca96 (patch)
tree59a88830232c0d1934e46187ce49269b371795a6 /tile.h
parent27dee01623e386ff08907c8507aa84be815d1d5f (diff)
downloadopenttd-870127fd307c1ac46c55cea2bd28a7301c54ca96.tar.xz
(svn r2358) Add macros for getting (GB) and setting (SB) a range of bits
Use them exemplarily to prettify (Get|Set)Tile(Type|Height)
Diffstat (limited to 'tile.h')
-rw-r--r--tile.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/tile.h b/tile.h
index d7194d9d7..7704275b5 100644
--- a/tile.h
+++ b/tile.h
@@ -46,15 +46,14 @@ static inline bool CorrectZ(uint tileh)
static inline uint TileHeight(TileIndex tile)
{
assert(tile < MapSize());
- return _map_type_and_height[tile] & 0xf;
+ return GB(_map_type_and_height[tile], 0, 4);
}
static inline void SetTileHeight(TileIndex tile, uint height)
{
assert(tile < MapSize());
assert(height < 16);
- _map_type_and_height[tile] &= ~0x0F;
- _map_type_and_height[tile] |= height;
+ SB(_map_type_and_height[tile], 0, 4, height);
}
static inline uint TilePixelHeight(TileIndex tile)
@@ -65,14 +64,13 @@ static inline uint TilePixelHeight(TileIndex tile)
static inline TileType GetTileType(TileIndex tile)
{
assert(tile < MapSize());
- return _map_type_and_height[tile] >> 4;
+ return GB(_map_type_and_height[tile], 4, 4);
}
static inline void SetTileType(TileIndex tile, TileType type)
{
assert(tile < MapSize());
- _map_type_and_height[tile] &= ~0xF0;
- _map_type_and_height[tile] |= type << 4;
+ SB(_map_type_and_height[tile], 4, 4, type);
}
static inline bool IsTileType(TileIndex tile, TileType type)