author | rubidium |
Sun, 25 Mar 2007 12:02:13 +0000 | |
branch | noai |
changeset 9520 | f7cf8bea10db |
parent 9497 | f6678533ccba |
child 9524 | 283d23931bb4 |
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 ai_town.hpp Everything to query towns */ |
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 |
#ifndef AI_TOWN_HPP |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
6 |
#define AI_TOWN_HPP |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
7 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
8 |
#include "ai_object.hpp" |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
9 |
|
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
10 |
/** |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
11 |
* Class that handles all town related functions. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
12 |
*/ |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
13 |
class AITown : public AIObject { |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
14 |
public: |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
15 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
16 |
* Gets the maximum town index; there are no valid towns with a higher index. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
17 |
* @return the maximum town index. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
18 |
* @post return value is always non-negative. |
9380
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 |
TownID GetMaxTownID(); |
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 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
23 |
* Gets the number of towns. This is different than GetMaxTownID() |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
24 |
* because of the way OpenTTD works internally. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
25 |
* @return the number of towns. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
26 |
* @post return value is always non-negative. |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
27 |
*/ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
28 |
int32 GetTownCount(); |
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 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
31 |
* Checks whether the given town index is valid. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
32 |
* @param town_id the index to check. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
33 |
* @return true if and only if the town is valid. |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
34 |
*/ |
9497
f6678533ccba
(svn r9369) [NoAI] -Codechange: make some IsValidXXX() function static, so they can be used by the other classes without the need for an instance.
rubidium
parents:
9448
diff
changeset
|
35 |
static bool IsValidTown(TownID town_id); |
9380
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 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
38 |
* Get the name of the town. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
39 |
* @param town_id the town to get the name of. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
40 |
* @pre town_id has to be valid (use IsValidTown()). |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
41 |
* @return the name of the town. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
42 |
* @note the returned name must be free'd (C++ only). |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
43 |
*/ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
44 |
char *GetName(TownID town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
45 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
46 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
47 |
* Gets the number of inhabitants in the town. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
48 |
* @param town_id the town to get the name of. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
49 |
* @pre town_id has to be valid (use IsValidTown()). |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
50 |
* @return the number of inhabitants. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
51 |
* @post return value is always non-negative. |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
52 |
*/ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
53 |
int32 GetPopulation(TownID town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
54 |
|
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
55 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
56 |
* Gets the location of the town. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
57 |
* @param town_id the location of the town. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
58 |
* @pre town_id has to be valid (use IsValidTown()). |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
59 |
* @return the location of the town. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
60 |
* @post return value is always positive and below AIMap::GetMapSize(). |
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
61 |
*/ |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
62 |
TileIndex GetLocation(TownID town_id); |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
63 |
}; |
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
64 |
|
9425
8eec6d10844a
(svn r9227) [NoAI] -Change: renamed SQUIRREL_CLASS to DEFINE_SQUIRREL_CLASS
truelight
parents:
9422
diff
changeset
|
65 |
#ifdef DEFINE_SQUIRREL_CLASS |
9422
33efcc5f1b09
(svn r9223) [NoAI] -Change: moved squirrel/engine.cpp to squirrel.cpp in root
truelight
parents:
9405
diff
changeset
|
66 |
void SQAITownRegister(Squirrel *engine) { |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
9380
diff
changeset
|
67 |
DefSQClass <AITown> SQAITown("AITown"); |
9397
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
68 |
SQAITown.PreRegister(engine); |
9404
ef9e171617a3
(svn r9201) [NoAI] -Change: make adding a default-constructor for DefSQClass optional
truelight
parents:
9397
diff
changeset
|
69 |
SQAITown.AddConstructor(engine); |
9397
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
70 |
SQAITown.DefSQFunction(engine, &AITown::GetMaxTownID, "GetMaxTownID"); |
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
71 |
SQAITown.DefSQFunction(engine, &AITown::GetTownCount, "GetTownCount"); |
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
72 |
SQAITown.DefSQFunction(engine, &AITown::IsValidTown, "IsValidTown"); |
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
73 |
SQAITown.DefSQFunction(engine, &AITown::GetName, "GetName"); |
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
74 |
SQAITown.DefSQFunction(engine, &AITown::GetPopulation, "GetPopulation"); |
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
75 |
SQAITown.DefSQFunction(engine, &AITown::GetLocation, "GetLocation"); |
d8f8db9c1a2e
(svn r9189) [NoAI] -Cleanup: cleaned up DefSQClass a bit by using the SquirrelEngine
truelight
parents:
9387
diff
changeset
|
76 |
SQAITown.PostRegister(engine); |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
9380
diff
changeset
|
77 |
} |
9520
f7cf8bea10db
(svn r9440) [NoAI] -Codechange: use the identifier used for the #ifdef in the #endif not something that looks like the identifier.
rubidium
parents:
9497
diff
changeset
|
78 |
#endif /* DEFINE_SQUIRREL_CLASS */ |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
9380
diff
changeset
|
79 |
|
9380
f4c7eb98b43d
(svn r9169) [NoAI] -Add: some wrapper functions for town related queries.
rubidium
parents:
diff
changeset
|
80 |
#endif /* AI_TOWN_HPP */ |