rubidium@9380: /* $Id$ */ rubidium@9380: rubidium@9380: /** @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@9380: truelight@9448: /** truelight@9448: * Class that handles all town related functions. truelight@9448: */ rubidium@9380: class AITown : public AIObject { rubidium@9380: public: rubidium@9380: /** truelight@9529: * The name of the class, needed by several sub-processes. truelight@9529: */ 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. truelight@9448: * @return the maximum town index. truelight@9448: * @post return value is always non-negative. rubidium@9380: */ rubidium@9380: 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. truelight@9448: * @return the number of towns. truelight@9448: * @post return value is always non-negative. rubidium@9380: */ rubidium@9380: int32 GetTownCount(); rubidium@9380: rubidium@9380: /** truelight@9448: * Checks whether the given town index is valid. truelight@9448: * @param town_id the index to check. truelight@9448: * @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. truelight@9448: * @param town_id the town to get the name of. truelight@9448: * @pre town_id has to be valid (use IsValidTown()). truelight@9448: * @return the name of the town. truelight@9448: * @note the returned name must be free'd (C++ only). rubidium@9380: */ truelight@9582: static char *GetName(TownID town_id); rubidium@9380: rubidium@9380: /** truelight@9448: * Gets the number of inhabitants in the town. truelight@9448: * @param town_id the town to get the name of. truelight@9448: * @pre town_id has to be valid (use IsValidTown()). truelight@9448: * @return the number of inhabitants. truelight@9448: * @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. truelight@9448: * @param town_id the location of the town. truelight@9448: * @pre town_id has to be valid (use IsValidTown()). truelight@9448: * @return the location of the town. truelight@9448: * @post return value is always positive and below AIMap::GetMapSize(). rubidium@9380: */ truelight@9582: static TileIndex GetLocation(TownID town_id); rubidium@9380: }; rubidium@9380: rubidium@9380: #endif /* AI_TOWN_HPP */