# HG changeset patch # User truelight # Date 1176381344 0 # Node ID 40f54a61bb17452673f579d47a2ae0e8af65927b # Parent 398688c1a07a92e3c83ed1cb348297943c84fffe (svn r9606) [NoAI] -Fix: make GetXXX in AITown static, so we can use it without AITown instance diff -r 398688c1a07a -r 40f54a61bb17 src/ai/api/ai_town.cpp --- 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(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; } diff -r 398688c1a07a -r 40f54a61bb17 src/ai/api/ai_town.hpp --- 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); }