OpenTTD Source: src/tile_type.h Source File

OpenTTD Source 15.0-RC2

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
13#include "core/strong_typedef_type.hpp"
14
15 static constexpr uint TILE_SIZE = 16;
16 static constexpr uint TILE_UNIT_MASK = TILE_SIZE - 1;
17 static constexpr uint TILE_PIXELS = 32;
18 static constexpr uint TILE_HEIGHT = 8;
19
20 static constexpr uint MAX_BUILDING_PIXELS = 200;
21 static constexpr int MAX_VEHICLE_PIXEL_X = 192;
22 static constexpr int MAX_VEHICLE_PIXEL_Y = 96;
23
24 static constexpr uint MAX_TILE_HEIGHT = 255;
25
26 static constexpr uint MIN_HEIGHTMAP_HEIGHT = 1;
27 static constexpr uint MIN_CUSTOM_TERRAIN_TYPE = 1;
28
29 static constexpr uint MIN_MAP_HEIGHT_LIMIT = 15;
30 static constexpr uint MAX_MAP_HEIGHT_LIMIT = MAX_TILE_HEIGHT;
31
32 static constexpr uint MIN_SNOWLINE_HEIGHT = 2;
33 static constexpr uint DEF_SNOWLINE_HEIGHT = 10;
34 static constexpr uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2);
35
36 static constexpr uint DEF_SNOW_COVERAGE = 40;
37 static constexpr uint DEF_DESERT_COVERAGE = 50;
38
39
47 enum TileType : uint8_t {
48 MP_CLEAR,
49 MP_RAILWAY,
50 MP_ROAD,
51 MP_HOUSE,
52 MP_TREES,
53 MP_STATION,
54 MP_WATER,
55 MP_VOID,
56 MP_INDUSTRY,
57 MP_TUNNELBRIDGE,
58 MP_OBJECT,
59};
60
76 enum TropicZone : uint8_t {
77 TROPICZONE_NORMAL = 0,
78 TROPICZONE_DESERT = 1,
79 TROPICZONE_RAINFOREST = 2,
80};
81
87 using TileIndex = StrongType::Typedef<uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int32_t>, StrongType::Compatible<int64_t>>;
88
89/* Make sure the size is as expected. */
90static_assert(sizeof(TileIndex) == 4);
91
95 inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32_t)-1 };
96
97#endif /* TILE_TYPE_H */
strong_typedef_type.hpp
Type (helpers) for making a strong typedef that is a distinct type.
StrongType::Compatible
Mix-in which makes the new Typedef compatible with another type (which is not the base type).
Definition strong_typedef_type.hpp:104
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
MAX_TILE_HEIGHT
static constexpr uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Definition tile_type.h:24
TILE_UNIT_MASK
static constexpr uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
Definition tile_type.h:16
MAX_BUILDING_PIXELS
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
DEF_SNOWLINE_HEIGHT
static constexpr uint DEF_SNOWLINE_HEIGHT
Default snowline height.
Definition tile_type.h:33
MIN_CUSTOM_TERRAIN_TYPE
static constexpr uint MIN_CUSTOM_TERRAIN_TYPE
Lowest possible peak value for world generation.
Definition tile_type.h:27
DEF_DESERT_COVERAGE
static constexpr uint DEF_DESERT_COVERAGE
Default desert coverage.
Definition tile_type.h:37
MAX_VEHICLE_PIXEL_Y
static constexpr int MAX_VEHICLE_PIXEL_Y
Maximum height of a vehicle in pixels in ZOOM_BASE.
Definition tile_type.h:22
MIN_MAP_HEIGHT_LIMIT
static constexpr uint MIN_MAP_HEIGHT_LIMIT
Lower bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:29
TropicZone
TropicZone
Additional infos of a tile on a tropic game.
Definition tile_type.h:76
TROPICZONE_RAINFOREST
@ TROPICZONE_RAINFOREST
Rainforest tile.
Definition tile_type.h:79
TROPICZONE_DESERT
@ TROPICZONE_DESERT
Tile is desert.
Definition tile_type.h:78
TROPICZONE_NORMAL
@ TROPICZONE_NORMAL
Normal tropiczone.
Definition tile_type.h:77
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
TileIndex
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:87
MAX_SNOWLINE_HEIGHT
static constexpr uint MAX_SNOWLINE_HEIGHT
Maximum allowed snowline height.
Definition tile_type.h:34
MAX_MAP_HEIGHT_LIMIT
static constexpr uint MAX_MAP_HEIGHT_LIMIT
Upper bound of maximum allowed heightlevel (in the construction settings)
Definition tile_type.h:30
TILE_SIZE
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15
TILE_PIXELS
static constexpr uint TILE_PIXELS
Pixel distance between tile columns/rows in ZOOM_BASE.
Definition tile_type.h:17
MIN_HEIGHTMAP_HEIGHT
static constexpr uint MIN_HEIGHTMAP_HEIGHT
Lowest possible peak value for heightmap creation.
Definition tile_type.h:26
DEF_SNOW_COVERAGE
static constexpr uint DEF_SNOW_COVERAGE
Default snow coverage.
Definition tile_type.h:36
MIN_SNOWLINE_HEIGHT
static constexpr uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
Definition tile_type.h:32
MAX_VEHICLE_PIXEL_X
static constexpr int MAX_VEHICLE_PIXEL_X
Maximum width of a vehicle in pixels in ZOOM_BASE.
Definition tile_type.h:21
TILE_HEIGHT
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
TileType
The different types of tiles.
Definition tile_type.h:47
MP_TREES
@ MP_TREES
Tile got trees.
Definition tile_type.h:52
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition tile_type.h:50
MP_STATION
@ MP_STATION
A tile of a station.
Definition tile_type.h:53
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition tile_type.h:57
MP_CLEAR
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
Definition tile_type.h:48
MP_HOUSE
@ MP_HOUSE
A house by a town.
Definition tile_type.h:51
MP_WATER
@ MP_WATER
Water tile.
Definition tile_type.h:54
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition tile_type.h:49
MP_INDUSTRY
@ MP_INDUSTRY
Part of an industry.
Definition tile_type.h:56
MP_VOID
@ MP_VOID
Invisible tiles at the SW and SE border.
Definition tile_type.h:55
MP_OBJECT
@ MP_OBJECT
Contains objects such as transmitters and owned land.
Definition tile_type.h:58