28 #include "genworld.h" |
28 #include "genworld.h" |
29 #include "date.h" |
29 #include "date.h" |
30 #include "water_map.h" |
30 #include "water_map.h" |
31 #include "tree_map.h" |
31 #include "tree_map.h" |
32 #include "cargotype.h" |
32 #include "cargotype.h" |
|
33 #include "newgrf_industrytiles.h" |
|
34 #include "newgrf_callbacks.h" |
33 |
35 |
34 void ShowIndustryViewWindow(int industry); |
36 void ShowIndustryViewWindow(int industry); |
35 void BuildOilRig(TileIndex tile); |
37 void BuildOilRig(TileIndex tile); |
36 |
38 |
37 static byte _industry_sound_ctr; |
39 static byte _industry_sound_ctr; |
239 IndustryDrawCoalPlantSparks, |
241 IndustryDrawCoalPlantSparks, |
240 }; |
242 }; |
241 |
243 |
242 static void DrawTile_Industry(TileInfo *ti) |
244 static void DrawTile_Industry(TileInfo *ti) |
243 { |
245 { |
244 const IndustryGfx gfx = GetIndustryGfx(ti->tile); |
246 IndustryGfx gfx = GetIndustryGfx(ti->tile); |
245 const Industry *ind; |
247 Industry *ind = GetIndustryByTile(ti->tile); |
|
248 const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); |
246 const DrawBuildingsTileStruct *dits; |
249 const DrawBuildingsTileStruct *dits; |
247 byte z; |
250 byte z; |
248 SpriteID image; |
251 SpriteID image; |
249 SpriteID pal; |
252 SpriteID pal; |
250 |
253 |
251 /* Pointer to industry */ |
|
252 ind = GetIndustryByTile(ti->tile); |
|
253 |
|
254 /* Retrieve pointer to the draw industry tile struct */ |
254 /* Retrieve pointer to the draw industry tile struct */ |
255 dits = &_industry_draw_tile_data[gfx << 2 | (GetIndustryTileSpec(gfx)->anim_state ? |
255 if (gfx >= NEW_INDUSTRYTILEOFFSET) { |
|
256 /* Draw the tile using the specialized method of newgrf industrytile. |
|
257 * DrawNewIndustry will return false if ever the resolver could not |
|
258 * find any sprite to display. So in this case, we will jump on the |
|
259 * substitute gfx instead. */ |
|
260 if (indts->grf_prop.spritegroup != NULL && DrawNewIndustryTile(ti, ind, gfx, indts)) { |
|
261 return; |
|
262 } else { |
|
263 /* No sprite group (or no valid one) found, meaning no graphics associated. |
|
264 * Use the substitute one instead */ |
|
265 gfx = indts->grf_prop.subst_id; |
|
266 /* And point the industrytile spec accordingly */ |
|
267 indts = GetIndustryTileSpec(indts->grf_prop.subst_id); |
|
268 } |
|
269 } |
|
270 |
|
271 dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ? |
256 GetIndustryAnimationState(ti->tile) & 3 : |
272 GetIndustryAnimationState(ti->tile) & 3 : |
257 GetIndustryConstructionStage(ti->tile))]; |
273 GetIndustryConstructionStage(ti->tile))]; |
258 |
274 |
259 image = dits->ground.sprite; |
275 image = dits->ground.sprite; |
260 if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->ground.pal == PAL_NONE) { |
276 if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->ground.pal == PAL_NONE) { |