src/road.h
author belugas
Wed, 12 Sep 2007 23:56:21 +0000
changeset 7566 a8dd64b03224
parent 7395 7eee624d9741
child 7641 3a75903fd892
permissions -rw-r--r--
(svn r11091) -Codechange: Partial rewrite of the road management code of towns, in order to make it more readable and with improved performance. (FS#1161 by skidd13)
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
     1
/* $Id$ */
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
     2
6393
e1e4939d19b5 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6248
diff changeset
     3
/** @file road.h */
e1e4939d19b5 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6248
diff changeset
     4
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
     5
#ifndef ROAD_H
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
     6
#define ROAD_H
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
     7
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
     8
#include "helpers.hpp"
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
     9
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    10
/**
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    11
 * The different roadtypes we support
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    12
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    13
 * @note currently only ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    14
 */
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    15
enum RoadType {
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    16
	ROADTYPE_ROAD = 0,      ///< Basic road type
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    17
	ROADTYPE_TRAM = 1,      ///< Trams
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    18
	ROADTYPE_HWAY = 2,      ///< Only a placeholder. Not sure what we are going to do with this road type.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    19
	ROADTYPE_END,           ///< Used for iterations
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    20
	INVALID_ROADTYPE = 0xFF ///< flag for invalid roadtype
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    21
};
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    22
DECLARE_POSTFIX_INCREMENT(RoadType);
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    23
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    24
/**
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    25
 * The different roadtypes we support, but then a bitmask of them
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    26
 * @note currently only roadtypes with ROADTYPE_ROAD and ROADTYPE_TRAM are supported.
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    27
 */
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    28
enum RoadTypes {
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    29
	ROADTYPES_NONE     = 0,                                                 ///< No roadtypes
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    30
	ROADTYPES_ROAD     = 1 << ROADTYPE_ROAD,                                ///< Road
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    31
	ROADTYPES_TRAM     = 1 << ROADTYPE_TRAM,                                ///< Trams
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    32
	ROADTYPES_HWAY     = 1 << ROADTYPE_HWAY,                                ///< Highway (or whatever substitute)
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    33
	ROADTYPES_ROADTRAM = ROADTYPES_ROAD | ROADTYPES_TRAM,                   ///< Road + trams
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    34
	ROADTYPES_ROADHWAY = ROADTYPES_ROAD | ROADTYPES_HWAY,                   ///< Road + highway (or whatever substitute)
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    35
	ROADTYPES_TRAMHWAY = ROADTYPES_TRAM | ROADTYPES_HWAY,                   ///< Trams + highway (or whatever substitute)
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    36
	ROADTYPES_ALL      = ROADTYPES_ROAD | ROADTYPES_TRAM | ROADTYPES_HWAY,  ///< Road + trams + highway (or whatever substitute)
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    37
};
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    38
DECLARE_ENUM_AS_BIT_SET(RoadTypes);
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    39
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    40
/**
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    41
 * Whether the given roadtype is valid.
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    42
 * @param rt the roadtype to check for validness
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    43
 * @return true if and only if valid
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    44
 */
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    45
static inline bool IsValidRoadType(RoadType rt)
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    46
{
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6661
diff changeset
    47
	return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    48
}
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    49
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    50
/**
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    51
 * Are the given bits pointing to valid roadtypes?
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    52
 * @param rts the roadtypes to check for validness
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    53
 * @return true if and only if valid
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    54
 */
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    55
static inline bool AreValidRoadTypes(RoadTypes rts)
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    56
{
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6661
diff changeset
    57
	return HASBIT(rts, ROADTYPE_ROAD) || HASBIT(rts, ROADTYPE_TRAM);
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    58
}
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    59
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    60
/**
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    61
 * Maps a RoadType to the corresponding RoadTypes value
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    62
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    63
 * @param rt the roadtype to get the roadtypes from
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    64
 * @return the roadtypes with the given roadtype
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    65
 */
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    66
static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    67
{
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    68
	return (RoadTypes)(1 << rt);
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    69
}
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    70
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    71
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    72
 * Returns the RoadTypes which are not present in the given RoadTypes
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    73
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    74
 * This function returns the complement of a given RoadTypes.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    75
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    76
 * @param r The given RoadTypes
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    77
 * @return The complement of the given RoadTypes
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    78
 * @note The unused value ROADTYPES_HWAY will be used, too.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    79
 */
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    80
static inline RoadTypes ComplementRoadTypes(RoadTypes r)
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    81
{
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    82
	return (RoadTypes)(ROADTYPES_ALL ^ r);
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    83
}
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
    84
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    85
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    86
 * Enumeration for the road parts on a tile.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    87
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    88
 * This enumeration defines the possible road parts which
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    89
 * can be build on a tile.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    90
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6116
diff changeset
    91
enum RoadBits {
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    92
	ROAD_NONE = 0U,                  ///< No road-part is build
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    93
	ROAD_NW   = 1U,                  ///< North-west part
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    94
	ROAD_SW   = 2U,                  ///< South-west part
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    95
	ROAD_SE   = 4U,                  ///< South-east part
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    96
	ROAD_NE   = 8U,                  ///< North-east part
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    97
	ROAD_X    = ROAD_SW | ROAD_NE,   ///< Full road along the x-axis (south-west + north-east)
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    98
	ROAD_Y    = ROAD_NW | ROAD_SE,   ///< Full road along the y-axis (north-west + south-east)
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
    99
	ROAD_ALL  = ROAD_X  | ROAD_Y     ///< Full 4-way crossing
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6116
diff changeset
   100
};
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   101
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   102
DECLARE_ENUM_AS_BIT_SET(RoadBits);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   103
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   104
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   105
 * Calculate the complement of a RoadBits value
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   106
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   107
 * Simply flips all bits in the RoadBits value to get the complement
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   108
 * of the RoadBits.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   109
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   110
 * @param r The given RoadBits value
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   111
 * @return the complement
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   112
 */
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   113
static inline RoadBits ComplementRoadBits(RoadBits r)
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   114
{
3900
2c84ed52709d (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);
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   116
}
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   117
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   118
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   119
 * Create the road-part which belongs to the given DiagDirection
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   120
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   121
 * This function returns a RoadBits value which belongs to
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   122
 * the given DiagDirection.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   123
 *
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   124
 * @param d The DiagDirection
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   125
 * @return The result RoadBits which the selected road-part set
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   126
 */
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   127
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   128
{
7566
a8dd64b03224 (svn r11091) -Codechange: Partial rewrite of the road management code of towns, in order to make it more readable and with improved performance. (FS#1161 by skidd13)
belugas
parents: 7395
diff changeset
   129
	return (RoadBits)(ROAD_NW << (3 ^ d));
3518
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   130
}
c1e19f08fc25 (svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
diff changeset
   131
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   132
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   133
 * Checks whether the trackdir means that we are reversing.
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   134
 * @param dir the trackdir to check
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   135
 * @return true if it is a reversing road trackdir
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   136
 */
6009
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   137
static inline bool IsReversingRoadTrackdir(Trackdir dir)
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   138
{
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   139
	return (dir & 0x07) >= 6;
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   140
}
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   141
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   142
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   143
 * Checks whether the given trackdir is a straight road
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   144
 * @param dir the trackdir to check
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   145
 * @return true if it is a straight road trackdir
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   146
 */
6009
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   147
static inline bool IsStraightRoadTrackdir(Trackdir dir)
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   148
{
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   149
	return (dir & 0x06) == 0;
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   150
}
bbe756070082 (svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents: 5587
diff changeset
   151
6116
0a63874accb6 (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: 6009
diff changeset
   152
/**
0a63874accb6 (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: 6009
diff changeset
   153
 * Is it allowed to remove the given road bits from the given tile?
0a63874accb6 (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: 6009
diff changeset
   154
 * @param tile      the tile to remove the road from
0a63874accb6 (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: 6009
diff changeset
   155
 * @param remove    the roadbits that are going to be removed
0a63874accb6 (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: 6009
diff changeset
   156
 * @param owner     the actual owner of the roadbits of the tile
0a63874accb6 (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: 6009
diff changeset
   157
 * @param edge_road are the removed bits from a town?
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
   158
 * @param rt        the road type to remove the bits from
6116
0a63874accb6 (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: 6009
diff changeset
   159
 * @return true when it is allowed to remove the road bits
0a63874accb6 (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: 6009
diff changeset
   160
 */
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6393
diff changeset
   161
bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt);
6116
0a63874accb6 (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: 6009
diff changeset
   162
7395
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   163
/**
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   164
 * Draw the catenary for tram road bits
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   165
 * @param ti   information about the tile (position, slope)
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   166
 * @param tram the roadbits to draw the catenary for
7eee624d9741 (svn r10764) -Documentation: [FS#1099]: of road.h. Based on a patch by Progman.
rubidium
parents: 6691
diff changeset
   167
 */
6691
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6661
diff changeset
   168
void DrawTramCatenary(TileInfo *ti, RoadBits tram);
f9adbb0be102 (svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents: 6661
diff changeset
   169
4666
172a0cdf28a6 (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 */