~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/ai/api/ai_tile.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman
  • Date: 2009-06-09 21:46:28 UTC
  • mfrom: (1.1.7 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090609214628-6z5uodi6178z050l
[ Matthijs Kooijman ]
* New upstream release.
* Link against libicu to enable right-to-left language support. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: ai_tile.hpp 15190 2009-01-21 02:31:55Z Yexo $ */
 
1
/* $Id: ai_tile.hpp 16531 2009-06-07 15:26:33Z rubidium $ */
2
2
 
3
3
/** @file ai_tile.hpp Everything to query and manipulate tiles. */
4
4
 
29
29
 
30
30
                /** Tile can't be lowered any lower */
31
31
                ERR_TILE_TOO_LOW,                      // [STR_1003_ALREADY_AT_SEA_LEVEL]
32
 
        };
33
 
 
34
 
        /**
35
 
         * Enumeration for the slope-type (from slopes.h).
 
32
 
 
33
                /** The area was already flat */
 
34
                ERR_AREA_ALREADY_FLAT,                 // [STR_ALREADY_LEVELLED]
 
35
 
 
36
                /** There is a tunnel underneed */
 
37
                ERR_EXCAVATION_WOULD_DAMAGE,           // [STR_1002_EXCAVATION_WOULD_DAMAGE]
 
38
        };
 
39
 
 
40
        /**
 
41
         * Enumeration for corners of tiles.
 
42
         */
 
43
        enum Corner {
 
44
                CORNER_W       = 0,      //!< West corner
 
45
                CORNER_S       = 1,      //!< South corner
 
46
                CORNER_E       = 2,      //!< East corner
 
47
                CORNER_N       = 3,      //!< North corner
 
48
 
 
49
                CORNER_INVALID = 0xFF,
 
50
        };
 
51
 
 
52
        /**
 
53
         * Enumeration for the slope-type.
36
54
         *
37
55
         * This enumeration use the chars N, E, S, W corresponding the
38
56
         *  direction North, East, South and West. The top corner of a tile
41
59
        enum Slope {
42
60
                /* Values are important, as they represent the internal state of the game. */
43
61
                SLOPE_FLAT     = 0x00,                                  //!< A flat tile
44
 
                SLOPE_W        = 0x01,                                  //!< The west corner of the tile is raised
45
 
                SLOPE_S        = 0x02,                                  //!< The south corner of the tile is raised
46
 
                SLOPE_E        = 0x04,                                  //!< The east corner of the tile is raised
47
 
                SLOPE_N        = 0x08,                                  //!< The north corner of the tile is raised
48
 
                SLOPE_STEEP    = 0x10,                                  //!< Indicates the slope is steep
 
62
                SLOPE_W        = 1 << CORNER_W,                         //!< The west corner of the tile is raised
 
63
                SLOPE_S        = 1 << CORNER_S,                         //!< The south corner of the tile is raised
 
64
                SLOPE_E        = 1 << CORNER_E,                         //!< The east corner of the tile is raised
 
65
                SLOPE_N        = 1 << CORNER_N,                         //!< The north corner of the tile is raised
 
66
                SLOPE_STEEP    = 0x10,                                  //!< Indicates the slope is steep (The corner opposite of the not-raised corner is raised two times)
49
67
                SLOPE_NW       = SLOPE_N | SLOPE_W,                     //!< North and west corner are raised
50
68
                SLOPE_SW       = SLOPE_S | SLOPE_W,                     //!< South and west corner are raised
51
69
                SLOPE_SE       = SLOPE_S | SLOPE_E,                     //!< South and east corner are raised
52
70
                SLOPE_NE       = SLOPE_N | SLOPE_E,                     //!< North and east corner are raised
53
71
                SLOPE_EW       = SLOPE_E | SLOPE_W,                     //!< East and west corner are raised
54
72
                SLOPE_NS       = SLOPE_N | SLOPE_S,                     //!< North and south corner are raised
55
 
                SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, //!< All corner are raised, similar to SLOPE_FLAT
 
73
                SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, //!< Bit mask containing all 'simple' slopes. Does not appear as a slope.
56
74
                SLOPE_NWS      = SLOPE_N | SLOPE_W | SLOPE_S,           //!< North, west and south corner are raised
57
75
                SLOPE_WSE      = SLOPE_W | SLOPE_S | SLOPE_E,           //!< West, south and east corner are raised
58
76
                SLOPE_SEN      = SLOPE_S | SLOPE_E | SLOPE_N,           //!< South, east and north corner are raised
62
80
                SLOPE_STEEP_E  = SLOPE_STEEP | SLOPE_SEN,               //!< A steep slope falling to west (from east)
63
81
                SLOPE_STEEP_N  = SLOPE_STEEP | SLOPE_ENW,               //!< A steep slope falling to south (from north)
64
82
 
65
 
                SLOPE_INVALID  = 0xFF,                                  //!< An invalid slope
 
83
                SLOPE_INVALID  = 0xFFFF,                                //!< An invalid slope
66
84
        };
67
85
 
68
86
        /**
129
147
 
130
148
        /**
131
149
         * Check if a tile has a steep slope.
 
150
         * Steep slopes are slopes with a height difference of 2 across one diagonal of the tile.
132
151
         * @param slope The slope to check on.
133
152
         * @pre slope != SLOPE_INVALID.
134
153
         * @return True if the slope is a steep slope.
137
156
 
138
157
        /**
139
158
         * Check if a tile has a halftile slope.
 
159
         * Halftile slopes appear on top of halftile foundations. E.g. the slope you get when building a horizontal railtrack on the top of a SLOPE_N or SLOPE_STEEP_N.
140
160
         * @param slope The slope to check on.
141
161
         * @pre slope != SLOPE_INVALID.
142
162
         * @return True if the slope is a halftile slope.
 
163
         * @note Currently there is no API function that would return or accept a halftile slope.
143
164
         */
