OpenTTD Source: src/rail_type.h Source File

OpenTTD Source 15.0-beta1

rail_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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef RAIL_TYPE_H
11#define RAIL_TYPE_H
12
13#include "core/enum_type.hpp"
14
15typedef uint32_t RailTypeLabel;
16
17static const RailTypeLabel RAILTYPE_LABEL_RAIL = 'RAIL';
18static const RailTypeLabel RAILTYPE_LABEL_ELECTRIC = 'ELRL';
19static const RailTypeLabel RAILTYPE_LABEL_MONO = 'MONO';
20static const RailTypeLabel RAILTYPE_LABEL_MAGLEV = 'MGLV';
21
27 enum RailType : uint8_t {
28 RAILTYPE_BEGIN = 0,
29 RAILTYPE_RAIL = 0,
30 RAILTYPE_ELECTRIC = 1,
31 RAILTYPE_MONO = 2,
32 RAILTYPE_MAGLEV = 3,
33 RAILTYPE_END = 64,
34 INVALID_RAILTYPE = 0xFF,
35};
36
38 DECLARE_POSTFIX_INCREMENT(RailType)
39
40
44enum RailTypes : uint64_t {
45 RAILTYPES_NONE = 0,
46 RAILTYPES_RAIL = 1 << RAILTYPE_RAIL,
47 RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC,
48 RAILTYPES_MONO = 1 << RAILTYPE_MONO,
49 RAILTYPES_MAGLEV = 1 << RAILTYPE_MAGLEV,
50 INVALID_RAILTYPES = UINT64_MAX,
51};
52 DECLARE_ENUM_AS_BIT_SET(RailTypes)
53
54#endif /* RAIL_TYPE_H */
enum_type.hpp
Type (helpers) for enums.
DECLARE_ENUM_AS_BIT_SET
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:35
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition enum_type.hpp:18
RailTypes
RailTypes
Allow incrementing of Track variables.
Definition rail_type.h:44
RAILTYPES_ELECTRIC
@ RAILTYPES_ELECTRIC
Electrified rails.
Definition rail_type.h:47
INVALID_RAILTYPES
@ INVALID_RAILTYPES
Invalid railtypes.
Definition rail_type.h:50
RAILTYPES_MAGLEV
@ RAILTYPES_MAGLEV
Ever fast maglev.
Definition rail_type.h:49
RAILTYPES_RAIL
@ RAILTYPES_RAIL
Non-electrified rails.
Definition rail_type.h:46
RAILTYPES_NONE
@ RAILTYPES_NONE
No rail types.
Definition rail_type.h:45
RAILTYPES_MONO
@ RAILTYPES_MONO
Monorail!
Definition rail_type.h:48
RailType
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:27
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition rail_type.h:28
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition rail_type.h:33
RAILTYPE_MONO
@ RAILTYPE_MONO
Monorail.
Definition rail_type.h:31
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition rail_type.h:34
RAILTYPE_ELECTRIC
@ RAILTYPE_ELECTRIC
Electric rails.
Definition rail_type.h:30
RAILTYPE_RAIL
@ RAILTYPE_RAIL
Standard non-electric rails.
Definition rail_type.h:29
RAILTYPE_MAGLEV
@ RAILTYPE_MAGLEV
Maglev.
Definition rail_type.h:32