# AIRoad Class Reference

Class that handles all road related functions. More...

`#include <ai_road.hpp>`

Inheritance diagram for AIRoad:

## Public Types
enum | ErrorMessages { ERR_ROAD_BASE = AIError::ERR_CAT_ROAD << AIError::ERR_CAT_BIT_SIZE, ERR_ROAD_WORKS_IN_PROGRESS, ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION, ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD, ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS }
| All road related error messages. More...
enum | RoadType { ROADTYPE_ROAD = 0, ROADTYPE_TRAM = 1, ROADTYPE_INVALID = -1 }
| Types of road known to the game. More...
enum | RoadVehicleType { ROADVEHTYPE_BUS, ROADVEHTYPE_TRUCK }
| Type of road station. More...
## Static Public Member Functions
static const char * | GetClassName ()
static RoadVehicleType | GetRoadVehicleTypeForCargo (CargoID cargo_type)
| Determines whether a busstop or a truckstop is needed to transport a certain cargo.
static bool | IsRoadTile (TileIndex tile)
| Checks whether the given tile is actually a tile with road that can be used to traverse a tile.
static bool | IsRoadDepotTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a road depot.
static bool | IsRoadStationTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a road station.
static bool | IsDriveThroughRoadStationTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a drive through road station.
static bool | IsRoadTypeAvailable (RoadType road_type)
| Check if a given RoadType is available.
static RoadType | GetCurrentRoadType ()
| Get the current RoadType set for all AIRoad functions.
static void | SetCurrentRoadType (RoadType road_type)
| Set the RoadType for all further AIRoad functions.
static bool | HasRoadType (TileIndex tile, RoadType road_type)
| Check if a given tile has RoadType.
static bool | AreRoadTilesConnected (TileIndex tile_from, TileIndex tile_to)
| Checks whether the given tiles are directly connected, i.e.
static int32 | CanBuildConnectedRoadParts (AITile::Slope slope, struct Array *existing, TileIndex start, TileIndex end)
| Lookup function for building road parts independend on whether the "building on slopes" setting is enabled or not.
static int32 | CanBuildConnectedRoadPartsHere (TileIndex tile, TileIndex start, TileIndex end)
| Lookup function for building road parts independend on whether the "building on slopes" setting is enabled or not.
static int32 | GetNeighbourRoadCount (TileIndex tile)
| Count how many neighbours are road.
static TileIndex | GetRoadDepotFrontTile (TileIndex depot)
| Gets the tile in front of a road depot.
static TileIndex | GetRoadStationFrontTile (TileIndex station)
| Gets the tile in front of a road station.
static TileIndex | GetDriveThroughBackTile (TileIndex station)
| Gets the tile at the back of a drive through road station.
static bool | BuildRoad (TileIndex start, TileIndex end)
| Builds a road from the center of tile start to the center of tile end.
static bool | BuildOneWayRoad (TileIndex start, TileIndex end)
| Builds a one-way road from the center of tile start to the center of tile end.
static bool | BuildRoadFull (TileIndex start, TileIndex end)
| Builds a road from the edge of tile start to the edge of tile end (both included).
static bool | BuildOneWayRoadFull (TileIndex start, TileIndex end)
| Builds a one-way road from the edge of tile start to the edge of tile end (both included).
static bool | BuildRoadDepot (TileIndex tile, TileIndex front)
| Builds a road depot.
static bool | BuildRoadStation (TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id)
| Builds a road bus or truck station.
static bool | BuildDriveThroughRoadStation (TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id)
| Builds a drive-through road bus or truck station.
static bool | RemoveRoad (TileIndex start, TileIndex end)
| Removes a road from the center of tile start to the center of tile end.
static bool | RemoveRoadFull (TileIndex start, TileIndex end)
| Removes a road from the edge of tile start to the edge of tile end (both included).
static bool | RemoveRoadDepot (TileIndex tile)
| Removes a road depot.
static bool | RemoveRoadStation (TileIndex tile)
| Removes a road bus or truck station.
## Static Private Member Functions
static bool | _BuildRoadInternal (TileIndex start, TileIndex end, bool one_way, bool full)
| Internal function used by Build(OneWay)Road(Full).
static bool | _BuildRoadStationInternal (TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id)
| Internal function used by Build(DriveThrough)RoadStation.

