OpenTTD
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"
#include "safeguards.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. More...
 
RoadBits CleanUpRoadBits (const TileIndex tile, RoadBits org_rb)
 Clean up unnecessary RoadBits of a planed tile. More...
 
bool HasRoadTypesAvail (const CompanyID company, const RoadTypes rts)
 Finds out, whether given company has all given RoadTypes available. More...
 
bool ValParamRoadType (const RoadType rt)
 Validate functions for rail building. More...
 
RoadTypes GetCompanyRoadtypes (CompanyID company)
 Get the road types the given company can build. More...
 

Detailed Description

Generic road related functions.

Definition in file road.cpp.

Function Documentation

◆ CleanUpRoadBits()

RoadBits CleanUpRoadBits ( const TileIndex  tile,
RoadBits  org_rb 
)

Clean up unnecessary RoadBits of a planed tile.

Parameters
tilecurrent tile
org_rbplaned RoadBits
Returns
optimised RoadBits

Definition at line 46 of file road.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, DiagDirToAxis(), DiagDirToRoadBits(), GetAnyRoadBits(), GetTileType(), IsNormalRoadTile(), 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().

◆ GetCompanyRoadtypes()

RoadTypes GetCompanyRoadtypes ( CompanyID  company)

Get the road types the given company can build.

Parameters
companythe company to get the roadtypes for.
Returns
the road types.

Definition at line 139 of file road.cpp.

References ROADTYPES_NONE.

◆ HasRoadTypesAvail()

bool HasRoadTypesAvail ( const CompanyID  company,
const RoadTypes  rts 
)

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

Parameters
companyID of company
rtsRoadTypes to test
Returns
true if company has all requested RoadTypes available

Definition at line 110 of file road.cpp.

References OWNER_DEITY, and OWNER_TOWN.

Referenced by CmdBuildBridge(), CmdBuildTunnel(), and ValParamRoadType().

◆ IsPossibleCrossing()

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

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

Parameters
tilethe current tile
axthe axis of the road over the rail
Returns
true if it is a valid tile

Definition at line 32 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().

◆ ValParamRoadType()

bool ValParamRoadType ( const RoadType  rt)

Validate functions for rail building.

Parameters
rtroad type to check.
Returns
true if the current company may build the road.

Definition at line 129 of file road.cpp.

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

Referenced by CmdBuildLongRoad(), and CmdBuildRoadDepot().