author | rubidium |
Wed, 14 Mar 2007 11:14:57 +0000 | |
branch | noai |
changeset 9380 | f4c7eb98b43d |
child 9405 | df6f3b4b0038 |
permissions | -rw-r--r-- |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
2 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
3 |
/** @file query.cpp handles the town-related functions of the AITown class */ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
4 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
5 |
#include "../ai_town.hpp" |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
6 |
#include "../../../town.h" |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
7 |
#include "../../../strings.h" |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
8 |
#include "../../../variables.h" /* For SetDParam */ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
9 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
10 |
TownID AITown::GetMaxTownID() |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
11 |
{ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
12 |
return ::GetMaxTownIndex(); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
13 |
} |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
14 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
15 |
int32 AITown::GetTownCount() |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
16 |
{ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
17 |
return ::GetNumTowns(); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
18 |
} |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
19 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
20 |
bool AITown::IsValidTown(TownID town_id) |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
21 |
{ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
22 |
return ::IsValidTownID(town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
23 |
} |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
24 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
25 |
char *AITown::GetName(TownID town_id) |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
26 |
{ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
27 |
static const int len = 64; |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
28 |
char *town_name = MallocT<char>(len); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
29 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
30 |
const Town *t = ::GetTown(town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
31 |
SetDParam(0, t->townnameparts); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
32 |
GetString(town_name, t->townnametype, &town_name[len - 1]); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
33 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
34 |
return town_name; |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
35 |
} |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
36 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
37 |
int32 AITown::GetPopulation(TownID town_id) |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
38 |
{ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
39 |
const Town *t = ::GetTown(town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
40 |
return t->population; |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
41 |
} |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
42 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
43 |
TileIndex AITown::GetLocation(TownID town_id) |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
44 |
{ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
45 |
const Town *t = ::GetTown(town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
46 |
return t->xy; |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
47 |
} |