00001
00002
00005 #ifndef INDUSTRY_MAP_H
00006 #define INDUSTRY_MAP_H
00007
00008 #include "industry.h"
00009 #include "tile_map.h"
00010
00011
00012
00018 enum {
00019 GFX_COAL_MINE_TOWER_NOT_ANIMATED = 0,
00020 GFX_COAL_MINE_TOWER_ANIMATED = 1,
00021 GFX_POWERPLANT_CHIMNEY = 8,
00022 GFX_POWERPLANT_SPARKS = 10,
00023 GFX_OILRIG_1 = 24,
00024 GFX_OILRIG_2 = 25,
00025 GFX_OILRIG_3 = 26,
00026 GFX_OILRIG_4 = 27,
00027 GFX_OILRIG_5 = 28,
00028 GFX_OILWELL_NOT_ANIMATED = 29,
00029 GFX_OILWELL_ANIMATED_1 = 30,
00030 GFX_OILWELL_ANIMATED_2 = 31,
00031 GFX_OILWELL_ANIMATED_3 = 32,
00032 GFX_COPPER_MINE_TOWER_NOT_ANIMATED = 47,
00033 GFX_COPPER_MINE_TOWER_ANIMATED = 48,
00034 GFX_COPPER_MINE_CHIMNEY = 49,
00035 GFX_GOLD_MINE_TOWER_NOT_ANIMATED = 79,
00036 GFX_GOLD_MINE_TOWER_ANIMATED = 88,
00037 GFX_TOY_FACTORY = 143,
00038 GFX_PLASTIC_FOUNTAIN_ANIMATED_1 = 148,
00039 GFX_PLASTIC_FOUNTAIN_ANIMATED_2 = 149,
00040 GFX_PLASTIC_FOUNTAIN_ANIMATED_3 = 150,
00041 GFX_PLASTIC_FOUNTAIN_ANIMATED_4 = 151,
00042 GFX_PLASTIC_FOUNTAIN_ANIMATED_5 = 152,
00043 GFX_PLASTIC_FOUNTAIN_ANIMATED_6 = 153,
00044 GFX_PLASTIC_FOUNTAIN_ANIMATED_7 = 154,
00045 GFX_PLASTIC_FOUNTAIN_ANIMATED_8 = 155,
00046 GFX_BUBBLE_GENERATOR = 161,
00047 GFX_BUBBLE_CATCHER = 162,
00048 GFX_TOFFEE_QUARY = 165,
00049 GFX_SUGAR_MINE_SIEVE = 174,
00050 GFX_WATERTILE_SPECIALCHECK = 255,
00051 };
00052
00059 static inline IndustryID GetIndustryIndex(TileIndex t)
00060 {
00061 assert(IsTileType(t, MP_INDUSTRY));
00062 return _m[t].m2;
00063 }
00064
00071 static inline Industry *GetIndustryByTile(TileIndex t)
00072 {
00073 return GetIndustry(GetIndustryIndex(t));
00074 }
00075
00082 static inline bool IsIndustryCompleted(TileIndex t)
00083 {
00084 assert(IsTileType(t, MP_INDUSTRY));
00085 return HasBit(_m[t].m1, 7);
00086 }
00087
00088 IndustryType GetIndustryType(TileIndex tile);
00089
00096 static inline void SetIndustryCompleted(TileIndex tile, bool isCompleted)
00097 {
00098 assert(IsTileType(tile, MP_INDUSTRY));
00099 SB(_m[tile].m1, 7, 1, isCompleted ? 1 :0);
00100 }
00101
00108 static inline byte GetIndustryConstructionStage(TileIndex tile)
00109 {
00110 assert(IsTileType(tile, MP_INDUSTRY));
00111 return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
00112 }
00113
00120 static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
00121 {
00122 assert(IsTileType(tile, MP_INDUSTRY));
00123 SB(_m[tile].m1, 0, 2, value);
00124 }
00125
00126 static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
00127 {
00128 assert(IsTileType(t, MP_INDUSTRY));
00129 return _m[t].m5 | (GB(_m[t].m6, 2, 1) << 8);
00130 }
00131
00138 static inline IndustryGfx GetIndustryGfx(TileIndex t)
00139 {
00140 assert(IsTileType(t, MP_INDUSTRY));
00141 return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
00142 }
00143
00150 static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
00151 {
00152 assert(IsTileType(t, MP_INDUSTRY));
00153 _m[t].m5 = GB(gfx, 0, 8);
00154 SB(_m[t].m6, 2, 1, GB(gfx, 8, 1));
00155 }
00156
00164 static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random)
00165 {
00166 SetTileType(t, MP_INDUSTRY);
00167 _m[t].m1 = 0;
00168 _m[t].m2 = index;
00169 _m[t].m3 = 0;
00170 _m[t].m4 = 0;
00171 SetIndustryGfx(t, gfx);
00172 _me[t].m7 = random;
00173 }
00174
00181 static inline byte GetIndustryConstructionCounter(TileIndex tile)
00182 {
00183 assert(IsTileType(tile, MP_INDUSTRY));
00184 return GB(_m[tile].m1, 2, 2);
00185 }
00186
00193 static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
00194 {
00195 assert(IsTileType(tile, MP_INDUSTRY));
00196 SB(_m[tile].m1, 2, 2, value);
00197 }
00198
00206 static inline void ResetIndustryConstructionStage(TileIndex tile)
00207 {
00208 assert(IsTileType(tile, MP_INDUSTRY));
00209 SB(_m[tile].m1, 0, 4, 0);
00210 SB(_m[tile].m1, 7, 1, 0);
00211 }
00212
00218 static inline byte GetIndustryAnimationLoop(TileIndex tile)
00219 {
00220 assert(IsTileType(tile, MP_INDUSTRY));
00221 return _m[tile].m4;
00222 }
00223
00230 static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
00231 {
00232 assert(IsTileType(tile, MP_INDUSTRY));
00233 _m[tile].m4 = count;
00234 }
00235
00241 static inline byte GetIndustryAnimationState(TileIndex tile)
00242 {
00243 assert(IsTileType(tile, MP_INDUSTRY));
00244 return _m[tile].m3;
00245 }
00246
00253 static inline void SetIndustryAnimationState(TileIndex tile, byte state)
00254 {
00255 assert(IsTileType(tile, MP_INDUSTRY));
00256 _m[tile].m3 = state;
00257 }
00258
00266 static inline byte GetIndustryRandomBits(TileIndex tile)
00267 {
00268 assert(IsTileType(tile, MP_INDUSTRY));
00269 return _me[tile].m7;
00270 }
00271
00279 static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
00280 {
00281 assert(IsTileType(tile, MP_INDUSTRY));
00282 _me[tile].m7 = bits;
00283 }
00284
00292 static inline byte GetIndustryTriggers(TileIndex tile)
00293 {
00294 assert(IsTileType(tile, MP_INDUSTRY));
00295 return GB(_m[tile].m6, 3, 3);
00296 }
00297
00298
00306 static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
00307 {
00308 assert(IsTileType(tile, MP_INDUSTRY));
00309 SB(_m[tile].m6, 3, 3, triggers);
00310 }
00311
00312 #endif