diff options
Diffstat (limited to 'src/script/api/script_rail.hpp')
-rw-r--r-- | src/script/api/script_rail.hpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/src/script/api/script_rail.hpp b/src/script/api/script_rail.hpp index 57b0fa42b..0fac99a74 100644 --- a/src/script/api/script_rail.hpp +++ b/src/script/api/script_rail.hpp @@ -17,14 +17,14 @@ /** * Class that handles all rail related functions. */ -class AIRail : public AIObject { +class ScriptRail : public ScriptObject { public: /** * All rail related error messages. */ enum ErrorMessages { /** Base for rail building / maintaining errors */ - ERR_RAIL_BASE = AIError::ERR_CAT_RAIL << AIError::ERR_CAT_BIT_SIZE, + ERR_RAIL_BASE = ScriptError::ERR_CAT_RAIL << ScriptError::ERR_CAT_BIT_SIZE, /** One-way roads cannot have crossings */ ERR_CROSSING_ON_ONEWAY_ROAD, // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD] @@ -105,7 +105,7 @@ public: * used to traverse a tile. This excludes rail depots but includes * stations and waypoints. * @param tile The tile to check. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @return True if and only if the tile has rail. */ static bool IsRailTile(TileIndex tile); @@ -120,7 +120,7 @@ public: /** * Checks whether the given tile is actually a tile with a rail depot. * @param tile The tile to check. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @return True if and only if the tile has a rail depot. */ static bool IsRailDepotTile(TileIndex tile); @@ -128,7 +128,7 @@ public: /** * Checks whether the given tile is actually a tile with a rail station. * @param tile The tile to check. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @return True if and only if the tile has a rail station. */ static bool IsRailStationTile(TileIndex tile); @@ -136,7 +136,7 @@ public: /** * Checks whether the given tile is actually a tile with a rail waypoint. * @param tile The tile to check. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @return True if and only if the tile has a rail waypoint. */ static bool IsRailWaypointTile(TileIndex tile); @@ -149,13 +149,13 @@ public: static bool IsRailTypeAvailable(RailType rail_type); /** - * Get the current RailType set for all AIRail functions. + * Get the current RailType set for all ScriptRail functions. * @return The RailType currently set. */ static RailType GetCurrentRailType(); /** - * Set the RailType for all further AIRail functions. + * Set the RailType for all further ScriptRail functions. * @param rail_type The RailType to set. */ static void SetCurrentRailType(RailType rail_type); @@ -164,28 +164,28 @@ public: * Check if a train build for a rail type can run on another rail type. * @param engine_rail_type The rail type the train is build for. * @param track_rail_type The type you want to check. - * @pre AIRail::IsRailTypeAvailable(engine_rail_type). - * @pre AIRail::IsRailTypeAvailable(track_rail_type). + * @pre ScriptRail::IsRailTypeAvailable(engine_rail_type). + * @pre ScriptRail::IsRailTypeAvailable(track_rail_type). * @return Whether a train build for 'engine_rail_type' can run on 'track_rail_type'. * @note Even if a train can run on a RailType that doesn't mean that it'll be * able to power the train. Use TrainHasPowerOnRail for that. */ - static bool TrainCanRunOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type); + static bool TrainCanRunOnRail(ScriptRail::RailType engine_rail_type, ScriptRail::RailType track_rail_type); /** * Check if a train build for a rail type has power on another rail type. * @param engine_rail_type The rail type the train is build for. * @param track_rail_type The type you want to check. - * @pre AIRail::IsRailTypeAvailable(engine_rail_type). - * @pre AIRail::IsRailTypeAvailable(track_rail_type). + * @pre ScriptRail::IsRailTypeAvailable(engine_rail_type). + * @pre ScriptRail::IsRailTypeAvailable(track_rail_type). * @return Whether a train build for 'engine_rail_type' has power on 'track_rail_type'. */ - static bool TrainHasPowerOnRail(AIRail::RailType engine_rail_type, AIRail::RailType track_rail_type); + static bool TrainHasPowerOnRail(ScriptRail::RailType engine_rail_type, ScriptRail::RailType track_rail_type); /** * Get the RailType that is used on a tile. * @param tile The tile to check. - * @pre AITile::HasTransportType(tile, AITile.TRANSPORT_RAIL). + * @pre ScriptTile::HasTransportType(tile, ScriptTile.TRANSPORT_RAIL). * @return The RailType that is used on a tile. */ static RailType GetRailType(TileIndex tile); @@ -195,13 +195,13 @@ public: * @param start_tile One corner of the rectangle. * @param end_tile The opposite corner of the rectangle. * @param convert_to The RailType you want to convert the rails to. - * @pre AIMap::IsValidTile(start_tile). - * @pre AIMap::IsValidTile(end_tile). + * @pre ScriptMap::IsValidTile(start_tile). + * @pre ScriptMap::IsValidTile(end_tile). * @pre IsRailTypeAvailable(convert_to). - * @exception AIRail::ERR_UNSUITABLE_TRACK + * @exception ScriptRail::ERR_UNSUITABLE_TRACK * @return Whether at least some rail has been converted successfully. */ - static bool ConvertRailType(TileIndex start_tile, TileIndex end_tile, AIRail::RailType convert_to); + static bool ConvertRailType(TileIndex start_tile, TileIndex end_tile, ScriptRail::RailType convert_to); /** * Gets the tile in front of a rail depot. @@ -223,12 +223,12 @@ public: * Builds a rail depot. * @param tile Place to build the depot. * @param front The tile exactly in front of the depot. - * @pre AIMap::IsValidTile(tile). - * @pre AIMap::IsValidTile(front). + * @pre ScriptMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(front). * @pre 'tile' is not equal to 'front', but in a straight line of it. * @pre IsRailTypeAvailable(GetCurrentRailType()). - * @exception AIError::ERR_FLAT_LAND_REQUIRED - * @exception AIError::ERR_AREA_NOT_CLEAR + * @exception ScriptError::ERR_FLAT_LAND_REQUIRED + * @exception ScriptError::ERR_AREA_NOT_CLEAR * @return Whether the rail depot has been/can be build or not. */ static bool BuildRailDepot(TileIndex tile, TileIndex front); @@ -239,19 +239,19 @@ public: * @param direction The direction to build the station. * @param num_platforms The number of platforms to build. * @param platform_length The length of each platform. - * @param station_id The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT. + * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT. * @pre IsRailTypeAvailable(GetCurrentRailType()). - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @pre direction == RAILTRACK_NW_SE || direction == RAILTRACK_NE_SW. * @pre num_platforms > 0 && num_platforms <= 255. * @pre platform_length > 0 && platform_length <= 255. - * @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id). - * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIError::ERR_AREA_NOT_CLEAR - * @exception AIError::ERR_FLAT_LAND_REQUIRED - * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION - * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS - * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN + * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id). + * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY + * @exception ScriptError::ERR_AREA_NOT_CLEAR + * @exception ScriptError::ERR_FLAT_LAND_REQUIRED + * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION + * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS + * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN * @return Whether the station has been/can be build or not. */ static bool BuildRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id); @@ -264,27 +264,27 @@ public: * @param direction The direction to build the station. * @param num_platforms The number of platforms to build. * @param platform_length The length of each platform. - * @param station_id The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT. + * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT. * @param cargo_id The CargoID of the cargo that will be transported from / to this station. - * @param source_industry The IndustryType of the industry you'll transport goods from, AIIndustryType::INDUSTRYTYPE_UNKNOWN or AIIndustryType::INDUSTRYTYPE_TOWN. - * @param goal_industry The IndustryType of the industry you'll transport goods to, AIIndustryType::INDUSTRYTYPE_UNKNOWN or AIIndustryType::INDUSTRYTYPE_TOWN. + * @param source_industry The IndustryType of the industry you'll transport goods from, ScriptIndustryType::INDUSTRYTYPE_UNKNOWN or ScriptIndustryType::INDUSTRYTYPE_TOWN. + * @param goal_industry The IndustryType of the industry you'll transport goods to, ScriptIndustryType::INDUSTRYTYPE_UNKNOWN or ScriptIndustryType::INDUSTRYTYPE_TOWN. * @param distance The manhattan distance you'll transport the cargo over. * @param source_station True if this is the source station, false otherwise. * @pre IsRailTypeAvailable(GetCurrentRailType()). - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @pre direction == RAILTRACK_NW_SE || direction == RAILTRACK_NE_SW. * @pre num_platforms > 0 && num_platforms <= 255. * @pre platform_length > 0 && platform_length <= 255. - * @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id). - * @pre AICargo::IsValidCargo(cargo_type) - * @pre source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry). - * @pre goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry). - * @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY - * @exception AIError::ERR_AREA_NOT_CLEAR - * @exception AIError::ERR_FLAT_LAND_REQUIRED - * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION - * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS - * @exception AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN + * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id). + * @pre ScriptCargo::IsValidCargo(cargo_type) + * @pre source_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(source_industry). + * @pre goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry). + * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY + * @exception ScriptError::ERR_AREA_NOT_CLEAR + * @exception ScriptError::ERR_FLAT_LAND_REQUIRED + * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION + * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS + * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN * @return Whether the station has been/can be build or not. */ static bool BuildNewGRFRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, int distance, bool source_station); @@ -292,11 +292,11 @@ public: /** * Build a rail waypoint. * @param tile Place to build the waypoint. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @pre IsRailTile(tile). * @pre GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE. * @pre IsRailTypeAvailable(GetCurrentRailType()). - * @exception AIError::ERR_FLAT_LAND_REQUIRED + * @exception ScriptError::ERR_FLAT_LAND_REQUIRED * @return Whether the rail waypoint has been/can be build or not. */ static bool BuildRailWaypoint(TileIndex tile); @@ -336,13 +336,13 @@ public: * Build rail on the given tile. * @param tile The tile to build on. * @param rail_track The RailTrack to build. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @pre IsRailTypeAvailable(GetCurrentRailType()). - * @exception AIError::ERR_AREA_NOT_CLEAR - * @exception AIError::ERR_LAND_SLOPED_WRONG - * @exception AIRoad::ERR_ROAD_WORKS_IN_PROGRESS - * @exception AIRail::ERR_CROSSING_ON_ONEWAY_ROAD - * @exception AIError::ERR_ALREADY_BUILT + * @exception ScriptError::ERR_AREA_NOT_CLEAR + * @exception ScriptError::ERR_LAND_SLOPED_WRONG + * @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS + * @exception ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD + * @exception ScriptError::ERR_ALREADY_BUILT * @return Whether the rail has been/can be build or not. * @note You can only build a single track with this function so do not * use the values from RailTrack as bitmask. @@ -353,7 +353,7 @@ public: * Remove rail on the given tile. * @param tile The tile to remove rail from. * @param rail_track The RailTrack to remove. - * @pre AIMap::IsValidTile(tile). + * @pre ScriptMap::IsValidTile(tile). * @pre (GetRailTracks(tile) & rail_track) != 0. * @return Whether the rail has been/can be removed or not. * @note You can only remove a single track with this function so do not @@ -367,8 +367,8 @@ public: * @param tile The tile that is checked. * @param to The second tile to connect. * @pre from != to. - * @pre AIMap::DistanceManhattan(from, tile) == 1. - * @pre AIMap::DistanceManhattan(to, tile) == 1. + * @pre ScriptMap::DistanceManhattan(from, tile) == 1. + * @pre ScriptMap::DistanceManhattan(to, tile) == 1. * @return True if 'tile' connects 'from' and 'to'. */ static bool AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to); @@ -379,18 +379,18 @@ public: * @param tile The first tile to build on. * @param to The tile just after the last tile to build on. * @pre from != to. - * @pre AIMap::DistanceManhattan(from, tile) == 1. - * @pre AIMap::DistanceManhattan(to, tile) >= 1. - * @pre (abs(abs(AIMap::GetTileX(to) - AIMap::GetTileX(tile)) - - * abs(AIMap::GetTileY(to) - AIMap::GetTileY(tile))) <= 1) || - * (AIMap::GetTileX(from) == AIMap::GetTileX(tile) && AIMap::GetTileX(tile) == AIMap::GetTileX(to)) || - * (AIMap::GetTileY(from) == AIMap::GetTileY(tile) && AIMap::GetTileY(tile) == AIMap::GetTileY(to)). + * @pre ScriptMap::DistanceManhattan(from, tile) == 1. + * @pre ScriptMap::DistanceManhattan(to, tile) >= 1. + * @pre (abs(abs(ScriptMap::GetTileX(to) - ScriptMap::GetTileX(tile)) - + * abs(ScriptMap::GetTileY(to) - ScriptMap::GetTileY(tile))) <= 1) || + * (ScriptMap::GetTileX(from) == ScriptMap::GetTileX(tile) && ScriptMap::GetTileX(tile) == ScriptMap::GetTileX(to)) || + * (ScriptMap::GetTileY(from) == ScriptMap::GetTileY(tile) && ScriptMap::GetTileY(tile) == ScriptMap::GetTileY(to)). * @pre IsRailTypeAvailable(GetCurrentRailType()). - * @exception AIError::ERR_AREA_NOT_CLEAR - * @exception AIError::ERR_LAND_SLOPED_WRONG - * @exception AIRail::ERR_CROSSING_ON_ONEWAY_ROAD - * @exception AIRoad::ERR_ROAD_WORKS_IN_PROGRESS - * @exception AIError::ERR_ALREADY_BUILT + * @exception ScriptError::ERR_AREA_NOT_CLEAR + * @exception ScriptError::ERR_LAND_SLOPED_WRONG + * @exception ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD + * @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS + * @exception ScriptError::ERR_ALREADY_BUILT * @note Construction will fail if an obstacle is found between the start and end tiles. * @return Whether the rail has been/can be build or not. */ @@ -402,19 +402,19 @@ public: * @param tile The first tile to remove rail from. * @param to The tile just after the last tile to remove rail from. * @pre from != to. - * @pre AIMap::DistanceManhattan(from, tile) == 1. - * @pre AIMap::DistanceManhattan(to, tile) >= 1. - * @pre (abs(abs(AIMap::GetTileX(to) - AIMap::GetTileX(tile)) - - * abs(AIMap::GetTileY(to) - AIMap::GetTileY(tile))) <= 1) || - * (AIMap::GetTileX(from) == AIMap::GetTileX(tile) && AIMap::GetTileX(tile) == AIMap::GetTileX(to)) || - * (AIMap::GetTileY(from) == AIMap::GetTileY(tile) && AIMap::GetTileY(tile) == AIMap::GetTileY(to)). + * @pre ScriptMap::DistanceManhattan(from, tile) == 1. + * @pre ScriptMap::DistanceManhattan(to, tile) >= 1. + * @pre (abs(abs(ScriptMap::GetTileX(to) - ScriptMap::GetTileX(tile)) - + * abs(ScriptMap::GetTileY(to) - ScriptMap::GetTileY(tile))) <= 1) || + * (ScriptMap::GetTileX(from) == ScriptMap::GetTileX(tile) && ScriptMap::GetTileX(tile) == ScriptMap::GetTileX(to)) || + * (ScriptMap::GetTileY(from) == ScriptMap::GetTileY(tile) && ScriptMap::GetTileY(tile) == ScriptMap::GetTileY(to)). * @return Whether the rail has been/can be removed or not. */ static bool RemoveRail(TileIndex from, TileIndex tile, TileIndex to); /** * Get the SignalType of the signal on a tile or SIGNALTYPE_NONE if there is no signal. - * @pre AIMap::DistanceManhattan(tile, front) == 1. + * @pre ScriptMap::DistanceManhattan(tile, front) == 1. * @param tile The tile that might have a signal. * @param front The tile in front of 'tile'. * @return The SignalType of the signal on 'tile' facing to 'front'. @@ -426,9 +426,9 @@ public: * @param tile The tile to build on. * @param front The tile in front of the signal. * @param signal The SignalType to build. - * @pre AIMap::DistanceManhattan(tile, front) == 1. + * @pre ScriptMap::DistanceManhattan(tile, front) == 1. * @pre IsRailTile(tile) && !IsRailStationTile(tile) && !IsRailWaypointTile(tile). - * @exception AIRail::ERR_UNSUITABLE_TRACK + * @exception ScriptRail::ERR_UNSUITABLE_TRACK * @return Whether the signal has been/can be build or not. */ static bool BuildSignal(TileIndex tile, TileIndex front, SignalType signal); @@ -437,7 +437,7 @@ public: * Remove a signal. * @param tile The tile to remove the signal from. * @param front The tile in front of the signal. - * @pre AIMap::DistanceManhattan(tile, front) == 1. + * @pre ScriptMap::DistanceManhattan(tile, front) == 1. * @pre GetSignalType(tile, front) != SIGNALTYPE_NONE. * @return Whether the signal has been/can be removed or not. */ |