Fix: Violation of strict weak ordering in engine name sorter
[openttd-github.git] / src / rail_type.h
blob874a8ebbb649787c939c90e705591073abce1fd5
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 */
8 /** @file rail_type.h The different types of rail */
10 #ifndef RAIL_TYPE_H
11 #define RAIL_TYPE_H
13 #include "core/enum_type.hpp"
15 typedef uint32 RailTypeLabel;
17 static const RailTypeLabel RAILTYPE_RAIL_LABEL = 'RAIL';
18 static const RailTypeLabel RAILTYPE_ELECTRIC_LABEL = 'ELRL';
19 static const RailTypeLabel RAILTYPE_MONO_LABEL = 'MONO';
20 static const RailTypeLabel RAILTYPE_MAGLEV_LABEL = 'MGLV';
22 /**
23 * Enumeration for all possible railtypes.
25 * This enumeration defines all 4 possible railtypes.
27 enum RailType : byte {
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)
39 /** Define basic enum properties */
40 template <> struct EnumPropsT<RailType> : MakeEnumPropsT<RailType, byte, RAILTYPE_BEGIN, RAILTYPE_END, INVALID_RAILTYPE, 6> {};
42 /**
43 * The different railtypes we support, but then a bitmask of them.
44 * @note Must be treated as a uint64 type, narrowing it causes bit membership tests to give wrong results, as in bug #6951.
46 enum RailTypes : uint64 {
47 RAILTYPES_NONE = 0, ///< No rail types
48 RAILTYPES_RAIL = 1 << RAILTYPE_RAIL, ///< Non-electrified rails
49 RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails
50 RAILTYPES_MONO = 1 << RAILTYPE_MONO, ///< Monorail!
51 RAILTYPES_MAGLEV = 1 << RAILTYPE_MAGLEV, ///< Ever fast maglev
52 INVALID_RAILTYPES = UINT64_MAX, ///< Invalid railtypes
54 DECLARE_ENUM_AS_BIT_SET(RailTypes)
56 #endif /* RAIL_TYPE_H */