src/road.h
author truelight
Sun, 09 Sep 2007 23:57:47 +0000
changeset 8051 ec4e97b7b70c
parent 7891 5aac5be5fc2c
child 8062 9eb6efa04d44
permissions -rw-r--r--
(svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
3069
0e6aca11c3da (svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff changeset
     1
/* $Id$ */
0e6aca11c3da (svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff changeset
     2
6889
f7f6d9cb07a0 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6574
diff changeset
     3
/** @file road.h */
f7f6d9cb07a0 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6574
diff changeset
     4
3518
53847cf852c6 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents: 3497
diff changeset
     5
#ifndef ROAD_H
53847cf852c6 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents: 3497
diff changeset
     6
#define ROAD_H
3069
0e6aca11c3da (svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff changeset
     7
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
     8
#include "helpers.hpp"
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
     9
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    10
/**
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    11
 * The different roadtypes we support
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    12
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    13
 * @note currently only ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    14
 */
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    15
enum RoadType {
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    16
	ROADTYPE_ROAD = 0,      ///< Basic road type
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    17
	ROADTYPE_TRAM = 1,      ///< Trams
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    18
	ROADTYPE_HWAY = 2,      ///< Only a placeholder. Not sure what we are going to do with this road type.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    19
	ROADTYPE_END,           ///< Used for iterations
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    20
	INVALID_ROADTYPE = 0xFF ///< flag for invalid roadtype
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    21
};
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    22
DECLARE_POSTFIX_INCREMENT(RoadType);
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    23
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    24
/**
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    25
 * The different roadtypes we support, but then a bitmask of them
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    26
 * @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    27
 */
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    28
enum RoadTypes {
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    29
	ROADTYPES_NONE     = 0,                                                 ///< No roadtypes
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    30
	ROADTYPES_ROAD     = 1 << ROADTYPE_ROAD,                                ///< Road
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    31
	ROADTYPES_TRAM     = 1 << ROADTYPE_TRAM,                                ///< Trams
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    32
	ROADTYPES_HWAY     = 1 << ROADTYPE_HWAY,                                ///< Highway (or whatever substitute)
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    33
	ROADTYPES_ROADTRAM = ROADTYPES_ROAD | ROADTYPES_TRAM,                   ///< Road + trams
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    34
	ROADTYPES_ROADHWAY = ROADTYPES_ROAD | ROADTYPES_HWAY,                   ///< Road + highway (or whatever substitute)
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    35
	ROADTYPES_TRAMHWAY = ROADTYPES_TRAM | ROADTYPES_HWAY,                   ///< Trams + highway (or whatever substitute)
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    36
	ROADTYPES_ALL      = ROADTYPES_ROAD | ROADTYPES_TRAM | ROADTYPES_HWAY,  ///< Road + trams + highway (or whatever substitute)
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    37
};
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    38
DECLARE_ENUM_AS_BIT_SET(RoadTypes);
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    39
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    40
/**
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    41
 * Whether the given roadtype is valid.
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    42
 * @param rt the roadtype to check for validness
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    43
 * @return true if and only if valid
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    44
 */
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    45
static inline bool IsValidRoadType(RoadType rt)
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    46
{
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7157
diff changeset
    47
	return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    48
}
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    49
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    50
/**
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    51
 * Are the given bits pointing to valid roadtypes?
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    52
 * @param rts the roadtypes to check for validness
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    53
 * @return true if and only if valid
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    54
 */
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    55
static inline bool AreValidRoadTypes(RoadTypes rts)
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    56
{
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7157
diff changeset
    57
	return HASBIT(rts, ROADTYPE_ROAD) || HASBIT(rts, ROADTYPE_TRAM);
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    58
}
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    59
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    60
/**
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    61
 * Maps a RoadType to the corresponding RoadTypes value
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    62
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    63
 * @param rt the roadtype to get the roadtypes from
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    64
 * @return the roadtypes with the given roadtype
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    65
 */
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    66
static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    67
{
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    68
	return (RoadTypes)(1 << rt);
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    69
}
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    70
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    71
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    72
 * Returns the RoadTypes which are not present in the given RoadTypes
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    73
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    74
 * This function returns the complement of a given RoadTypes.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    75
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    76
 * @param r The given RoadTypes
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    77
 * @return The complement of the given RoadTypes
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    78
 * @note The unused value ROADTYPES_HWAY will be used, too.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    79
 */
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    80
static inline RoadTypes ComplementRoadTypes(RoadTypes r)
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    81
{
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    82
	return (RoadTypes)(ROADTYPES_ALL ^ r);
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    83
}
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
    84
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    85
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    86
 * Enumeration for the road parts on a tile.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    87
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    88
 * This enumeration defines the possible road parts which
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    89
 * can be build on a tile.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    90
 */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6442
diff changeset
    91
enum RoadBits {
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    92
	ROAD_NONE = 0U,                  ///< No road-part is build
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    93
	ROAD_NW   = 1U,                  ///< North-west part
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    94
	ROAD_SW   = 2U,                  ///< South-west part
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    95
	ROAD_SE   = 4U,                  ///< South-east part
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    96
	ROAD_NE   = 8U,                  ///< North-east part
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    97
	ROAD_X    = ROAD_SW | ROAD_NE,   ///< Full road along the x-axis (south-west + north-east)
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    98
	ROAD_Y    = ROAD_NW | ROAD_SE,   ///< Full road along the y-axis (north-west + south-east)
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
    99
	ROAD_ALL  = ROAD_X  | ROAD_Y     ///< Full 4-way crossing
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6442
diff changeset
   100
};
3069
0e6aca11c3da (svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff changeset
   101
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   102
DECLARE_ENUM_AS_BIT_SET(RoadBits);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   103
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   104
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   105
 * Calculate the complement of a RoadBits value
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   106
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   107
 * Simply flips all bits in the RoadBits value to get the complement
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   108
 * of the RoadBits.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   109
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   110
 * @param r The given RoadBits value
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   111
 * @return the complement
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   112
 */
3103
fb7f22d3bc9b (svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents: 3099
diff changeset
   113
static inline RoadBits ComplementRoadBits(RoadBits r)
fb7f22d3bc9b (svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents: 3099
diff changeset
   114
{
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3795
diff changeset
   115
	return (RoadBits)(ROAD_ALL ^ r);
3103
fb7f22d3bc9b (svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents: 3099
diff changeset
   116
}
fb7f22d3bc9b (svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents: 3099
diff changeset
   117
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   118
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   119
 * Create the road-part which belongs to the given DiagDirection
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   120
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   121
 * This function returns a RoadBits value which belongs to
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   122
 * the given DiagDirection.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   123
 *
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   124
 * @param d The DiagDirection
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   125
 * @return The result RoadBits which the selected road-part set
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   126
 */
3146
36523d434783 (svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents: 3145
diff changeset
   127
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
36523d434783 (svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents: 3145
diff changeset
   128
{
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3795
diff changeset
   129
	return (RoadBits)(1U << (3 ^ d));
3146
36523d434783 (svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents: 3145
diff changeset
   130
}
36523d434783 (svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents: 3145
diff changeset
   131
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   132
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   133
 * Checks whether the trackdir means that we are reversing.
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   134
 * @param dir the trackdir to check
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   135
 * @return true if it is a reversing road trackdir
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   136
 */
6335
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   137
static inline bool IsReversingRoadTrackdir(Trackdir dir)
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   138
{
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   139
	return (dir & 0x07) >= 6;
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   140
}
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   141
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   142
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   143
 * Checks whether the given trackdir is a straight road
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   144
 * @param dir the trackdir to check
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   145
 * @return true if it is a straight road trackdir
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   146
 */
6335
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   147
static inline bool IsStraightRoadTrackdir(Trackdir dir)
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   148
{
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   149
	return (dir & 0x06) == 0;
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   150
}
0c3dc188f099 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5838
diff changeset
   151
6442
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   152
/**
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   153
 * Is it allowed to remove the given road bits from the given tile?
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   154
 * @param tile      the tile to remove the road from
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   155
 * @param remove    the roadbits that are going to be removed
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   156
 * @param owner     the actual owner of the roadbits of the tile
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   157
 * @param edge_road are the removed bits from a town?
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
   158
 * @param rt        the road type to remove the bits from
6442
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   159
 * @return true when it is allowed to remove the road bits
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   160
 */
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6889
diff changeset
   161
bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt);
6442
10b44714b85d (svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents: 6335
diff changeset
   162
7891
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   163
/**
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   164
 * Draw the catenary for tram road bits
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   165
 * @param ti   information about the tile (position, slope)
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   166
 * @param tram the roadbits to draw the catenary for
5aac5be5fc2c (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 7187
diff changeset
   167
 */
7187
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7157
diff changeset
   168
void DrawTramCatenary(TileInfo *ti, RoadBits tram);
f7dc3204d457 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 7157
diff changeset
   169
4666
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3900
diff changeset
   170
#endif /* ROAD_H */