Class that handles all road related functions. More...
#include <script_road.hpp>
Public Types | |
| enum | ErrorMessages { ERR_ROAD_BASE = ScriptError::ERR_CAT_ROAD << ScriptError::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 = ::ROADTYPE_ROAD, ROADTYPE_TRAM = ::ROADTYPE_TRAM, ROADTYPE_INVALID = -1 } |
Types of road known to the game. 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 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 ScriptRoad functions. | |
| static void | SetCurrentRoadType (RoadType road_type) |
| Set the RoadType for all further ScriptRoad 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 (ScriptTile::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 Money | GetBuildCost (RoadType roadtype, BuildType build_type) |
| Get the baseprice of building a road-related object. | |
| static uint16 | GetMaintenanceCostFactor (RoadType roadtype) |
| Get the maintenance cost factor of a roadtype. | |
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. | |
Class that handles all road related functions.
ai game
Definition at line 21 of file script_road.hpp.
Types of road-related objects in the game.
| BT_ROAD |
Build a piece of road. |
| BT_DEPOT |
Build a road depot. |
| BT_BUS_STOP |
Build a bus stop. |
| BT_TRUCK_STOP |
Build a truck stop. |
Definition at line 67 of file script_road.hpp.
All road related error messages.
Definition at line 26 of file script_road.hpp.
| enum ScriptRoad::RoadType |
Types of road known to the game.
| ROADTYPE_ROAD |
Build road objects. |
| ROADTYPE_TRAM |
Build tram objects. |
| ROADTYPE_INVALID |
Invalid RoadType. |
Definition at line 47 of file script_road.hpp.
Type of road station.
| ROADVEHTYPE_BUS |
Build objects useable for busses and passenger trams. |
| ROADVEHTYPE_TRUCK |
Build objects useable for trucks and cargo trams. |
Definition at line 59 of file script_road.hpp.
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. |
Definition at line 78 of file script_road.cpp.
References abs(), DRD_BOTH, DRD_SOUTHBOUND, GetAnyRoadBits(), GetCurrentRoadType(), GetDisallowedRoadDirections(), ScriptObject::GetRoadType(), HasBit(), IsNormalRoadTile(), IsRoadTypeAvailable(), IsValidTile(), TileX(), and TileY().
| bool ScriptRoad::BuildDriveThroughRoadStation | ( | TileIndex | tile, | |
| TileIndex | front, | |||
| RoadVehicleType | road_veh_type, | |||
| StationID | station_id | |||
| ) | [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, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT. |
Definition at line 532 of file script_road.cpp.
References _BuildRoadStationInternal().
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. |
Definition at line 469 of file script_road.cpp.
References _BuildRoadInternal(), EnforcePrecondition, ScriptObject::GetCompany(), and OWNER_DEITY.
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. | |
| start | The start tile of the road. | |
| end | The end tile of the road. |
Definition at line 480 of file script_road.cpp.
References _BuildRoadInternal(), EnforcePrecondition, ScriptObject::GetCompany(), and OWNER_DEITY.
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. |
Definition at line 464 of file script_road.cpp.
References _BuildRoadInternal().
Builds a road depot.
| tile | Place to build the depot. | |
| front | The tile exactly in front of the depot. |
Definition at line 486 of file script_road.cpp.
References CMD_BUILD_ROAD_DEPOT, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCompany(), GetCurrentRoadType(), ScriptObject::GetRoadType(), IsRoadTypeAvailable(), IsValidTile(), OWNER_DEITY, TileX(), and TileY().
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. |
Definition at line 475 of file script_road.cpp.
References _BuildRoadInternal().
| bool ScriptRoad::BuildRoadStation | ( | TileIndex | tile, | |
| TileIndex | front, | |||
| RoadVehicleType | road_veh_type, | |||
| StationID | station_id | |||
| ) | [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, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT. |
Definition at line 527 of file script_road.cpp.
References _BuildRoadStationInternal().
| int32 ScriptRoad::CanBuildConnectedRoadParts | ( | ScriptTile::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.
| 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. ScriptMap.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: ScriptMap.GetTileIndex(0, 1), ScriptMap.GetTileIndex(0, -1), ScriptMap.GetTileIndex(1, 0) and ScriptMap.GetTileIndex(-1, 0). | |
| end | The tile from where the 'tile to be considered' will be exited. This is a relative tile, sovalid parameters are: ScriptMap.GetTileIndex(0, 1), ScriptMap.GetTileIndex(0, -1), ScriptMap.GetTileIndex(1, 0) and ScriptMap.GetTileIndex(-1, 0). |
Definition at line 343 of file script_road.cpp.
References _settings_game, Array::array, ConstructionSettings::build_on_slopes, GameSettings::construction, LookupWithBuildOnSlopes(), LookupWithoutBuildOnSlopes(), NormaliseTileOffset(), and Array::size.
Referenced by CanBuildConnectedRoadPartsHere().
| int32 ScriptRoad::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.
| tile | The the tile to examine. | |
| start | The tile from where "tile" will be entered. | |
| end | The tile from where "tile" will be exited. |
Definition at line 364 of file script_road.cpp.
References Array::array, CanBuildConnectedRoadParts(), DistanceManhattan(), GetAllRoadBits(), GetAnyRoadBits(), ScriptTile::GetSlope(), HasBit(), IsNormalRoadTile(), IsValidTile(), lengthof, ROADTYPE_BEGIN, Array::size, and TileDiffXY().
Get the baseprice of building a road-related object.
| roadtype | the roadtype that is build (on) | |
| build_type | the type of object to build |
Definition at line 579 of file script_road.cpp.
References BT_BUS_STOP, BT_DEPOT, BT_ROAD, BT_TRUCK_STOP, GetPrice(), and IsRoadTypeAvailable().
| ScriptRoad::RoadType ScriptRoad::GetCurrentRoadType | ( | ) | [static] |
Get the current RoadType set for all ScriptRoad functions.
Definition at line 59 of file script_road.cpp.
References ScriptObject::GetRoadType().
Referenced by _BuildRoadInternal(), _BuildRoadStationInternal(), AreRoadTilesConnected(), BuildRoadDepot(), GetNeighbourRoadCount(), IsDriveThroughRoadStationTile(), IsRoadDepotTile(), IsRoadStationTile(), RemoveRoad(), and RemoveRoadFull().
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. |
Definition at line 445 of file script_road.cpp.
References GetRoadStopDir(), INVALID_TILE, IsDriveThroughRoadStationTile(), ReverseDiagDir(), and TileOffsByDiagDir().
| uint16 ScriptRoad::GetMaintenanceCostFactor | ( | RoadType | roadtype | ) | [static] |
Get the maintenance cost factor of a roadtype.
| roadtype | The roadtype to get the maintenance factor of. |
Definition at line 592 of file script_road.cpp.
References IsRoadTypeAvailable(), and ROADTYPE_TRAM.
| int32 ScriptRoad::GetNeighbourRoadCount | ( | TileIndex | tile | ) | [static] |
Count how many neighbours are road.
| tile | The tile to check on. |
Definition at line 415 of file script_road.cpp.
References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, GetCurrentRoadType(), IsRoadTypeAvailable(), IsValidTile(), NeighbourHasReachableRoad(), RoadTypeToRoadTypes(), TileX(), and TileY().
Gets the tile in front of a road depot.
| depot | The road depot tile. |
Definition at line 431 of file script_road.cpp.
References GetRoadDepotDirection(), INVALID_TILE, IsRoadDepotTile(), and TileOffsByDiagDir().
Gets the tile in front of a road station.
| station | The road station tile. |
Definition at line 438 of file script_road.cpp.
References GetRoadStopDir(), INVALID_TILE, IsRoadStationTile(), and TileOffsByDiagDir().
| ScriptRoad::RoadVehicleType ScriptRoad::GetRoadVehicleTypeForCargo | ( | CargoID | cargo_type | ) | [static] |
Determines whether a busstop or a truckstop is needed to transport a certain cargo.
| cargo_type | The cargo to test. |
Definition at line 19 of file script_road.cpp.
References ScriptCargo::CC_PASSENGERS, ScriptCargo::HasCargoClass(), and ROADVEHTYPE_BUS.
Check if a given tile has RoadType.
| tile | The tile to check. | |
| road_type | The RoadType to check for. |
Definition at line 71 of file script_road.cpp.
References GetAnyRoadBits(), IsRoadTypeAvailable(), and ScriptMap::IsValidTile().
| bool ScriptRoad::IsDriveThroughRoadStationTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is actually a tile with a drive through road station.
| tile | The tile to check. |
Definition at line 47 of file script_road.cpp.
References GetCurrentRoadType(), GetRoadTypes(), IsDriveThroughStopTile(), IsValidTile(), and RoadTypeToRoadTypes().
Referenced by GetDriveThroughBackTile(), and IsRoadTile().
| bool ScriptRoad::IsRoadDepotTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is actually a tile with a road depot.
| tile | The tile to check. |
Definition at line 32 of file script_road.cpp.
References GetCurrentRoadType(), GetRoadTileType(), GetRoadTypes(), IsTileType(), IsValidTile(), MP_ROAD, ROAD_TILE_DEPOT, and RoadTypeToRoadTypes().
Referenced by GetRoadDepotFrontTile().
| bool ScriptRoad::IsRoadStationTile | ( | TileIndex | tile | ) | [static] |
Checks whether the given tile is actually a tile with a road station.
| tile | The tile to check. |
Definition at line 40 of file script_road.cpp.
References GetCurrentRoadType(), GetRoadTypes(), IsRoadStopTile(), IsValidTile(), and RoadTypeToRoadTypes().
Referenced by GetRoadStationFrontTile().
| bool ScriptRoad::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.
| tile | The tile to check. |
Definition at line 24 of file script_road.cpp.
References GetRoadTileType(), IsDriveThroughRoadStationTile(), IsTileType(), IsValidTile(), MP_ROAD, and ROAD_TILE_DEPOT.
| bool ScriptRoad::IsRoadTypeAvailable | ( | RoadType | road_type | ) | [static] |
Check if a given RoadType is available.
| road_type | The RoadType to check for. |
Definition at line 54 of file script_road.cpp.
References ScriptObject::GetCompany(), HasRoadTypesAvail(), and RoadTypeToRoadTypes().
Referenced by _BuildRoadInternal(), _BuildRoadStationInternal(), AreRoadTilesConnected(), BuildRoadDepot(), GetBuildCost(), GetMaintenanceCostFactor(), GetNeighbourRoadCount(), ScriptStation::HasRoadType(), HasRoadType(), RemoveRoad(), RemoveRoadFull(), and SetCurrentRoadType().
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. |
| ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY | ||
| ScriptError::ERR_VEHICLE_IN_THE_WAY | ||
| ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS |
Definition at line 537 of file script_road.cpp.
References CMD_REMOVE_LONG_ROAD, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCompany(), GetCurrentRoadType(), ScriptObject::GetRoadType(), IsRoadTypeAvailable(), IsValidTile(), OWNER_DEITY, TileX(), and TileY().
| bool ScriptRoad::RemoveRoadDepot | ( | TileIndex | tile | ) | [static] |
Removes a road depot.
| tile | Place to remove the depot from. |
Definition at line 559 of file script_road.cpp.
References CMD_LANDSCAPE_CLEAR, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCompany(), GetRoadTileType(), IsTileType(), IsValidTile(), MP_ROAD, OWNER_DEITY, and ROAD_TILE_DEPOT.
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. |
| ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY | ||
| ScriptError::ERR_VEHICLE_IN_THE_WAY | ||
| ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS |
Definition at line 548 of file script_road.cpp.
References CMD_REMOVE_LONG_ROAD, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCompany(), GetCurrentRoadType(), ScriptObject::GetRoadType(), IsRoadTypeAvailable(), IsValidTile(), OWNER_DEITY, TileX(), and TileY().
| bool ScriptRoad::RemoveRoadStation | ( | TileIndex | tile | ) | [static] |
Removes a road bus or truck station.
| tile | Place to remove the station from. |
Definition at line 569 of file script_road.cpp.
References CMD_REMOVE_ROAD_STOP, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCompany(), GetRoadStopType(), IsRoadStop(), IsTileType(), IsValidTile(), MP_STATION, and OWNER_DEITY.
| void ScriptRoad::SetCurrentRoadType | ( | RoadType | road_type | ) | [static] |
Set the RoadType for all further ScriptRoad functions.
| road_type | The RoadType to set. |
Definition at line 64 of file script_road.cpp.
References IsRoadTypeAvailable(), and ScriptObject::SetRoadType().
1.7.1