Changeset - r17916:2bf9901eff3f
[Not reviewed]
master
0 3 0
frosch - 13 years ago 2011-08-08 21:26:58
frosch@openttd.org
(svn r22731) -Fix: [NewGRF] The construction stage sprites were incorrectly selected in cases other than 1 or 4 sprites per set.
3 files changed with 21 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/newgrf_house.cpp
Show inline comments
 
@@ -476,7 +476,7 @@ void DrawNewHouseTile(TileInfo *ti, Hous
 
		/* Limit the building stage to the number of stages supplied. */
 
		const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
 
		byte stage = GetHouseBuildingStage(ti->tile);
 
		stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1);
 
		stage = tlgroup->GetConstructionStageOffset(stage);
 
		DrawTileLayout(ti, tlgroup, stage, house_id);
 
	}
 
}
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -263,7 +263,7 @@ bool DrawNewIndustryTile(TileInfo *ti, I
 
		/* Limit the building stage to the number of stages supplied. */
 
		const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
 
		byte stage = GetIndustryConstructionStage(ti->tile);
 
		stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1);
 
		stage = tlgroup->GetConstructionStageOffset(stage);
 
		IndustryDrawTileLayout(ti, tlgroup, i->random_colour, stage, gfx);
 
		return true;
 
	}
src/newgrf_spritegroup.h
Show inline comments
 
@@ -292,6 +292,25 @@ struct TileLayoutSpriteGroup : SpriteGro
 
	NewGRFSpriteLayout dts;
 

	
 
	const DrawTileSprites *ProcessRegisters(uint8 *stage) const;
 

	
 
	/**
 
	 * Determines which sprite to use from a spriteset for a specific construction stage.
 
	 * @param construction_stage Construction stage 0 - 3.
 
	 * @return Sprite to use
 
	 */
 
	uint GetConstructionStageOffset(uint construction_stage) const
 
	{
 
		uint num_sprites = this->num_building_stages;
 
		assert(num_sprites > 0);
 
		if (num_sprites > 4) num_sprites = 4;
 
		switch (construction_stage) {
 
			case 0: return 0;
 
			case 1: return num_sprites > 2 ? 1 : 0;
 
			case 2: return num_sprites > 2 ? num_sprites - 2 : 0;
 
			case 3: return num_sprites - 1;
 
			default: NOT_REACHED();
 
		}
 
	}
 
};
 

	
 
struct IndustryProductionSpriteGroup : SpriteGroup {
0 comments (0 inline, 0 general)