| author | truebrain |
| Mon, 30 Jun 2008 12:15:10 +0000 | |
| branch | noai |
| changeset 11097 | 6967c52c78c5 |
| parent 10952 | d16212cc2394 |
| 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" |
|
10847
6c003b73a276
(svn r13398) [NoAI] -Add: added AISign::GetOwner (on request by Finaldeath)
truebrain
parents:
10776
diff
changeset
|
10 |
#include "ai_company.hpp" |
| 9511 | 11 |
|
12 |
/** |
|
|
9513
258f78c74b0c
(svn r9410) [NoAI] -Fix: some copy-paste mistakes...
rubidium
parents:
9511
diff
changeset
|
13 |
* Class that handles all sign related functions. |
| 9511 | 14 |
*/ |
15 |
class AISign : public AIObject {
|
|
16 |
public: |
|
|
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
17 |
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
|
18 |
|
|
10096
780921b39016
(svn r12627) [NoAI] -Fix: last few commits missed some comments around enums
truebrain
parents:
10090
diff
changeset
|
19 |
/** |
|
780921b39016
(svn r12627) [NoAI] -Fix: last few commits missed some comments around enums
truebrain
parents:
10090
diff
changeset
|
20 |
* All sign related error messages. |
|
780921b39016
(svn r12627) [NoAI] -Fix: last few commits missed some comments around enums
truebrain
parents:
10090
diff
changeset
|
21 |
*/ |
|
10090
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
22 |
enum ErrorMessages {
|
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
23 |
|
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
24 |
/** Base for sign building related errors */ |
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
25 |
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
|
26 |
|
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
27 |
/** Too many signs have been placed */ |
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
28 |
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
|
29 |
}; |
|
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
30 |
|
|
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
31 |
/** |
| 9511 | 32 |
* 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
|
33 |
* @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
|
34 |
* @post Return value is always non-negative. |
| 9511 | 35 |
*/ |
|
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
|
36 |
static SignID GetMaxSignID(); |
| 9511 | 37 |
|
38 |
/** |
|
39 |
* 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
|
40 |
* @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
|
41 |
* @return True if and only if the sign is valid. |
| 9511 | 42 |
*/ |
43 |
static bool IsValidSign(SignID sign_id); |
|
44 |
||
45 |
/** |
|
46 |
* 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
|
47 |
* @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
|
48 |
* @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
|
49 |
* @return The text on the sign. |
| 9511 | 50 |
*/ |
|
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
|
51 |
static char *GetText(SignID sign_id); |
| 9511 | 52 |
|
53 |
/** |
|
54 |
* 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
|
55 |
* @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
|
56 |
* @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
|
57 |
* @return The location of the sign. |
| 9511 | 58 |
*/ |
|
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
|
59 |
static TileIndex GetLocation(SignID sign_id); |
| 9511 | 60 |
|
61 |
/** |
|
62 |
* 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
|
63 |
* @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
|
64 |
* @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
|
65 |
* @pre AIMap::IsValidTile(location). |
|
10090
d6a6cac2fb25
(svn r12614) [NoAI] -Add: support for GetLastError in AISign. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
66 |
* @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
|
67 |
* @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
|
68 |
* @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
|
69 |
* 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
|
70 |
* failure. |
| 9511 | 71 |
*/ |
|
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
|
72 |
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
|
73 |
|
|
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
74 |
/** |
|
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
75 |
* 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
|
76 |
* @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
|
77 |
* @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
|
78 |
* @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
|
79 |
*/ |
|
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9801
diff
changeset
|
80 |
static bool RemoveSign(SignID sign_id); |
| 9511 | 81 |
}; |
82 |
||
83 |
#endif /* AI_SIGN_HPP */ |