Changeset - r14326:1841c0b7ac36
[Not reviewed]
master
0 1 0
frosch - 15 years ago 2010-01-22 21:52:20
frosch@openttd.org
(svn r18889) -Codechange: Use (GroundSprite|SpriteLayout)PaletteTransform() also for drawing of default industries. They are compatible since the bubblegenerator is also randomly recoloured.
1 file changed with 3 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -289,100 +289,92 @@ static void IndustryDrawCoalPlantSparks(
 
			AddChildSpriteScreen(image + SPR_IT_POWER_PLANT_TRANSFORMERS,
 
				PAL_NONE,
 
				_coal_plant_sparks[image - 1].x,
 
				_coal_plant_sparks[image - 1].y
 
			);
 
		}
 
	}
 
}
 

	
 
typedef void IndustryDrawTileProc(const TileInfo *ti);
 
static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
 
	IndustryDrawSugarMine,
 
	IndustryDrawToffeeQuarry,
 
	IndustryDrawBubbleGenerator,
 
	IndustryDrawToyFactory,
 
	IndustryDrawCoalPlantSparks,
 
};
 

	
 
static void DrawTile_Industry(TileInfo *ti)
 
{
 
	IndustryGfx gfx = GetIndustryGfx(ti->tile);
 
	Industry *ind = Industry::GetByTile(ti->tile);
 
	const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
 
	const DrawBuildingsTileStruct *dits;
 
	SpriteID image;
 
	PaletteID 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 */
 
			if (indts->grf_prop.subst_id != INVALID_INDUSTRYTILE) {
 
				gfx = indts->grf_prop.subst_id;
 
				/* And point the industrytile spec accordingly */
 
				indts = GetIndustryTileSpec(gfx);
 
			}
 
		}
 
	}
 

	
 
	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_COLOUR) && dits->ground.pal == PAL_NONE) {
 
		pal = GENERAL_SPRITE_COLOUR(ind->random_colour);
 
	} else {
 
		pal = dits->ground.pal;
 
	}
 
	SpriteID image = dits->ground.sprite;
 

	
 
	/* DrawFoundation() modifes ti->z and ti->tileh */
 
	if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
 

	
 
	/* If the ground sprite is the default flat water sprite, draw also canal/river borders.
 
	 * Do not do this if the tile's WaterClass is 'land'. */
 
	if (image == SPR_FLAT_WATER_TILE && IsIndustryTileOnWater(ti->tile)) {
 
		DrawWaterClassGround(ti);
 
	} else {
 
		DrawGroundSprite(image, pal);
 
		DrawGroundSprite(image, GroundSpritePaletteTransform(image, dits->ground.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)));
 
	}
 

	
 
	/* If industries are transparent and invisible, do not draw the upper part */
 
	if (IsInvisibilitySet(TO_INDUSTRIES)) return;
 

	
 
	/* Add industry on top of the ground? */
 
	image = dits->building.sprite;
 
	if (image != 0) {
 
		AddSortableSpriteToDraw(image,
 
			(HasBit(image, PALETTE_MODIFIER_COLOUR) && dits->building.pal == PAL_NONE) ? GENERAL_SPRITE_COLOUR(ind->random_colour) : dits->building.pal,
 
		AddSortableSpriteToDraw(image, SpriteLayoutPaletteTransform(image, dits->building.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)),
 
			ti->x + dits->subtile_x,
 
			ti->y + dits->subtile_y,
 
			dits->width,
 
			dits->height,
 
			dits->dz,
 
			ti->z,
 
			IsTransparencySet(TO_INDUSTRIES));
 

	
 
		if (IsTransparencySet(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 Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
 
{
0 comments (0 inline, 0 general)