author | rubidium |
Mon, 07 Apr 2008 18:41:49 +0000 | |
branch | noai |
changeset 10090 | d6a6cac2fb25 |
parent 9838 | 0839682a601b |
child 10096 | 780921b39016 |
permissions | -rw-r--r-- |
9511 | 1 |
/* $Id$ */ |
2 |
||
9829
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
3 |
/** @file ai_sign.hpp Everything to query and build signs. */ |
9511 | 4 |
|
5 |
#ifndef AI_SIGN_HPP |
|
6 |
#define AI_SIGN_HPP |
|
7 |
||
8 |
#include "ai_object.hpp" |
|
10090
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
9 |
#include "ai_error.hpp" |
9511 | 10 |
|
11 |
/** |
|
9513
258f78c74b0c
(svn r9410) [NoAI] -Fix: some copy-paste mistakes...
rubidium
parents:
9511
diff
changeset
|
12 |
* Class that handles all sign related functions. |
9511 | 13 |
*/ |
14 |
class AISign : public AIObject { |
|
15 |
public: |
|
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
16 |
static const char *GetClassName() { return "AISign"; } |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
17 |
|
10090
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
18 |
enum ErrorMessages { |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
19 |
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
20 |
/** Base for sign building related errors */ |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
21 |
ERR_SIGN_BASE = AIError::ERR_CAT_SIGN << AIError::ERR_CAT_BIT_SIZE, |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
22 |
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
23 |
/** Too many signs have been placed */ |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
24 |
ERR_SIGN_TOO_MANY_SIGNS, // [STR_2808_TOO_MANY_SIGNS] |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
25 |
}; |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
26 |
|
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
27 |
/** |
9511 | 28 |
* Gets the maximum sign index; there are no valid signs with a higher index. |
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
29 |
* @return The maximum sign index. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
30 |
* @post Return value is always non-negative. |
9511 | 31 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9596
diff
changeset
|
32 |
static SignID GetMaxSignID(); |
9511 | 33 |
|
34 |
/** |
|
9513
258f78c74b0c
(svn r9410) [NoAI] -Fix: some copy-paste mistakes...
rubidium
parents:
9511
diff
changeset
|
35 |
* Gets the number of signs. This is different than GetMaxSignID() |
9511 | 36 |
* because of the way OpenTTD works internally. |
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
37 |
* @return The number of signs. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
38 |
* @post Return value is always non-negative. |
9511 | 39 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9596
diff
changeset
|
40 |
static int32 GetSignCount(); |
9511 | 41 |
|
42 |
/** |
|
43 |
* Checks whether the given sign index is valid. |
|
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
44 |
* @param sign_id The index to check. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
45 |
* @return True if and only if the sign is valid. |
9511 | 46 |
*/ |
47 |
static bool IsValidSign(SignID sign_id); |
|
48 |
||
49 |
/** |
|
50 |
* Get the text on the sign. |
|
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
51 |
* @param sign_id The sign to get the text of. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
52 |
* @pre IsValidSign(sign_id). |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
53 |
* @return The text on the sign. |
9511 | 54 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9596
diff
changeset
|
55 |
static char *GetText(SignID sign_id); |
9511 | 56 |
|
57 |
/** |
|
58 |
* Gets the location of the sign. |
|
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
59 |
* @param sign_id The sign to get the location of. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
60 |
* @pre IsValidSign(sign_id). |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
61 |
* @return The location of the sign. |
9511 | 62 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9596
diff
changeset
|
63 |
static TileIndex GetLocation(SignID sign_id); |
9511 | 64 |
|
65 |
/** |
|
66 |
* Builds a sign on the map. |
|
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
67 |
* @param location The place to build the sign. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
68 |
* @param text The text to place on the sign. |
9801
03a3eebd7fb7
(svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents:
9737
diff
changeset
|
69 |
* @pre AIMap::IsValidTile(location). |
10090
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
70 |
* @pre text is of non-zero length. |
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
71 |
* @exception ERR_SIGN_TOO_MANY_SIGNS |
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
72 |
* @return The SignID of the build sign (use IsValidSign() to check for validity). |
9562
2f4087d63527
(svn r9500) [NoAI] -Add: document behavoir in test-mode
truelight
parents:
9541
diff
changeset
|
73 |
* In test-mode it returns 0 if successful, or any other value to indicate |
2f4087d63527
(svn r9500) [NoAI] -Add: document behavoir in test-mode
truelight
parents:
9541
diff
changeset
|
74 |
* failure. |
9511 | 75 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9596
diff
changeset
|
76 |
static SignID BuildSign(TileIndex location, const char *text); |
9829
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
77 |
|
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
78 |
/** |
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
79 |
* Removes a sign from the map. |
9838
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
80 |
* @param sign_id The sign to remove. |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
81 |
* @pre IsValidSign(sign_id). |
0839682a601b
(svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents:
9829
diff
changeset
|
82 |
* @return True if and only if the sign has been removed. |
9829
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
83 |
*/ |
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
84 |
static bool RemoveSign(SignID sign_id); |
9511 | 85 |
}; |
86 |
||
87 |
#endif /* AI_SIGN_HPP */ |