4 |
4 |
5 #ifndef AI_TILE_HPP |
5 #ifndef AI_TILE_HPP |
6 #define AI_TILE_HPP |
6 #define AI_TILE_HPP |
7 |
7 |
8 #include "ai_abstractlist.hpp" |
8 #include "ai_abstractlist.hpp" |
|
9 #include "ai_error.hpp" |
9 |
10 |
10 /** |
11 /** |
11 * Class that handles all tile related functions. |
12 * Class that handles all tile related functions. |
12 */ |
13 */ |
13 class AITile : public AIObject { |
14 class AITile : public AIObject { |
14 public: |
15 public: |
15 static const char *GetClassName() { return "AITile"; } |
16 static const char *GetClassName() { return "AITile"; } |
|
17 |
|
18 /** |
|
19 * Error messages related to modifying tiles. |
|
20 */ |
|
21 enum ErrorMessages { |
|
22 |
|
23 /** Base for tile related errors */ |
|
24 ERR_TILE_BASE = AIError::ERR_CAT_TILE << AIError::ERR_CAT_BIT_SIZE, |
|
25 |
|
26 /** Tile can't be raised any higher */ |
|
27 ERR_TILE_TOO_HIGH, //< [STR_1003_ALREADY_AT_SEA_LEVEL] |
|
28 |
|
29 /** Tile can't be lowered any lower */ |
|
30 ERR_TILE_TOO_LOW, //< [STR_1003_ALREADY_AT_SEA_LEVEL] |
|
31 |
|
32 /** Tile can't be raised or lowered because it is to close to the map */ |
|
33 ERR_TILE_TOO_CLOSE_TO_EDGE, //< [STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP] |
|
34 }; |
16 |
35 |
17 /** |
36 /** |
18 * Enumeration for the slope-type (from slopes.h). |
37 * Enumeration for the slope-type (from slopes.h). |
19 * |
38 * |
20 * This enumeration use the chars N, E, S, W corresponding the |
39 * This enumeration use the chars N, E, S, W corresponding the |
140 * Raise the given corners of the tile. The corners can be combined, |
159 * Raise the given corners of the tile. The corners can be combined, |
141 * for example: SLOPE_N | SLOPE_W (= SLOPE_NW) |
160 * for example: SLOPE_N | SLOPE_W (= SLOPE_NW) |
142 * @param tile The tile to raise. |
161 * @param tile The tile to raise. |
143 * @param slope Corners to raise (SLOPE_xxx). |
162 * @param slope Corners to raise (SLOPE_xxx). |
144 * @pre AIMap::IsValidTile(tile). |
163 * @pre AIMap::IsValidTile(tile). |
|
164 * @exception AIERROR::ERR_AREA_NOT_CLEAR |
|
165 * @exception AITILE::ERR_TILE_TOO_HIGH |
|
166 * @exception AITILE::ERR_TILE_CLOSE_TO_EDGE |
145 * @return 0 means failed, 1 means success. |
167 * @return 0 means failed, 1 means success. |
146 */ |
168 */ |
147 static bool RaiseTile(TileIndex tile, int32 slope); |
169 static bool RaiseTile(TileIndex tile, int32 slope); |
148 |
170 |
149 /** |
171 /** |
150 * Lower the given corners of the tile. The corners can be combined, |
172 * Lower the given corners of the tile. The corners can be combined, |
151 * for example: SLOPE_N | SLOPE_W (= SLOPE_NW) |
173 * for example: SLOPE_N | SLOPE_W (= SLOPE_NW) |
152 * @param tile The tile to lower. |
174 * @param tile The tile to lower. |
153 * @param slope Corners to lower (SLOPE_xxx). |
175 * @param slope Corners to lower (SLOPE_xxx). |
154 * @pre AIMap::IsValidTile(tile). |
176 * @pre AIMap::IsValidTile(tile). |
|
177 * @exception AIERROR::ERR_AREA_NOT_CLEAR |
|
178 * @exception AITILE::ERR_TILE_TOO_LOW |
|
179 * @exception AITILE::ERR_TILE_CLOSE_TO_EDGE |
155 * @return 0 means failed, 1 means success. |
180 * @return 0 means failed, 1 means success. |
156 */ |
181 */ |
157 static bool LowerTile(TileIndex tile, int32 slope); |
182 static bool LowerTile(TileIndex tile, int32 slope); |
158 |
183 |
159 /** |
184 /** |
160 * Destroy everything on the given tile. |
185 * Destroy everything on the given tile. |
161 * @param tile The tile to demolish. |
186 * @param tile The tile to demolish. |
162 * @pre AIMap::IsValidTile(tile). |
187 * @pre AIMap::IsValidTile(tile). |
|
188 * @exception AIERROR::ERR_AREA_NOT_CLEAR |
163 * @return True if and only if the tile was demolished. |
189 * @return True if and only if the tile was demolished. |
164 */ |
190 */ |
165 static bool DemolishTile(TileIndex tile); |
191 static bool DemolishTile(TileIndex tile); |
166 }; |
192 }; |
167 |
193 |