00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef INDUSTRY_MAP_H
00013 #define INDUSTRY_MAP_H
00014
00015 #include "industrytype.h"
00016 #include "water_map.h"
00017
00018
00024 enum IndustryGraphics {
00025 GFX_COAL_MINE_TOWER_NOT_ANIMATED = 0,
00026 GFX_COAL_MINE_TOWER_ANIMATED = 1,
00027 GFX_POWERPLANT_CHIMNEY = 8,
00028 GFX_POWERPLANT_SPARKS = 10,
00029 GFX_OILRIG_1 = 24,
00030 GFX_OILRIG_2 = 25,
00031 GFX_OILRIG_3 = 26,
00032 GFX_OILRIG_4 = 27,
00033 GFX_OILRIG_5 = 28,
00034 GFX_OILWELL_NOT_ANIMATED = 29,
00035 GFX_OILWELL_ANIMATED_1 = 30,
00036 GFX_OILWELL_ANIMATED_2 = 31,
00037 GFX_OILWELL_ANIMATED_3 = 32,
00038 GFX_COPPER_MINE_TOWER_NOT_ANIMATED = 47,
00039 GFX_COPPER_MINE_TOWER_ANIMATED = 48,
00040 GFX_COPPER_MINE_CHIMNEY = 49,
00041 GFX_GOLD_MINE_TOWER_NOT_ANIMATED = 79,
00042 GFX_GOLD_MINE_TOWER_ANIMATED = 88,
00043 GFX_TOY_FACTORY = 143,
00044 GFX_PLASTIC_FOUNTAIN_ANIMATED_1 = 148,
00045 GFX_PLASTIC_FOUNTAIN_ANIMATED_2 = 149,
00046 GFX_PLASTIC_FOUNTAIN_ANIMATED_3 = 150,
00047 GFX_PLASTIC_FOUNTAIN_ANIMATED_4 = 151,
00048 GFX_PLASTIC_FOUNTAIN_ANIMATED_5 = 152,
00049 GFX_PLASTIC_FOUNTAIN_ANIMATED_6 = 153,
00050 GFX_PLASTIC_FOUNTAIN_ANIMATED_7 = 154,
00051 GFX_PLASTIC_FOUNTAIN_ANIMATED_8 = 155,
00052 GFX_BUBBLE_GENERATOR = 161,
00053 GFX_BUBBLE_CATCHER = 162,
00054 GFX_TOFFEE_QUARY = 165,
00055 GFX_SUGAR_MINE_SIEVE = 174,
00056 GFX_WATERTILE_SPECIALCHECK = 255,
00057 };
00058
00065 static inline IndustryID GetIndustryIndex(TileIndex t)
00066 {
00067 assert(IsTileType(t, MP_INDUSTRY));
00068 return _m[t].m2;
00069 }
00070
00077 static inline bool IsIndustryCompleted(TileIndex t)
00078 {
00079 assert(IsTileType(t, MP_INDUSTRY));
00080 return HasBit(_m[t].m1, 7);
00081 }
00082
00083 IndustryType GetIndustryType(TileIndex tile);
00084
00091 static inline void SetIndustryCompleted(TileIndex tile, bool isCompleted)
00092 {
00093 assert(IsTileType(tile, MP_INDUSTRY));
00094 SB(_m[tile].m1, 7, 1, isCompleted ? 1 :0);
00095 }
00096
00103 static inline byte GetIndustryConstructionStage(TileIndex tile)
00104 {
00105 assert(IsTileType(tile, MP_INDUSTRY));
00106 return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
00107 }
00108
00115 static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
00116 {
00117 assert(IsTileType(tile, MP_INDUSTRY));
00118 SB(_m[tile].m1, 0, 2, value);
00119 }
00120
00128 static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
00129 {
00130 assert(IsTileType(t, MP_INDUSTRY));
00131 return _m[t].m5 | (GB(_m[t].m6, 2, 1) << 8);
00132 }
00133
00140 static inline IndustryGfx GetIndustryGfx(TileIndex t)
00141 {
00142 assert(IsTileType(t, MP_INDUSTRY));
00143 return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
00144 }
00145
00152 static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
00153 {
00154 assert(IsTileType(t, MP_INDUSTRY));
00155 _m[t].m5 = GB(gfx, 0, 8);
00156 SB(_m[t].m6, 2, 1, GB(gfx, 8, 1));
00157 }
00158
00165 static inline byte GetIndustryConstructionCounter(TileIndex tile)
00166 {
00167 assert(IsTileType(tile, MP_INDUSTRY));
00168 return GB(_m[tile].m1, 2, 2);
00169 }
00170
00177 static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
00178 {
00179 assert(IsTileType(tile, MP_INDUSTRY));
00180 SB(_m[tile].m1, 2, 2, value);
00181 }
00182
00190 static inline void ResetIndustryConstructionStage(TileIndex tile)
00191 {
00192 assert(IsTileType(tile, MP_INDUSTRY));
00193 SB(_m[tile].m1, 0, 4, 0);
00194 SB(_m[tile].m1, 7, 1, 0);
00195 }
00196
00202 static inline byte GetIndustryAnimationLoop(TileIndex tile)
00203 {
00204 assert(IsTileType(tile, MP_INDUSTRY));
00205 return _m[tile].m4;
00206 }
00207
00214 static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
00215 {
00216 assert(IsTileType(tile, MP_INDUSTRY));
00217 _m[tile].m4 = count;
00218 }
00219
00227 static inline byte GetIndustryRandomBits(TileIndex tile)
00228 {
00229 assert(IsTileType(tile, MP_INDUSTRY));
00230 return _m[tile].m3;
00231 }
00232
00240 static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
00241 {
00242 assert(IsTileType(tile, MP_INDUSTRY));
00243 _m[tile].m3 = bits;
00244 }
00245
00253 static inline byte GetIndustryTriggers(TileIndex tile)
00254 {
00255 assert(IsTileType(tile, MP_INDUSTRY));
00256 return GB(_m[tile].m6, 3, 3);
00257 }
00258
00259
00267 static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
00268 {
00269 assert(IsTileType(tile, MP_INDUSTRY));
00270 SB(_m[tile].m6, 3, 3, triggers);
00271 }
00272
00281 static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
00282 {
00283 SetTileType(t, MP_INDUSTRY);
00284 _m[t].m1 = 0;
00285 _m[t].m2 = index;
00286 SetIndustryRandomBits(t, random);
00287 _m[t].m4 = 0;
00288 SetIndustryGfx(t, gfx);
00289 SetIndustryTriggers(t, 0);
00290 SetWaterClass(t, wc);
00291 _me[t].m7 = 0;
00292 }
00293
00294 #endif