## Detailed Description

Class that handles all road related functions.

Definition at line 15 of file ai_road.hpp.

## Member Enumeration Documentation

enum AIRoad::ErrorMessages

All road related error messages.

Enumerator:

  ERR_ROAD_BASE | Base for road building / maintaining errors.
  ERR_ROAD_WORKS_IN_PROGRESS | Road works are in progress.
  ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION | Drive through is in the wrong direction.
  ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD | Drive through roads can't be build on town owned roads.
  ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS | One way roads can't have junctions.

Definition at line 22 of file ai_road.hpp.

enum AIRoad::RoadType

Types of road known to the game.

Enumerator:

  ROADTYPE_ROAD | Build road objects.
  ROADTYPE_TRAM | Build tram objects.
  ROADTYPE_INVALID | Invalid RoadType.

Definition at line 43 of file ai_road.hpp.

enum AIRoad::RoadVehicleType

Type of road station.

Enumerator:

  ROADVEHTYPE_BUS | Build objects useable for busses and passenger trams.
  ROADVEHTYPE_TRUCK | Build objects useable for trucks and cargo trams.

Definition at line 54 of file ai_road.hpp.

## Member Function Documentation

AIRoad::RoadVehicleType AIRoad::GetRoadVehicleTypeForCargo | ( | CargoID | cargo_type | ) | `[static]`

Determines whether a busstop or a truckstop is needed to transport a certain cargo.

Parameters:

  | cargo_type | The cargo to test.

Precondition:
  AICargo::IsValidCargo(cargo_type).

Returns:
  The road vehicle type needed to transport the cargo.

Definition at line 15 of file ai_road.cpp.

References AICargo::CC_PASSENGERS, AICargo::HasCargoClass(), ROADVEHTYPE_BUS, and ROADVEHTYPE_TRUCK.

bool AIRoad::IsRoadTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with road that can be used to traverse a tile.

This excludes road depots and 'normal' road stations, but includes drive through stations.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has road.

Definition at line 20 of file ai_road.cpp.

References IsDriveThroughRoadStationTile(), IsTileType(), IsValidTile(), and MP_ROAD.

bool AIRoad::IsRoadDepotTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a road depot.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a road depot.

Definition at line 28 of file ai_road.cpp.

References GetCurrentRoadType(), IsTileType(), IsValidTile(), MP_ROAD, and RoadTypeToRoadTypes().

Referenced by GetRoadDepotFrontTile().

bool AIRoad::IsRoadStationTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a road station.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a road station.

Definition at line 36 of file ai_road.cpp.

References GetCurrentRoadType(), IsValidTile(), and RoadTypeToRoadTypes().

Referenced by GetRoadStationFrontTile().

bool AIRoad::IsDriveThroughRoadStationTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a drive through road station.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a drive through road station.

Definition at line 43 of file ai_road.cpp.

References GetCurrentRoadType(), IsValidTile(), and RoadTypeToRoadTypes().

Referenced by GetDriveThroughBackTile(), and IsRoadTile().

bool AIRoad::IsRoadTypeAvailable | ( | RoadType | road_type | ) | `[static]`

Check if a given RoadType is available.

Parameters:

  | road_type | The RoadType to check for.

Returns:
  True if this RoadType can be used.

Definition at line 50 of file ai_road.cpp.

References HasRoadTypesAvail(), and RoadTypeToRoadTypes().

