OpenTTD

road_type.h
Go to the documentation of this file.
1 /* $Id: road_type.h 23595 2011-12-19 17:48:04Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
9
12 #ifndef ROAD_TYPE_H
13 #define ROAD_TYPE_H
14
15 #include "core/enum_type.hpp"
16
22 enum RoadType {
23 ROADTYPE_BEGIN = 0,
24 ROADTYPE_ROAD = 0,
25 ROADTYPE_TRAM = 1,
26 ROADTYPE_END,
27 INVALID_ROADTYPE = 0xFF,
28 };
29 DECLARE_POSTFIX_INCREMENT(RoadType)
30 template <> struct EnumPropsT<RoadType> : MakeEnumPropsT<RoadType, byte, ROADTYPE_BEGIN, ROADTYPE_END, INVALID_ROADTYPE, 2> {};
31
36 enum RoadTypes {
37 ROADTYPES_NONE = 0,
38 ROADTYPES_ROAD = 1 << ROADTYPE_ROAD,
39 ROADTYPES_TRAM = 1 << ROADTYPE_TRAM,
40 ROADTYPES_ALL = ROADTYPES_ROAD | ROADTYPES_TRAM,
41 ROADTYPES_END,
42 INVALID_ROADTYPES = 0xFF,
43 };
44 DECLARE_ENUM_AS_BIT_SET(RoadTypes)
45 template <> struct EnumPropsT<RoadTypes> : MakeEnumPropsT<RoadTypes, byte, ROADTYPES_NONE, ROADTYPES_END, INVALID_ROADTYPES, 2> {};
46 typedef SimpleTinyEnumT<RoadTypes, byte> RoadTypesByte;
47
48
55 enum RoadBits {
56 ROAD_NONE = 0U,
57 ROAD_NW = 1U,
58 ROAD_SW = 2U,
59 ROAD_SE = 4U,
60 ROAD_NE = 8U,
61 ROAD_X = ROAD_SW | ROAD_NE,
62 ROAD_Y = ROAD_NW | ROAD_SE,
63
64 ROAD_N = ROAD_NE | ROAD_NW,
65 ROAD_E = ROAD_NE | ROAD_SE,
66 ROAD_S = ROAD_SE | ROAD_SW,
67 ROAD_W = ROAD_NW | ROAD_SW,
68
69 ROAD_ALL = ROAD_X | ROAD_Y,
70
71 ROAD_END = ROAD_ALL + 1,
72 };
73 DECLARE_ENUM_AS_BIT_SET(RoadBits)
74 template <> struct EnumPropsT<RoadBits> : MakeEnumPropsT<RoadBits, byte, ROAD_NONE, ROAD_END, ROAD_NONE, 4> {};
75
76 #endif /* ROAD_TYPE_H */
MakeEnumPropsT
Helper template class that makes basic properties of given enumeration type visible from outsize...
Definition: enum_type.hpp:66
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
ROADTYPES_ALL
Road + trams.
Definition: road_type.h:40
ROADTYPE_ROAD
Basic road type.
Definition: road_type.h:24
ROAD_X
Full road along the x-axis (south-west + north-east)
Definition: road_type.h:61
ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
ROAD_SW
South-west part.
Definition: road_type.h:58
INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
enum_type.hpp
Type (helpers) for enums.
ROAD_END
Out-of-range roadbits, used for iterations.
Definition: road_type.h:71
ROAD_ALL
Full 4-way crossing.
Definition: road_type.h:69
ROAD_S
Road at the two southern edges.
Definition: road_type.h:66
ROAD_E
Road at the two eastern edges.
Definition: road_type.h:65
ROADTYPE_TRAM
Trams.
Definition: road_type.h:25
EnumPropsT
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:52
RoadBits
RoadBits
Enumeration for the road parts on a tile.
Definition: road_type.h:55
ROAD_NONE
No road-part is build.
Definition: road_type.h:56
INVALID_ROADTYPES
Invalid roadtypes.
Definition: road_type.h:42
ROAD_NE
North-east part.
Definition: road_type.h:60
ROADTYPES_TRAM
Trams.
Definition: road_type.h:39
SimpleTinyEnumT
Template of struct holding enum types (on most archs, enums are stored in an int32).
Definition: enum_type.hpp:139
RoadTypes
RoadTypes
The different roadtypes we support, but then a bitmask of them.
Definition: road_type.h:36
ROAD_NW
North-west part.
Definition: road_type.h:57
ROAD_SE
South-east part.
Definition: road_type.h:59
ROADTYPE_BEGIN
Used for iterations.
Definition: road_type.h:23
ROADTYPES_END
Used for iterations?
Definition: road_type.h:41
ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:37
ROAD_Y
Full road along the y-axis (north-west + south-east)
Definition: road_type.h:62
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
ROADTYPES_ROAD
Road.
Definition: road_type.h:38
ROAD_N
Road at the two northern edges.
Definition: road_type.h:64
ROAD_W
Road at the two western edges.
Definition: road_type.h:67