Class that handles all station related functions. More...
#include <script_station.hpp>
Public Types | |
enum | ErrorMessages { ERR_STATION_BASE = ScriptError::ERR_CAT_STATION << ScriptError::ERR_CAT_BIT_SIZE, ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION, ERR_STATION_TOO_MANY_STATIONS, ERR_STATION_TOO_MANY_STATIONS_IN_TOWN } |
All station related error messages. More... | |
enum | StationType { STATION_TRAIN = ::FACIL_TRAIN, STATION_TRUCK_STOP = ::FACIL_TRUCK_STOP, STATION_BUS_STOP = ::FACIL_BUS_STOP, STATION_AIRPORT = ::FACIL_AIRPORT, STATION_DOCK = ::FACIL_DOCK, STATION_ANY = STATION_TRAIN | STATION_TRUCK_STOP | STATION_BUS_STOP | STATION_AIRPORT | STATION_DOCK } |
Type of stations known in the game. More... | |
Static Public Member Functions | |
static bool | IsValidStation (StationID station_id) |
Checks whether the given station is valid and owned by you. | |
static ScriptCompany::CompanyID | GetOwner (StationID station_id) |
Get the owner of a station. | |
static StationID | GetStationID (TileIndex tile) |
Get the StationID of a tile, if there is a station. | |
static int32 | GetCargoWaiting (StationID station_id, CargoID cargo_id) |
See how much cargo there is waiting on a station. | |
static int32 | GetCargoRating (StationID station_id, CargoID cargo_id) |
See how high the rating is of a cargo on a station. | |
static int32 | GetCoverageRadius (ScriptStation::StationType station_type) |
Get the coverage radius of this type of station. | |
static int32 | GetStationCoverageRadius (StationID station_id) |
Get the coverage radius of this station. | |
static int32 | GetDistanceManhattanToTile (StationID station_id, TileIndex tile) |
Get the manhattan distance from the tile to the ScriptStation::GetLocation() of the station. | |
static int32 | GetDistanceSquareToTile (StationID station_id, TileIndex tile) |
Get the square distance from the tile to the ScriptStation::GetLocation() of the station. | |
static bool | IsWithinTownInfluence (StationID station_id, TownID town_id) |
Find out if this station is within the rating influence of a town. | |
static bool | HasStationType (StationID station_id, StationType station_type) |
Check if any part of the station contains a station of the type StationType. | |
static bool | HasRoadType (StationID station_id, ScriptRoad::RoadType road_type) |
Check if any part of the station contains a station of the type RoadType. | |
static TownID | GetNearestTown (StationID station_id) |
Get the town that was nearest to the given station when the station was built. |
Class that handles all station related functions.
ai game
Definition at line 23 of file script_station.hpp.
All station related error messages.
Definition at line 28 of file script_station.hpp.
Type of stations known in the game.
STATION_TRAIN |
Train station. |
STATION_TRUCK_STOP |
Truck station. |
STATION_BUS_STOP |
Bus station. |
STATION_AIRPORT | |
STATION_DOCK |
Dock. |
STATION_ANY |
All station types. |
Definition at line 45 of file script_station.hpp.
See how high the rating is of a cargo on a station.
station_id | The station to get the cargo-rating of. | |
cargo_id | The cargo to get the cargo-rating of. |
Definition at line 49 of file script_station.cpp.
References ScriptCargo::IsValidCargo(), IsValidStation(), and ToPercent8().
See how much cargo there is waiting on a station.
station_id | The station to get the cargo-waiting of. | |
cargo_id | The cargo to get the cargo-waiting of. |
Definition at line 41 of file script_station.cpp.
References ScriptCargo::IsValidCargo(), and IsValidStation().
int32 ScriptStation::GetCoverageRadius | ( | ScriptStation::StationType | station_type | ) | [static] |
Get the coverage radius of this type of station.
station_type | The type of station. |
Definition at line 57 of file script_station.cpp.
References _settings_game, HasExactlyOneBit(), StationSettings::modified_catchment, GameSettings::station, STATION_AIRPORT, STATION_BUS_STOP, STATION_DOCK, STATION_TRAIN, and STATION_TRUCK_STOP.
Get the manhattan distance from the tile to the ScriptStation::GetLocation() of the station.
station_id | The station to get the distance to. | |
tile | The tile to get the distance to. |
Definition at line 80 of file script_station.cpp.
References DistanceManhattan(), ScriptBaseStation::GetLocation(), and IsValidStation().
Get the square distance from the tile to the ScriptStation::GetLocation() of the station.
station_id | The station to get the distance to. | |
tile | The tile to get the distance to. |
Definition at line 87 of file script_station.cpp.
References DistanceSquare(), ScriptBaseStation::GetLocation(), and IsValidStation().
Get the town that was nearest to the given station when the station was built.
station_id | The station to look at. |
Definition at line 126 of file script_station.cpp.
References IsValidStation().
ScriptCompany::CompanyID ScriptStation::GetOwner | ( | StationID | station_id | ) | [static] |
Get the owner of a station.
station_id | The station to get the owner of. |
Definition at line 28 of file script_station.cpp.
References IsValidStation().
int32 ScriptStation::GetStationCoverageRadius | ( | StationID | station_id | ) | [static] |
Get the coverage radius of this station.
station_id | The station to get the coverage radius of. |
Definition at line 73 of file script_station.cpp.
References IsValidStation().
Get the StationID of a tile, if there is a station.
tile | The tile to find the stationID of |
Definition at line 35 of file script_station.cpp.
References GetStationIndex(), IsTileType(), IsValidTile(), and MP_STATION.
bool ScriptStation::HasRoadType | ( | StationID | station_id, | |
ScriptRoad::RoadType | road_type | |||
) | [static] |
Check if any part of the station contains a station of the type RoadType.
station_id | The station to look at. | |
road_type | The RoadType to look for. |
Definition at line 109 of file script_station.cpp.
References GetRoadTypes(), ScriptRoad::IsRoadTypeAvailable(), IsValidStation(), ROADSTOP_BUS, ROADSTOP_TRUCK, and RoadTypeToRoadTypes().
bool ScriptStation::HasStationType | ( | StationID | station_id, | |
StationType | station_type | |||
) | [static] |
Check if any part of the station contains a station of the type StationType.
station_id | The station to look at. | |
station_type | The StationType to look for. |
Definition at line 101 of file script_station.cpp.
References HasExactlyOneBit(), and IsValidStation().
Referenced by ScriptAirport::GetAirportType().
bool ScriptStation::IsValidStation | ( | StationID | station_id | ) | [static] |
Checks whether the given station is valid and owned by you.
station_id | The station to check. |
Definition at line 22 of file script_station.cpp.
References ScriptObject::GetCompany(), and OWNER_DEITY.
Referenced by ScriptRoad::_BuildRoadStationInternal(), ScriptAirport::BuildAirport(), ScriptMarine::BuildDock(), ScriptRail::BuildNewGRFRailStation(), ScriptRail::BuildRailStation(), GetCargoRating(), GetCargoWaiting(), GetDistanceManhattanToTile(), GetDistanceSquareToTile(), GetNearestTown(), GetOwner(), GetStationCoverageRadius(), HasRoadType(), HasStationType(), IsWithinTownInfluence(), ScriptCargoList_StationAccepting::ScriptCargoList_StationAccepting(), and ScriptTileList_StationType::ScriptTileList_StationType().
Find out if this station is within the rating influence of a town.
The service quality of stations with signs within this radius influences the rating of the town.
station_id | The station to check. | |
town_id | The town to check. |
Definition at line 94 of file script_station.cpp.
References ScriptBaseStation::GetLocation(), and IsValidStation().