00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef CLEAR_MAP_H
00013 #define CLEAR_MAP_H
00014
00015 #include "bridge_map.h"
00016 #include "industry_type.h"
00017
00021 enum ClearGround {
00022 CLEAR_GRASS = 0,
00023 CLEAR_ROUGH = 1,
00024 CLEAR_ROCKS = 2,
00025 CLEAR_FIELDS = 3,
00026 CLEAR_SNOW = 4,
00027 CLEAR_DESERT = 5
00028 };
00029
00030
00037 static inline ClearGround GetClearGround(TileIndex t)
00038 {
00039 assert(IsTileType(t, MP_CLEAR));
00040 return (ClearGround)GB(_m[t].m5, 2, 3);
00041 }
00042
00049 static inline bool IsClearGround(TileIndex t, ClearGround ct)
00050 {
00051 return GetClearGround(t) == ct;
00052 }
00053
00054
00061 static inline uint GetClearDensity(TileIndex t)
00062 {
00063 assert(IsTileType(t, MP_CLEAR));
00064 return GB(_m[t].m5, 0, 2);
00065 }
00066
00073 static inline void AddClearDensity(TileIndex t, int d)
00074 {
00075 assert(IsTileType(t, MP_CLEAR));
00076 _m[t].m5 += d;
00077 }
00078
00079
00086 static inline uint GetClearCounter(TileIndex t)
00087 {
00088 assert(IsTileType(t, MP_CLEAR));
00089 return GB(_m[t].m5, 5, 3);
00090 }
00091
00098 static inline void AddClearCounter(TileIndex t, int c)
00099 {
00100 assert(IsTileType(t, MP_CLEAR));
00101 _m[t].m5 += c << 5;
00102 }
00103
00110 static inline void SetClearCounter(TileIndex t, uint c)
00111 {
00112 assert(IsTileType(t, MP_CLEAR));
00113 SB(_m[t].m5, 5, 3, c);
00114 }
00115
00116
00124 static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
00125 {
00126 assert(IsTileType(t, MP_CLEAR));
00127 _m[t].m5 = 0 << 5 | type << 2 | density;
00128 }
00129
00130
00137 static inline uint GetFieldType(TileIndex t)
00138 {
00139 assert(GetClearGround(t) == CLEAR_FIELDS);
00140 return GB(_m[t].m3, 0, 4);
00141 }
00142
00149 static inline void SetFieldType(TileIndex t, uint f)
00150 {
00151 assert(GetClearGround(t) == CLEAR_FIELDS);
00152 SB(_m[t].m3, 0, 4, f);
00153 }
00154
00161 static inline IndustryID GetIndustryIndexOfField(TileIndex t)
00162 {
00163 assert(GetClearGround(t) == CLEAR_FIELDS);
00164 return(IndustryID) _m[t].m2;
00165 }
00166
00173 static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
00174 {
00175 assert(GetClearGround(t) == CLEAR_FIELDS);
00176 _m[t].m2 = i;
00177 }
00178
00179
00186 static inline uint GetFenceSE(TileIndex t)
00187 {
00188 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00189 return GB(_m[t].m4, 2, 3);
00190 }
00191
00199 static inline void SetFenceSE(TileIndex t, uint h)
00200 {
00201 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00202 SB(_m[t].m4, 2, 3, h);
00203 }
00204
00211 static inline uint GetFenceSW(TileIndex t)
00212 {
00213 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00214 return GB(_m[t].m4, 5, 3);
00215 }
00216
00224 static inline void SetFenceSW(TileIndex t, uint h)
00225 {
00226 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00227 SB(_m[t].m4, 5, 3, h);
00228 }
00229
00230
00237 static inline void MakeClear(TileIndex t, ClearGround g, uint density)
00238 {
00239
00240
00241 if (!MayHaveBridgeAbove(t)) SB(_m[t].m6, 6, 2, 0);
00242
00243 SetTileType(t, MP_CLEAR);
00244 SetTileOwner(t, OWNER_NONE);
00245 _m[t].m2 = 0;
00246 _m[t].m3 = 0;
00247 _m[t].m4 = 0 << 5 | 0 << 2;
00248 SetClearGroundDensity(t, g, density);
00249 SB(_m[t].m6, 2, 4, 0);
00250 _me[t].m7 = 0;
00251 }
00252
00253
00260 static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
00261 {
00262 SetTileType(t, MP_CLEAR);
00263 SetTileOwner(t, OWNER_NONE);
00264 _m[t].m2 = industry;
00265 _m[t].m3 = field_type;
00266 _m[t].m4 = 0 << 5 | 0 << 2;
00267 SetClearGroundDensity(t, CLEAR_FIELDS, 3);
00268 SB(_m[t].m6, 2, 4, 0);
00269 _me[t].m7 = 0;
00270 }
00271
00272 #endif