# road_map.h File Reference

Map accessors for roads. More...

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

Go to the source code of this file.

## Data Structures
struct | EnumPropsT< DisallowedRoadDirections >
## 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 | HasCrossingReservation (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 | GetCrossingReservationTrackBits (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.
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, DepotID did, DiagDirection dir, RoadType rt)

## 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 163 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 92 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
  | straight_tunnel_bridge_entrance | whether to return straight road bits for tunnels/bridges.

Returns:
  the road bits of the given tile

Definition at line 17 of file road_map.cpp.

References AxisToRoadBits(), DIAGDIR_NE, DiagDirToAxis(), DiagDirToRoadBits(), GetRoadStopDir(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), IsDriveThroughStopTile(), IsRoadStopTile(), 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 TrackBits GetCrossingReservationTrackBits | ( | 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 255 of file road_map.h.

References HasCrossingReservation(), and TRACK_BIT_NONE.

Referenced by GetReservedTrackbits().

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 178 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 81 of file road_map.h.

References ROADTYPE_ROAD, and ROADTYPE_TRAM.

Referenced by CmdBuildRoad(), and RemoveRoad().

static bool HasCrossingReservation | ( | 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 230 of file road_map.h.

References _m, and HasBit().

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

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 157 of file road_map.h.

References OWNER_TOWN, and ROADTYPE_ROAD.

Referenced by TownViewWindow::CanDeleteTown(), UpdateNearestTownForRoadTiles(), and Town::~Town().

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 243 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 189 of file road_map.h.

References _m, and SB().

Referenced by CmdBuildRoad(), and RemoveRoad().