Functions

# road.cpp File Reference

Generic road related functions. More...

`#include "stdafx.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 44 of file road.cpp.

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

Referenced by GrowTownInTile().

RoadTypes GetCompanyRoadtypes | ( | 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 134 of file road.cpp.

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

Referenced by AfterLoadGame(), DoStartupNewCompany(), and StartupEngines().

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

References _generating_world, Company::avail_roadtypes, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), OWNER_DEITY, OWNER_TOWN, and ROADTYPES_ROAD.

Referenced by CmdBuildBridge(), CmdBuildRoadStop(), CmdBuildTunnel(), 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 30 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 124 of file road.cpp.

References _current_company, HasRoadTypesAvail(), and RoadTypeToRoadTypes().

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