author | truebrain |
Mon, 30 Jun 2008 13:51:28 +0000 | |
branch | noai |
changeset 11102 | aacdde10b4ad |
parent 9723 | eee46cb39750 |
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 |
|
9574 | 3 |
/** @file clear_map.h Map accessors for 'clear' tiles */ |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
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 |
|
5828
d54db61cc830
(svn r8014) -Codechange (r7573): When a tile is cleared, empty the general purpose bits in
maedhros
parents:
5726
diff
changeset
|
8 |
#include "bridge_map.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9574
diff
changeset
|
9 |
#include "industry_type.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
|
10 |
|
9574 | 11 |
/** |
12 |
* 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
|
13 |
*/ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6449
diff
changeset
|
14 |
enum ClearGround { |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
15 |
CLEAR_GRASS = 0, ///< 0-3 |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
16 |
CLEAR_ROUGH = 1, ///< 3 |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
17 |
CLEAR_ROCKS = 2, ///< 3 |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
18 |
CLEAR_FIELDS = 3, ///< 3 |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
19 |
CLEAR_SNOW = 4, ///< 0-3 |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
20 |
CLEAR_DESERT = 5 ///< 1,3 |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6449
diff
changeset
|
21 |
}; |
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
|
22 |
|
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 |
|
9574 | 24 |
/** |
25 |
* Get the type of clear tile. |
|
26 |
* @param t the tile to get the clear ground type of |
|
27 |
* @pre IsTileType(t, MP_CLEAR) |
|
28 |
* @return the ground type |
|
29 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
30 |
static inline ClearGround GetClearGround(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
31 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
32 |
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
|
33 |
return (ClearGround)GB(_m[t].m5, 2, 3); |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
34 |
} |
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
|
35 |
|
9574 | 36 |
/** |
37 |
* Set the type of clear tile. |
|
38 |
* @param t the tile to set the clear ground type of |
|
39 |
* @param ct the ground type |
|
40 |
* @pre IsTileType(t, MP_CLEAR) |
|
41 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
42 |
static inline bool IsClearGround(TileIndex t, ClearGround ct) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
43 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
44 |
return GetClearGround(t) == ct; |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
45 |
} |
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 |
|
9574 | 48 |
/** |
49 |
* Get the density of a non-field clear tile. |
|
50 |
* @param t the tile to get the density of |
|
51 |
* @pre IsTileType(t, MP_CLEAR) |
|
52 |
* @return the density |
|
53 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
54 |
static inline uint GetClearDensity(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
55 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
56 |
assert(IsTileType(t, MP_CLEAR)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
57 |
return GB(_m[t].m5, 0, 2); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
58 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
59 |
|
9574 | 60 |
/** |
61 |
* Increment the density of a non-field clear tile. |
|
62 |
* @param t the tile to increment the density of |
|
63 |
* @param d the amount to increment the density with |
|
64 |
* @pre IsTileType(t, MP_CLEAR) |
|
65 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
66 |
static inline void AddClearDensity(TileIndex t, int d) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
67 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
68 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
69 |
_m[t].m5 += d; |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
70 |
} |
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 |
|
9574 | 73 |
/** |
74 |
* Get the counter used to advance to the next clear density/field type. |
|
75 |
* @param t the tile to get the counter of |
|
76 |
* @pre IsTileType(t, MP_CLEAR) |
|
77 |
* @return the value of the counter |
|
78 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
79 |
static inline uint GetClearCounter(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
80 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
81 |
assert(IsTileType(t, MP_CLEAR)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
82 |
return GB(_m[t].m5, 5, 3); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
83 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
84 |
|
9574 | 85 |
/** |
86 |
* Increments the counter used to advance to the next clear density/field type. |
|
87 |
* @param t the tile to increment the counter of |
|
88 |
* @param c the amount to increment the counter with |
|
89 |
* @pre IsTileType(t, MP_CLEAR) |
|
90 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
91 |
static inline void AddClearCounter(TileIndex t, int c) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
92 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
93 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
94 |
_m[t].m5 += c << 5; |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
95 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
96 |
|
9574 | 97 |
/** |
98 |
* Sets the counter used to advance to the next clear density/field type. |
|
99 |
* @param t the tile to set the counter of |
|
100 |
* @param c the amount to set the counter to |
|
101 |
* @pre IsTileType(t, MP_CLEAR) |
|
102 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
103 |
static inline void SetClearCounter(TileIndex t, uint c) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
104 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
105 |
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
106 |
SB(_m[t].m5, 5, 3, c); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
107 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
108 |
|
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
|
109 |
|
9574 | 110 |
/** |
111 |
* Sets ground type and density in one go, also sets the counter to 0 |
|
112 |
* @param t the tile to set the ground type and density for |
|
113 |
* @param type the new ground type of the tile |
|
114 |
* @param density the density of the ground tile |
|
115 |
* @pre IsTileType(t, MP_CLEAR) |
|
116 |
*/ |
|
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
|
117 |
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
|
118 |
{ |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
119 |
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
|
120 |
_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
|
121 |
} |
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 |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
123 |
|
9574 | 124 |
/** |
125 |
* Get the field type (production stage) of the field |
|
126 |
* @param t the field to get the type of |
|
127 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
128 |
* @return the field type |
|
129 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
130 |
static inline uint GetFieldType(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
131 |
{ |
3447 | 132 |
assert(GetClearGround(t) == CLEAR_FIELDS); |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
133 |
return GB(_m[t].m3, 0, 4); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
134 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
135 |
|
9574 | 136 |
/** |
137 |
* Set the field type (production stage) of the field |
|
138 |
* @param t the field to get the type of |
|
139 |
* @param f the field type |
|
140 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
141 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
142 |
static inline void SetFieldType(TileIndex t, uint f) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
143 |
{ |
3447 | 144 |
assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
145 |
SB(_m[t].m3, 0, 4, f); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
146 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
147 |
|
9574 | 148 |
/** |
149 |
* Get the industry (farm) that made the field |
|
150 |
* @param t the field to get creating industry of |
|
151 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
152 |
* @return the industry that made the field |
|
153 |
*/ |
|
154 |
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
|
155 |
{ |
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 |
assert(GetClearGround(t) == CLEAR_FIELDS); |
9574 | 157 |
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
|
158 |
} |
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 |
|
9574 | 160 |
/** |
161 |
* Set the industry (farm) that made the field |
|
162 |
* @param t the field to get creating industry of |
|
163 |
* @param i the industry that made the field |
|
164 |
* @pre GetClearGround(t) == CLEAR_FIELDS |
|
165 |
*/ |
|
166 |
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
|
167 |
{ |
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 |
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
|
169 |
_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
|
170 |
} |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
171 |
|
9574 | 172 |
|
173 |
/** |
|
174 |
* Is there a fence at the south eastern border? |
|
175 |
* @param t the tile to check for fences |
|
176 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
177 |
* @return 0 if there is no fence, otherwise the fence type |
|
178 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
179 |
static inline uint GetFenceSE(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
180 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
181 |
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
182 |
return GB(_m[t].m4, 2, 3); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
183 |
} |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
184 |
|
9574 | 185 |
/** |
186 |
* Sets the type of fence (and whether there is one) for the south |
|
187 |
* eastern border. |
|
188 |
* @param t the tile to check for fences |
|
189 |
* @param h 0 if there is no fence, otherwise the fence type |
|
190 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
191 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
192 |
static inline void SetFenceSE(TileIndex t, uint h) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
193 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
194 |
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
|
195 |
SB(_m[t].m4, 2, 3, h); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
196 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
197 |
|
9574 | 198 |
/** |
199 |
* Is there a fence at the south western border? |
|
200 |
* @param t the tile to check for fences |
|
201 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
202 |
* @return 0 if there is no fence, otherwise the fence type |
|
203 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
204 |
static inline uint GetFenceSW(TileIndex t) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
205 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
206 |
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
207 |
return GB(_m[t].m4, 5, 3); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
208 |
} |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
209 |
|
9574 | 210 |
/** |
211 |
* Sets the type of fence (and whether there is one) for the south |
|
212 |
* western border. |
|
213 |
* @param t the tile to check for fences |
|
214 |
* @param h 0 if there is no fence, otherwise the fence type |
|
215 |
* @pre IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES) |
|
216 |
*/ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
217 |
static inline void SetFenceSW(TileIndex t, uint h) |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
218 |
{ |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
219 |
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
|
220 |
SB(_m[t].m4, 5, 3, h); |
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3291
diff
changeset
|
221 |
} |
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
222 |
|
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
223 |
|
9574 | 224 |
/** |
225 |
* Make a clear tile. |
|
226 |
* @param t the tile to make a clear tile |
|
227 |
* @param g the type of ground |
|
228 |
* @param density the density of the grass/snow/desert etc |
|
229 |
*/ |
|
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
230 |
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
|
231 |
{ |
5828
d54db61cc830
(svn r8014) -Codechange (r7573): When a tile is cleared, empty the general purpose bits in
maedhros
parents:
5726
diff
changeset
|
232 |
/* 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
|
233 |
* 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
|
234 |
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
|
235 |
|
3076
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
236 |
SetTileType(t, MP_CLEAR); |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
237 |
SetTileOwner(t, OWNER_NONE); |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
238 |
_m[t].m2 = 0; |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
239 |
_m[t].m3 = 0; |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
240 |
_m[t].m4 = 0 << 5 | 0 << 2; |
3291 | 241 |
SetClearGroundDensity(t, g, density); |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5847
diff
changeset
|
242 |
SB(_m[t].m6, 2, 4, 0); // Clear the rest of m6, bits 2 to 5 |
3291 | 243 |
} |
244 |
||
245 |
||
9574 | 246 |
/** |
247 |
* Make a (farm) field tile. |
|
248 |
* @param t the tile to make a farm field |
|
249 |
* @param field_type the 'growth' level of the field |
|
250 |
* @param industry the industry this tile belongs to |
|
251 |
*/ |
|
252 |
static inline void MakeField(TileIndex t, uint field_type, IndustryID industry) |
|
3291 | 253 |
{ |
254 |
SetTileType(t, MP_CLEAR); |
|
255 |
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
|
256 |
_m[t].m2 = industry; |
3291 | 257 |
_m[t].m3 = field_type; |
258 |
_m[t].m4 = 0 << 5 | 0 << 2; |
|
3447 | 259 |
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
|
260 |
} |
9584f34a83dc
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
261 |
|
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
|
262 |
#endif /* CLEAR_MAP_H */ |