144
165
        static bool IsHalftileSlope(Slope slope);
145
166
 
193
214
 
194
215
        /**
195
216
         * Get the slope of a tile.
 
217
         * This is the slope of the bare tile. A possible foundation on the tile does not influence this slope.
196
218
         * @param tile The tile to check on.
197
219
         * @pre AIMap::IsValidTile(tile).
198
 
         * @return 0 means flat, others indicate internal state of slope.
 
220
         * @return Bit mask encoding the slope. See #Slope for a description of the returned values.
199
221
         */
200
222
        static Slope GetSlope(TileIndex tile);
201
223
 
211
233
        static Slope GetComplementSlope(Slope slope);
212
234
 
213
235
        /**
214
 
         * Get the height of the tile.
 
236
         * Get the height of the north corner of a tile.
 
237
         * The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
 
238
         * @deprecated This function is deprecated and might be removed in future versions of the API. Use GetMinHeight(), GetMaxHeight() or GetCornerHeight() instead.
215
239
         * @param tile The tile to check on.
216
240
         * @pre AIMap::IsValidTile(tile).
217
 
         * @return The height of the tile, ranging from 0 to 15.
 
241
         * @return The height of the north corner of the tile, ranging from 0 to 15.
218
242
         */
219
243
        static int32 GetHeight(TileIndex tile);
220
244
 
221
245
        /**
 
246
         * Get the minimal height on a tile.
 
247
         * The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
 
248
         * @param tile The tile to check on.
 
249
         * @pre AIMap::IsValidTile(tile).
 
250
         * @return The height of the lowest corner of the tile, ranging from 0 to 15.
 
251
         */
 
252
        static int32 GetMinHeight(TileIndex tile);
 
253
 
 
254
        /**
 
255
         * Get the maximal height on a tile.
 
256
         * The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
 
257
         * @param tile The tile to check on.
 
258
         * @pre AIMap::IsValidTile(tile).
 
259
         * @return The height of the highest corner of the tile, ranging from 0 to 15.
 
260
         */
 
261
        static int32 GetMaxHeight(TileIndex tile);
 
262
 
 
263
        /**
 
264
         * Get the height of a certain corner of a tile.
 
265
         * The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
 
266
         * @param tile The tile to check on.
 
267
         * @param corner The corner to query.
 
268
         * @pre AIMap::IsValidTile(tile).
 
269
         * @return The height of the lowest corner of the tile, ranging from 0 to 15.
 
270
         */
 
271
        static int32 GetCornerHeight(TileIndex tile, Corner corner);
 
272
 
 
273
        /**
222
274
         * Get the owner of the tile.
223
275
         * @param tile The tile to get the owner from.
224
276
         * @pre AIMap::IsValidTile(tile).
251
303
         * @param height The height of the station.
252
304
         * @param radius The radius of the station.
253
305
         * @pre AIMap::IsValidTile(tile).
 
306
         * @pre width > 0.
 
307
         * @pre height > 0.
 
308
         * @pre radius > 0.
254
309
         * @return Value below 8 means no acceptance; the more the better.
255
310
         */
256
 
        static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
 
311
        static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
257
312
 
258
313
        /**
259
314
         * Checks how many tiles in the radius produces this cargo.
265
320
         * @param height The height of the station.
266
321
         * @param radius The radius of the station.
267
322
         * @pre AIMap::IsValidTile(tile).
 
323
         * @pre width > 0.
 
324
         * @pre height > 0.
 
325
         * @pre radius > 0.
268
326
         * @return The tiles that produce this cargo within radius of the tile.
269
327
         * @note Town(houses) are not included in the value.
270
328
         */
271
 
        static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
 
329
        static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
272
330
 
273
331
        /**
274
332
         * Get the manhattan distance from the tile to the tile.
288
346
 
289
347
        /**
290
348
         * Raise the given corners of the tile. The corners can be combined,
291
 
         *  for example: SLOPE_N | SLOPE_W (= SLOPE_NW)
 
349
         *  for example: SLOPE_N | SLOPE_W (= SLOPE_NW) will raise the west and the north corner.
 
350
         * @note The corners will be modified in the order west (first), south, east, north (last).
 
351
         *       Changing one corner might cause another corner to be changed too. So modifiing
 
352
         *       multiple corners may result in changing some corners by multiple steps.
292
353
         * @param tile The tile to raise.
293
354
         * @param slope Corners to raise (SLOPE_xxx).
294
355
         * @pre tile < AIMap::GetMapSize().
301
362
 
302
363
        /**
303
364
         * Lower the given corners of the tile. The corners can be combined,
304
 
         *  for example: SLOPE_N | SLOPE_W (= SLOPE_NW)
 
365
         *  for example: SLOPE_N | SLOPE_W (= SLOPE_NW) will lower the west and the north corner.
 
366
         * @note The corners will be modified in the order west (first), south, east, north (last).
 
367
         *       Changing one corner might cause another corner to be changed too. So modifiing
 
368
         *       multiple corners may result in changing some corners by multiple steps.
305
369
         * @param tile The tile to lower.
306
370
         * @param slope Corners to lower (SLOPE_xxx).
307
371
         * @pre tile < AIMap::GetMapSize().