# road_map.h File Reference

Map accessors for roads. More...

`#include "track_func.h"`
`#include "rail_type.h"`
`#include "town_type.h"`
`#include "road_func.h"`
`#include "tile_map.h"`

Go to the source code of this file.

## Defines
#define | IsOnDesert IsOnSnow
#define | ToggleDesert ToggleSnow
## Enumerations
enum | RoadTileType { ROAD_TILE_NORMAL, ROAD_TILE_CROSSING, ROAD_TILE_DEPOT }
enum | DisallowedRoadDirections { DRD_NONE, DRD_SOUTHBOUND, DRD_NORTHBOUND, DRD_BOTH, DRD_END }
| Which directions are disallowed ? More...
enum | Roadside { ROADSIDE_BARREN = 0, ROADSIDE_GRASS = 1, ROADSIDE_PAVED = 2, ROADSIDE_STREET_LIGHTS = 3, ROADSIDE_TREES = 5, ROADSIDE_GRASS_ROAD_WORKS = 6, ROADSIDE_PAVED_ROAD_WORKS = 7 }
## Functions
static RoadTileType | GetRoadTileType (TileIndex t)
static bool | IsNormalRoad (TileIndex t)
static bool | IsNormalRoadTile (TileIndex t)
static bool | IsLevelCrossing (TileIndex t)
static bool | IsLevelCrossingTile (TileIndex t)
static bool | IsRoadDepot (TileIndex t)
static bool | IsRoadDepotTile (TileIndex t)
static RoadBits | GetRoadBits (TileIndex t, RoadType rt)
static RoadBits | GetOtherRoadBits (TileIndex t, RoadType rt)
| Get all RoadBits set on a tile except from the given RoadType.
static RoadBits | GetAllRoadBits (TileIndex tile)
| Get all set RoadBits on the given tile.
static void | SetRoadBits (TileIndex t, RoadBits r, RoadType rt)
static RoadTypes | GetRoadTypes (TileIndex t)
static void | SetRoadTypes (TileIndex t, RoadTypes rt)
static bool | HasTileRoadType (TileIndex t, RoadType rt)
static Owner | GetRoadOwner (TileIndex t, RoadType rt)
static void | SetRoadOwner (TileIndex t, RoadType rt, Owner o)
static bool | IsRoadOwner (TileIndex t, RoadType rt, Owner o)
static bool | HasTownOwnedRoad (TileIndex t)
| Checks if given tile has town owned road.
| DECLARE_ENUM_AS_BIT_SET (DisallowedRoadDirections)
static DisallowedRoadDirections | GetDisallowedRoadDirections (TileIndex t)
| Gets the disallowed directions.
static void | SetDisallowedRoadDirections (TileIndex t, DisallowedRoadDirections drd)
| Sets the disallowed directions.
static Axis | GetCrossingRoadAxis (TileIndex t)
static Axis | GetCrossingRailAxis (TileIndex t)
static RoadBits | GetCrossingRoadBits (TileIndex tile)
static Track | GetCrossingRailTrack (TileIndex tile)
static TrackBits | GetCrossingRailBits (TileIndex tile)
static bool | GetCrossingReservation (TileIndex t)
| Get the reservation state of the rail crossing.
static void | SetCrossingReservation (TileIndex t, bool b)
| Set the reservation state of the rail crossing.
static TrackBits | GetRailCrossingReservation (TileIndex t)
| Get the reserved track bits for a rail crossing.
static bool | IsCrossingBarred (TileIndex t)
static void | SetCrossingBarred (TileIndex t, bool barred)
static void | UnbarCrossing (TileIndex t)
static void | BarCrossing (TileIndex t)
static bool | IsOnSnow (TileIndex t)
static void | ToggleSnow (TileIndex t)
static Roadside | GetRoadside (TileIndex tile)
static void | SetRoadside (TileIndex tile, Roadside s)
static bool | HasRoadWorks (TileIndex t)
static bool | IncreaseRoadWorksCounter (TileIndex t)
static void | StartRoadWorks (TileIndex t)
static void | TerminateRoadWorks (TileIndex t)
static DiagDirection | GetRoadDepotDirection (TileIndex t)
RoadBits | GetAnyRoadBits (TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance=false)
| Returns the RoadBits on an arbitrary tile Special behaviour: road depots: entrance is treated as road piece road tunnels: entrance is treated as road piece bridge ramps: start of the ramp is treated as road piece bridge middle parts: bridge itself is ignored.
bool | IsPossibleCrossing (const TileIndex tile, Axis ax)
| Return if the tile is a valid tile for a crossing.
static void | MakeRoadNormal (TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
static void | MakeRoadCrossing (TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town)
static void | MakeRoadDepot (TileIndex t, Owner owner, DiagDirection dir, RoadType rt, TownID town)

## Detailed Description

Map accessors for roads.

Definition in file road_map.h.

## Enumeration Type Documentation

enum DisallowedRoadDirections

Which directions are disallowed ?

Enumerator:

  DRD_NONE | None of the directions are disallowed.
  DRD_SOUTHBOUND | All southbound traffic is disallowed.
  DRD_NORTHBOUND | All northbound traffic is disallowed.
  DRD_BOTH | All directions are disallowed.

Definition at line 156 of file road_map.h.

## Function Documentation

static RoadBits GetAllRoadBits | ( | TileIndex | tile | ) | `[inline, static]`

Get all set RoadBits on the given tile.

Parameters:

  | tile | The tile from which we want to get the RoadBits

Returns:
  all set RoadBits of the tile

Definition at line 85 of file road_map.h.

References ROADTYPE_ROAD, and ROADTYPE_TRAM.

Referenced by AIRoad::CanBuildConnectedRoadPartsHere(), and CmdBuildRoadStop().

RoadBits GetAnyRoadBits | ( | TileIndex | tile,
|  | RoadType | rt,
|  | bool | straight_tunnel_bridge_entrance = `false` |
| ) |  |  |

Returns the RoadBits on an arbitrary tile Special behaviour:

- road depots: entrance is treated as road piece
- road tunnels: entrance is treated as road piece
- bridge ramps: start of the ramp is treated as road piece
- bridge middle parts: bridge itself is ignored.

If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y for bridge ramps and tunnel entrances is returned depending on the orientation of the tunnel or bridge.

Parameters:

  | tile | the tile to get the road bits for
  | rt | the road type to get the road bits form
  | stbe | whether to return straight road bits for tunnels/bridges.

Returns:
  the road bits of the given tile

Definition at line 10 of file road_map.cpp.

References AxisToRoadBits(), DIAGDIR_NE, DiagDirToAxis(), DiagDirToRoadBits(), GetRoadStopDir(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, ReverseDiagDir(), ROAD_NONE, ROAD_X, ROAD_Y, and TRANSPORT_ROAD.

Referenced by AIRoad::AreRoadTilesConnected(), AIRoad::CanBuildConnectedRoadPartsHere(), CanRemoveRoadWithStop(), CheckAllowRemoveRoad(), CleanUpRoadBits(), CmdBuildRoad(), GetTownRoadBits(), AIRoad::HasRoadType(), and RoadFindPathToDest().

static bool GetCrossingReservation | ( | TileIndex | t | ) | `[inline, static]`

Get the reservation state of the rail crossing.

Precondition:
  IsLevelCrossingTile(t)

Parameters:

  | t | the crossing tile

Returns:
  reservation state

Definition at line 222 of file road_map.h.

References _m, and HasBit().

Referenced by DrawTile_Road(), GetRailCrossingReservation(), RemoveRoad(), TryReserveRailTrack(), and UpdateLevelCrossing().

static DisallowedRoadDirections GetDisallowedRoadDirections | ( | TileIndex | t | ) | `[inline, static]`

Gets the disallowed directions.

Parameters:

  | t | the tile to get the directions from

Returns:
  the disallowed directions

Definition at line 170 of file road_map.h.

References _m, and GB().

Referenced by AIRoad::AreRoadTilesConnected(), CmdBuildRoad(), CmdBuildSingleRail(), CmdTurnRoadVeh(), and DrawRoadBits().

static RoadBits GetOtherRoadBits | ( | TileIndex | t,
|  | RoadType | rt |
| ) |  |  | `[inline, static]`

Get all RoadBits set on a tile except from the given RoadType.

Parameters:

  | t | The tile from which we want to get the RoadBits
  | rt | The RoadType which we exclude from the querry

Returns:
  all set RoadBits of the tile which are not from the given RoadType

Definition at line 74 of file road_map.h.

References ROADTYPE_ROAD, and ROADTYPE_TRAM.

Referenced by CmdBuildRoad(), and RemoveRoad().

static TrackBits GetRailCrossingReservation | ( | TileIndex | t | ) | `[inline, static]`

Get the reserved track bits for a rail crossing.

Precondition:
  IsLevelCrossingTile(t)

Parameters:

  | t | the tile

Returns:
  reserved track bits

Definition at line 247 of file road_map.h.

References GetCrossingReservation(), and TRACK_BIT_NONE.

Referenced by GetReservedTrackbits().

static bool HasTownOwnedRoad | ( | TileIndex | t | ) | `[inline, static]`

Checks if given tile has town owned road.

Parameters:

  | t | tile to check

Returns:
  true iff tile has road and the road is owned by a town

Precondition:
  IsTileType(t, MP_ROAD)

Definition at line 150 of file road_map.h.

References OWNER_TOWN, and ROADTYPE_ROAD.

Referenced by UpdateNearestTownForRoadTiles().

bool IsPossibleCrossing | ( | const TileIndex | tile,
|  | Axis | ax |
| ) |  |  |

Return if the tile is a valid tile for a crossing.

Note:
  function is overloaded

Parameters:

  | tile | the curent tile
  | ax | the axis of the road over the rail

Returns:
  true if it is a valid tile

Definition at line 18 of file road.cpp.

References AXIS_X, GetFoundationSlope(), GetRailTileType(), GetTrackBits(), IsTileType(), MP_RAILWAY, RAIL_TILE_NORMAL, SLOPE_FLAT, TRACK_BIT_X, and TRACK_BIT_Y.

Referenced by CleanUpRoadBits().

static void SetCrossingReservation | ( | TileIndex | t,
|  | bool | b |
| ) |  |  | `[inline, static]`

Set the reservation state of the rail crossing.

Note:
  Works for both waypoints and rail depots

Precondition:
  IsLevelCrossingTile(t)

Parameters:

  | t | the crossing tile
  | b | the reservation state

Definition at line 235 of file road_map.h.

References _m, and SB().

Referenced by CmdBuildRoad(), TryReserveRailTrack(), and UnreserveRailTrack().

static void SetDisallowedRoadDirections | ( | TileIndex | t,
|  | DisallowedRoadDirections | drd |
| ) |  |  | `[inline, static]`

Sets the disallowed directions.

Parameters:

  | t | the tile to set the directions for
  | drd | the disallowed directions

Definition at line 181 of file road_map.h.

References _m, and SB().

Referenced by CmdBuildRoad(), and RemoveRoad().