src/map_func.h
branchnoai
changeset 9724 b39bc69bb2f2
parent 9723 eee46cb39750
child 10455 22c441f5adf9
--- a/src/map_func.h	Wed Jan 09 18:11:12 2008 +0000
+++ b/src/map_func.h	Sun Feb 03 20:17:54 2008 +0000
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-/** @file map.h */
+/** @file map_func.h */
 
 #ifndef MAP_FUNC_H
 #define MAP_FUNC_H
@@ -57,6 +57,17 @@
 }
 
 /**
+ * Logarithm of the map size along the y side.
+ * @note try to avoid using this one
+ * @return 2^"return value" == MapSizeY()
+ */
+static inline uint MapLogY()
+{
+	extern uint _map_log_y;
+	return _map_log_y;
+}
+
+/**
  * Get the size of the map along the X
  * @return the number of tiles along the X of the map
  */
@@ -227,7 +238,7 @@
 /**
  * Adds an offset to a tile and check if we are still on the map.
  */
-uint TileAddWrap(TileIndex tile, int addx, int addy);
+TileIndex TileAddWrap(TileIndex tile, int addx, int addy);
 
 /**
  * Returns the TileIndexDiffC offset from a DiagDirection.
@@ -244,6 +255,20 @@
 }
 
 /**
+ * Returns the TileIndexDiffC offset from a Direction.
+ *
+ * @param dir The given direction
+ * @return The offset as TileIndexDiffC value
+ */
+static inline TileIndexDiffC TileIndexDiffCByDir(Direction dir)
+{
+	extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
+
+	assert(IsValidDirection(dir));
+	return _tileoffs_by_dir[dir];
+}
+
+/**
  * Add a TileIndexDiffC to a TileIndex and returns the new one.
  *
  * Returns tile + the diff given in diff. If the result tile would end up