2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-01-18 03:48:29 +00:00
|
|
|
/** @file road_type.h Enums and other types related to roads. */
|
2007-12-18 20:38:16 +00:00
|
|
|
|
|
|
|
#ifndef ROAD_TYPE_H
|
|
|
|
#define ROAD_TYPE_H
|
|
|
|
|
|
|
|
#include "core/enum_type.hpp"
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
extern uint32_t _road_layout_change_counter;
|
2019-05-24 17:51:30 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
typedef uint32_t RoadTypeLabel;
|
2019-04-06 06:46:15 +00:00
|
|
|
|
2023-11-10 22:37:22 +00:00
|
|
|
static const RoadTypeLabel ROADTYPE_LABEL_ROAD = 'ROAD';
|
|
|
|
static const RoadTypeLabel ROADTYPE_LABEL_TRAM = 'ELRL';
|
2023-11-08 23:45:08 +00:00
|
|
|
|
2007-12-18 20:38:16 +00:00
|
|
|
/**
|
|
|
|
* The different roadtypes we support
|
|
|
|
*
|
|
|
|
* @note currently only ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
|
|
|
|
*/
|
|
|
|
enum RoadType {
|
2019-04-06 06:46:15 +00:00
|
|
|
ROADTYPE_BEGIN = 0, ///< Used for iterations
|
|
|
|
ROADTYPE_ROAD = 0, ///< Basic road type
|
|
|
|
ROADTYPE_TRAM = 1, ///< Trams
|
|
|
|
ROADTYPE_END = 63, ///< Used for iterations
|
|
|
|
INVALID_ROADTYPE = 63, ///< flag for invalid roadtype
|
2007-12-18 20:38:16 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_POSTFIX_INCREMENT(RoadType)
|
2019-04-06 06:46:15 +00:00
|
|
|
template <> struct EnumPropsT<RoadType> : MakeEnumPropsT<RoadType, byte, ROADTYPE_BEGIN, ROADTYPE_END, INVALID_ROADTYPE, 6> {};
|
2007-12-18 20:38:16 +00:00
|
|
|
|
|
|
|
/**
|
2019-04-06 06:46:15 +00:00
|
|
|
* The different roadtypes we support, but then a bitmask of them.
|
2024-01-07 16:41:53 +00:00
|
|
|
* @note Must be treated as a uint64_t type, narrowing it causes bit membership tests to give wrong results.
|
2007-12-18 20:38:16 +00:00
|
|
|
*/
|
2024-01-07 16:41:53 +00:00
|
|
|
enum RoadTypes : uint64_t {
|
2009-03-02 22:57:47 +00:00
|
|
|
ROADTYPES_NONE = 0, ///< No roadtypes
|
|
|
|
ROADTYPES_ROAD = 1 << ROADTYPE_ROAD, ///< Road
|
|
|
|
ROADTYPES_TRAM = 1 << ROADTYPE_TRAM, ///< Trams
|
2019-04-06 06:46:15 +00:00
|
|
|
INVALID_ROADTYPES = UINT64_MAX, ///< Invalid roadtypes
|
2007-12-18 20:38:16 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(RoadTypes)
|
2007-12-18 20:38:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enumeration for the road parts on a tile.
|
|
|
|
*
|
|
|
|
* This enumeration defines the possible road parts which
|
|
|
|
* can be build on a tile.
|
|
|
|
*/
|
|
|
|
enum RoadBits {
|
|
|
|
ROAD_NONE = 0U, ///< No road-part is build
|
|
|
|
ROAD_NW = 1U, ///< North-west part
|
|
|
|
ROAD_SW = 2U, ///< South-west part
|
|
|
|
ROAD_SE = 4U, ///< South-east part
|
|
|
|
ROAD_NE = 8U, ///< North-east part
|
|
|
|
ROAD_X = ROAD_SW | ROAD_NE, ///< Full road along the x-axis (south-west + north-east)
|
|
|
|
ROAD_Y = ROAD_NW | ROAD_SE, ///< Full road along the y-axis (north-west + south-east)
|
2009-07-22 16:56:36 +00:00
|
|
|
|
|
|
|
ROAD_N = ROAD_NE | ROAD_NW, ///< Road at the two northern edges
|
|
|
|
ROAD_E = ROAD_NE | ROAD_SE, ///< Road at the two eastern edges
|
|
|
|
ROAD_S = ROAD_SE | ROAD_SW, ///< Road at the two southern edges
|
|
|
|
ROAD_W = ROAD_NW | ROAD_SW, ///< Road at the two western edges
|
|
|
|
|
2010-04-20 17:49:11 +00:00
|
|
|
ROAD_ALL = ROAD_X | ROAD_Y, ///< Full 4-way crossing
|
|
|
|
|
2011-12-19 17:48:04 +00:00
|
|
|
ROAD_END = ROAD_ALL + 1, ///< Out-of-range roadbits, used for iterations
|
2007-12-18 20:38:16 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(RoadBits)
|
2010-04-20 17:49:11 +00:00
|
|
|
template <> struct EnumPropsT<RoadBits> : MakeEnumPropsT<RoadBits, byte, ROAD_NONE, ROAD_END, ROAD_NONE, 4> {};
|
2007-12-18 20:38:16 +00:00
|
|
|
|
|
|
|
#endif /* ROAD_TYPE_H */
|