(svn r12508) [NoAI] -Fix: @note that refer to @return should come after @return, not before @param
/* $Id$ */
/** @file ai_tile.hpp Everything to query and manipulate tiles. */
#ifndef AI_TILE_HPP
#define AI_TILE_HPP
#include "ai_abstractlist.hpp"
/**
* Class that handles all tile related functions.
*/
class AITile : public AIObject {
public:
static const char *GetClassName() { return "AITile"; }
/**
* Enumeration for the slope-type (from slopes.h).
*
* This enumeration use the chars N, E, S, W corresponding the
* direction North, East, South and West. The top corner of a tile
* is the north-part of the tile.
*/
enum Slope {
SLOPE_FLAT = 0x00, //!< A flat tile
SLOPE_W = 0x01, //!< The west corner of the tile is raised
SLOPE_S = 0x02, //!< The south corner of the tile is raised
SLOPE_E = 0x04, //!< The east corner of the tile is raised
SLOPE_N = 0x08, //!< The north corner of the tile is raised
SLOPE_STEEP = 0x10, //!< Indicates the slope is steep
SLOPE_NW = SLOPE_N | SLOPE_W, //!< North and west corner are raised
SLOPE_SW = SLOPE_S | SLOPE_W, //!< South and west corner are raised
SLOPE_SE = SLOPE_S | SLOPE_E, //!< South and east corner are raised
SLOPE_NE = SLOPE_N | SLOPE_E, //!< North and east corner are raised
SLOPE_EW = SLOPE_E | SLOPE_W, //!< East and west corner are raised
SLOPE_NS = SLOPE_N | SLOPE_S, //!< North and south corner are raised
SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, //!< All corner are raised, similar to SLOPE_FLAT
SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S, //!< North, west and south corner are raised
SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E, //!< West, south and east corner are raised
SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N, //!< South, east and north corner are raised
SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W, //!< East, north and west corner are raised
SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS, //!< A steep slope falling to east (from west)
SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE, //!< A steep slope falling to north (from south)
SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, //!< A steep slope falling to west (from east)
SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW //!< A steep slope falling to south (from north)
};
/**
* Check if this tile is buildable, i.e. no things on it that needs
* demolishing.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return True if it is buildable, false if not.
* @note Road and rail are considered buildable.
*/
static bool IsBuildable(TileIndex tile);
/**
* Check if this tile is buildable in a rectangle around a tile, with the
* entry in the list as top-left.
* @param tile The tile to check on.
* @param width The width of the rectangle.
* @param height The height of the rectangle.
* @pre AIMap::IsValidTile(tile).
* @return True if it is buildable, false if not.
* @note Road and rail are considered buildable.
*/
static bool IsBuildableRectangle(TileIndex tile, uint width, uint height);
/**
* Check if a tile is water.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return True if it is water, false if not.
*/
static bool IsWater(TileIndex tile);
/**
* Get the slope of a tile.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return 0 means flat, others indicate internal state of slope.
*/
static int32 GetSlope(TileIndex tile);
/**
* Get the height of the tile.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return The height of the tile, ranging from 0 to 15.
*/
static int32 GetHeight(TileIndex tile);
/**
* Check how much cargo this tile accepts.
* It creates a radius around the tile, and adds up all acceptance of this
* cargo.
* @param tile The tile to check on.
* @param cargo_type The cargo to check the acceptance of.
* @param width The width of the station.
* @param height The height of the station.
* @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile).
* @return Value below 8 means no acceptance; the more the better.
*/
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
/**
* Checks how many tiles in the radius produces this cargo.
* It creates a radius around the tile, and adds up all tiles that produce
* this cargo.
* @param tile The tile to check on.
* @param cargo_type The cargo to check the production of.
* @param width The width of the station.
* @param height The height of the station.
* @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile).
* @return The tiles that produce this cargo within radius of the tile.
* @note Town(houses) are not included in the value.
*/
static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
/**
* Get the manhattan distance from the tile to the tile.
* @param tile_from The tile to get the distance to.
* @param tile_to The tile to get the distance to.
* @return The distance between the two tiles.
*/
static int32 GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to);
/**
* Get the square distance from the tile to the tile.
* @param tile_from The tile to get the distance to.
* @param tile_to The tile to get the distance to.
* @return The distance between the two tiles.
*/
static int32 GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to);
/**
* Raise the given corners of the tile. The corners can be combined,
* for example: SLOPE_N | SLOPE_W (= SLOPE_NW)
* @param tile The tile to raise.
* @param slope Corners to raise (SLOPE_xxx).
* @pre AIMap::IsValidTile(tile).
* @return 0 means failed, 1 means success.
*/
static bool RaiseTile(TileIndex tile, int32 slope);
/**
* Lower the given corners of the tile. The corners can be combined,
* for example: SLOPE_N | SLOPE_W (= SLOPE_NW)
* @param tile The tile to lower.
* @param slope Corners to lower (SLOPE_xxx).
* @pre AIMap::IsValidTile(tile).
* @return 0 means failed, 1 means success.
*/
static bool LowerTile(TileIndex tile, int32 slope);
/**
* Destroy everything on the given tile.
* @param tile The tile to demolish.
* @pre AIMap::IsValidTile(tile).
* @return True if and only if the tile was demolished.
*/
static bool DemolishTile(TileIndex tile);
};
#endif /* AI_TILE_HPP */