00001
00002
00005 #ifndef CLEAR_MAP_H
00006 #define CLEAR_MAP_H
00007
00008 #include "bridge_map.h"
00009 #include "industry_type.h"
00010
00014 enum ClearGround {
00015 CLEAR_GRASS = 0,
00016 CLEAR_ROUGH = 1,
00017 CLEAR_ROCKS = 2,
00018 CLEAR_FIELDS = 3,
00019 CLEAR_SNOW = 4,
00020 CLEAR_DESERT = 5
00021 };
00022
00023
00030 static inline ClearGround GetClearGround(TileIndex t)
00031 {
00032 assert(IsTileType(t, MP_CLEAR));
00033 return (ClearGround)GB(_m[t].m5, 2, 3);
00034 }
00035
00042 static inline bool IsClearGround(TileIndex t, ClearGround ct)
00043 {
00044 return GetClearGround(t) == ct;
00045 }
00046
00047
00054 static inline uint GetClearDensity(TileIndex t)
00055 {
00056 assert(IsTileType(t, MP_CLEAR));
00057 return GB(_m[t].m5, 0, 2);
00058 }
00059
00066 static inline void AddClearDensity(TileIndex t, int d)
00067 {
00068 assert(IsTileType(t, MP_CLEAR));
00069 _m[t].m5 += d;
00070 }
00071
00072
00079 static inline uint GetClearCounter(TileIndex t)
00080 {
00081 assert(IsTileType(t, MP_CLEAR));
00082 return GB(_m[t].m5, 5, 3);
00083 }
00084
00091 static inline void AddClearCounter(TileIndex t, int c)
00092 {
00093 assert(IsTileType(t, MP_CLEAR));
00094 _m[t].m5 += c << 5;
00095 }
00096
00103 static inline void SetClearCounter(TileIndex t, uint c)
00104 {
00105 assert(IsTileType(t, MP_CLEAR));
00106 SB(_m[t].m5, 5, 3, c);
00107 }
00108
00109
00117 static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
00118 {
00119 assert(IsTileType(t, MP_CLEAR));
00120 _m[t].m5 = 0 << 5 | type << 2 | density;
00121 }
00122
00123
00130 static inline uint GetFieldType(TileIndex t)
00131 {
00132 assert(GetClearGround(t) == CLEAR_FIELDS);
00133 return GB(_m[t].m3, 0, 4);
00134 }
00135
00142 static inline void SetFieldType(TileIndex t, uint f)
00143 {
00144 assert(GetClearGround(t) == CLEAR_FIELDS);
00145 SB(_m[t].m3, 0, 4, f);
00146 }
00147
00154 static inline IndustryID GetIndustryIndexOfField(TileIndex t)
00155 {
00156 assert(GetClearGround(t) == CLEAR_FIELDS);
00157 return(IndustryID) _m[t].m2;
00158 }
00159
00166 static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
00167 {
00168 assert(GetClearGround(t) == CLEAR_FIELDS);
00169 _m[t].m2 = i;
00170 }
00171
00172
00179 static inline uint GetFenceSE(TileIndex t)
00180 {
00181 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00182 return GB(_m[t].m4, 2, 3);
00183 }
00184
00192 static inline void SetFenceSE(TileIndex t, uint h)
00193 {
00194 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00195 SB(_m[t].m4, 2, 3, h);
00196 }
00197
00204 static inline uint GetFenceSW(TileIndex t)
00205 {
00206 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00207 return GB(_m[t].m4, 5, 3);
00208 }
00209
00217 static inline void SetFenceSW(TileIndex t, uint h)
00218 {
00219 assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
00220 SB(_m[t].m4, 5, 3, h);
00221 }
00222
00223
00230 static inline void MakeClear(TileIndex t, ClearGround g, uint density)
00231 {
00232
00233
00234 if (!MayHaveBridgeAbove(t)) SB(_m[t].m6, 6, 2, 0);
00235
00236 SetTileType(t, MP_CLEAR);
00237 SetTileOwner(t, OWNER_NONE);
00238 _m[t].m2 = 0;
00239 _m[t].m3 = 0;
00240 _m[t].m4 = 0 << 5 | 0 << 2;
00241 SetClearGroundDensity(t, g, density);
00242 SB(_m[t].m6, 2, 4, 0);
00243 _me[t].m7 = 0;
00244 }
00245
00246
00253 static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
00254 {
00255 SetTileType(t, MP_CLEAR);
00256 SetTileOwner(t, OWNER_NONE);
00257 _m[t].m2 = industry;
00258 _m[t].m3 = field_type;
00259 _m[t].m4 = 0 << 5 | 0 << 2;
00260 SetClearGroundDensity(t, CLEAR_FIELDS, 3);
00261 SB(_m[t].m6, 2, 4, 0);
00262 _me[t].m7 = 0;
00263 }
00264
00265 #endif