(svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance noai
authortruelight
Thu, 12 Apr 2007 12:35:44 +0000
branchnoai
changeset 9582 40f54a61bb17
parent 9581 398688c1a07a
child 9583 c233c2897a45
(svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance
src/ai/api/ai_town.cpp
src/ai/api/ai_town.hpp
--- a/src/ai/api/ai_town.cpp	Thu Apr 12 12:19:13 2007 +0000
+++ b/src/ai/api/ai_town.cpp	Thu Apr 12 12:35:44 2007 +0000
@@ -25,7 +25,7 @@
 
 char *AITown::GetName(TownID town_id)
 {
-	if (!this->IsValidTown(town_id)) return NULL;
+	if (!AITown::IsValidTown(town_id)) return NULL;
 	static const int len = 64;
 	char *town_name = MallocT<char>(len);
 
@@ -37,14 +37,14 @@
 
 int32 AITown::GetPopulation(TownID town_id)
 {
-	if (!this->IsValidTown(town_id)) return 0;
+	if (!AITown::IsValidTown(town_id)) return 0;
 	const Town *t = ::GetTown(town_id);
 	return t->population;
 }
 
 TileIndex AITown::GetLocation(TownID town_id)
 {
-	if (!this->IsValidTown(town_id)) return INVALID_TILE;
+	if (!AITown::IsValidTown(town_id)) return INVALID_TILE;
 	const Town *t = ::GetTown(town_id);
 	return t->xy;
 }
--- a/src/ai/api/ai_town.hpp	Thu Apr 12 12:19:13 2007 +0000
+++ b/src/ai/api/ai_town.hpp	Thu Apr 12 12:35:44 2007 +0000
@@ -46,7 +46,7 @@
 	 * @return the name of the town.
 	 * @note the returned name must be free'd (C++ only).
 	 */
-	char *GetName(TownID town_id);
+	static char *GetName(TownID town_id);
 
 	/**
 	 * Gets the number of inhabitants in the town.
@@ -55,7 +55,7 @@
 	 * @return the number of inhabitants.
 	 * @post return value is always non-negative.
 	 */
-	int32 GetPopulation(TownID town_id);
+	static int32 GetPopulation(TownID town_id);
 
 	/**
 	 * Gets the location of the town.
@@ -64,7 +64,7 @@
 	 * @return the location of the town.
 	 * @post return value is always positive and below AIMap::GetMapSize().
 	 */
-	TileIndex GetLocation(TownID town_id);
+	static TileIndex GetLocation(TownID town_id);
 };
 
 #ifdef DEFINE_SQUIRREL_CLASS
@@ -78,14 +78,14 @@
 	SQAITown.PreRegister(engine);
 	SQAITown.AddConstructor(engine);
 
-	SQAITown.DefSQStaticMethod(engine, &AITown::GetClassName, "GetClassName", 1, "x");
-	SQAITown.DefSQStaticMethod(engine, &AITown::IsValidTown,  "IsValidTown",  2, "xi");
+	SQAITown.DefSQStaticMethod(engine, &AITown::GetClassName,  "GetClassName",  1, "x");
+	SQAITown.DefSQStaticMethod(engine, &AITown::IsValidTown,   "IsValidTown",   2, "xi");
+	SQAITown.DefSQStaticMethod(engine, &AITown::GetName,       "GetName",       2, "xi");
+	SQAITown.DefSQStaticMethod(engine, &AITown::GetPopulation, "GetPopulation", 2, "xi");
+	SQAITown.DefSQStaticMethod(engine, &AITown::GetLocation,   "GetLocation",   2, "xi");
 
-	SQAITown.DefSQMethod(engine, &AITown::GetMaxTownID,  "GetMaxTownID",  1, "x");
-	SQAITown.DefSQMethod(engine, &AITown::GetTownCount,  "GetTownCount",  1, "x");
-	SQAITown.DefSQMethod(engine, &AITown::GetName,       "GetName",       2, "xi");
-	SQAITown.DefSQMethod(engine, &AITown::GetPopulation, "GetPopulation", 2, "xi");
-	SQAITown.DefSQMethod(engine, &AITown::GetLocation,   "GetLocation",   2, "xi");
+	SQAITown.DefSQMethod(engine, &AITown::GetMaxTownID, "GetMaxTownID", 1, "x");
+	SQAITown.DefSQMethod(engine, &AITown::GetTownCount, "GetTownCount", 1, "x");
 
 	SQAITown.PostRegister(engine);
 }