Files
@ r11645:44e7d4260786
Branch filter:
Location: cpp/openttd-patchpack/source/src/road_func.h - annotation
r11645:44e7d4260786
3.9 KiB
text/x-c
(svn r16030) -Update: WebTranslator2 update to 2009-04-11 17:38:26
serbian - 50 fixed by etran (50)
traditional_chinese - 6 fixed, 2 changed by josesun (8)
serbian - 50 fixed by etran (50)
traditional_chinese - 6 fixed, 2 changed by josesun (8)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8113:7815c26d7612 r8102:c3f2dd9e9116 r8138:f851b4cbdad1 r10208:ef8fcc3dc4ca r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8734:d0410200053c r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8102:c3f2dd9e9116 r8236:a2ecfe92ab23 r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r8716:fe14dd1f6c9e r10207:a1fc2f2a33db r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8344:df24797cd78b r8342:c2c539be911f r8102:c3f2dd9e9116 | /* $Id$ */
/** @file road_func.h Functions related to roads. */
#ifndef ROAD_FUNC_H
#define ROAD_FUNC_H
#include "core/bitmath_func.hpp"
#include "road_type.h"
#include "direction_func.h"
#include "company_type.h"
/**
* Whether the given roadtype is valid.
* @param rt the roadtype to check for validness
* @return true if and only if valid
*/
static inline bool IsValidRoadType(RoadType rt)
{
return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
}
/**
* Are the given bits pointing to valid roadtypes?
* @param rts the roadtypes to check for validness
* @return true if and only if valid
*/
static inline bool AreValidRoadTypes(RoadTypes rts)
{
return HasBit(rts, ROADTYPE_ROAD) || HasBit(rts, ROADTYPE_TRAM);
}
/**
* Maps a RoadType to the corresponding RoadTypes value
*
* @param rt the roadtype to get the roadtypes from
* @return the roadtypes with the given roadtype
*/
static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
{
return (RoadTypes)(1 << rt);
}
/**
* Returns the RoadTypes which are not present in the given RoadTypes
*
* This function returns the complement of a given RoadTypes.
*
* @param r The given RoadTypes
* @return The complement of the given RoadTypes
* @note The unused value ROADTYPES_HWAY will be used, too.
*/
static inline RoadTypes ComplementRoadTypes(RoadTypes r)
{
return (RoadTypes)(ROADTYPES_ALL ^ r);
}
/**
* Calculate the complement of a RoadBits value
*
* Simply flips all bits in the RoadBits value to get the complement
* of the RoadBits.
*
* @param r The given RoadBits value
* @return the complement
*/
static inline RoadBits ComplementRoadBits(RoadBits r)
{
return (RoadBits)(ROAD_ALL ^ r);
}
/**
* Calculate the mirrored RoadBits
*
* Simply move the bits to their new position.
*
* @param r The given RoadBits value
* @return the mirrored
*/
static inline RoadBits MirrorRoadBits(RoadBits r)
{
return (RoadBits)(GB(r, 0, 2) << 2 | GB(r, 2, 2));
}
/**
* Calculate rotated RoadBits
*
* Move the Roadbits clockwise til they are in their final position.
*
* @param r The given RoadBits value
* @param rot The given Rotation angle
* @return the rotated
*/
static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
{
for (; rot > (DiagDirDiff)0; rot--){
r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
}
return r;
}
/**
* Check if we've got a straight road
*
* @param r The given RoadBits
* @return true if we've got a straight road
*/
static inline bool IsStraightRoad(RoadBits r)
{
return (r == ROAD_X || r == ROAD_Y);
}
/**
* Create the road-part which belongs to the given DiagDirection
*
* This function returns a RoadBits value which belongs to
* the given DiagDirection.
*
* @param d The DiagDirection
* @return The result RoadBits which the selected road-part set
*/
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
{
return (RoadBits)(ROAD_NW << (3 ^ d));
}
/**
* Create the road-part which belongs to the given Axis
*
* This function returns a RoadBits value which belongs to
* the given Axis.
*
* @param a The Axis
* @return The result RoadBits which the selected road-part set
*/
static inline RoadBits AxisToRoadBits(Axis a)
{
return a == AXIS_X ? ROAD_X : ROAD_Y;
}
/**
* Finds out, whether given company has all given RoadTypes available
* @param company ID of company
* @param rts RoadTypes to test
* @return true if company has all requested RoadTypes available
*/
bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts);
/**
* Validate functions for rail building.
* @param rt road type to check.
* @return true if the current company may build the road.
*/
bool ValParamRoadType(const RoadType rt);
/**
* Get the road types the given company can build.
* @param company the company to get the roadtypes for.
* @return the road types.
*/
RoadTypes GetCompanyRoadtypes(const CompanyID company);
void UpdateLevelCrossing(TileIndex tile, bool sound = true);
#endif /* ROAD_FUNC_H */
|