diff options
author | Erich Eckner <git@eckner.net> | 2018-11-21 15:24:28 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-01-16 21:58:17 +0100 |
commit | 5d00438a858bb4a404d2b5d5c6f9d9fa9e58663f (patch) | |
tree | 6b94e2ceb69d1a9d8453f8553aa4139d0ee9b0f4 | |
parent | b7fac710bafe0bb9173700c52d21343a42dae0db (diff) | |
download | openttd-5d00438a858bb4a404d2b5d5c6f9d9fa9e58663f.tar.xz |
ScaleByMapSize should not scale by layerCount(), too - and we need to move some lines from layer_func.h to map_func.h to avoid cyclic includes
-rw-r--r-- | src/layer_func.h | 59 | ||||
-rw-r--r-- | src/map_func.h | 60 |
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); } |