Mercurial > hg > openttd
annotate src/map_func.h @ 9745:26478249b3d0 draft
(svn r13880) -Codechange: Replace numbers with Colours enum on intro gui, and align a bit the code
author | belugas <belugas@openttd.org> |
---|---|
date | Wed, 30 Jul 2008 16:23:55 +0000 |
parents | b8910fe673fc |
children | 64dc1fb9eb38 |
rev | line source |
---|---|
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
8391
diff
changeset
|
3 /** @file map_func.h Functions related to maps. */ |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
4 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
5 #ifndef MAP_FUNC_H |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
6 #define MAP_FUNC_H |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
7 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
8 #include "tile_type.h" |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
9 #include "map_type.h" |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 #include "direction_func.h" |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 extern uint _map_tile_mask; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 * 'Wraps' the given tile to it is within the map. It does |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
16 * this by masking the 'high' bits of. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
17 * @param x the tile to 'wrap' |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
18 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
19 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
20 #define TILE_MASK(x) ((x) & _map_tile_mask) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
22 * Asserts when the tile is outside of the map. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
23 * @param x the tile to check |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
24 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
25 #define TILE_ASSERT(x) assert(TILE_MASK(x) == (x)); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
26 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
27 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
28 * Pointer to the tile-array. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
29 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
30 * This variable points to the tile-array which contains the tiles of |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
31 * the map. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
32 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
33 extern Tile *_m; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
34 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
35 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
36 * Pointer to the extended tile-array. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
37 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
38 * This variable points to the extended tile-array which contains the tiles |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
39 * of the map. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
40 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
41 extern TileExtended *_me; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
42 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
43 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
44 * Allocate a new map with the given size. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
45 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
46 void AllocateMap(uint size_x, uint size_y); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
47 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
48 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
49 * Logarithm of the map size along the X side. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
50 * @note try to avoid using this one |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
51 * @return 2^"return value" == MapSizeX() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
52 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
53 static inline uint MapLogX() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
54 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
55 extern uint _map_log_x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
56 return _map_log_x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
57 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
58 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
59 /** |
8391
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
60 * Logarithm of the map size along the y side. |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
61 * @note try to avoid using this one |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
62 * @return 2^"return value" == MapSizeY() |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
63 */ |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
64 static inline uint MapLogY() |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
65 { |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
66 extern uint _map_log_y; |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
67 return _map_log_y; |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
68 } |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
69 |
443c5f4c083f
(svn r11961) -Feature[newGRF]: Add support for Action 0D, var 13: informations about current map size.
belugas <belugas@openttd.org>
parents:
8380
diff
changeset
|
70 /** |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
71 * Get the size of the map along the X |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
72 * @return the number of tiles along the X of the map |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
73 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
74 static inline uint MapSizeX() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
75 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
76 extern uint _map_size_x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
77 return _map_size_x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
78 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
79 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
80 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
81 * Get the size of the map along the Y |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
82 * @return the number of tiles along the Y of the map |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
83 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
84 static inline uint MapSizeY() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
85 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
86 extern uint _map_size_y; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
87 return _map_size_y; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
88 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
89 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
90 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
91 * Get the size of the map |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
92 * @return the number of tiles of the map |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
93 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
94 static inline uint MapSize() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
96 extern uint _map_size; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
97 return _map_size; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
98 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
99 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
100 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
101 * Gets the maximum X coordinate within the map, including MP_VOID |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
102 * @return the maximum X coordinate |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
103 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
104 static inline uint MapMaxX() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
105 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
106 return MapSizeX() - 1; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
107 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
108 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
109 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
110 * Gets the maximum X coordinate within the map, including MP_VOID |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
111 * @return the maximum X coordinate |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
112 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
113 static inline uint MapMaxY() |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
114 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
115 return MapSizeY() - 1; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
116 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
117 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
118 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
119 * Scales relative to the number of tiles. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 uint ScaleByMapSize(uint); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
123 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
124 * Scale relative to the circumference of the map. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
125 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 uint ScaleByMapSize1D(uint); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 * An offset value between to tiles. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 * This value is used fro the difference between |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 * to tiles. It can be added to a tileindex to get |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 * the resulting tileindex of the start tile applied |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 * with this saved difference. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
136 * @see TileDiffXY(int, int) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
137 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 typedef int32 TileIndexDiff; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
141 * Returns the TileIndex of a coordinate. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
143 * @param x The x coordinate of the tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 * @param y The y coordinate of the tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 * @return The TileIndex calculated by the coordinate |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 static inline TileIndex TileXY(uint x, uint y) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
148 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
149 return (y * MapSizeX()) + x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
150 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
151 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
153 * Calculates an offset for the given coordinate(-offset). |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
154 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
155 * This function calculate an offset value which can be added to an |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
156 * #TileIndex. The coordinates can be negative. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 * @param x The offset in x direction |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 * @param y The offset in y direction |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 * @return The resulting offset value of the given coordinate |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 * @see ToTileIndexDiff(TileIndexDiffC) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
162 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 static inline TileIndexDiff TileDiffXY(int x, int y) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
165 /* Multiplication gives much better optimization on MSVC than shifting. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
166 * 0 << shift isn't optimized to 0 properly. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 * Typically x and y are constants, and then this doesn't result |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
168 * in any actual multiplication in the assembly code.. */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 return (y * MapSizeX()) + x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
170 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
171 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
172 static inline TileIndex TileVirtXY(uint x, uint y) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
173 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
174 return (y >> 4 << MapLogX()) + (x >> 4); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
175 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
176 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 * Get the X component of a tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
180 * @param tile the tile to get the X component of |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 * @return the X component |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
182 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
183 static inline uint TileX(TileIndex tile) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
184 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
185 return tile & MapMaxX(); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
187 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
188 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
189 * Get the Y component of a tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
190 * @param tile the tile to get the Y component of |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
191 * @return the Y component |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
192 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
193 static inline uint TileY(TileIndex tile) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
194 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
195 return tile >> MapLogX(); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
196 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
198 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
199 * Return the offset between to tiles from a TileIndexDiffC struct. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
200 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
201 * This function works like #TileDiffXY(int, int) and returns the |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
202 * difference between two tiles. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
203 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
204 * @param tidc The coordinate of the offset as TileIndexDiffC |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
205 * @return The difference between two tiles. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
206 * @see TileDiffXY(int, int) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
207 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
208 static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
209 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
210 return (tidc.y << MapLogX()) + tidc.x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
211 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
212 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
213 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
214 #ifndef _DEBUG |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
215 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
216 * Adds to tiles together. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
217 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
218 * @param x One tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
219 * @param y An other tile to add |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
220 * @return The resulting tile(index) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
221 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
222 #define TILE_ADD(x,y) ((x) + (y)) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
223 #else |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
224 extern TileIndex TileAdd(TileIndex tile, TileIndexDiff add, |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
225 const char *exp, const char *file, int line); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
226 #define TILE_ADD(x, y) (TileAdd((x), (y), #x " + " #y, __FILE__, __LINE__)) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
227 #endif |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
228 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
229 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
230 * Adds a given offset to a tile. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
231 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
232 * @param tile The tile to add an offset on it |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
233 * @param x The x offset to add to the tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
234 * @param y The y offset to add to the tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
235 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
236 #define TILE_ADDXY(tile, x, y) TILE_ADD(tile, TileDiffXY(x, y)) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
237 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
238 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
239 * Adds an offset to a tile and check if we are still on the map. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
240 */ |
8331
cecb4db460a2
(svn r11897) -Fix: Replace an uint with TileIndex and a small coding style fix.
frosch <frosch@openttd.org>
parents:
8139
diff
changeset
|
241 TileIndex TileAddWrap(TileIndex tile, int addx, int addy); |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
242 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
243 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
244 * Returns the TileIndexDiffC offset from a DiagDirection. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
245 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
246 * @param dir The given direction |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
247 * @return The offset as TileIndexDiffC value |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
248 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
249 static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
250 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
251 extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END]; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
252 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
253 assert(IsValidDiagDirection(dir)); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
254 return _tileoffs_by_diagdir[dir]; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
255 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
256 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
257 /** |
8380
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
258 * Returns the TileIndexDiffC offset from a Direction. |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
259 * |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
260 * @param dir The given direction |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
261 * @return The offset as TileIndexDiffC value |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
262 */ |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
263 static inline TileIndexDiffC TileIndexDiffCByDir(Direction dir) |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
264 { |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
265 extern const TileIndexDiffC _tileoffs_by_dir[DIR_END]; |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
266 |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
267 assert(IsValidDirection(dir)); |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
268 return _tileoffs_by_dir[dir]; |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
269 } |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
270 |
ccf4087c045f
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch <frosch@openttd.org>
parents:
8348
diff
changeset
|
271 /** |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
272 * Add a TileIndexDiffC to a TileIndex and returns the new one. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
273 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
274 * Returns tile + the diff given in diff. If the result tile would end up |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
275 * outside of the map, INVALID_TILE is returned instead. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
276 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
277 * @param tile The base tile to add the offset on |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
278 * @param diff The offset to add on the tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
279 * @return The resulting TileIndex |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
280 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
281 static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
282 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
283 int x = TileX(tile) + diff.x; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
284 int y = TileY(tile) + diff.y; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
285 if (x < 0 || y < 0 || x > (int)MapMaxX() || y > (int)MapMaxY()) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
286 return INVALID_TILE; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
287 else |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
288 return TileXY(x, y); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
289 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
290 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
291 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
292 * Returns the diff between two tiles |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
293 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
294 * @param tile_a from tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
295 * @param tile_b to tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
296 * @return the difference between tila_a and tile_b |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
297 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
298 static inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
299 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
300 TileIndexDiffC difference; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
301 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
302 difference.x = TileX(tile_a) - TileX(tile_b); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
303 difference.y = TileY(tile_a) - TileY(tile_b); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
304 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
305 return difference; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
306 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
307 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
308 /* Functions to calculate distances */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
309 uint DistanceManhattan(TileIndex, TileIndex); ///< also known as L1-Norm. Is the shortest distance one could go over diagonal tracks (or roads) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
310 uint DistanceSquare(TileIndex, TileIndex); ///< euclidian- or L2-Norm squared |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
311 uint DistanceMax(TileIndex, TileIndex); ///< also known as L-Infinity-Norm |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
312 uint DistanceMaxPlusManhattan(TileIndex, TileIndex); ///< Max + Manhattan |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
313 uint DistanceFromEdge(TileIndex); ///< shortest distance from any edge of the map |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
314 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
315 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
316 * Starts a loop which iterates to a square of tiles |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
317 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
318 * This macro starts 2 nested loops which iterates over a square of tiles. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
319 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
320 * @param var The name of the variable which contains the current tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
321 * @param w The width (x-width) of the square |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
322 * @param h The heigth (y-width) of the square |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
323 * @param tile The start tile of the square |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
324 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
325 #define BEGIN_TILE_LOOP(var, w, h, tile) \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
326 { \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
327 int h_cur = h; \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
328 uint var = tile; \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
329 do { \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
330 int w_cur = w; \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
331 do { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
332 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
333 * Ends the square-loop used before |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
334 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
335 * @see BEGIN_TILE_LOOP |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
336 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
337 #define END_TILE_LOOP(var, w, h, tile) \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
338 } while (++var, --w_cur != 0); \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
339 } while (var += TileDiffXY(0, 1) - (w), --h_cur != 0); \ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
340 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
341 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
342 * Convert a DiagDirection to a TileIndexDiff |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
343 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
344 * @param dir The DiagDirection |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
345 * @return The resulting TileIndexDiff |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
346 * @see TileIndexDiffCByDiagDir |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
347 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
348 static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
349 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
350 extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END]; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
351 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
352 assert(IsValidDiagDirection(dir)); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
353 return ToTileIndexDiff(_tileoffs_by_diagdir[dir]); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
354 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
355 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
356 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
357 * Convert a Direction to a TileIndexDiff. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
358 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
359 * @param dir The direction to convert from |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
360 * @return The resulting TileIndexDiff |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
361 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
362 static inline TileIndexDiff TileOffsByDir(Direction dir) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
363 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
364 extern const TileIndexDiffC _tileoffs_by_dir[DIR_END]; |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
365 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
366 assert(IsValidDirection(dir)); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
367 return ToTileIndexDiff(_tileoffs_by_dir[dir]); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
368 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
369 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
370 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
371 * Adds a DiagDir to a tile. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
372 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
373 * @param tile The current tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
374 * @param dir The direction in which we want to step |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
375 * @return the moved tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
376 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
377 static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
378 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
379 return TILE_ADD(tile, TileOffsByDiagDir(dir)); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
380 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
381 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
382 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
383 * A callback function type for searching tiles. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
384 * |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
385 * @param tile The tile to test |
9592
b8910fe673fc
(svn r13632) -Codechange: Use 'void *' for user-data of CircularTileSearch().
frosch <frosch@openttd.org>
parents:
9449
diff
changeset
|
386 * @param user_data additional data for the callback function to use |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
387 * @return A boolean value, depend on the definition of the function. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
388 */ |
9592
b8910fe673fc
(svn r13632) -Codechange: Use 'void *' for user-data of CircularTileSearch().
frosch <frosch@openttd.org>
parents:
9449
diff
changeset
|
389 typedef bool TestTileOnSearchProc(TileIndex tile, void *user_data); |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
390 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
391 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
392 * Searches for some cirumstances of a tile around a given tile with a helper function. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
393 */ |
9592
b8910fe673fc
(svn r13632) -Codechange: Use 'void *' for user-data of CircularTileSearch().
frosch <frosch@openttd.org>
parents:
9449
diff
changeset
|
394 bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data); |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
395 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
396 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
397 * Get a random tile out of a given seed. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
398 * @param r the random 'seed' |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
399 * @return a valid tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
400 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
401 static inline TileIndex RandomTileSeed(uint32 r) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
402 { |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
403 return TILE_MASK(r); |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
404 } |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
405 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
406 /** |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
407 * Get a valid random tile. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
408 * @note a define so 'random' gets inserted in the place where it is actually |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
409 * called, thus making the random traces more explicit. |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
410 * @return a valid tile |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
411 */ |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
412 #define RandomTile() RandomTileSeed(Random()) |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
413 |
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
414 #endif /* MAP_FUNC_H */ |