src/ai/api/ai_town.hpp
branchnoai
changeset 9582 40f54a61bb17
parent 9541 4bb34cea7fad
child 9594 5009a30f320a
equal deleted inserted replaced
9581:398688c1a07a 9582:40f54a61bb17
    44 	 * @param town_id the town to get the name of.
    44 	 * @param town_id the town to get the name of.
    45 	 * @pre town_id has to be valid (use IsValidTown()).
    45 	 * @pre town_id has to be valid (use IsValidTown()).
    46 	 * @return the name of the town.
    46 	 * @return the name of the town.
    47 	 * @note the returned name must be free'd (C++ only).
    47 	 * @note the returned name must be free'd (C++ only).
    48 	 */
    48 	 */
    49 	char *GetName(TownID town_id);
    49 	static char *GetName(TownID town_id);
    50 
    50 
    51 	/**
    51 	/**
    52 	 * Gets the number of inhabitants in the town.
    52 	 * Gets the number of inhabitants in the town.
    53 	 * @param town_id the town to get the name of.
    53 	 * @param town_id the town to get the name of.
    54 	 * @pre town_id has to be valid (use IsValidTown()).
    54 	 * @pre town_id has to be valid (use IsValidTown()).
    55 	 * @return the number of inhabitants.
    55 	 * @return the number of inhabitants.
    56 	 * @post return value is always non-negative.
    56 	 * @post return value is always non-negative.
    57 	 */
    57 	 */
    58 	int32 GetPopulation(TownID town_id);
    58 	static int32 GetPopulation(TownID town_id);
    59 
    59 
    60 	/**
    60 	/**
    61 	 * Gets the location of the town.
    61 	 * Gets the location of the town.
    62 	 * @param town_id the location of the town.
    62 	 * @param town_id the location of the town.
    63 	 * @pre town_id has to be valid (use IsValidTown()).
    63 	 * @pre town_id has to be valid (use IsValidTown()).
    64 	 * @return the location of the town.
    64 	 * @return the location of the town.
    65 	 * @post return value is always positive and below AIMap::GetMapSize().
    65 	 * @post return value is always positive and below AIMap::GetMapSize().
    66 	 */
    66 	 */
    67 	TileIndex GetLocation(TownID town_id);
    67 	static TileIndex GetLocation(TownID town_id);
    68 };
    68 };
    69 
    69 
    70 #ifdef DEFINE_SQUIRREL_CLASS
    70 #ifdef DEFINE_SQUIRREL_CLASS
    71 namespace SQConvert {
    71 namespace SQConvert {
    72 	/* Allow AITown to be used as Squirrel parameter */
    72 	/* Allow AITown to be used as Squirrel parameter */
    76 void SQAITownRegister(Squirrel *engine) {
    76 void SQAITownRegister(Squirrel *engine) {
    77 	DefSQClass <AITown> SQAITown("AITown");
    77 	DefSQClass <AITown> SQAITown("AITown");
    78 	SQAITown.PreRegister(engine);
    78 	SQAITown.PreRegister(engine);
    79 	SQAITown.AddConstructor(engine);
    79 	SQAITown.AddConstructor(engine);
    80 
    80 
    81 	SQAITown.DefSQStaticMethod(engine, &AITown::GetClassName, "GetClassName", 1, "x");
    81 	SQAITown.DefSQStaticMethod(engine, &AITown::GetClassName,  "GetClassName",  1, "x");
    82 	SQAITown.DefSQStaticMethod(engine, &AITown::IsValidTown,  "IsValidTown",  2, "xi");
    82 	SQAITown.DefSQStaticMethod(engine, &AITown::IsValidTown,   "IsValidTown",   2, "xi");
       
    83 	SQAITown.DefSQStaticMethod(engine, &AITown::GetName,       "GetName",       2, "xi");
       
    84 	SQAITown.DefSQStaticMethod(engine, &AITown::GetPopulation, "GetPopulation", 2, "xi");
       
    85 	SQAITown.DefSQStaticMethod(engine, &AITown::GetLocation,   "GetLocation",   2, "xi");
    83 
    86 
    84 	SQAITown.DefSQMethod(engine, &AITown::GetMaxTownID,  "GetMaxTownID",  1, "x");
    87 	SQAITown.DefSQMethod(engine, &AITown::GetMaxTownID, "GetMaxTownID", 1, "x");
    85 	SQAITown.DefSQMethod(engine, &AITown::GetTownCount,  "GetTownCount",  1, "x");
    88 	SQAITown.DefSQMethod(engine, &AITown::GetTownCount, "GetTownCount", 1, "x");
    86 	SQAITown.DefSQMethod(engine, &AITown::GetName,       "GetName",       2, "xi");
       
    87 	SQAITown.DefSQMethod(engine, &AITown::GetPopulation, "GetPopulation", 2, "xi");
       
    88 	SQAITown.DefSQMethod(engine, &AITown::GetLocation,   "GetLocation",   2, "xi");
       
    89 
    89 
    90 	SQAITown.PostRegister(engine);
    90 	SQAITown.PostRegister(engine);
    91 }
    91 }
    92 #endif /* DEFINE_SQUIRREL_CLASS */
    92 #endif /* DEFINE_SQUIRREL_CLASS */
    93 
    93