src/ai/api/ai_road.hpp
branchnoai
changeset 9838 0839682a601b
parent 9829 80fbe02a4184
child 10091 e4feb2f9fedf
equal deleted inserted replaced
9837:c9ec4f82e0d0 9838:0839682a601b
    13 class AIRoad : public AIObject {
    13 class AIRoad : public AIObject {
    14 public:
    14 public:
    15 	static const char *GetClassName() { return "AIRoad"; }
    15 	static const char *GetClassName() { return "AIRoad"; }
    16 
    16 
    17 	/**
    17 	/**
    18 	 * Checks whether the given tile is actually a tile with road that
    18 	 * Checks whether the given tile is actually a tile with road that can be
    19 	 * can be used to traverse a tile. This excludes road depots and
    19 	 *  used to traverse a tile. This excludes road depots and 'normal' road
    20 	 * 'normal' road stations, but includes drive through stations.
    20 	 *  stations, but includes drive through stations.
    21 	 * @param tile the tile to check.
    21 	 * @param tile The tile to check.
    22 	 * @pre AIMap::IsValidTile(tile).
    22 	 * @pre AIMap::IsValidTile(tile).
    23 	 * @return true if and only if the tile has road.
    23 	 * @return True if and only if the tile has road.
    24 	 */
    24 	 */
    25 	static bool IsRoadTile(TileIndex tile);
    25 	static bool IsRoadTile(TileIndex tile);
    26 
    26 
    27 	/**
    27 	/**
    28 	 * Checks whether the given tile is actually a tile with a road depot.
    28 	 * Checks whether the given tile is actually a tile with a road depot.
    29 	 * @param tile the tile to check.
    29 	 * @param tile The tile to check.
    30 	 * @pre AIMap::IsValidTile(tile).
    30 	 * @pre AIMap::IsValidTile(tile).
    31 	 * @return true if and only if the tile has a road depot.
    31 	 * @return True if and only if the tile has a road depot.
    32 	 */
    32 	 */
    33 	static bool IsRoadDepotTile(TileIndex tile);
    33 	static bool IsRoadDepotTile(TileIndex tile);
    34 
    34 
    35 	/**
    35 	/**
    36 	 * Checks whether the given tile is actually a tile with a road station.
    36 	 * Checks whether the given tile is actually a tile with a road station.
    37 	 * @param tile the tile to check.
    37 	 * @param tile The tile to check.
    38 	 * @pre AIMap::IsValidTile(tile).
    38 	 * @pre AIMap::IsValidTile(tile).
    39 	 * @return true if and only if the tile has a road station.
    39 	 * @return True if and only if the tile has a road station.
    40 	 */
    40 	 */
    41 	static bool IsRoadStationTile(TileIndex tile);
    41 	static bool IsRoadStationTile(TileIndex tile);
    42 
    42 
    43 	/**
    43 	/**
    44 	 * Checks whether the given tile is actually a tile with a drive through
    44 	 * Checks whether the given tile is actually a tile with a drive through
    45 	 * road station.
    45 	 *  road station.
    46 	 * @param tile the tile to check.
    46 	 * @param tile The tile to check.
    47 	 * @pre AIMap::IsValidTile(tile).
    47 	 * @pre AIMap::IsValidTile(tile).
    48 	 * @return true if and only if the tile has a drive through road station.
    48 	 * @return True if and only if the tile has a drive through road station.
    49 	 */
    49 	 */
    50 	static bool IsDriveThroughRoadStationTile(TileIndex tile);
    50 	static bool IsDriveThroughRoadStationTile(TileIndex tile);
    51 
    51 
    52 	/**
    52 	/**
    53 	 * Checks whether the given tiles are directly connected, i.e. whether
    53 	 * Checks whether the given tiles are directly connected, i.e. whether
    54 	 * a road vehicle can travel from the center of the first tile to the
    54 	 *  a road vehicle can travel from the center of the first tile to the
    55 	 * center of the second tile.
    55 	  * center of the second tile.
    56 	 * @param t1 the source tile.
    56 	 * @param tile_from The source tile.
    57 	 * @param t2 the destination tile.
    57 	 * @param tile_to The destination tile.
    58 	 * @pre AIMap::IsValidTile(t1).
    58 	 * @pre AIMap::IsValidTile(tile_from).
    59 	 * @pre AIMap::IsValidTile(t2).
    59 	 * @pre AIMap::IsValidTile(tile_to).
    60 	 * @pre t1 and t2 are directly neighbouring tiles.
    60 	 * @pre 'tile_from' and 'tile_to' are directly neighbouring tiles.
    61 	 * @return true if and only if a road vehicle can go from t1 to t2.
    61 	 * @return True if and only if a road vehicle can go from tile_from to tile_to.
    62 	 */
    62 	 */
    63 	static bool AreRoadTilesConnected(TileIndex t1, TileIndex t2);
    63 	static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
    64 
    64 
    65 	/**
    65 	/**
    66 	 * Count how many neighbours are road.
    66 	 * Count how many neighbours are road.
    67 	 * @param tile the tile to check on.
    67 	 * @param tile The tile to check on.
    68 	 * @pre AIMap::IsValidTile(tile).
    68 	 * @pre AIMap::IsValidTile(tile).
    69 	 * @return 0 means no neighbour road; max value is 4.
    69 	 * @return 0 means no neighbour road; max value is 4.
    70 	 */
    70 	 */
    71 	static int32 GetNeighbourRoadCount(TileIndex tile);
    71 	static int32 GetNeighbourRoadCount(TileIndex tile);
    72 
    72 
    73 	/**
    73 	/**
    74 	 * Gets the tile in front of a road depot.
    74 	 * Gets the tile in front of a road depot.
    75 	 * @param depot the road depot tile.
    75 	 * @param depot The road depot tile.
    76 	 * @pre IsRoadDepotTile(depot).
    76 	 * @pre IsRoadDepotTile(depot).
    77 	 * @return the tile in front of the depot.
    77 	 * @return The tile in front of the depot.
    78 	 */
    78 	 */
    79 	static TileIndex GetRoadDepotFrontTile(TileIndex depot);
    79 	static TileIndex GetRoadDepotFrontTile(TileIndex depot);
    80 
    80 
    81 	/**
    81 	/**
    82 	 * Gets the tile in front of a road station.
    82 	 * Gets the tile in front of a road station.
    83 	 * @param station the road station tile.
    83 	 * @param station The road station tile.
    84 	 * @pre IsRoadStationTile(station).
    84 	 * @pre IsRoadStationTile(station).
    85 	 * @return the tile in front of the road station.
    85 	 * @return The tile in front of the road station.
    86 	 */
    86 	 */
    87 	static TileIndex GetRoadStationFrontTile(TileIndex station);
    87 	static TileIndex GetRoadStationFrontTile(TileIndex station);
    88 
    88 
    89 	/**
    89 	/**
    90 	 * Gets the tile at the back of a drive through road station.
    90 	 * Gets the tile at the back of a drive through road station.
    91 	 * So, one side of the drive through station is retrieved with
    91 	 *  So, one side of the drive through station is retrieved with
    92 	 * GetTileInFrontOfStation, the other with this function.
    92 	 *  GetTileInFrontOfStation, the other with this function.
    93 	 * @param station the road station tile.
    93 	 * @param station The road station tile.
    94 	 * @pre IsDriveThroughRoadStationTile(station).
    94 	 * @pre IsDriveThroughRoadStationTile(station).
    95 	 * @return the tile at the back of the drive through road station.
    95 	 * @return The tile at the back of the drive through road station.
    96 	 */
    96 	 */
    97 	static TileIndex GetDriveThroughBackTile(TileIndex station);
    97 	static TileIndex GetDriveThroughBackTile(TileIndex station);
    98 
    98 
    99 	/**
    99 	/**
   100 	 * Builds a road from the center of tile start to the
   100 	 * Builds a road from the center of tile start to the center of tile end.
   101 	 * center of tile end.
   101 	 * @param start The start tile of the road.
   102 	 * @param start the start tile of the road.
   102 	 * @param end The end tile of the road.
   103 	 * @param end   the end tile of the road.
   103 	 * @pre 'start' is not equal to 'end'.
   104 	 * @pre start is not equal to end
       
   105 	 * @pre AIMap::IsValidTile(start).
   104 	 * @pre AIMap::IsValidTile(start).
   106 	 * @pre AIMap::IsValidTile(end).
   105 	 * @pre AIMap::IsValidTile(end).
   107 	 * @pre start and end are in a straight line, i.e.
   106 	 * @pre 'start' and 'end' are in a straight line, i.e.
   108 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   107 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   109 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   108 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   110 	 * @return whether the road has been/can be build or not.
   109 	 * @return Whether the road has been/can be build or not.
   111 	 */
   110 	 */
   112 	static bool BuildRoad(TileIndex start, TileIndex end);
   111 	static bool BuildRoad(TileIndex start, TileIndex end);
   113 
   112 
   114 	/**
   113 	/**
   115 	 * Builds a road from the edge of tile start to the
   114 	 * Builds a road from the edge of tile start to the edge of tile end (both
   116 	 * edge of tile end (both included).
   115 	 *  included).
   117 	 * @param start the start tile of the road.
   116 	 * @param start The start tile of the road.
   118 	 * @param end   the end tile of the road.
   117 	 * @param end The end tile of the road.
   119 	 * @pre start is not equal to end
   118 	 * @pre 'start' is not equal to 'end'.
   120 	 * @pre AIMap::IsValidTile(start).
   119 	 * @pre AIMap::IsValidTile(start).
   121 	 * @pre AIMap::IsValidTile(end).
   120 	 * @pre AIMap::IsValidTile(end).
   122 	 * @pre start and end are in a straight line, i.e.
   121 	 * @pre 'start' and 'end' are in a straight line, i.e.
   123 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   122 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   124 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   123 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   125 	 * @return whether the road has been/can be build or not.
   124 	 * @return Whether the road has been/can be build or not.
   126 	 */
   125 	 */
   127 	static bool BuildRoadFull(TileIndex start, TileIndex end);
   126 	static bool BuildRoadFull(TileIndex start, TileIndex end);
   128 
   127 
   129 	/**
   128 	/**
   130 	 * Builds a road depot.
   129 	 * Builds a road depot.
   131 	 * @param tile  place to build the depot.
   130 	 * @param tile Place to build the depot.
   132 	 * @param front the tile exactly in front of the depot
   131 	 * @param front The tile exactly in front of the depot.
   133 	 * @pre AIMap::IsValidTile(tile).
   132 	 * @pre AIMap::IsValidTile(tile).
   134 	 * @pre AIMap::IsValidTile(front).
   133 	 * @pre AIMap::IsValidTile(front).
   135 	 * @pre tile is not equal to front
   134 	 * @pre Tile is not equal to front.
   136 	 * @return whether the road depot has been/can be build or not.
   135 	 * @return Whether the road depot has been/can be build or not.
   137 	 */
   136 	 */
   138 	static bool BuildRoadDepot(TileIndex tile, TileIndex front);
   137 	static bool BuildRoadDepot(TileIndex tile, TileIndex front);
   139 
   138 
   140 	/**
   139 	/**
   141 	 * Builds a road bus or truck station.
   140 	 * Builds a road bus or truck station.
   142 	 * @param tile  place to build the depot.
   141 	 * @param tile Place to build the depot.
   143 	 * @param front the tile exactly in front of the station.
   142 	 * @param front The tile exactly in front of the station.
   144 	 *   For drive-through stations either entrance side can be used.
   143 	 *   For drive-through stations either entrance side can be used.
   145 	 * @param truck whether to build a truck (true) or bus (false) station.
   144 	 * @param truck Whether to build a truck (true) or bus (false) station.
   146 	 * @param drive_through whether to make the station drive through or not.
   145 	 * @param drive_through Whether to make the station drive through or not.
   147 	 * @pre AIMap::IsValidTile(tile).
   146 	 * @pre AIMap::IsValidTile(tile).
   148 	 * @pre AIMap::IsValidTile(front).
   147 	 * @pre AIMap::IsValidTile(front).
   149 	 * @pre tile is not equal to front
   148 	 * @pre 'tile' is not equal to 'front'.
   150 	 * @return whether the station has been/can be build or not.
   149 	 * @return Whether the station has been/can be build or not.
   151 	 */
   150 	 */
   152 	static bool BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through);
   151 	static bool BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through);
   153 
   152 
   154 	/**
   153 	/**
   155 	 * Removes a road from the center of tile start to the
   154 	 * Removes a road from the center of tile start to the center of tile end.
   156 	 * center of tile end.
   155 	 * @param start The start tile of the road.
   157 	 * @param start the start tile of the road.
   156 	 * @param end The end tile of the road.
   158 	 * @param end   the end tile of the road.
       
   159 	 * @pre AIMap::IsValidTile(start).
   157 	 * @pre AIMap::IsValidTile(start).
   160 	 * @pre AIMap::IsValidTile(end).
   158 	 * @pre AIMap::IsValidTile(end).
   161 	 * @pre start and end are in a straight line, i.e.
   159 	 * @pre 'start' and 'end' are in a straight line, i.e.
   162 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   160 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   163 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   161 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   164 	 * @return whether the road has been/can be removed or not.
   162 	 * @return Whether the road has been/can be removed or not.
   165 	 */
   163 	 */
   166 	static bool RemoveRoad(TileIndex start, TileIndex end);
   164 	static bool RemoveRoad(TileIndex start, TileIndex end);
   167 
   165 
   168 	/**
   166 	/**
   169 	 * Removes a road from the edge of tile start to the
   167 	 * Removes a road from the edge of tile start to the edge of tile end (both
   170 	 * edge of tile end (both included).
   168 	 *  included).
   171 	 * @param start the start tile of the road.
   169 	 * @param start The start tile of the road.
   172 	 * @param end   the end tile of the road.
   170 	 * @param end The end tile of the road.
   173 	 * @pre AIMap::IsValidTile(start).
   171 	 * @pre AIMap::IsValidTile(start).
   174 	 * @pre AIMap::IsValidTile(end).
   172 	 * @pre AIMap::IsValidTile(end).
   175 	 * @pre start and end are in a straight line, i.e.
   173 	 * @pre 'start' and 'end' are in a straight line, i.e.
   176 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   174 	 *  AIMap::GetTileX(start) == AIMap::GetTileX(end) or
   177 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   175 	 *  AIMap::GetTileY(start) == AIMap::GetTileY(end).
   178 	 * @return whether the road has been/can be removed or not.
   176 	 * @return Whether the road has been/can be removed or not.
   179 	 */
   177 	 */
   180 	static bool RemoveRoadFull(TileIndex start, TileIndex end);
   178 	static bool RemoveRoadFull(TileIndex start, TileIndex end);
   181 
   179 
   182 	/**
   180 	/**
   183 	 * Removes a road depot.
   181 	 * Removes a road depot.
   184 	 * @param tile place to remove the depot from.
   182 	 * @param tile Place to remove the depot from.
   185 	 * @pre AIMap::IsValidTile(tile).
   183 	 * @pre AIMap::IsValidTile(tile).
   186 	 * @pre tile is a road depot.
   184 	 * @pre Tile is a road depot.
   187 	 * @return whether the road depot has been/can be removed or not.
   185 	 * @return Whether the road depot has been/can be removed or not.
   188 	 */
   186 	 */
   189 	static bool RemoveRoadDepot(TileIndex tile);
   187 	static bool RemoveRoadDepot(TileIndex tile);
   190 
   188 
   191 	/**
   189 	/**
   192 	 * Removes a road bus or truck station.
   190 	 * Removes a road bus or truck station.
   193 	 * @param tile place to remove the station from.
   191 	 * @param tile Place to remove the station from.
   194 	 * @pre AIMap::IsValidTile(tile).
   192 	 * @pre AIMap::IsValidTile(tile).
   195 	 * @pre tile is a road station.
   193 	 * @pre Tile is a road station.
   196 	 * @return whether the station has been/can be removed or not.
   194 	 * @return Whether the station has been/can be removed or not.
   197 	 */
   195 	 */
   198 	static bool RemoveRoadStation(TileIndex tile);
   196 	static bool RemoveRoadStation(TileIndex tile);
   199 };
   197 };
   200 
   198 
   201 #endif /* AI_ROAD_HPP */
   199 #endif /* AI_ROAD_HPP */