author | KUDr |
Sat, 21 Apr 2007 08:23:57 +0000 | |
branch | cpp_gui |
changeset 6308 | 646711c5feaa |
parent 6307 | f40e88cff863 |
child 6872 | 1c4a4a609f85 |
child 8604 | 8afdd9877afd |
permissions | -rw-r--r-- |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
2 |
|
6307 | 3 |
/** @file clear_map.h Map accessors for 'clear' tiles */ |
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
4 |
|
3145
349b745dfbf4
(svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents:
3144
diff
changeset
|
5 |
#ifndef CLEAR_MAP_H |
349b745dfbf4
(svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents:
3144
diff
changeset
|
6 |
#define CLEAR_MAP_H |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
7 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
8 |
#include "macros.h" |
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
9 |
#include "tile.h" |
5828
d54db61cc830
(svn r8014) -Codechange (r7573): When a tile is cleared, empty the general purpose bits in
maedhros
parents:
5726
diff
changeset
|
10 |
#include "bridge_map.h" |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
11 |
|
6307 | 12 |
/** |
13 |
* Ground types. Valid densities in comments after the enum. |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
14 |
*/ |
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6268
diff
changeset
|
15 |
enum ClearGround { |
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
16 |
CLEAR_GRASS = 0, ///< 0-3 |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
17 |
CLEAR_ROUGH = 1, ///< 3 |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
18 |
CLEAR_ROCKS = 2, ///< 3 |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
19 |
CLEAR_FIELDS = 3, ///< 3 |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
20 |
CLEAR_SNOW = 4, ///< 0-3 |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
21 |
CLEAR_DESERT = 5 ///< 1,3 |
6298
c30fe89622df
(svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents:
6268
diff
changeset
|
22 |
}; |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
23 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
24 |
|
6307 | 25 |
/** |
26 |
* Get the type of clear tile. |
|
27 |
* @param t the tile to get the clear ground type of |
|
28 |
* @pre IsTileType(t, MP_CLEAR) |
|
29 |
* @return the ground type |
|
30 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
31 |
static inline ClearGround GetClearGround(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
32 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
33 |
assert(IsTileType(t, MP_CLEAR)); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5828
diff
changeset
|
34 |
return (ClearGround)GB(_m[t].m5, 2, 3); |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
35 |
} |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
36 |
|
6307 | 37 |
/** |
38 |
* Set the type of clear tile. |
|
39 |
* @param t the tile to set the clear ground type of |
|
40 |
* @param ct the ground type |
|
41 |
* @pre IsTileType(t, MP_CLEAR) |
|
42 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
43 |
static inline bool IsClearGround(TileIndex t, ClearGround ct) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
44 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
45 |
return GetClearGround(t) == ct; |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
46 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
47 |
|
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
48 |
|
6307 | 49 |
/** |
50 |
* Get the density of a non-field clear tile. |
|
51 |
* @param t the tile to get the density of |
|
52 |
* @pre IsTileType(t, MP_CLEAR) |
|
53 |
* @return the density |
|
54 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
55 |
static inline uint GetClearDensity(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
56 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
57 |
assert(IsTileType(t, MP_CLEAR)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
58 |
return GB(_m[t].m5, 0, 2); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
59 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
60 |
|
6307 | 61 |
/** |
62 |
* Increment the density of a non-field clear tile. |
|
63 |
* @param t the tile to increment the density of |
|
64 |
* @param d the amount to increment the density with |
|
65 |
* @pre IsTileType(t, MP_CLEAR) |
|
66 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
67 |
static inline void AddClearDensity(TileIndex t, int d) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
68 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
69 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
70 |
_m[t].m5 += d; |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
71 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
72 |
|
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
73 |
|
6307 | 74 |
/** |
75 |
* Get the counter used to advance to the next clear density/field type. |
|
76 |
* @param t the tile to get the counter of |
|
77 |
* @pre IsTileType(t, MP_CLEAR) |
|
78 |
* @return the value of the counter |
|
79 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
80 |
static inline uint GetClearCounter(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
81 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
82 |
assert(IsTileType(t, MP_CLEAR)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
83 |
return GB(_m[t].m5, 5, 3); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
84 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
85 |
|
6307 | 86 |
/** |
87 |
* Increments the counter used to advance to the next clear density/field type. |
|
88 |
* @param t the tile to increment the counter of |
|
89 |
* @param c the amount to increment the counter with |
|
90 |
* @pre IsTileType(t, MP_CLEAR) |
|
91 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
92 |
static inline void AddClearCounter(TileIndex t, int c) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
93 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
94 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
95 |
_m[t].m5 += c << 5; |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
96 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
97 |
|
6307 | 98 |
/** |
99 |
* Sets the counter used to advance to the next clear density/field type. |
|
100 |
* @param t the tile to set the counter of |
|
101 |
* @param c the amount to set the counter to |
|
102 |
* @pre IsTileType(t, MP_CLEAR) |
|
103 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
104 |
static inline void SetClearCounter(TileIndex t, uint c) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
105 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
106 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
107 |
SB(_m[t].m5, 5, 3, c); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
108 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
109 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
110 |
|
6307 | 111 |
/** |
112 |
* Sets ground type and density in one go, also sets the counter to 0 |
|
113 |
* @param t the tile to set the ground type and density for |
|
114 |
* @param type the new ground type of the tile |
|
115 |
* @param density the density of the ground tile |
|
116 |
* @pre IsTileType(t, MP_CLEAR) |
|
117 |
*/ |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
118 |
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
119 |
{ |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
120 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
121 |
_m[t].m5 = 0 << 5 | type << 2 | density; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
122 |
} |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
123 |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
124 |
|
6307 | 125 |
/** |
126 |
* Get the field type (production stage) of the field |
|
127 |
* @param t the field to get the type of |
|
128 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
129 |
* @return the field type |
|
130 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
131 |
static inline uint GetFieldType(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
132 |
{ |
3447 | 133 |
assert(GetClearGround(t) == CLEAR_FIELDS); |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
134 |
return GB(_m[t].m3, 0, 4); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
135 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
136 |
|
6307 | 137 |
/** |
138 |
* Set the field type (production stage) of the field |
|
139 |
* @param t the field to get the type of |
|
140 |
* @param f the field type |
|
141 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
142 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
143 |
static inline void SetFieldType(TileIndex t, uint f) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
144 |
{ |
3447 | 145 |
assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
146 |
SB(_m[t].m3, 0, 4, f); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
147 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
148 |
|
6307 | 149 |
/** |
150 |
* Get the industry (farm) that made the field |
|
151 |
* @param t the field to get creating industry of |
|
152 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
153 |
* @return the industry that made the field |
|
154 |
*/ |
|
155 |
static inline IndustryID GetIndustryIndexOfField(TileIndex t) |
|
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
156 |
{ |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
157 |
assert(GetClearGround(t) == CLEAR_FIELDS); |
6307 | 158 |
return(IndustryID) _m[t].m2; |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
159 |
} |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
160 |
|
6307 | 161 |
/** |
162 |
* Set the industry (farm) that made the field |
|
163 |
* @param t the field to get creating industry of |
|
164 |
* @param i the industry that made the field |
|
165 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
166 |
*/ |
|
167 |
static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i) |
|
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
168 |
{ |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
169 |
assert(GetClearGround(t) == CLEAR_FIELDS); |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
170 |
_m[t].m2 = i; |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
171 |
} |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
172 |
|
6307 | 173 |
|
174 |
/** |
|
175 |
* Is there a fence at the south eastern border? |
|
176 |
* @param t the tile to check for fences |
|
177 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
178 |
* @return 0 if there is no fence, otherwise the fence type |
|
179 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
180 |
static inline uint GetFenceSE(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
181 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
182 |
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
183 |
return GB(_m[t].m4, 2, 3); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
184 |
} |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
185 |
|
6307 | 186 |
/** |
187 |
* Sets the type of fence (and whether there is one) for the south |
|
188 |
* eastern border. |
|
189 |
* @param t the tile to check for fences |
|
190 |
* @param h 0 if there is no fence, otherwise the fence type |
|
191 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
192 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
193 |
static inline void SetFenceSE(TileIndex t, uint h) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
194 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
195 |
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
196 |
SB(_m[t].m4, 2, 3, h); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
197 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
198 |
|
6307 | 199 |
/** |
200 |
* Is there a fence at the south western border? |
|
201 |
* @param t the tile to check for fences |
|
202 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
203 |
* @return 0 if there is no fence, otherwise the fence type |
|
204 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
205 |
static inline uint GetFenceSW(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
206 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
207 |
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
208 |
return GB(_m[t].m4, 5, 3); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
209 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
210 |
|
6307 | 211 |
/** |
212 |
* Sets the type of fence (and whether there is one) for the south |
|
213 |
* western border. |
|
214 |
* @param t the tile to check for fences |
|
215 |
* @param h 0 if there is no fence, otherwise the fence type |
|
216 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
217 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
218 |
static inline void SetFenceSW(TileIndex t, uint h) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
219 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
220 |
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
221 |
SB(_m[t].m4, 5, 3, h); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
222 |
} |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
223 |
|
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
224 |
|
6307 | 225 |
/** |
226 |
* Make a clear tile. |
|
227 |
* @param t the tile to make a clear tile |
|
228 |
* @param g the type of ground |
|
229 |
* @param density the density of the grass/snow/desert etc |
|
230 |
*/ |
|
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
231 |
static inline void MakeClear(TileIndex t, ClearGround g, uint density) |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
232 |
{ |
5828
d54db61cc830
(svn r8014) -Codechange (r7573): When a tile is cleared, empty the general purpose bits in
maedhros
parents:
5726
diff
changeset
|
233 |
/* If this is a non-bridgeable tile, clear the bridge bits while the rest |
d54db61cc830
(svn r8014) -Codechange (r7573): When a tile is cleared, empty the general purpose bits in
maedhros
parents:
5726
diff
changeset
|
234 |
* of the tile information is still here. */ |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
235 |
if (!MayHaveBridgeAbove(t)) SB(_m[t].m6, 6, 2, 0); |
5828
d54db61cc830
(svn r8014) -Codechange (r7573): When a tile is cleared, empty the general purpose bits in
maedhros
parents:
5726
diff
changeset
|
236 |
|
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
237 |
SetTileType(t, MP_CLEAR); |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
238 |
SetTileOwner(t, OWNER_NONE); |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
239 |
_m[t].m2 = 0; |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
240 |
_m[t].m3 = 0; |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
241 |
_m[t].m4 = 0 << 5 | 0 << 2; |
3291 | 242 |
SetClearGroundDensity(t, g, density); |
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5847
diff
changeset
|
243 |
SB(_m[t].m6, 2, 4, 0); // Clear the rest of m6, bits 2 to 5 |
3291 | 244 |
} |
245 |
||
246 |
||
6307 | 247 |
/** |
248 |
* Make a (farm) field tile. |
|
249 |
* @param t the tile to make a farm field |
|
250 |
* @param field_type the 'growth' level of the field |
|
251 |
* @param industry the industry this tile belongs to |
|
252 |
*/ |
|
253 |
static inline void MakeField(TileIndex t, uint field_type, IndustryID industry) |
|
3291 | 254 |
{ |
255 |
SetTileType(t, MP_CLEAR); |
|
256 |
SetTileOwner(t, OWNER_NONE); |
|
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
3516
diff
changeset
|
257 |
_m[t].m2 = industry; |
3291 | 258 |
_m[t].m3 = field_type; |
259 |
_m[t].m4 = 0 << 5 | 0 << 2; |
|
3447 | 260 |
SetClearGroundDensity(t, CLEAR_FIELDS, 3); |
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
261 |
} |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
262 |
|
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4328
diff
changeset
|
263 |
#endif /* CLEAR_MAP_H */ |