equal
deleted
inserted
replaced
23 return ::IsValidTownID(town_id); |
23 return ::IsValidTownID(town_id); |
24 } |
24 } |
25 |
25 |
26 char *AITown::GetName(TownID town_id) |
26 char *AITown::GetName(TownID town_id) |
27 { |
27 { |
|
28 if (!this->IsValidTown(town_id)) return NULL; |
28 static const int len = 64; |
29 static const int len = 64; |
29 char *town_name = MallocT<char>(len); |
30 char *town_name = MallocT<char>(len); |
30 |
31 |
31 SetDParam(0, town_id); |
32 SetDParam(0, town_id); |
32 GetString(town_name, STR_TOWN, &town_name[len - 1]); |
33 GetString(town_name, STR_TOWN, &town_name[len - 1]); |
34 return town_name; |
35 return town_name; |
35 } |
36 } |
36 |
37 |
37 int32 AITown::GetPopulation(TownID town_id) |
38 int32 AITown::GetPopulation(TownID town_id) |
38 { |
39 { |
|
40 if (!this->IsValidTown(town_id)) return 0; |
39 const Town *t = ::GetTown(town_id); |
41 const Town *t = ::GetTown(town_id); |
40 return t->population; |
42 return t->population; |
41 } |
43 } |
42 |
44 |
43 TileIndex AITown::GetLocation(TownID town_id) |
45 TileIndex AITown::GetLocation(TownID town_id) |
44 { |
46 { |
|
47 if (!this->IsValidTown(town_id)) return INVALID_TILE; |
45 const Town *t = ::GetTown(town_id); |
48 const Town *t = ::GetTown(town_id); |
46 return t->xy; |
49 return t->xy; |
47 } |
50 } |