industry_map.h

Go to the documentation of this file.
00001 /* $Id: industry_map.h 13982 2008-08-03 18:56:44Z peter1138 $ */
00002 
00005 #ifndef INDUSTRY_MAP_H
00006 #define INDUSTRY_MAP_H
00007 
00008 #include "industry.h"
00009 #include "tile_map.h"
00010 #include "water_map.h"
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 
00162 static inline bool IsIndustryTileOnWater(TileIndex t)
00163 {
00164   assert(IsTileType(t, MP_INDUSTRY));
00165   return (GetWaterClass(t) != WATER_CLASS_INVALID);
00166 }
00167 
00175 static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
00176 {
00177   SetTileType(t, MP_INDUSTRY);
00178   _m[t].m1 = 0;
00179   _m[t].m2 = index;
00180   _m[t].m3 = 0;
00181   _m[t].m4 = 0;
00182   SetIndustryGfx(t, gfx);
00183   _me[t].m7 = random;
00184   SetWaterClass(t, wc);
00185 }
00186 
00193 static inline byte GetIndustryConstructionCounter(TileIndex tile)
00194 {
00195   assert(IsTileType(tile, MP_INDUSTRY));
00196   return GB(_m[tile].m1, 2, 2);
00197 }
00198 
00205 static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
00206 {
00207   assert(IsTileType(tile, MP_INDUSTRY));
00208   SB(_m[tile].m1, 2, 2, value);
00209 }
00210 
00218 static inline void ResetIndustryConstructionStage(TileIndex tile)
00219 {
00220   assert(IsTileType(tile, MP_INDUSTRY));
00221   SB(_m[tile].m1, 0, 4, 0);
00222   SB(_m[tile].m1, 7, 1, 0);
00223 }
00224 
00230 static inline byte GetIndustryAnimationLoop(TileIndex tile)
00231 {
00232   assert(IsTileType(tile, MP_INDUSTRY));
00233   return _m[tile].m4;
00234 }
00235 
00242 static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
00243 {
00244   assert(IsTileType(tile, MP_INDUSTRY));
00245   _m[tile].m4 = count;
00246 }
00247 
00253 static inline byte GetIndustryAnimationState(TileIndex tile)
00254 {
00255   assert(IsTileType(tile, MP_INDUSTRY));
00256   return _m[tile].m3;
00257 }
00258 
00265 static inline void SetIndustryAnimationState(TileIndex tile, byte state)
00266 {
00267   assert(IsTileType(tile, MP_INDUSTRY));
00268   _m[tile].m3 = state;
00269 }
00270 
00278 static inline byte GetIndustryRandomBits(TileIndex tile)
00279 {
00280   assert(IsTileType(tile, MP_INDUSTRY));
00281   return _me[tile].m7;
00282 }
00283 
00291 static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
00292 {
00293   assert(IsTileType(tile, MP_INDUSTRY));
00294   _me[tile].m7 = bits;
00295 }
00296 
00304 static inline byte GetIndustryTriggers(TileIndex tile)
00305 {
00306   assert(IsTileType(tile, MP_INDUSTRY));
00307   return GB(_m[tile].m6, 3, 3);
00308 }
00309 
00310 
00318 static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
00319 {
00320   assert(IsTileType(tile, MP_INDUSTRY));
00321   SB(_m[tile].m6, 3, 3, triggers);
00322 }
00323 
00324 #endif /* INDUSTRY_MAP_H */

Generated on Mon Feb 16 23:12:07 2009 for openttd by  doxygen 1.5.6