OpenTTD AI API
20241117-master-ga6c526cfa0
|
Class that handles all road related functions. More...
Public Types | |
enum | ErrorMessages { ERR_ROAD_BASE , 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 , ERR_ROADTYPE_DISALLOWS_CROSSING , ERR_UNSUITABLE_ROAD } |
All road related error messages. More... | |
enum | RoadType { ROADTYPE_ROAD , ROADTYPE_TRAM , ROADTYPE_INVALID } |
Types of road known to the game. More... | |
enum | RoadTramTypes : int { ROADTRAMTYPES_ROAD , ROADTRAMTYPES_TRAM } |
Road/tram types. More... | |
enum | RoadVehicleType { ROADVEHTYPE_BUS , ROADVEHTYPE_TRUCK } |
Type of road station. More... | |
enum | BuildType { BT_ROAD , BT_DEPOT , BT_BUS_STOP , BT_TRUCK_STOP } |
Types of road-related objects in the game. More... | |
Static Public Member Functions | |
static string | GetName (RoadType road_type) |
Get the name of a road type. More... | |
static RoadVehicleType | GetRoadVehicleTypeForCargo (CargoID cargo_type) |
Determines whether a busstop or a truckstop is needed to transport a certain cargo. More... | |
static bool | IsRoadTile (TileIndex tile) |
Checks whether the given tile is actually a tile with road that can be used to traverse a tile. More... | |
static bool | IsRoadDepotTile (TileIndex tile) |
Checks whether the given tile is actually a tile with a road depot. More... | |
static bool | IsRoadStationTile (TileIndex tile) |
Checks whether the given tile is actually a tile with a road station. More... | |
static bool | IsDriveThroughRoadStationTile (TileIndex tile) |
Checks whether the given tile is actually a tile with a drive through road station. More... | |
static bool | IsRoadTypeAvailable (RoadType road_type) |
Check if a given RoadType is available. More... | |
static RoadType | GetCurrentRoadType () |
Get the current RoadType set for all AIRoad functions. More... | |
static void | SetCurrentRoadType (RoadType road_type) |
Set the RoadType for all further AIRoad functions. More... | |
static bool | RoadVehCanRunOnRoad (AIRoad::RoadType engine_road_type, AIRoad::RoadType road_road_type) |
Check if a road vehicle built for a road type can run on another road type. More... | |
static bool | RoadVehHasPowerOnRoad (AIRoad::RoadType engine_road_type, AIRoad::RoadType road_road_type) |
Check if a road vehicle built for a road type has power on another road type. More... | |
static bool | ConvertRoadType (TileIndex start_tile, TileIndex end_tile, RoadType road_type) |
Convert the road on all tiles within a rectangle to another RoadType. More... | |
static bool | HasRoadType (TileIndex tile, RoadType road_type) |
Check if a given tile has RoadType. More... | |
static bool | AreRoadTilesConnected (TileIndex tile_from, TileIndex tile_to) |
Checks whether the given tiles are directly connected, i.e. More... | |
static int | CanBuildConnectedRoadParts (AITile::Slope slope, Array< TileIndex > &&existing, TileIndex start, TileIndex end) |
Lookup function for building road parts independent of whether the "building on slopes" setting is enabled or not. More... | |
static int | CanBuildConnectedRoadPartsHere (TileIndex tile, TileIndex start, TileIndex end) |
Lookup function for building road parts independent of whether the "building on slopes" setting is enabled or not. More... | |
static int | GetNeighbourRoadCount (TileIndex tile) |
Count how many neighbours are road. More... | |
static TileIndex | GetRoadDepotFrontTile (TileIndex depot) |
Gets the tile in front of a road depot. More... | |
static TileIndex | GetRoadStationFrontTile (TileIndex station) |
Gets the tile in front of a road station. More... | |
static TileIndex | GetDriveThroughBackTile (TileIndex station) |
Gets the tile at the back of a drive through road station. More... | |
static bool | BuildRoad (TileIndex start, TileIndex end) |
Builds a road from the center of tile start to the center of tile end. More... | |
static bool | BuildOneWayRoad (TileIndex start, TileIndex end) |
Builds a one-way road from the center of tile start to the center of tile end. More... | |
static bool | BuildRoadFull (TileIndex start, TileIndex end) |
Builds a road from the edge of tile start to the edge of tile end (both included). More... | |
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). More... | |
static bool | BuildRoadDepot (TileIndex tile, TileIndex front) |
Builds a road depot. More... | |
static bool | BuildRoadStation (TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id) |
Builds a road bus or truck station. More... | |
static bool | BuildDriveThroughRoadStation (TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id) |
Builds a drive-through road bus or truck station. More... | |
static bool | RemoveRoad (TileIndex start, TileIndex end) |
Removes a road from the center of tile start to the center of tile end. More... | |
static bool | RemoveRoadFull (TileIndex start, TileIndex end) |
Removes a road from the edge of tile start to the edge of tile end (both included). More... | |
static bool | RemoveRoadDepot (TileIndex tile) |
Removes a road depot. More... | |
static bool | RemoveRoadStation (TileIndex tile) |
Removes a road bus or truck station. More... | |
static Money | GetBuildCost (RoadType roadtype, BuildType build_type) |
Get the baseprice of building a road-related object. More... | |
static RoadTramTypes | GetRoadTramType (RoadType roadtype) |
Test if a road type is for road or trams. More... | |
static int | GetMaxSpeed (RoadType road_type) |
Get the maximum speed of road vehicles running on this roadtype. More... | |
static int | GetMaintenanceCostFactor (RoadType roadtype) |
Get the maintenance cost factor of a road type. More... | |
Class that handles all road related functions.
enum AIRoad::BuildType |
All road related error messages.
enum AIRoad::RoadTramTypes : int |
enum AIRoad::RoadType |
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.
tile_from | The source tile. |
tile_to | The destination tile. |
|
static |
Builds a drive-through road bus or truck station.
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. |
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).
start | The start tile of the road. |
end | The end tile of the road. |
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).
start | The start tile of the road. |
end | The end tile of the road. |
Builds a road from the center of tile start to the center of tile end.
start | The start tile of the road. |
end | The end tile of the road. |
Builds a road depot.
tile | Place to build the depot. |
front | The tile exactly in front of the depot. |
Builds a road from the edge of tile start to the edge of tile end (both included).
start | The start tile of the road. |
end | The end tile of the road. |
|
static |
Builds a road bus or truck station.
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. |
|
static |
Lookup function for building road parts independent of 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.
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). |
|
static |
Lookup function for building road parts independent of whether the "building on slopes" setting is enabled or not.
This implementation can be used for reasoning about an existing tile.
tile | The tile to examine. |
start | The tile from where "tile" will be entered. |
end | The tile from where "tile" will be exited. |
|
static |
Convert the road on all tiles within a rectangle to another RoadType.
start_tile | One corner of the rectangle. |
end_tile | The opposite corner of the rectangle. |
road_type | The RoadType you want to convert. |
AIRoad::ERR_UNSUITABLE_ROAD |
Get the baseprice of building a road-related object.
roadtype | the roadtype of the object to build |
build_type | the type of object to build |
|
static |
Get the current RoadType set for all AIRoad functions.
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.
station | The road station tile. |
|
static |
Get the maintenance cost factor of a road type.
roadtype | The road type to get the maintenance factor of. |
|
static |
Get the maximum speed of road vehicles running on this roadtype.
road_type | The roadtype to get the maximum speed of. |
|
static |
Get the name of a road type.
road_type | The road type to get the name of. |
|
static |
Count how many neighbours are road.
tile | The tile to check on. |
Gets the tile in front of a road depot.
depot | The road depot tile. |
Gets the tile in front of a road station.
station | The road station tile. |
|
static |
Test if a road type is for road or trams.
roadtype | the roadtype to test. |
|
static |
Determines whether a busstop or a truckstop is needed to transport a certain cargo.
cargo_type | The cargo to test. |
Check if a given tile has RoadType.
tile | The tile to check. |
road_type | The RoadType to check for. |
|
static |
Checks whether the given tile is actually a tile with a drive through road station.
tile | The tile to check. |
|
static |
Checks whether the given tile is actually a tile with a road depot.
tile | The tile to check. |
|
static |
Checks whether the given tile is actually a tile with a road station.
tile | The tile to check. |
|
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.
tile | The tile to check. |
|
static |
Check if a given RoadType is available.
road_type | The RoadType to check for. |
Removes a road from the center of tile start to the center of tile end.
start | The start tile of the road. |
end | The end tile of the road. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY | |
AIError::ERR_VEHICLE_IN_THE_WAY | |
AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |
|
static |
Removes a road depot.
tile | Place to remove the depot from. |
Removes a road from the edge of tile start to the edge of tile end (both included).
start | The start tile of the road. |
end | The end tile of the road. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY | |
AIError::ERR_VEHICLE_IN_THE_WAY | |
AIRoad::ERR_ROAD_WORKS_IN_PROGRESS |
|
static |
Removes a road bus or truck station.
tile | Place to remove the station from. |
|
static |
Check if a road vehicle built for a road type can run on another road type.
engine_road_type | The road type the road vehicle is built for. |
road_road_type | The road type you want to check. |
|
static |
Check if a road vehicle built for a road type has power on another road type.
engine_road_type | The road type the road vehicle is built for. |
road_road_type | The road type you want to check. |