rubidium@9380: /* $Id$ */ rubidium@9380: truebrain@9829: /** @file ai_town.hpp Everything to query towns. */ rubidium@9380: rubidium@9380: #ifndef AI_TOWN_HPP rubidium@9380: #define AI_TOWN_HPP rubidium@9380: rubidium@9380: #include "ai_object.hpp" rubidium@9723: #include "../../town_type.h" rubidium@9380: truelight@9448: /** truelight@9448: * Class that handles all town related functions. truelight@9448: */ rubidium@9380: class AITown : public AIObject { rubidium@9380: public: truelight@9529: static const char *GetClassName() { return "AITown"; } truelight@9529: truelight@9529: /** truelight@9448: * Gets the maximum town index; there are no valid towns with a higher index. truebrain@9838: * @return The maximum town index. truebrain@9838: * @post Return value is always non-negative. rubidium@9380: */ truebrain@9737: static TownID GetMaxTownID(); rubidium@9380: rubidium@9380: /** truelight@9448: * Gets the number of towns. This is different than GetMaxTownID() truelight@9448: * because of the way OpenTTD works internally. truebrain@9838: * @return The number of towns. truebrain@9838: * @post Return value is always non-negative. rubidium@9380: */ truebrain@9737: static int32 GetTownCount(); rubidium@9380: rubidium@9380: /** truelight@9448: * Checks whether the given town index is valid. truebrain@9838: * @param town_id The index to check. truebrain@9838: * @return True if and only if the town is valid. rubidium@9380: */ rubidium@9497: static bool IsValidTown(TownID town_id); rubidium@9380: rubidium@9380: /** truelight@9448: * Get the name of the town. truebrain@9838: * @param town_id The town to get the name of. truebrain@9838: * @pre IsValidTown(town_id). truebrain@9838: * @return The name of the town. rubidium@9380: */ truelight@9582: static char *GetName(TownID town_id); rubidium@9380: rubidium@9380: /** truelight@9448: * Gets the number of inhabitants in the town. truebrain@9838: * @param town_id The town to get the name of. truebrain@9838: * @pre IsValidTown(town_id). truebrain@9838: * @return The number of inhabitants. truebrain@9838: * @post Return value is always non-negative. rubidium@9380: */ truelight@9582: static int32 GetPopulation(TownID town_id); rubidium@9380: rubidium@9380: /** truelight@9448: * Gets the location of the town. truebrain@9838: * @param town_id The location of the town. truebrain@9838: * @pre IsValidTown(town_id). truebrain@9838: * @return The location of the town. rubidium@9380: */ truelight@9582: static TileIndex GetLocation(TownID town_id); truebrain@9814: truebrain@9814: /** truebrain@9814: * Get the manhattan distance from the tile to the AITown::GetLocation() truebrain@9814: * of the town. truebrain@9814: * @param town_id The town to get the distance to. truebrain@9814: * @param tile The tile to get the distance to. truebrain@9838: * @pre IsValidTown(town_id). truebrain@9814: * @return The distance between town and tile. truebrain@9814: */ truebrain@9814: static int32 GetDistanceManhattanToTile(TownID town_id, TileIndex tile); truebrain@9814: truebrain@9814: /** truebrain@9814: * Get the square distance from the tile to the AITown::GetLocation() truebrain@9814: * of the town. truebrain@9814: * @param town_id The town to get the distance to. truebrain@9814: * @param tile The tile to get the distance to. truebrain@9838: * @pre IsValidTown(town_id). truebrain@9814: * @return The distance between town and tile. truebrain@9814: */ truebrain@9814: static int32 GetDistanceSquareToTile(TownID town_id, TileIndex tile); rubidium@9380: }; rubidium@9380: rubidium@9380: #endif /* AI_TOWN_HPP */