Mercurial > hg > openttd
annotate src/tile_map.h @ 10208:39cf8eebfda5 draft
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Tue, 30 Sep 2008 20:51:04 +0000 |
parents | c54d140df948 |
children | 7881d9cd55ab |
rev | line source |
---|---|
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
3 /** @file tile_map.h Map writing/reading functions for tiles. */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
4 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
5 #ifndef TILE_MAP_H |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
6 #define TILE_MAP_H |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
7 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
8 #include "tile_type.h" |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
9 #include "slope_type.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
10 #include "company_type.h" |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
8113
diff
changeset
|
11 #include "map_func.h" |
8113
c35412099303
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium <rubidium@openttd.org>
parents:
8108
diff
changeset
|
12 #include "core/bitmath_func.hpp" |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 * Returns the height of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
16 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
17 * This function returns the height of the northern corner of a tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
18 * This is saved in the global map-array. It does not take affect by |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
19 * any slope-data of the tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
20 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 * @param tile The tile to get the height from |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
22 * @return the height of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
23 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
24 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
25 static inline uint TileHeight(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
26 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
27 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
28 return GB(_m[tile].type_height, 0, 4); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
29 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
30 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
31 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
32 * Sets the height of a tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
33 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
34 * This function sets the height of the northern corner of a tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
35 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
36 * @param tile The tile to change the height |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
37 * @param height The new height value of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
38 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
39 * @pre heigth <= MAX_TILE_HEIGHT |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
40 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
41 static inline void SetTileHeight(TileIndex tile, uint height) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
42 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
43 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
44 assert(height <= MAX_TILE_HEIGHT); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
45 SB(_m[tile].type_height, 0, 4, height); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
46 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
47 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
48 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
49 * Returns the height of a tile in pixels. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
50 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
51 * This function returns the height of the northern corner of a tile in pixels. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
52 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
53 * @param tile The tile to get the height |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
54 * @return The height of the tile in pixel |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
55 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
56 static inline uint TilePixelHeight(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
57 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
58 return TileHeight(tile) * TILE_HEIGHT; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
59 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
60 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
61 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
62 * Get the tiletype of a given tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
63 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
64 * @param tile The tile to get the TileType |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
65 * @return The tiletype of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
66 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
67 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
68 static inline TileType GetTileType(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
69 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
70 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
71 return (TileType)GB(_m[tile].type_height, 4, 4); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
72 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
73 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
74 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
75 * Set the type of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
76 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
77 * This functions sets the type of a tile. If the type |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
78 * MP_VOID is selected the tile must be at the south-west or |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
79 * south-east edges of the map and vice versa. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
80 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
81 * @param tile The tile to save the new type |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
82 * @param type The type to save |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
83 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
84 * @pre type MP_VOID <=> tile is on the south-east or south-west edge. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
85 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
86 static inline void SetTileType(TileIndex tile, TileType type) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
87 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
88 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
89 /* VOID tiles (and no others) are exactly allowed at the lower left and right |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
90 * edges of the map */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
91 assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
92 SB(_m[tile].type_height, 4, 4, type); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
93 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
94 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
96 * Checks if a tile is a give tiletype. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
97 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
98 * This function checks if a tile got the given tiletype. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
99 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
100 * @param tile The tile to check |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
101 * @param type The type to check agains |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
102 * @return true If the type matches agains the type of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
103 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
104 static inline bool IsTileType(TileIndex tile, TileType type) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
105 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
106 return GetTileType(tile) == type; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
107 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
108 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
109 /** |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
110 * Checks if a tile is valid |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
111 * |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
112 * @param tile The tile to check |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
113 * @return True if the tile is on the map and not one of MP_VOID. |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
114 */ |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
115 static inline bool IsValidTile(TileIndex tile) |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
116 { |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
117 return tile < MapSize() && !IsTileType(tile, MP_VOID); |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
118 } |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
119 |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
120 /** |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 * Returns the owner of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
123 * This function returns the owner of a tile. This cannot used |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
124 * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
8651
diff
changeset
|
125 * as no company owned any of these buildings. |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 * @param tile The tile to check |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 * @return The owner of the tile |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
129 * @pre IsValidTile(tile) |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
130 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 static inline Owner GetTileOwner(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 { |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
134 assert(IsValidTile(tile)); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 assert(!IsTileType(tile, MP_HOUSE)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
136 assert(!IsTileType(tile, MP_INDUSTRY)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
137 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 return (Owner)_m[tile].m1; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
141 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 * Sets the owner of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
143 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 * This function sets the owner status of a tile. Note that you cannot |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 * @param tile The tile to change the owner status. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
148 * @param owner The new owner. |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
149 * @pre IsValidTile(tile) |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
150 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
151 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 static inline void SetTileOwner(TileIndex tile, Owner owner) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
153 { |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
154 assert(IsValidTile(tile)); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
155 assert(!IsTileType(tile, MP_HOUSE)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
156 assert(!IsTileType(tile, MP_INDUSTRY)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 _m[tile].m1 = owner; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
162 * Checks if a tile belongs to the given owner |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 * @param tile The tile to check |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
165 * @param owner The owner to check agains |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
166 * @return True if a tile belongs the the given owner |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
168 static inline bool IsTileOwner(TileIndex tile, Owner owner) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
170 return GetTileOwner(tile) == owner; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
171 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
172 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
173 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
174 * Set the tropic zone |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
175 * @param tile the tile to set the zone of |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
176 * @param type the new type |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
177 * @pre tile < MapSize() |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 static inline void SetTropicZone(TileIndex tile, TropicZone type) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
180 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
182 SB(_m[tile].m6, 0, 2, type); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
183 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
184 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
185 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 * Get the tropic zone |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
187 * @param tile the tile to get the zone of |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
188 * @pre tile < MapSize() |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
189 * @return the zone type |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
190 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
191 static inline TropicZone GetTropicZone(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
192 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
193 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
194 return (TropicZone)GB(_m[tile].m6, 0, 2); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
195 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
196 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 Slope GetTileSlope(TileIndex tile, uint *h); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
198 uint GetTileZ(TileIndex tile); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
199 uint GetTileMaxZ(TileIndex tile); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
200 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
201 #endif /* TILE_TYPE_H */ |