OpenTTD Source 20260721-master-g25ec12c62d
slope_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
12
13#ifndef SLOPE_TYPE_H
14#define SLOPE_TYPE_H
15
16#include "core/enum_type.hpp"
17
21enum Corner : uint8_t {
22 CORNER_W = 0,
23 CORNER_S = 1,
24 CORNER_E = 2,
25 CORNER_N = 3,
26 CORNER_END,
27 CORNER_INVALID = 0xFF
28};
29
34template <typename T>
36
84
85
86static constexpr uint8_t NUM_SLOPES = 19;
87
94template <typename T>
96
103template <typename T>
105
110#define M(x) (1U << (x))
113#undef M
114
115
119enum class Foundation : uint8_t {
125
126 /* Halftile foundations */
133
134 /* Special anti-zig-zag foundations for single horizontal/vertical track */
140
141 Invalid = 0xFF,
142};
143
144#endif /* SLOPE_TYPE_H */
A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific enum class.
#define T
Climate temperate.
Definition engines.h:91
Type (helpers) for enums.
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
@ Invalid
broken savegame (used internally)
Definition saveload.h:434
Corner
Enumeration of tile corners.
Definition slope_type.h:21
Slope
Enumeration for the slope-type.
Definition slope_type.h:53
@ SLOPE_HALFTILE_N
the north halftile is leveled (non continuous slope)
Definition slope_type.h:81
@ SLOPE_W
the west corner of the tile is raised
Definition slope_type.h:55
@ SLOPE_HALFTILE_MASK
three bits used for halftile slopes
Definition slope_type.h:77
@ SLOPE_ELEVATED
bit mask containing all 'simple' slopes
Definition slope_type.h:66
@ SLOPE_NS
north and south corner are raised
Definition slope_type.h:65
@ SLOPE_E
the east corner of the tile is raised
Definition slope_type.h:57
@ SLOPE_WSE
west, south and east corner are raised
Definition slope_type.h:68
@ SLOPE_S
the south corner of the tile is raised
Definition slope_type.h:56
@ SLOPE_N
the north corner of the tile is raised
Definition slope_type.h:58
@ SLOPE_SEN
south, east and north corner are raised
Definition slope_type.h:69
@ SLOPE_ENW
east, north and west corner are raised
Definition slope_type.h:70
@ SLOPE_SW
south and west corner are raised
Definition slope_type.h:61
@ SLOPE_FLAT
a flat tile
Definition slope_type.h:54
@ SLOPE_STEEP_W
a steep slope falling to east (from west)
Definition slope_type.h:71
@ SLOPE_HALFTILE_E
the east halftile is leveled (non continuous slope)
Definition slope_type.h:80
@ SLOPE_NE
north and east corner are raised
Definition slope_type.h:63
@ SLOPE_HALFTILE_S
the south halftile is leveled (non continuous slope)
Definition slope_type.h:79
@ SLOPE_STEEP_E
a steep slope falling to west (from east)
Definition slope_type.h:73
@ SLOPE_SE
south and east corner are raised
Definition slope_type.h:62
@ SLOPE_HALFTILE_W
the west halftile is leveled (non continuous slope)
Definition slope_type.h:78
@ SLOPE_NWS
north, west and south corner are raised
Definition slope_type.h:67
@ SLOPE_NW
north and west corner are raised
Definition slope_type.h:60
@ SLOPE_STEEP_N
a steep slope falling to south (from north)
Definition slope_type.h:74
@ SLOPE_STEEP_S
a steep slope falling to north (from south)
Definition slope_type.h:72
@ SLOPE_HALFTILE
one halftile is leveled (non continuous slope)
Definition slope_type.h:76
@ SLOPE_EW
east and west corner are raised
Definition slope_type.h:64
@ SLOPE_STEEP
indicates the slope is steep
Definition slope_type.h:59
static constexpr uint8_t NUM_SLOPES
The total number of possible slope types.
Definition slope_type.h:86
Foundation
Enumeration for Foundations.
Definition slope_type.h:119
@ Leveled
The tile is leveled up to a flat slope.
Definition slope_type.h:121
@ SteepLower
The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on...
Definition slope_type.h:124
@ RailW
Foundation for TRACK_BIT_LEFT, but not a leveled foundation.
Definition slope_type.h:135
@ HalfTileE
Level east halftile non-continuously.
Definition slope_type.h:130
@ None
The tile has no foundation, the slope remains unchanged.
Definition slope_type.h:120
@ HalfTileS
Level south halftile non-continuously.
Definition slope_type.h:129
@ End
End marker.
Definition slope_type.h:139
@ RailS
Foundation for TRACK_BIT_LOWER, but not a leveled foundation.
Definition slope_type.h:136
@ RailN
Foundation for TRACK_BIT_UPPER, but not a leveled foundation.
Definition slope_type.h:138
@ HalfTileN
Level north halftile non-continuously.
Definition slope_type.h:131
@ InclinedY
The tile has an along Y-axis inclined foundation.
Definition slope_type.h:123
@ SteepBoth
The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is lev...
Definition slope_type.h:127
@ InclinedX
The tile has an along X-axis inclined foundation.
Definition slope_type.h:122
@ HalfTileEnd
End marker for halftile foundations.
Definition slope_type.h:132
@ RailE
Foundation for TRACK_BIT_RIGHT, but not a leveled foundation.
Definition slope_type.h:137
@ HalfTileW
Level west halftile non-continuously.
Definition slope_type.h:128
static const uint32_t VALID_LEVEL_CROSSING_SLOPES
Constant bitset with safe slopes for building a level crossing.
Definition slope_type.h:112
EnumClassIndexContainer< std::array< T, SLOPE_ELEVATED >, Slope > NonSteepSlopeIndexArray
Array with non steep Slope as index.
Definition slope_type.h:104
EnumIndexArray< T, Corner, CORNER_END > CornerIndexArray
Array with Corner as index.
Definition slope_type.h:35
#define M(x)
Helper for creating a bitset of slopes.
Definition slope_type.h:110
EnumClassIndexContainer< std::array< T, SLOPE_STEEP|SLOPE_ELEVATED >, Slope > SlopeIndexArray
Array with Slope as index.
Definition slope_type.h:95