# road.cpp File Reference

Generic road related functions. More...

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "rail_map.h"`
`#include "road_map.h"`
`#include "water_map.h"`
`#include "genworld.h"`
`#include "company_func.h"`
`#include "company_base.h"`
`#include "engine_base.h"`
`#include "date_func.h"`
`#include "landscape.h"`

Go to the source code of this file.

## Functions

static bool | IsPossibleCrossing (const TileIndex tile, Axis ax)
| Return if the tile is a valid tile for a crossing.
RoadBits | CleanUpRoadBits (const TileIndex tile, RoadBits org_rb)
| Clean up unneccesary RoadBits of a planed tile.
bool | HasRoadTypesAvail (const CompanyID company, const RoadTypes rts)
| Finds out, whether given company has all given RoadTypes available.
bool | ValParamRoadType (const RoadType rt)
| Validate functions for rail building.
RoadTypes | GetCompanyRoadtypes (CompanyID company)
| Get the road types the given company can build.

## Detailed Description

Generic road related functions.

Definition in file road.cpp.

## Function Documentation

RoadBits CleanUpRoadBits | ( | const TileIndex | tile,
|  | RoadBits | org_rb |
| ) |  |  |

Clean up unneccesary RoadBits of a planed tile.

Parameters:

  | tile | current tile
  | org_rb | planed RoadBits

Returns:
  optimised RoadBits

Definition at line 39 of file road.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, DiagDirToAxis(), DiagDirToRoadBits(), GetAnyRoadBits(), GetTileType(), HasExactlyOneBit(), IsPossibleCrossing(), IsValidTile(), IsWater(), MirrorRoadBits(), MP_CLEAR, MP_RAILWAY, MP_ROAD, MP_STATION, MP_TREES, MP_TUNNELBRIDGE, MP_WATER, ROAD_NONE, ROADTYPE_ROAD, ROADTYPE_TRAM, and TileAddByDiagDir().

Referenced by GrowTownInTile().

RoadTypes GetCompanyRoadtypes | ( | const CompanyID | company | ) |

Get the road types the given company can build.

Parameters:

  | company | the company to get the roadtypes for.

Returns:
  the road types.

Definition at line 112 of file road.cpp.

References _date, _settings_game, DAYS_IN_YEAR, EF_ROAD_TRAM, GameSettings::game_creation, HasBit(), GameCreationSettings::landscape, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), and VEH_ROAD.

Referenced by DoStartupNewCompany().

bool HasRoadTypesAvail | ( | const CompanyID | company,
|  | const RoadTypes | rts |
| ) |  |  |

Finds out, whether given company has all given RoadTypes available.

Parameters:

  | company | ID of company
  | rts | RoadTypes to test

Returns:
  true if company has all requested RoadTypes available

Definition at line 93 of file road.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), IsGeneratingWorld(), OWNER_TOWN, and ROADTYPES_ROAD.

Referenced by CmdBuildBridge(), CmdBuildRoadStop(), CmdBuildTunnel(), AIRoad::IsRoadTypeAvailable(), and ValParamRoadType().

static bool IsPossibleCrossing | ( | const TileIndex | tile,
|  | Axis | ax |
| ) |  |  | `[static]`

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

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 31 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().

bool ValParamRoadType | ( | const RoadType | rt | ) |

Validate functions for rail building.

Parameters:

  | rt | road type to check.

Returns:
  true if the current company may build the road.

Definition at line 107 of file road.cpp.

References HasRoadTypesAvail(), and RoadTypeToRoadTypes().

Referenced by CmdBuildLongRoad(), CmdBuildRoad(), and CmdBuildRoadDepot().