summaryrefslogtreecommitdiff
path: root/map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-01-06 11:39:00 +0000
committertron <tron@openttd.org>2005-01-06 11:39:00 +0000
commitf8c95a1dbeac23296cacc83ae25d2a8b352cd83d (patch)
treef875975dc056d7d3fea370018fa0bdf62837fd3e /map.h
parent790b03c7071388addd4cb064e473e96f8e1f12e0 (diff)
downloadopenttd-f8c95a1dbeac23296cacc83ae25d2a8b352cd83d.tar.xz
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
Diffstat (limited to 'map.h')
-rw-r--r--map.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/map.h b/map.h
index 7a5ed5ff4..c234de5a8 100644
--- a/map.h
+++ b/map.h
@@ -26,13 +26,22 @@ static inline uint MapSize(void) { return MapSizeX() * MapSizeY(); }
typedef int16 TileIndexDiff;
+typedef struct TileIndexDiffC {
+ int16 x;
+ int16 y;
+} TileIndexDiffC;
+
+static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
+{
+ return (tidc.y << MapLogX()) + tidc.x;
+}
static inline TileIndexDiff TileOffsByDir(uint dir)
{
- extern const TileIndexDiff _tileoffs_by_dir[4];
+ extern const TileIndexDiffC _tileoffs_by_dir[4];
assert(dir < lengthof(_tileoffs_by_dir));
- return _tileoffs_by_dir[dir];
+ return ToTileIndexDiff(_tileoffs_by_dir[dir]);
}
#endif