--- a/src/ai/api/ai_town.cpp Sun Mar 18 19:39:27 2007 +0000
+++ b/src/ai/api/ai_town.cpp Sun Mar 18 19:52:09 2007 +0000
@@ -25,6 +25,7 @@
char *AITown::GetName(TownID town_id)
{
+ if (!this->IsValidTown(town_id)) return NULL;
static const int len = 64;
char *town_name = MallocT<char>(len);
@@ -36,12 +37,14 @@
int32 AITown::GetPopulation(TownID town_id)
{
+ if (!this->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;
const Town *t = ::GetTown(town_id);
return t->xy;
}