summaryrefslogtreecommitdiff
path: root/map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-01-07 17:02:43 +0000
committertron <tron@openttd.org>2005-01-07 17:02:43 +0000
commit7ca6b2b8b0d6f66966fa2ff01e3e9961314dfcc4 (patch)
treee4137b60a824b45ce09f668d58520e36dba10256 /map.h
parentf5c33e50733c46cee14e84ade6da0c171d96064b (diff)
downloadopenttd-7ca6b2b8b0d6f66966fa2ff01e3e9961314dfcc4.tar.xz
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
Diffstat (limited to 'map.h')
-rw-r--r--map.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/map.h b/map.h
index c234de5a8..f7bb61b70 100644
--- a/map.h
+++ b/map.h
@@ -4,6 +4,8 @@
#define TILE_X_BITS 8
#define TILE_Y_BITS 8
+#define TILE_MASK(x) (int)((x) & ((1 << (MapLogX() + MapLogY())) - 1))
+
extern byte _map_type_and_height[];
extern byte _map5[];
extern byte _map3_lo[];
@@ -24,6 +26,20 @@ static inline uint MapMaxY(void) { return MapSizeY() - 1; }
/* The number of tiles in the map */
static inline uint MapSize(void) { return MapSizeX() * MapSizeY(); }
+
+typedef uint16 TileIndex;
+
+static inline uint TileX(TileIndex tile)
+{
+ return tile & MapMaxX();
+}
+
+static inline uint TileY(TileIndex tile)
+{
+ return tile >> MapLogX();
+}
+
+
typedef int16 TileIndexDiff;
typedef struct TileIndexDiffC {