src/industry_cmd.cpp
changeset 6970 b489d8ec5d4a
parent 6950 14ecb0acdfb4
child 6976 1f3da800b6c2
--- a/src/industry_cmd.cpp	Tue Jun 19 17:32:01 2007 +0000
+++ b/src/industry_cmd.cpp	Tue Jun 19 17:33:12 2007 +0000
@@ -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 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 */
+	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);
+		}
+	}
 
-	/* Retrieve pointer to the draw industry tile struct */
-	dits = &_industry_draw_tile_data[gfx << 2 | (GetIndustryTileSpec(gfx)->anim_state ?
+	dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ?
 			GetIndustryAnimationState(ti->tile) & 3 :
 			GetIndustryConstructionStage(ti->tile))];