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/>.
8 /** @file rail_type.h The different types of rail */
13 #include "core/enum_type.hpp"
15 typedef uint32_t RailTypeLabel
;
17 static const RailTypeLabel RAILTYPE_LABEL_RAIL
= 'RAIL';
18 static const RailTypeLabel RAILTYPE_LABEL_ELECTRIC
= 'ELRL';
19 static const RailTypeLabel RAILTYPE_LABEL_MONO
= 'MONO';
20 static const RailTypeLabel RAILTYPE_LABEL_MAGLEV
= 'MGLV';
23 * Enumeration for all possible railtypes.
25 * This enumeration defines all 4 possible railtypes.
27 enum RailType
: uint8_t {
28 RAILTYPE_BEGIN
= 0, ///< Used for iterations
29 RAILTYPE_RAIL
= 0, ///< Standard non-electric rails
30 RAILTYPE_ELECTRIC
= 1, ///< Electric rails
31 RAILTYPE_MONO
= 2, ///< Monorail
32 RAILTYPE_MAGLEV
= 3, ///< Maglev
33 RAILTYPE_END
= 64, ///< Used for iterations
34 INVALID_RAILTYPE
= 0xFF, ///< Flag for invalid railtype
37 /** Allow incrementing of Track variables */
38 DECLARE_POSTFIX_INCREMENT(RailType
)
41 * The different railtypes we support, but then a bitmask of them.
42 * @note Must be treated as a uint64_t type, narrowing it causes bit membership tests to give wrong results, as in bug #6951.
44 enum RailTypes
: uint64_t {
45 RAILTYPES_NONE
= 0, ///< No rail types
46 RAILTYPES_RAIL
= 1 << RAILTYPE_RAIL
, ///< Non-electrified rails
47 RAILTYPES_ELECTRIC
= 1 << RAILTYPE_ELECTRIC
, ///< Electrified rails
48 RAILTYPES_MONO
= 1 << RAILTYPE_MONO
, ///< Monorail!
49 RAILTYPES_MAGLEV
= 1 << RAILTYPE_MAGLEV
, ///< Ever fast maglev
50 INVALID_RAILTYPES
= UINT64_MAX
, ///< Invalid railtypes
52 DECLARE_ENUM_AS_BIT_SET(RailTypes
)
54 #endif /* RAIL_TYPE_H */