OpenTTD Source 20260129-master-g2bb01bd0e4
tile_type.h
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef TILE_TYPE_H
11#define TILE_TYPE_H
12
14
15static constexpr uint TILE_SIZE = 16;
16static constexpr uint TILE_UNIT_MASK = TILE_SIZE - 1;
17static constexpr uint TILE_PIXELS = 32;
18static constexpr uint TILE_HEIGHT = 8;
19
20static constexpr uint MAX_BUILDING_PIXELS = 200;
21static constexpr int MAX_VEHICLE_PIXEL_X = 192;
22static constexpr int MAX_VEHICLE_PIXEL_Y = 96;
23
24static constexpr uint MAX_TILE_HEIGHT = 255;
25
26static constexpr uint MIN_HEIGHTMAP_HEIGHT = 1;
27static constexpr uint MIN_CUSTOM_TERRAIN_TYPE = 1;
28
29static constexpr uint MIN_MAP_HEIGHT_LIMIT = 15;
30static constexpr uint MAX_MAP_HEIGHT_LIMIT = MAX_TILE_HEIGHT;
31
32static constexpr uint MIN_SNOWLINE_HEIGHT = 2;
33static constexpr uint DEF_SNOWLINE_HEIGHT = 10;
34static constexpr uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2);
35
36static constexpr uint DEF_SNOW_COVERAGE = 40;
37static constexpr uint DEF_DESERT_COVERAGE = 50;
38
39static constexpr size_t TILE_TYPE_BITS = 4;
40
48enum class TileType : uint8_t {
49 Clear,
50 Railway,
51 Road,
52 House,
53 Trees,
54 Station,
55 Water,
56 Void,
57 Industry,
59 Object,
60 End,
61 MaxSize = 1U << TILE_TYPE_BITS,
62};
63
64static_assert(TileType::End <= TileType::MaxSize);
65
86
93
94/* Make sure the size is as expected. */
95static_assert(sizeof(TileIndex) == 4);
96
100inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32_t)-1 };
101
102#endif /* TILE_TYPE_H */
Type (helpers) for making a strong typedef that is a distinct type.
Mix-in which makes the new Typedef compatible with another type (which is not the base type).
static constexpr uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition tile_type.h:24
static constexpr uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
Definition tile_type.h:16
static constexpr uint MAX_BUILDING_PIXELS
Maximum height of a building in pixels in ZOOM_BASE. (Also applies to "bridge buildings" on the bridg...
Definition tile_type.h:20
static constexpr size_t TILE_TYPE_BITS
How many bits in map array are dedicated for type of each tile.
Definition tile_type.h:39
static constexpr uint DEF_SNOWLINE_HEIGHT
Default snowline height.
Definition tile_type.h:33
static constexpr uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition tile_type.h:27
static constexpr uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition tile_type.h:37
static constexpr int MAX_VEHICLE_PIXEL_Y
Maximum height of a vehicle in pixels in ZOOM_BASE.
Definition tile_type.h:22
static constexpr uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:29
TropicZone
Additional infos of a tile on a tropic game.
Definition tile_type.h:81
@ TROPICZONE_RAINFOREST
Rainforest tile.
Definition tile_type.h:84
@ TROPICZONE_DESERT
Tile is desert.
Definition tile_type.h:83
@ TROPICZONE_NORMAL
Normal tropiczone.
Definition tile_type.h:82
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:100
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
static constexpr uint MAX_SNOWLINE_HEIGHT
Maximum allowed snowline height.
Definition tile_type.h:34
static constexpr uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:30
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15
static constexpr uint TILE_PIXELS
Pixel distance between tile columns/rows in ZOOM_BASE.
Definition tile_type.h:17
static constexpr uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition tile_type.h:26
static constexpr uint DEF_SNOW_COVERAGE
Default snow coverage.
Definition tile_type.h:36
static constexpr uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
Definition tile_type.h:32
static constexpr int MAX_VEHICLE_PIXEL_X
Maximum width of a vehicle in pixels in ZOOM_BASE.
Definition tile_type.h:21
static constexpr uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in ZOOM_BASE.
Definition tile_type.h:18
TileType
The different types of tiles.
Definition tile_type.h:48
@ TunnelBridge
Tunnel entry/exit and bridge heads.
@ Water
Water tile.
@ MaxSize
The maximum possible number of tile types to be stored in map.
@ Station
A tile of a station or airport.
@ Object
Contains objects such as transmitters and owned land.
@ Industry
Part of an industry.
@ Railway
A tile with railway.
@ Void
Invisible tiles at the SW and SE border.
@ End
End marker.
@ Trees
Tile with one or more trees.
@ House
A house by a town.
@ Road
A tile with road and/or tram tracks.
@ Clear
A tile without any structures, i.e. grass, rocks, farm fields etc.