src/industry_map.h
branchgamebalance
changeset 9908 0fa543611bbe
parent 9895 7bd07f43b0e3
child 7132 08abbae3073e
equal deleted inserted replaced
9907:3b068c3a1c74 9908:0fa543611bbe
    49 	GFX_TOFFEE_QUARY                   = 165,
    49 	GFX_TOFFEE_QUARY                   = 165,
    50 	GFX_SUGAR_MINE_SIEVE               = 174,
    50 	GFX_SUGAR_MINE_SIEVE               = 174,
    51 	NUM_INDUSTRY_GFXES                 = 175,
    51 	NUM_INDUSTRY_GFXES                 = 175,
    52 };
    52 };
    53 
    53 
       
    54 /**
       
    55  * Get the industry ID of the given tile
       
    56  * @param t the tile to get the industry ID from
       
    57  * @pre IsTileType(t, MP_INDUSTRY)
       
    58  * @return the industry ID
       
    59  */
    54 static inline IndustryID GetIndustryIndex(TileIndex t)
    60 static inline IndustryID GetIndustryIndex(TileIndex t)
    55 {
    61 {
    56 	assert(IsTileType(t, MP_INDUSTRY));
    62 	assert(IsTileType(t, MP_INDUSTRY));
    57 	return _m[t].m2;
    63 	return _m[t].m2;
    58 }
    64 }
    59 
    65 
       
    66 /**
       
    67  * Get the industry of the given tile
       
    68  * @param t the tile to get the industry from
       
    69  * @pre IsTileType(t, MP_INDUSTRY)
       
    70  * @return the industry
       
    71  */
    60 static inline Industry* GetIndustryByTile(TileIndex t)
    72 static inline Industry* GetIndustryByTile(TileIndex t)
    61 {
    73 {
    62 	return GetIndustry(GetIndustryIndex(t));
    74 	return GetIndustry(GetIndustryIndex(t));
    63 }
    75 }
    64 
    76 
       
    77 /**
       
    78  * Is this industry tile fully built?
       
    79  * @param t the tile to analyze
       
    80  * @pre IsTileType(t, MP_INDUSTRY)
       
    81  * @return true if and only if the industry tile is fully built
       
    82  */
    65 static inline bool IsIndustryCompleted(TileIndex t)
    83 static inline bool IsIndustryCompleted(TileIndex t)
    66 {
    84 {
    67 	assert(IsTileType(t, MP_INDUSTRY));
    85 	assert(IsTileType(t, MP_INDUSTRY));
    68 	return HASBIT(_m[t].m1, 7);
    86 	return HASBIT(_m[t].m1, 7);
    69 }
    87 }
   104 {
   122 {
   105 	assert(IsTileType(tile, MP_INDUSTRY));
   123 	assert(IsTileType(tile, MP_INDUSTRY));
   106 	SB(_m[tile].m1, 0, 2, value);
   124 	SB(_m[tile].m1, 0, 2, value);
   107 }
   125 }
   108 
   126 
       
   127 /**
       
   128  * Get the industry graphics ID for the given industry tile
       
   129  * @param t the tile to get the gfx for
       
   130  * @pre IsTileType(t, MP_INDUSTRY)
       
   131  * @return the gfx ID
       
   132  */
   109 static inline IndustryGfx GetIndustryGfx(TileIndex t)
   133 static inline IndustryGfx GetIndustryGfx(TileIndex t)
   110 {
   134 {
   111 	assert(IsTileType(t, MP_INDUSTRY));
   135 	assert(IsTileType(t, MP_INDUSTRY));
   112 	return _m[t].m5;
   136 	return _m[t].m5;
   113 }
   137 }
   114 
   138 
       
   139 /**
       
   140  * Set the industry graphics ID for the given industry tile
       
   141  * @param t   the tile to set the gfx for
       
   142  * @pre IsTileType(t, MP_INDUSTRY)
       
   143  * @param gfx the graphics ID
       
   144  */
   115 static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
   145 static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
   116 {
   146 {
   117 	assert(IsTileType(t, MP_INDUSTRY));
   147 	assert(IsTileType(t, MP_INDUSTRY));
   118 	_m[t].m5 = gfx;
   148 	_m[t].m5 = gfx;
   119 }
   149 }
   120 
   150 
       
   151 /**
       
   152  * Make the given tile an industry tile
       
   153  * @param t     the tile to make an industry tile
       
   154  * @param index the industry this tile belongs to
       
   155  * @param gfx   the graphics to use for the tile
       
   156  */
   121 static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx)
   157 static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx)
   122 {
   158 {
   123 	SetTileType(t, MP_INDUSTRY);
   159 	SetTileType(t, MP_INDUSTRY);
   124 	_m[t].m1 = 0;
   160 	_m[t].m1 = 0;
   125 	_m[t].m2 = index;
   161 	_m[t].m2 = index;
   155 /**
   191 /**
   156  * Reset the construction stage counter of the industry,
   192  * Reset the construction stage counter of the industry,
   157  * as well as the completion bit.
   193  * as well as the completion bit.
   158  * In fact, it is the same as restarting construction frmo ground up
   194  * In fact, it is the same as restarting construction frmo ground up
   159  * @param tile the tile to query
   195  * @param tile the tile to query
   160  * @param generating_world whether generating a world or not
       
   161  * @pre IsTileType(tile, MP_INDUSTRY)
   196  * @pre IsTileType(tile, MP_INDUSTRY)
   162  */
   197  */
   163 static inline void ResetIndustryConstructionStage(TileIndex tile)
   198 static inline void ResetIndustryConstructionStage(TileIndex tile)
   164 {
   199 {
   165 	assert(IsTileType(tile, MP_INDUSTRY));
   200 	assert(IsTileType(tile, MP_INDUSTRY));
   166 	_m[tile].m1 = 0;
   201 	_m[tile].m1 = 0;
   167 }
   202 }
   168 
   203 
       
   204 /** Structure used to make a mapping from industry gfx to industry type */
   169 struct IndustryTypeSolver {
   205 struct IndustryTypeSolver {
   170 	IndustryGfx MinGfx;
   206 	IndustryGfx MinGfx; ///< The first gfx index for the industry type
   171 	IndustryGfx MaxGfx;
   207 	IndustryGfx MaxGfx; ///< The last gfx index for the industry type
   172 };
   208 };
   173 
   209 
   174 static const IndustryTypeSolver industry_gfx_Solver [IT_END] = {
   210 /** Mapping of industry gfx to industry type */
       
   211 static const IndustryTypeSolver industry_gfx_Solver[IT_END] = {
   175 	{  0,   6}, ///< IT_COAL_MINE
   212 	{  0,   6}, ///< IT_COAL_MINE
   176 	{  7,  10}, ///< IT_POWER_STATION,
   213 	{  7,  10}, ///< IT_POWER_STATION,
   177 	{ 11,  15}, ///< IT_SAWMILL,
   214 	{ 11,  15}, ///< IT_SAWMILL,
   178 	{ 16,  17}, ///< IT_FOREST,
   215 	{ 16,  17}, ///< IT_FOREST,
   179 	{ 18,  23}, ///< IT_OIL_REFINERY,
   216 	{ 18,  23}, ///< IT_OIL_REFINERY,
   245 }
   282 }
   246 
   283 
   247 /**
   284 /**
   248  * Set the animation state
   285  * Set the animation state
   249  * @param tile the tile to set the animation state of
   286  * @param tile the tile to set the animation state of
   250  * @param count the new animation state
   287  * @param state the new animation state
   251  * @pre IsTileType(tile, MP_INDUSTRY)
   288  * @pre IsTileType(tile, MP_INDUSTRY)
   252  */
   289  */
   253 static inline void SetIndustryAnimationState(TileIndex tile, byte state)
   290 static inline void SetIndustryAnimationState(TileIndex tile, byte state)
   254 {
   291 {
   255 	assert(IsTileType(tile, MP_INDUSTRY));
   292 	assert(IsTileType(tile, MP_INDUSTRY));