Referenced by _BuildRoadInternal(), _BuildRoadStationInternal(), AreRoadTilesConnected(), BuildRoadDepot(), GetNeighbourRoadCount(), AIStation::HasRoadType(), HasRoadType(), RemoveRoad(), RemoveRoadFull(), and SetCurrentRoadType().

AIRoad::RoadType AIRoad::GetCurrentRoadType | ( |  | ) | `[static]`

Get the current RoadType set for all AIRoad functions.

Returns:
  The RoadType currently set.

Definition at line 55 of file ai_road.cpp.

References AIObject::GetRoadType().

Referenced by _BuildRoadInternal(), _BuildRoadStationInternal(), AreRoadTilesConnected(), BuildRoadDepot(), GetNeighbourRoadCount(), IsDriveThroughRoadStationTile(), IsRoadDepotTile(), IsRoadStationTile(), RemoveRoad(), and RemoveRoadFull().

void AIRoad::SetCurrentRoadType | ( | RoadType | road_type | ) | `[static]`

Set the RoadType for all further AIRoad functions.

Parameters:

  | road_type | The RoadType to set.

Definition at line 60 of file ai_road.cpp.

References IsRoadTypeAvailable(), and AIObject::SetRoadType().

bool AIRoad::HasRoadType | ( | TileIndex | tile,
|  | RoadType | road_type |
| ) |  |  | `[static]`

Check if a given tile has RoadType.

Parameters:

  | tile | The tile to check.
  | road_type | The RoadType to check for.

Precondition:
  AIMap::IsValidTile(tile).

  IsRoadTypeAvailable(road_type).

Returns:
  True if the tile contains a RoadType object.

Definition at line 67 of file ai_road.cpp.

References GetAnyRoadBits(), IsRoadTypeAvailable(), AIMap::IsValidTile(), and ROAD_NONE.

bool AIRoad::AreRoadTilesConnected | ( | TileIndex | tile_from,
|  | TileIndex | tile_to |
| ) |  |  | `[static]`

Checks whether the given tiles are directly connected, i.e.

whether a road vehicle can travel from the center of the first tile to the center of the second tile.

Parameters:

  | tile_from | The source tile.
  | tile_to | The destination tile.

Precondition:
  IsRoadTypeAvailable(GetCurrentRoadType()).

  AIMap::IsValidTile(tile_from).

  AIMap::IsValidTile(tile_to).

  'tile_from' and 'tile_to' are directly neighbouring tiles.

Returns:
  True if and only if a road vehicle can go from tile_from to tile_to.

Definition at line 74 of file ai_road.cpp.

References abs(), DRD_BOTH, DRD_NONE, DRD_NORTHBOUND, DRD_SOUTHBOUND, GetAnyRoadBits(), GetCurrentRoadType(), GetDisallowedRoadDirections(), AIObject::GetRoadType(), HasBit(), IsRoadTypeAvailable(), IsValidTile(), TileX(), and TileY().

