src/ai/api/ai_road.hpp
branchnoai
changeset 10993 203b90795f80
parent 10972 986675d19245
--- a/src/ai/api/ai_road.hpp	Tue Jun 17 11:46:09 2008 +0000
+++ b/src/ai/api/ai_road.hpp	Tue Jun 17 13:06:32 2008 +0000
@@ -7,6 +7,7 @@
 
 #include "ai_object.hpp"
 #include "ai_error.hpp"
+#include "ai_tile.hpp"
 
 /**
  * Class that handles all road related functions.
@@ -124,6 +125,58 @@
 	static bool AreRoadTilesConnected(TileIndex tile_from, TileIndex tile_to);
 
 	/**
+	 * 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.
+	 * @param slope The slope of the tile to examine.
+	 * @param 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.
+	 * @param 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).
+	 * @param 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).
+	 * @pre start != end.
+	 * @pre slope must be a valid slope, i.e. one specified in AITile::Slope.
+	 * @note Passing data that would be invalid in-game, e.g. existing containing
+	 *       road parts that can not be build on a tile with the given slope,
+	 *       does not necessarily means that -1 is returned, i.e. not all
+	 *       preconditions written here or assumed by the game are extensively
+	 *       checked to make sure the data entered is valid.
+	 * @return 0 when the build parts do not connect, 1 when they do connect once
+	 *         they are build or 2 when building the first part automatically
+	 *         builds the second part. -1 means the preconditions are not met.
+	 */
+	static int32 CanBuildConnectedRoadParts(AITile::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.
+	 *  This implementation can be used for reasoning about an existing tile.
+	 * @param tile The the tile to examine.
+	 * @param start The tile from where "tile" will be entered.
+	 * @param end The tile from where "tile" will be exited.
+	 * @pre start != end.
+	 * @pre tile != start.
+	 * @pre tile != end.
+	 * @pre AIMap.IsValidTile(tile).
+	 * @pre AIMap.IsValidTile(start).
+	 * @pre AIMap.IsValidTile(end).
+	 * @pre AIMap.GetDistanceManhattanToTile(tile, start) == 1.
+	 * @pre AIMap.GetDistanceManhattanToTile(tile, end) == 1.
+	 * @return 0 when the build parts do not connect, 1 when they do connect once
+	 *         they are build or 2 when building the first part automatically
+	 *         builds the second part. -1 means the preconditions are not met.
+	 */
+	static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
+
+	/**
 	 * Count how many neighbours are road.
 	 * @param tile The tile to check on.
 	 * @pre AIMap::IsValidTile(tile).