summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/layer_func.h59
-rw-r--r--src/map_func.h60
2 files changed, 59 insertions, 60 deletions
diff --git a/src/layer_func.h b/src/layer_func.h
index be060cc27..d472d23b5 100644
--- a/src/layer_func.h
+++ b/src/layer_func.h
@@ -28,65 +28,6 @@ void FixUndergroundHeights();
#define FOR_ALL_LAYERS(var) for (uint var = 0; var < LayerCount(); var++)
-
-/**
- * Get the size of the layer along the X
- * @return the number of tiles along the X of the layer
- */
-static inline uint LayerSizeX()
-{
- extern uint _map_size_x;
- return _map_size_x;
-}
-
-/**
- * Get the size of the layer along the Y
- * @return the number of tiles along the Y of the layer
- */
-static inline uint LayerSizeY()
-{
- extern uint _layer_size_y;
- return _layer_size_y;
-}
-
-/**
- * Gets the maximum X coordinate within the map, including MP_VOID
- * @return the maximum X coordinate
- */
-static inline uint LayerMaxX()
-{
- return LayerSizeX() - 1;
-}
-
-/**
- * Gets the maximum Y coordinate within the map, including MP_VOID
- * @return the maximum Y coordinate
- */
-static inline uint LayerMaxY()
-{
- return LayerSizeY() - 1;
-}
-
-/**
- * Get the layer counts
- * @return the number of layers
- */
-static inline uint LayerCount()
-{
- extern uint _layer_count;
- return _layer_count;
-}
-
-/**
- * Get the layer counts
- * @return the number of layers
- */
-static inline uint LayerCountLog()
-{
- extern uint _layer_count_log;
- return _layer_count_log;
-}
-
/**
* Get the X component of a tile
* @param tile the tile to get the X component of
diff --git a/src/map_func.h b/src/map_func.h
index e8ab9036e..e00251243 100644
--- a/src/map_func.h
+++ b/src/map_func.h
@@ -114,6 +114,64 @@ static inline uint MapMaxY()
}
/**
+ * Get the size of the layer along the X
+ * @return the number of tiles along the X of the layer
+ */
+static inline uint LayerSizeX()
+{
+ extern uint _map_size_x;
+ return _map_size_x;
+}
+
+/**
+ * Get the size of the layer along the Y
+ * @return the number of tiles along the Y of the layer
+ */
+static inline uint LayerSizeY()
+{
+ extern uint _layer_size_y;
+ return _layer_size_y;
+}
+
+/**
+ * Gets the maximum X coordinate within the map, including MP_VOID
+ * @return the maximum X coordinate
+ */
+static inline uint LayerMaxX()
+{
+ return LayerSizeX() - 1;
+}
+
+/**
+ * Gets the maximum Y coordinate within the map, including MP_VOID
+ * @return the maximum Y coordinate
+ */
+static inline uint LayerMaxY()
+{
+ return LayerSizeY() - 1;
+}
+
+/**
+ * Get the layer counts
+ * @return the number of layers
+ */
+static inline uint LayerCount()
+{
+ extern uint _layer_count;
+ return _layer_count;
+}
+
+/**
+ * Get the layer counts
+ * @return the number of layers
+ */
+static inline uint LayerCountLog()
+{
+ extern uint _layer_count_log;
+ return _layer_count_log;
+}
+
+/**
* Scales the given value by the map size, where the given value is
* for a 256 by 256 map.
* @param n the value to scale
@@ -123,7 +181,7 @@ static inline uint ScaleByMapSize(uint n)
{
/* Subtract 12 from shift in order to prevent integer overflow
* for large values of n. It's safe since the min mapsize is 64x64. */
- return CeilDiv(n << (MapLogX() + MapLogY() - 12), 1 << 4);
+ return CeilDiv(n << (MapLogX() + MapLogY() - LayerCountLog() - 12), 1 << 4);
}