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@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@9380: 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: */ rubidium@9380: 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: */ rubidium@9380: 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: */ rubidium@9380: TileIndex GetLocation(TownID town_id); rubidium@9380: }; rubidium@9380: truelight@9425: #ifdef DEFINE_SQUIRREL_CLASS truelight@9422: void SQAITownRegister(Squirrel *engine) { truelight@9387: DefSQClass SQAITown("AITown"); truelight@9397: SQAITown.PreRegister(engine); truelight@9404: SQAITown.AddConstructor(engine); truelight@9397: SQAITown.DefSQFunction(engine, &AITown::GetMaxTownID, "GetMaxTownID"); truelight@9397: SQAITown.DefSQFunction(engine, &AITown::GetTownCount, "GetTownCount"); truelight@9397: SQAITown.DefSQFunction(engine, &AITown::IsValidTown, "IsValidTown"); truelight@9397: SQAITown.DefSQFunction(engine, &AITown::GetName, "GetName"); truelight@9397: SQAITown.DefSQFunction(engine, &AITown::GetPopulation, "GetPopulation"); truelight@9397: SQAITown.DefSQFunction(engine, &AITown::GetLocation, "GetLocation"); truelight@9397: SQAITown.PostRegister(engine); truelight@9387: } truelight@9387: #endif /* SQUIRREL_CLASS */ truelight@9387: rubidium@9380: #endif /* AI_TOWN_HPP */