# 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 "settings_type.h"`
`#include "landscape.h"`

Go to the source code of this file.

## Functions
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 26 of file road.cpp.

References CountBits(), DIAGDIR_BEGIN, DIAGDIR_END, DiagDirToAxis(), DiagDirToRoadBits(), GetAnyRoadBits(), GetTileType(), 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 98 of file road.cpp.

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

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 80 of file road.cpp.

References IsGeneratingWorld(), OWNER_TOWN, and ROADTYPES_ROAD.

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

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(), GetTrackBits(), HasSignals(), IsTileType(), MP_RAILWAY, 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 93 of file road.cpp.

References HasRoadTypesAvail(), and RoadTypeToRoadTypes().

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