diff options
author | belugas <belugas@openttd.org> | 2007-06-19 17:33:12 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2007-06-19 17:33:12 +0000 |
commit | 2ad0d708cc9aeb55bbde1becae6a631e2d23e604 (patch) | |
tree | 7dce3da428d6c168798136589729b15e8493b68d /src/industry_cmd.cpp | |
parent | 2a6b7e4e02556f00161be4ac884b74486d6a9c6e (diff) | |
download | openttd-2ad0d708cc9aeb55bbde1becae6a631e2d23e604.tar.xz |
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
Heavily based on Maedhros's newhouses implementation
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r-- | src/industry_cmd.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 4be1ef63b..1f0dfd4e9 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -30,6 +30,8 @@ #include "water_map.h" #include "tree_map.h" #include "cargotype.h" +#include "newgrf_industrytiles.h" +#include "newgrf_callbacks.h" void ShowIndustryViewWindow(int industry); void BuildOilRig(TileIndex tile); @@ -241,18 +243,32 @@ static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = { static void DrawTile_Industry(TileInfo *ti) { - const IndustryGfx gfx = GetIndustryGfx(ti->tile); - const Industry *ind; + IndustryGfx gfx = GetIndustryGfx(ti->tile); + Industry *ind = GetIndustryByTile(ti->tile); + const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); const DrawBuildingsTileStruct *dits; byte z; SpriteID image; SpriteID pal; - /* Pointer to industry */ - ind = GetIndustryByTile(ti->tile); - /* Retrieve pointer to the draw industry tile struct */ - dits = &_industry_draw_tile_data[gfx << 2 | (GetIndustryTileSpec(gfx)->anim_state ? + if (gfx >= NEW_INDUSTRYTILEOFFSET) { + /* Draw the tile using the specialized method of newgrf industrytile. + * DrawNewIndustry will return false if ever the resolver could not + * find any sprite to display. So in this case, we will jump on the + * substitute gfx instead. */ + if (indts->grf_prop.spritegroup != NULL && DrawNewIndustryTile(ti, ind, gfx, indts)) { + return; + } else { + /* No sprite group (or no valid one) found, meaning no graphics associated. + * Use the substitute one instead */ + gfx = indts->grf_prop.subst_id; + /* And point the industrytile spec accordingly */ + indts = GetIndustryTileSpec(indts->grf_prop.subst_id); + } + } + + dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ? GetIndustryAnimationState(ti->tile) & 3 : GetIndustryConstructionStage(ti->tile))]; |