summaryrefslogtreecommitdiff
path: root/map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-06-25 16:44:57 +0000
committertron <tron@openttd.org>2005-06-25 16:44:57 +0000
commitbec5e4fb4cc475596e1f22db9232e2bd9a190d89 (patch)
treeed8629cbd76a9334fd657971f55ef5cb63c9915f /map.h
parent61f6f07edd837728d72e83daa0a4b8893ec77307 (diff)
downloadopenttd-bec5e4fb4cc475596e1f22db9232e2bd9a190d89.tar.xz
(svn r2487) Replace TILE_XY by TileXY/TileDiffXY
Diffstat (limited to 'map.h')
-rw-r--r--map.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/map.h b/map.h
index 128917743..cd904d0c4 100644
--- a/map.h
+++ b/map.h
@@ -3,8 +3,6 @@
#include "stdafx.h"
-#define TILE_XY(x,y) (((y) << MapLogX()) + (x))
-
#define TILE_MASK(x) ((x) & ((1 << (MapLogX() + MapLogY())) - 1))
#define TILE_ASSERT(x) assert(TILE_MASK(x) == (x));
@@ -35,6 +33,17 @@ uint ScaleByMapSize(uint); // Scale relative to the number of tiles
uint ScaleByMapSize1D(uint); // Scale relative to the circumference of the map
typedef uint32 TileIndex;
+typedef int32 TileIndexDiff;
+
+static inline TileIndex TileXY(uint x, uint y)
+{
+ return (y << MapLogX()) + x;
+}
+
+static inline TileIndexDiff TileDiffXY(int x, int y)
+{
+ return (y << MapLogX()) + x;
+}
static inline TileIndex TileVirtXY(uint x, uint y)
{
@@ -70,8 +79,6 @@ static inline uint TileY(TileIndex tile)
}
-typedef int32 TileIndexDiff;
-
typedef struct TileIndexDiffC {
int16 x;
int16 y;
@@ -91,7 +98,7 @@ static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
#define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__))
#endif
-#define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TILE_XY(x, y))
+#define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y))
uint TileAddWrap(TileIndex tile, int addx, int addy);
@@ -109,7 +116,7 @@ static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC dif
if (x < 0 || y < 0 || x > (int)MapMaxX() || y > (int)MapMaxY())
return INVALID_TILE;
else
- return TILE_XY(x, y);
+ return TileXY(x, y);
}
// Functions to calculate distances