File diff r7332:5ef3101b123d → r7333:94b25d4d956c
src/industry_cmd.cpp
Show inline comments
 
@@ -254,112 +254,105 @@ static void DrawTile_Industry(TileInfo *
 
	IndustryGfx gfx = GetIndustryGfx(ti->tile);
 
	Industry *ind = GetIndustryByTile(ti->tile);
 
	const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
 
	const DrawBuildingsTileStruct *dits;
 
	byte z;
 
	SpriteID image;
 
	SpriteID pal;
 

	
 
	/* 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);
 
		}
 
	}
 

	
 
	dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ?
 
			GetIndustryAnimationState(ti->tile) & INDUSTRY_COMPLETED :
 
			GetIndustryConstructionStage(ti->tile))];
 

	
 
	image = dits->ground.sprite;
 
	if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->ground.pal == PAL_NONE) {
 
		pal = GENERAL_SPRITE_COLOR(ind->random_color);
 
	} else {
 
		pal = dits->ground.pal;
 
	}
 

	
 
	z = ti->z;
 
	/* Add bricks below the industry? */
 
	if (ti->tileh != SLOPE_FLAT) {
 
		DrawFoundation(ti, ti->tileh);
 
		z += TILE_HEIGHT;
 
	}
 

	
 
	DrawGroundSprite(image, pal);
 

	
 
	/* Add industry on top of the ground? */
 
	image = dits->building.sprite;
 
	if (image != 0) {
 
		if (HASBIT(_transparent_opt, TO_INDUSTRIES)) {
 
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
 
			pal = PALETTE_TO_TRANSPARENT;
 
		} else if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->building.pal == PAL_NONE) {
 
			pal = GENERAL_SPRITE_COLOR(ind->random_color);
 
		} else {
 
			pal = dits->building.pal;
 
		}
 

	
 
		AddSortableSpriteToDraw(image, pal,
 
		AddSortableSpriteToDraw(image,
 
			(HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->building.pal == PAL_NONE) ? GENERAL_SPRITE_COLOR(ind->random_color) : dits->building.pal,
 
			ti->x + dits->subtile_x,
 
			ti->y + dits->subtile_y,
 
			dits->width  + 1,
 
			dits->height + 1,
 
			dits->dz,
 
			z);
 
			z,
 
			HASBIT(_transparent_opt, TO_INDUSTRIES));
 

	
 
		if (HASBIT(_transparent_opt, TO_INDUSTRIES)) return;
 
	}
 

	
 
	{
 
		int proc = dits->draw_proc - 1;
 
		if (proc >= 0) _industry_draw_tile_procs[proc](ti);
 
	}
 
}
 

	
 
static uint GetSlopeZ_Industry(TileIndex tile, uint x, uint y)
 
{
 
	return GetTileMaxZ(tile);
 
}
 

	
 
static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh)
 
{
 
	return SLOPE_FLAT;
 
}
 

	
 
static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac)
 
{
 
	IndustryGfx gfx = GetIndustryGfx(tile);
 
	const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
 

	
 
	/* When we have to use a callback, we put our data in the next two variables */
 
	CargoID raw_accepts_cargo[lengthof(itspec->accepts_cargo)];
 
	uint8 raw_acceptance[lengthof(itspec->acceptance)];
 

	
 
	/* And then these will always point to a same sized array with the required data */
 
	const CargoID *accepts_cargo = itspec->accepts_cargo;
 
	const uint8 *acceptance = itspec->acceptance;
 

	
 
	if (HASBIT(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) {
 
		uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile);
 
		if (res != CALLBACK_FAILED) {
 
			accepts_cargo = raw_accepts_cargo;
 
			for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile);
 
		}
 
	}
 

	
 
	if (HASBIT(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) {
 
		uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile);
 
		if (res != CALLBACK_FAILED) {
 
			acceptance = raw_acceptance;
 
			for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_acceptance[i] = GB(res, i * 4, 4);
 
		}
 
	}