Translations update
[openttd/fttd.git] / src / tile / zoneheight.h
blobecaa989eed409f1ee20289539f9ca17b4aa7a2de
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file tile/zoneheight.h Types related to tile zone and height. */
10 #ifndef TILE_ZONEHEIGHT_H
11 #define TILE_ZONEHEIGHT_H
13 #include "../stdafx.h"
14 #include "../core/bitmath_func.hpp"
15 #include "../direction_type.h"
17 static const uint MAX_TILE_HEIGHT = 255; ///< Maximum allowed tile height
19 static const uint MIN_MAX_HEIGHTLEVEL = 15; ///< Lower bound of maximum allowed heightlevel (in the construction settings)
20 static const uint DEF_MAX_HEIGHTLEVEL = 30; ///< Default maximum allowed heightlevel (in the construction settings)
21 static const uint MAX_MAX_HEIGHTLEVEL = MAX_TILE_HEIGHT; ///< Upper bound of maximum allowed heightlevel (in the construction settings)
23 static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height
24 static const uint DEF_SNOWLINE_HEIGHT = 15; ///< Default snowline height
25 static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
27 /**
28 * Tropic zone of a tile (subtropic climate only).
30 * The tropiczone is not modified during gameplay. It mainly affects tree growth (desert tiles are visible though).
32 * In randomly generated maps:
33 * TROPICZONE_DESERT: Generated everywhere, if there is neither water nor mountains (TileHeight >= 4) in a certain distance from the tile.
34 * TROPICZONE_RAINFOREST: Generated everywhere, if there is no desert in a certain distance from the tile.
35 * TROPICZONE_NORMAL: Everywhere else, i.e. between desert and rainforest and on sea (if you clear the water).
37 * In scenarios:
38 * TROPICZONE_NORMAL: Default value.
39 * TROPICZONE_DESERT: Placed manually.
40 * TROPICZONE_RAINFOREST: Placed if you plant certain rainforest-trees.
42 enum TropicZone {
43 TROPICZONE_NORMAL = 0, ///< Normal tropiczone
44 TROPICZONE_DESERT = 1, ///< Tile is desert
45 TROPICZONE_RAINFOREST = 2, ///< Rainforest tile
48 /** Zone and height of a tile. */
49 struct TileZH {
50 byte height; ///< height of the (northern corner of the) tile
51 byte zb; ///< tile zone (2 most significant bits), bridge above (2 least significant bits)
54 /**
55 * Get the height of a tile
57 * This function returns the height of the northern corner of a tile.
59 * @param t The tile whose height to get
60 * @return The height of the tile
62 static inline uint tilezh_get_height(const TileZH *t)
64 return t->height;
67 /**
68 * Set the height of a tile
70 * This function sets the height of the northern corner of a tile.
72 * @param t The tile whose height to set
73 * @param height The new height value of the tile
74 * @pre height <= MAX_TILE_HEIGHT
76 static inline void tilezh_set_height(TileZH *t, uint height)
78 assert(height <= MAX_TILE_HEIGHT);
79 t->height = height;
82 /**
83 * Get the tropic zone of a tile
84 * @param t The tile whose zone to get
85 * @return The zone type of the tile
87 static inline TropicZone tilezh_get_zone(const TileZH *t)
89 return (TropicZone)GB(t->zb, 6, 2);
92 /**
93 * Set the tropic zone of a tile
94 * @param t The tile whose zone to set
95 * @param z The new zone type
96 * @pre tile < MapSize()
98 static inline void tilezh_set_zone(TileZH *t, TropicZone z)
100 SB(t->zb, 6, 2, z);
105 * Check if this tile has a bridge over it
106 * @param t The tile to check
107 * @return Whether there is a bridge above the tile
109 static inline bool tile_has_bridge_above (const TileZH *t)
111 return GB(t->zb, 0, 2) != 0;
115 * Get the axis of the bridge over a tile
116 * @param t The tile
117 * @pre tile_has_bridge_above(t)
118 * @return The axis of the bridge
120 static inline Axis tile_get_bridge_axis (const TileZH *t)
122 assert (tile_has_bridge_above (t));
123 return (Axis)(GB(t->zb, 0, 2) - 1);
127 * Remove the bridge over a tile
128 * @param t The tile
130 static inline void tile_clear_bridge_above (TileZH *t)
132 SB(t->zb, 0, 2, 0);
136 * Set a bridge over a tile
137 * @param t The tile
138 * @param a Axis of the bridge
139 * @pre !tile_has_bridge_above(t)
141 static inline void tile_set_bridge_above (TileZH *t, Axis a)
143 assert (!tile_has_bridge_above (t));
144 SB(t->zb, 0, 2, 1 << a);
147 #endif /* TILE_ZONEHEIGHT_H */