|
1 /* $Id$ */ |
|
2 |
|
3 /** @file ai_sign.hpp Everything to query and build signs */ |
|
4 |
|
5 #ifndef AI_SIGN_HPP |
|
6 #define AI_SIGN_HPP |
|
7 |
|
8 #include "ai_object.hpp" |
|
9 |
|
10 /** |
|
11 * Class that handles all town related functions. |
|
12 */ |
|
13 class AISign : public AIObject { |
|
14 public: |
|
15 /** |
|
16 * Gets the maximum sign index; there are no valid signs with a higher index. |
|
17 * @return the maximum town index. |
|
18 * @post return value is always non-negative. |
|
19 */ |
|
20 SignID GetMaxSignID(); |
|
21 |
|
22 /** |
|
23 * Gets the number of signs. This is different than GetSignTownID() |
|
24 * because of the way OpenTTD works internally. |
|
25 * @return the number of signs. |
|
26 * @post return value is always non-negative. |
|
27 */ |
|
28 int32 GetSignCount(); |
|
29 |
|
30 /** |
|
31 * Checks whether the given sign index is valid. |
|
32 * @param sign_id the index to check. |
|
33 * @return true if and only if the sign is valid. |
|
34 */ |
|
35 static bool IsValidSign(SignID sign_id); |
|
36 |
|
37 /** |
|
38 * Get the text on the sign. |
|
39 * @param sign_id the sign to get the text of. |
|
40 * @pre sign_id has to be valid (use IsValidSign()). |
|
41 * @return the text on the sign. |
|
42 * @note the returned name must be free'd (C++ only). |
|
43 */ |
|
44 char *GetText(SignID sign_id); |
|
45 |
|
46 /** |
|
47 * Gets the location of the sign. |
|
48 * @param sign_id the sign to get the location of. |
|
49 * @pre sign_id has to be valid (use IsValidSign()). |
|
50 * @return the location of the sign. |
|
51 * @post return value is always positive and below AIMap::GetMapSize(). |
|
52 */ |
|
53 TileIndex GetLocation(SignID sign_id); |
|
54 |
|
55 /** |
|
56 * Removes a sign from the map. |
|
57 * @param sign_id the sign to remove. |
|
58 * @pre sign_id has to be valid (use IsValidSign()). |
|
59 * @return true if and only if the sign has been removed. |
|
60 */ |
|
61 bool RemoveSign(SignID sign_id); |
|
62 |
|
63 /** |
|
64 * Builds a sign on the map. |
|
65 * @param location the place to build the sign. |
|
66 * @param text the text to place on the sign. |
|
67 * @pre location is always positive and below AIMap::GetMapSize() |
|
68 * @pre text is not NULL and non-empty, i.e. length is positive. |
|
69 * @return the SignID of the build sign (use IsValidSign() to check for validity). |
|
70 */ |
|
71 SignID BuildSign(TileIndex location, const char *text); |
|
72 }; |
|
73 |
|
74 #ifdef DEFINE_SQUIRREL_CLASS |
|
75 void SQAISignRegister(Squirrel *engine) { |
|
76 DefSQClass <AISign> SQAISign("AISign"); |
|
77 SQAISign.PreRegister(engine); |
|
78 SQAISign.AddConstructor(engine); |
|
79 SQAISign.DefSQFunction(engine, &AISign::GetMaxSignID, "GetMaxSignID"); |
|
80 SQAISign.DefSQFunction(engine, &AISign::GetSignCount, "GetSignCount"); |
|
81 SQAISign.DefSQFunction(engine, &AISign::IsValidSign, "IsValidSign"); |
|
82 SQAISign.DefSQFunction(engine, &AISign::GetText, "GetText"); |
|
83 SQAISign.DefSQFunction(engine, &AISign::GetLocation, "GetLocation"); |
|
84 SQAISign.DefSQFunction(engine, &AISign::RemoveSign, "RemoveSign"); |
|
85 SQAISign.DefSQFunction(engine, &AISign::BuildSign, "BuildSign"); |
|
86 SQAISign.PostRegister(engine); |
|
87 } |
|
88 #endif /* SQUIRREL_CLASS */ |
|
89 |
|
90 #endif /* AI_SIGN_HPP */ |