industry_map.h

Go to the documentation of this file.
00001 /* $Id: industry_map.h 15643 2009-03-08 16:10:39Z smatz $ */
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 
00174 static inline byte GetIndustryConstructionCounter(TileIndex tile)
00175 {
00176   assert(IsTileType(tile, MP_INDUSTRY));
00177   return GB(_m[tile].m1, 2, 2);
00178 }
00179 
00186 static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
00187 {
00188   assert(IsTileType(tile, MP_INDUSTRY));
00189   SB(_m[tile].m1, 2, 2, value);
00190 }
00191 
00199 static inline void ResetIndustryConstructionStage(TileIndex tile)
00200 {
00201   assert(IsTileType(tile, MP_INDUSTRY));
00202   SB(_m[tile].m1, 0, 4, 0);
00203   SB(_m[tile].m1, 7, 1, 0);
00204 }
00205 
00211 static inline byte GetIndustryAnimationLoop(TileIndex tile)
00212 {
00213   assert(IsTileType(tile, MP_INDUSTRY));
00214   return _m[tile].m4;
00215 }
00216 
00223 static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
00224 {
00225   assert(IsTileType(tile, MP_INDUSTRY));
00226   _m[tile].m4 = count;
00227 }
00228 
00234 static inline byte GetIndustryAnimationState(TileIndex tile)
00235 {
00236   assert(IsTileType(tile, MP_INDUSTRY));
00237   return _m[tile].m3;
00238 }
00239 
00246 static inline void SetIndustryAnimationState(TileIndex tile, byte state)
00247 {
00248   assert(IsTileType(tile, MP_INDUSTRY));
00249   _m[tile].m3 = state;
00250 }
00251 
00259 static inline byte GetIndustryRandomBits(TileIndex tile)
00260 {
00261   assert(IsTileType(tile, MP_INDUSTRY));
00262   return _me[tile].m7;
00263 }
00264 
00272 static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
00273 {
00274   assert(IsTileType(tile, MP_INDUSTRY));
00275   _me[tile].m7 = bits;
00276 }
00277 
00285 static inline byte GetIndustryTriggers(TileIndex tile)
00286 {
00287   assert(IsTileType(tile, MP_INDUSTRY));
00288   return GB(_m[tile].m6, 3, 3);
00289 }
00290 
00291 
00299 static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
00300 {
00301   assert(IsTileType(tile, MP_INDUSTRY));
00302   SB(_m[tile].m6, 3, 3, triggers);
00303 }
00304 
00312 static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
00313 {
00314   SetTileType(t, MP_INDUSTRY);
00315   _m[t].m1 = 0;
00316   _m[t].m2 = index;
00317   _m[t].m3 = 0;
00318   _m[t].m4 = 0;
00319   SetIndustryGfx(t, gfx); // m5, part of m6
00320   SetIndustryTriggers(t, 0); // rest of m6
00321   SetIndustryRandomBits(t, random); // m7
00322   SetWaterClass(t, wc);
00323 }
00324 
00325 #endif /* INDUSTRY_MAP_H */

Generated on Fri Jul 31 22:33:15 2009 for OpenTTD by  doxygen 1.5.6