Fix ca19a0d: Send the proper network command when loading favorite face
[openttd-github.git] / src / tile_type.h
blob6b5514d90e4c662c520e27f5cc114d300f354daf
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_type.h Types related to tiles. */
10 #ifndef TILE_TYPE_H
11 #define TILE_TYPE_H
13 #include "core/strong_typedef_type.hpp"
15 static const uint TILE_SIZE = 16; ///< Tile size in world coordinates.
16 static const uint TILE_UNIT_MASK = TILE_SIZE - 1; ///< For masking in/out the inner-tile world coordinate units.
17 static const uint TILE_PIXELS = 32; ///< Pixel distance between tile columns/rows in #ZOOM_LVL_BASE.
18 static const uint TILE_HEIGHT = 8; ///< Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
20 static const uint MAX_BUILDING_PIXELS = 200; ///< Maximum height of a building in pixels in #ZOOM_LVL_BASE. (Also applies to "bridge buildings" on the bridge floor.)
21 static const int MAX_VEHICLE_PIXEL_X = 192; ///< Maximum width of a vehicle in pixels in #ZOOM_LVL_BASE.
22 static const int MAX_VEHICLE_PIXEL_Y = 96; ///< Maximum height of a vehicle in pixels in #ZOOM_LVL_BASE.
24 static const uint MAX_TILE_HEIGHT = 255; ///< Maximum allowed tile height
26 static const uint MIN_HEIGHTMAP_HEIGHT = 1; ///< Lowest possible peak value for heightmap creation
27 static const uint MIN_CUSTOM_TERRAIN_TYPE = 1; ///< Lowest possible peak value for world generation
29 static const uint MIN_MAP_HEIGHT_LIMIT = 15; ///< Lower bound of maximum allowed heightlevel (in the construction settings)
30 static const uint MAX_MAP_HEIGHT_LIMIT = MAX_TILE_HEIGHT; ///< Upper bound of maximum allowed heightlevel (in the construction settings)
32 static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height
33 static const uint DEF_SNOWLINE_HEIGHT = 10; ///< Default snowline height
34 static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
36 static const uint DEF_SNOW_COVERAGE = 40; ///< Default snow coverage.
37 static const uint DEF_DESERT_COVERAGE = 50; ///< Default desert coverage.
40 /**
41 * The different types of tiles.
43 * Each tile belongs to one type, according whatever is build on it.
45 * @note A railway with a crossing street is marked as MP_ROAD.
47 enum TileType {
48 MP_CLEAR, ///< A tile without any structures, i.e. grass, rocks, farm fields etc.
49 MP_RAILWAY, ///< A railway
50 MP_ROAD, ///< A tile with road (or tram tracks)
51 MP_HOUSE, ///< A house by a town
52 MP_TREES, ///< Tile got trees
53 MP_STATION, ///< A tile of a station
54 MP_WATER, ///< Water tile
55 MP_VOID, ///< Invisible tiles at the SW and SE border
56 MP_INDUSTRY, ///< Part of an industry
57 MP_TUNNELBRIDGE, ///< Tunnel entry/exit and bridge heads
58 MP_OBJECT, ///< Contains objects such as transmitters and owned land
61 /**
62 * Additional infos of a tile on a tropic game.
64 * The tropiczone is not modified during gameplay. It mainly affects tree growth. (desert tiles are visible though)
66 * In randomly generated maps:
67 * TROPICZONE_DESERT: Generated everywhere, if there is neither water nor mountains (TileHeight >= 4) in a certain distance from the tile.
68 * TROPICZONE_RAINFOREST: Generated everywhere, if there is no desert in a certain distance from the tile.
69 * TROPICZONE_NORMAL: Everywhere else, i.e. between desert and rainforest and on sea (if you clear the water).
71 * In scenarios:
72 * TROPICZONE_NORMAL: Default value.
73 * TROPICZONE_DESERT: Placed manually.
74 * TROPICZONE_RAINFOREST: Placed if you plant certain rainforest-trees.
76 enum TropicZone {
77 TROPICZONE_NORMAL = 0, ///< Normal tropiczone
78 TROPICZONE_DESERT = 1, ///< Tile is desert
79 TROPICZONE_RAINFOREST = 2, ///< Rainforest tile
82 /**
83 * The index/ID of a Tile.
85 struct TileIndex : StrongIntegralTypedef<uint32, TileIndex> {
86 using StrongIntegralTypedef<uint32, TileIndex>::StrongIntegralTypedef;
88 /** Implicit conversion to the base type for e.g. array indexing. */
89 constexpr operator uint32() const { return this->value; }
91 /* Import operators from the base class into our overload set. */
92 using StrongIntegralTypedef::operator ==;
93 using StrongIntegralTypedef::operator !=;
94 using StrongIntegralTypedef::operator +;
95 using StrongIntegralTypedef::operator -;
97 /* Add comparison and add/sub for signed ints as e.g. 0 is signed and will
98 * match ambiguously when only unsigned overloads are present. */
99 constexpr bool operator ==(int rhs) const { return this->value == (uint32)rhs; }
100 constexpr bool operator !=(int rhs) const { return this->value != (uint32)rhs; }
101 constexpr TileIndex operator +(int rhs) const { return { (uint32)(this->value + rhs) }; }
102 constexpr TileIndex operator -(int rhs) const { return { (uint32)(this->value - rhs) }; }
106 * The very nice invalid tile marker
108 static inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32)-1 };
110 #endif /* TILE_TYPE_H */