changeset 15769:e61270493ab3 draft

(svn r20443) -Codechange: more TileHash to a more generic location
author rubidium <rubidium@openttd.org>
date Tue, 10 Aug 2010 23:31:43 +0000
parents 4559798876dc
children ecdb897e3cd5
files src/tile_map.h src/town.h
diffstat 2 files changed, 32 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/tile_map.h
+++ b/src/tile_map.h
@@ -206,4 +206,35 @@
 uint GetTileZ(TileIndex tile);
 uint GetTileMaxZ(TileIndex tile);
 
-#endif /* TILE_TYPE_H */
+
+/**
+ * Calculate a hash value from a tile position
+ *
+ * @param x The X coordinate
+ * @param y The Y coordinate
+ * @return The hash of the tile
+ */
+static inline uint TileHash(uint x, uint y)
+{
+	uint hash = x >> 4;
+	hash ^= x >> 6;
+	hash ^= y >> 4;
+	hash -= y >> 6;
+	return hash;
+}
+
+/**
+ * Get the last two bits of the TileHash
+ *  from a tile position.
+ *
+ * @see TileHash()
+ * @param x The X coordinate
+ * @param y The Y coordinate
+ * @return The last two bits from hash of the tile
+ */
+static inline uint TileHash2Bit(uint x, uint y)
+{
+	return GB(TileHash(x, y), 0, 2);
+}
+
+#endif /* TILE_MAP_H */
--- a/src/town.h
+++ b/src/town.h
@@ -233,36 +233,6 @@
 extern TownID _new_town_id;
 
 /**
- * Calculate a hash value from a tile position
- *
- * @param x The X coordinate
- * @param y The Y coordinate
- * @return The hash of the tile
- */
-static inline uint TileHash(uint x, uint y)
-{
-	uint hash = x >> 4;
-	hash ^= x >> 6;
-	hash ^= y >> 4;
-	hash -= y >> 6;
-	return hash;
-}
-
-/**
- * Get the last two bits of the TileHash
- *  from a tile position.
- *
- * @see TileHash()
- * @param x The X coordinate
- * @param y The Y coordinate
- * @return The last two bits from hash of the tile
- */
-static inline uint TileHash2Bit(uint x, uint y)
-{
-	return GB(TileHash(x, y), 0, 2);
-}
-
-/**
  * Set the default name for a depot/waypoint
  * @tparam T The type/class to make a default name for
  * @param obj The object/instance we want to find the name for