rubidium@9379: /* $Id$ */ rubidium@9379: truebrain@9829: /** @file ai_map.hpp Everything to query and manipulate map metadata. */ rubidium@9379: rubidium@9379: #ifndef AI_MAP_HPP rubidium@9379: #define AI_MAP_HPP rubidium@9379: rubidium@9379: #include "ai_object.hpp" rubidium@9379: truelight@9448: /** truelight@9448: * Class that handles all map related functions. truelight@9448: */ rubidium@9379: class AIMap : public AIObject { rubidium@9379: public: truelight@9529: static const char *GetClassName() { return "AIMap"; } truelight@9529: truelight@9529: /** truelight@9448: * Checks whether the given tile is valid. truelight@9448: * @param t the tile to check. truelight@9448: * @return true is the tile it within the boundaries of the map. rubidium@9379: */ truelight@9655: static bool IsValidTile(TileIndex t); rubidium@9379: rubidium@9379: /** truelight@9448: * Gets the number of tiles in the map. truelight@9448: * @return the size of the map in tiles. truelight@9448: * @post return value is always positive. rubidium@9379: */ truelight@9655: static TileIndex GetMapSize(); rubidium@9379: rubidium@9379: /** truelight@9448: * Gets the amount of tiles along the SW and NE border. truelight@9448: * @return the length along the SW and NE borders. truelight@9448: * @post return value is always positive. rubidium@9379: */ truelight@9655: static uint32 GetMapSizeX(); rubidium@9379: rubidium@9379: /** truelight@9448: * Gets the amount of tiles along the SE and NW border. truelight@9448: * @return the length along the SE and NW borders. truelight@9448: * @post return value is always positive. rubidium@9379: */ truelight@9655: static uint32 GetMapSizeY(); rubidium@9379: rubidium@9379: /** truelight@9448: * Gets the place along the SW/NE border (X-value). truelight@9448: * @param t the tile to get the X-value of. truelight@9448: * @pre t has to be valid (use IsValidTile(t)). truelight@9448: * @return the X-value. truelight@9448: * @post return value is lower than GetMapSizeX(). rubidium@9379: */ truelight@9655: static uint32 GetTileX(TileIndex t); rubidium@9379: rubidium@9379: /** truelight@9448: * Gets the place along the SE/NW border (Y-value). truelight@9448: * @param t the tile to get the Y-value of. truelight@9448: * @pre t has to be valid (use IsValidTile(t)). truelight@9448: * @return the Y-value. truelight@9448: * @post return value is lower than GetMapSizeY(). rubidium@9379: */ truelight@9655: static uint32 GetTileY(TileIndex t); rubidium@9489: rubidium@9489: /** rubidium@9502: * Gets the TileIndex given a x,y-coordinate. rubidium@9502: * @param x the X coordinate. rubidium@9502: * @param y the Y coordinate. rubidium@9502: * @pre x has to be lower than GetMapSizeX(). rubidium@9502: * @pre y has to be lower than GetMapSizeY(). rubidium@9502: * @return the TileIndex for the given x,y coordinate. rubidium@9502: */ truelight@9655: static TileIndex GetTileIndex(uint32 x, uint32 y); rubidium@9502: rubidium@9502: /** rubidium@9489: * Calculates the Manhattan distance; the difference of rubidium@9489: * the X and Y added together. rubidium@9489: * @param t1 the start. rubidium@9489: * @param t2 the destination. rubidium@9489: * @pre t1 has to be valid (use IsValidTile(t1)). rubidium@9489: * @pre t2 has to be valid (use IsValidTile(t2)). rubidium@9489: * @return the Manhattan distance. rubidium@9489: */ truelight@9655: static uint32 DistanceManhattan(TileIndex t1, TileIndex t2); rubidium@9489: rubidium@9489: /** rubidium@9489: * Calculates the distance between xy1 and xy2 via 1D calculation. rubidium@9489: * (so the distance between X or the distance between Y, depending rubidium@9489: * on which one is bigger). rubidium@9489: * @param t1 the start. rubidium@9489: * @param t2 the destination. rubidium@9489: * @pre t1 has to be valid (use IsValidTile(t1)). rubidium@9489: * @pre t2 has to be valid (use IsValidTile(t2)). rubidium@9489: * @return the maximum distance of X and Y. rubidium@9489: */ truelight@9655: static uint32 DistanceMax(TileIndex t1, TileIndex t2); rubidium@9489: rubidium@9489: /** rubidium@9489: * The squared distance between the two tiles. rubidium@9489: * This is the distance is the length of the shortest straight rubidium@9489: * line between both points. rubidium@9489: * @param t1 the start. rubidium@9489: * @param t2 the destination. rubidium@9489: * @pre t1 has to be valid (use IsValidTile(t1)). rubidium@9489: * @pre t2 has to be valid (use IsValidTile(t2)). rubidium@9489: * @return the distance. rubidium@9489: */ truelight@9655: static uint32 DistanceSquare(TileIndex t1, TileIndex t2); rubidium@9489: rubidium@9489: /** rubidium@9489: * Calculates the shortest distance to the edge. rubidium@9489: * @param t from where the distance has to be calculated. rubidium@9489: * @pre t has to be valid (use IsValidTile(t)). rubidium@9489: * @return the distances to the closest edge. rubidium@9489: */ truelight@9655: static uint32 DistanceFromEdge(TileIndex t); rubidium@9379: }; rubidium@9379: rubidium@9379: #endif /* AI_MAP_HPP */