equal
deleted
inserted
replaced
|
1 /* $Id$ */ |
|
2 |
|
3 /** @file ai_town.cpp handles the town-related functions of the AITown class */ |
|
4 |
|
5 #include "ai_town.hpp" |
|
6 #include "../../town.h" |
|
7 #include "../../strings.h" |
|
8 #include "../../variables.h" /* For SetDParam */ |
|
9 #include "table/strings.h" |
|
10 |
|
11 TownID AITown::GetMaxTownID() |
|
12 { |
|
13 return ::GetMaxTownIndex(); |
|
14 } |
|
15 |
|
16 int32 AITown::GetTownCount() |
|
17 { |
|
18 return ::GetNumTowns(); |
|
19 } |
|
20 |
|
21 bool AITown::IsValidTown(TownID town_id) |
|
22 { |
|
23 return ::IsValidTownID(town_id); |
|
24 } |
|
25 |
|
26 char *AITown::GetName(TownID town_id) |
|
27 { |
|
28 static const int len = 64; |
|
29 char *town_name = MallocT<char>(len); |
|
30 |
|
31 SetDParam(0, town_id); |
|
32 GetString(town_name, STR_TOWN, &town_name[len - 1]); |
|
33 |
|
34 return town_name; |
|
35 } |
|
36 |
|
37 int32 AITown::GetPopulation(TownID town_id) |
|
38 { |
|
39 const Town *t = ::GetTown(town_id); |
|
40 return t->population; |
|
41 } |
|
42 |
|
43 TileIndex AITown::GetLocation(TownID town_id) |
|
44 { |
|
45 const Town *t = ::GetTown(town_id); |
|
46 return t->xy; |
|
47 } |