int32 AIRoad::CanBuildConnectedRoadParts | ( | AITile::Slope | slope,
|  | struct Array * | existing,
|  | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Lookup function for building road parts independend on whether the "building on slopes" setting is enabled or not.

This implementation can be used for abstract reasoning about a tile as it needs the slope and existing road parts of the tile as information.

Parameters:

  | slope | The slope of the tile to examine.
  | existing | An array with the existing neighbours in the same format as "start" and "end", e.g. AIMap.GetTileIndex(0, 1). As a result of this all values of the existing array must be of type integer.
  | start | The tile from where the 'tile to be considered' will be entered. This is a relative tile, so valid parameters are: AIMap.GetTileIndex(0, 1), AIMap.GetTileIndex(0, -1), AIMap.GetTileIndex(1, 0) and AIMap.GetTileIndex(-1, 0).
  | end | The tile from where the 'tile to be considered' will be exited. This is a relative tile, sovalid parameters are: AIMap.GetTileIndex(0, 1), AIMap.GetTileIndex(0, -1), AIMap.GetTileIndex(1, 0) and AIMap.GetTileIndex(-1, 0).

Precondition:
  start != end.

  slope must be a valid slope, i.e. one specified in AITile::Slope.

Note:
  Passing data that would be invalid in-game, e.g. existing containing road parts that can not be build on a tile with the given slope, does not necessarily means that -1 is returned, i.e. not all preconditions written here or assumed by the game are extensively checked to make sure the data entered is valid.

Returns:
  0 when the build parts do not connect, 1 when they do connect once they are build or 2 when building the first part automatically builds the second part. -1 means the preconditions are not met.

Definition at line 351 of file ai_road.cpp.

References _settings_game, ConstructionSettings::build_on_slopes, GameSettings::construction, LookupWithBuildOnSlopes(), LookupWithoutBuildOnSlopes(), and NormaliseTileOffset().

Referenced by CanBuildConnectedRoadPartsHere().

int32 AIRoad::CanBuildConnectedRoadPartsHere | ( | TileIndex | tile,
|  | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Lookup function for building road parts independend on whether the "building on slopes" setting is enabled or not.

This implementation can be used for reasoning about an existing tile.

Parameters:

  | tile | The the tile to examine.
  | start | The tile from where "tile" will be entered.
  | end | The tile from where "tile" will be exited.

Precondition:
  start != end.

  tile != start.

  tile != end.

  AIMap.IsValidTile(tile).

  AIMap.IsValidTile(start).

  AIMap.IsValidTile(end).

  AIMap.GetDistanceManhattanToTile(tile, start) == 1.

  AIMap.GetDistanceManhattanToTile(tile, end) == 1.

Returns:
  0 when the build parts do not connect, 1 when they do connect once they are build or 2 when building the first part automatically builds the second part. -1 means the preconditions are not met.

Definition at line 372 of file ai_road.cpp.

References CanBuildConnectedRoadParts(), DistanceManhattan(), GetAllRoadBits(), GetAnyRoadBits(), AITile::GetSlope(), HasBit(), IsValidTile(), lengthof, ROAD_NONE, ROADTYPE_BEGIN, ROADTYPE_END, and TileDiffXY().

int32 AIRoad::GetNeighbourRoadCount | ( | TileIndex | tile | ) | `[static]`

Count how many neighbours are road.

Parameters:

  | tile | The tile to check on.

Precondition:
  AIMap::IsValidTile(tile).

  IsRoadTypeAvailable(GetCurrentRoadType()).

Returns:
  0 means no neighbour road; max value is 4.

Definition at line 422 of file ai_road.cpp.

References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, GetCurrentRoadType(), IsRoadTypeAvailable(), IsValidTile(), NeighbourHasReachableRoad(), RoadTypeToRoadTypes(), TileX(), and TileY().

TileIndex AIRoad::GetRoadDepotFrontTile | ( | TileIndex | depot | ) | `[static]`

Gets the tile in front of a road depot.

Parameters:

  | depot | The road depot tile.

Precondition:
  IsRoadDepotTile(depot).

Returns:
  The tile in front of the depot.

Definition at line 438 of file ai_road.cpp.

References INVALID_TILE, IsRoadDepotTile(), and TileOffsByDiagDir().

TileIndex AIRoad::GetRoadStationFrontTile | ( | TileIndex | station | ) | `[static]`

Gets the tile in front of a road station.

Parameters:

  | station | The road station tile.

Precondition:
  IsRoadStationTile(station).

Returns:
  The tile in front of the road station.

Definition at line 445 of file ai_road.cpp.

References GetRoadStopDir(), INVALID_TILE, IsRoadStationTile(), and TileOffsByDiagDir().

TileIndex AIRoad::GetDriveThroughBackTile | ( | TileIndex | station | ) | `[static]`

Gets the tile at the back of a drive through road station.

So, one side of the drive through station is retrieved with GetTileInFrontOfStation, the other with this function.

Parameters:

  | station | The road station tile.

Precondition:
  IsDriveThroughRoadStationTile(station).

Returns:
  The tile at the back of the drive through road station.

Definition at line 452 of file ai_road.cpp.

References GetRoadStopDir(), INVALID_TILE, IsDriveThroughRoadStationTile(), ReverseDiagDir(), and TileOffsByDiagDir().

bool AIRoad::BuildRoad | ( | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Builds a road from the center of tile start to the center of tile end.

Parameters:

  | start | The start tile of the road.
  | end | The end tile of the road.

Precondition:
  'start' is not equal to 'end'.

  AIMap::IsValidTile(start).

  AIMap::IsValidTile(end).

  'start' and 'end' are in a straight line, i.e. AIMap::GetTileX(start) == AIMap::GetTileX(end) or AIMap::GetTileY(start) == AIMap::GetTileY(end).

  IsRoadTypeAvailable(GetCurrentRoadType()).

Exceptions:

  | AIError::ERR_ALREADY_BUILT |
  | AIError::ERR_LAND_SLOPED_WRONG |
  | AIError::ERR_AREA_NOT_CLEAR |
  | AIRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS |
  | AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |
  | AIError::ERR_VEHICLE_IN_THE_WAY |

Returns:
  Whether the road has been/can be build or not.

Definition at line 471 of file ai_road.cpp.

References _BuildRoadInternal().

bool AIRoad::BuildOneWayRoad | ( | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Builds a one-way road from the center of tile start to the center of tile end.

If the road already exists, it is made one-way road. If the road already exists and is already one-way in this direction, the road is made two-way again. If the road already exists but is one-way in the other direction, it's made a 'no'-way road (it's forbidden to enter the tile from any direction).

Parameters:

  | start | The start tile of the road.
  | end | The end tile of the road.

Precondition:
  'start' is not equal to 'end'.

  AIMap::IsValidTile(start).

  AIMap::IsValidTile(end).

  'start' and 'end' are in a straight line, i.e. AIMap::GetTileX(start) == AIMap::GetTileX(end) or AIMap::GetTileY(start) == AIMap::GetTileY(end).

  GetCurrentRoadType() == ROADTYPE_ROAD.

Exceptions:

  | AIError::ERR_ALREADY_BUILT |
  | AIError::ERR_LAND_SLOPED_WRONG |
  | AIError::ERR_AREA_NOT_CLEAR |
  | AIRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS |
  | AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |
  | AIError::ERR_VEHICLE_IN_THE_WAY |

Returns:
  Whether the road has been/can be build or not.

Definition at line 476 of file ai_road.cpp.

References _BuildRoadInternal().

bool AIRoad::BuildRoadFull | ( | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Builds a road from the edge of tile start to the edge of tile end (both included).

Parameters:

  | start | The start tile of the road.
  | end | The end tile of the road.

Precondition:
  'start' is not equal to 'end'.

  AIMap::IsValidTile(start).

  AIMap::IsValidTile(end).

  'start' and 'end' are in a straight line, i.e. AIMap::GetTileX(start) == AIMap::GetTileX(end) or AIMap::GetTileY(start) == AIMap::GetTileY(end).

  IsRoadTypeAvailable(GetCurrentRoadType()).

Exceptions:

  | AIError::ERR_ALREADY_BUILT |
  | AIError::ERR_LAND_SLOPED_WRONG |
  | AIError::ERR_AREA_NOT_CLEAR |
  | AIRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS |
  | AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |
  | AIError::ERR_VEHICLE_IN_THE_WAY |

Returns:
  Whether the road has been/can be build or not.

Definition at line 481 of file ai_road.cpp.

References _BuildRoadInternal().

bool AIRoad::BuildOneWayRoadFull | ( | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Builds a one-way road from the edge of tile start to the edge of tile end (both included).

If the road already exists, it is made one-way road. If the road already exists and is already one-way in this direction, the road is made two-way again. If the road already exists but is one-way in the other direction, it's made a 'no'-way road (it's forbidden to enter the tile from any direction).

Parameters:

  | start | The start tile of the road.
  | start | The start tile of the road.
  | end | The end tile of the road.

Precondition:
  'start' is not equal to 'end'.

  AIMap::IsValidTile(start).

  AIMap::IsValidTile(end).

  'start' and 'end' are in a straight line, i.e. AIMap::GetTileX(start) == AIMap::GetTileX(end) or AIMap::GetTileY(start) == AIMap::GetTileY(end).

  GetCurrentRoadType() == ROADTYPE_ROAD.

Exceptions:

  | AIError::ERR_ALREADY_BUILT |
  | AIError::ERR_LAND_SLOPED_WRONG |
  | AIError::ERR_AREA_NOT_CLEAR |
  | AIRoad::ERR_ROAD_ONE_WAY_ROADS_CANNOT_HAVE_JUNCTIONS |
  | AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |
  | AIError::ERR_VEHICLE_IN_THE_WAY |

Returns:
  Whether the road has been/can be build or not.

Definition at line 486 of file ai_road.cpp.

References _BuildRoadInternal().

bool AIRoad::BuildRoadDepot | ( | TileIndex | tile,
|  | TileIndex | front |
| ) |  |  | `[static]`

Builds a road depot.

Parameters:

  | tile | Place to build the depot.
  | front | The tile exactly in front of the depot.

Precondition:
  AIMap::IsValidTile(tile).

  AIMap::IsValidTile(front).

  'tile' is not equal to 'front', but in a straight line of it.

  IsRoadTypeAvailable(GetCurrentRoadType()).

Exceptions:

  | AIError::ERR_FLAT_LAND_REQUIRED |
  | AIError::ERR_AREA_NOT_CLEAR |

Returns:
  Whether the road depot has been/can be build or not.

Definition at line 491 of file ai_road.cpp.

References CMD_BUILD_ROAD_DEPOT, AIObject::DoCommand(), EnforcePrecondition, GetCurrentRoadType(), AIObject::GetRoadType(), IsRoadTypeAvailable(), IsValidTile(), TileX(), and TileY().

bool AIRoad::BuildRoadStation | ( | TileIndex | tile,
|  | TileIndex | front,
|  | RoadVehicleType | road_veh_type,
|  | StationID | station_id |
| ) |  |  | `[static]`

Builds a road bus or truck station.

Parameters:

  | tile | Place to build the station.
  | front | The tile exactly in front of the station.
  | road_veh_type | Whether to build a truck or bus station.
  | station_id | The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.

Precondition:
  AIMap::IsValidTile(tile).

  AIMap::IsValidTile(front).

  'tile' is not equal to 'front', but in a straight line of it.

  station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).

  GetCurrentRoadType() == ROADTYPE_ROAD.

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_FLAT_LAND_REQUIRED |
  | AIRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION |
  | AIRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD |
  | AIError::ERR_VEHICLE_IN_THE_WAY |
  | AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION |
  | AIStation::ERR_STATION_TOO_MANY_STATIONS |
  | AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN |

Returns:
  Whether the station has been/can be build or not.

Definition at line 529 of file ai_road.cpp.

References _BuildRoadStationInternal().

bool AIRoad::BuildDriveThroughRoadStation | ( | TileIndex | tile,
|  | TileIndex | front,
|  | RoadVehicleType | road_veh_type,
|  | StationID | station_id |
| ) |  |  | `[static]`

Builds a drive-through road bus or truck station.

Parameters:

  | tile | Place to build the station.
  | front | A tile on the same axis with 'tile' as the station shall be oriented.
  | road_veh_type | Whether to build a truck or bus station.
  | station_id | The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.

Precondition:
  AIMap::IsValidTile(tile).

  AIMap::IsValidTile(front).

  'tile' is not equal to 'front', but in a straight line of it.

  station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).

  IsRoadTypeAvailable(GetCurrentRoadType()).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_FLAT_LAND_REQUIRED |
  | AIRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION |
  | AIRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD |
  | AIError::ERR_VEHICLE_IN_THE_WAY |
  | AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION |
  | AIStation::ERR_STATION_TOO_MANY_STATIONS |
  | AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN |

Returns:
  Whether the station has been/can be build or not.

Definition at line 534 of file ai_road.cpp.

References _BuildRoadStationInternal().

bool AIRoad::RemoveRoad | ( | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Removes a road from the center of tile start to the center of tile end.

Parameters:

  | start | The start tile of the road.
  | end | The end tile of the road.

Precondition:
  AIMap::IsValidTile(start).

  AIMap::IsValidTile(end).

  'start' and 'end' are in a straight line, i.e. AIMap::GetTileX(start) == AIMap::GetTileX(end) or AIMap::GetTileY(start) == AIMap::GetTileY(end).

  IsRoadTypeAvailable(GetCurrentRoadType()).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_VEHICLE_IN_THE_WAY |
  | AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |

Returns:
  Whether the road has been/can be removed or not.

Definition at line 539 of file ai_road.cpp.

References CMD_REMOVE_LONG_ROAD, AIObject::DoCommand(), EnforcePrecondition, GetCurrentRoadType(), AIObject::GetRoadType(), IsRoadTypeAvailable(), IsValidTile(), TileX(), and TileY().

bool AIRoad::RemoveRoadFull | ( | TileIndex | start,
|  | TileIndex | end |
| ) |  |  | `[static]`

Removes a road from the edge of tile start to the edge of tile end (both included).

Parameters:

  | start | The start tile of the road.
  | end | The end tile of the road.

Precondition:
  AIMap::IsValidTile(start).

  AIMap::IsValidTile(end).

  'start' and 'end' are in a straight line, i.e. AIMap::GetTileX(start) == AIMap::GetTileX(end) or AIMap::GetTileY(start) == AIMap::GetTileY(end).

  IsRoadTypeAvailable(GetCurrentRoadType()).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_VEHICLE_IN_THE_WAY |
  | AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |

Returns:
  Whether the road has been/can be removed or not.

Definition at line 549 of file ai_road.cpp.

References CMD_REMOVE_LONG_ROAD, AIObject::DoCommand(), EnforcePrecondition, GetCurrentRoadType(), AIObject::GetRoadType(), IsRoadTypeAvailable(), IsValidTile(), TileX(), and TileY().

bool AIRoad::RemoveRoadDepot | ( | TileIndex | tile | ) | `[static]`

Removes a road depot.

Parameters:

  | tile | Place to remove the depot from.

Precondition:
  AIMap::IsValidTile(tile).

  Tile is a road depot.

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_VEHICLE_IN_THE_WAY |

Returns:
  Whether the road depot has been/can be removed or not.

Definition at line 559 of file ai_road.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsTileType(), IsValidTile(), and MP_ROAD.

bool AIRoad::RemoveRoadStation | ( | TileIndex | tile | ) | `[static]`

Removes a road bus or truck station.

Parameters:

  | tile | Place to remove the station from.

Precondition:
  AIMap::IsValidTile(tile).

  Tile is a road station.

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_VEHICLE_IN_THE_WAY |

Returns:
  Whether the station has been/can be removed or not.

Definition at line 568 of file ai_road.cpp.

References CMD_REMOVE_ROAD_STOP, AIObject::DoCommand(), EnforcePrecondition, IsRoadStop(), IsTileType(), IsValidTile(), and MP_STATION.

The documentation for this class was generated from the following files:

- src/ai/api/ai_road.hpp
- src/ai/api/ai_road.cpp