Changeset - r14200:1807a9ce785f
[Not reviewed]
master
0 3 0
frosch - 15 years ago 2010-01-08 20:42:12
frosch@openttd.org
(svn r18761) -Fix [FS#3497]: Spritelayouts do not need an Action 1 if only using default sprites.
3 files changed with 28 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -2905,34 +2905,43 @@ static void NewSpriteGroup(byte *buf, si
 

	
 
					break;
 
				}
 

	
 
				case GSF_TOWNHOUSE:
 
				case GSF_INDUSTRYTILES: {
 
					byte num_sprite_sets      = _cur_grffile->spriteset_numents;
 
					byte num_spriteset_ents   = _cur_grffile->spriteset_numents;
 
					byte num_spritesets       = _cur_grffile->spriteset_numsets;
 
					byte num_building_sprites = max((uint8)1, type);
 
					uint i;
 

	
 
					TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup();
 
					act_group = group;
 
					group->num_building_stages = num_sprite_sets;
 
					/* num_building_stages should be 1, if we are only using non-custom sprites */
 
					group->num_building_stages = max((uint8)1, num_spriteset_ents);
 
					group->dts = CallocT<DrawTileSprites>(1);
 

	
 
					/* Groundsprite */
 
					group->dts->ground.sprite = grf_load_word(&buf);
 
					group->dts->ground.pal    = grf_load_word(&buf);
 

	
 
					/* Remap transparent/colour modifier bits */
 
					MapSpriteMappingRecolour(&group->dts->ground);
 

	
 
					if (HasBit(group->dts->ground.pal, 15)) {
 
						/* Bit 31 set means this is a custom sprite, so rewrite it to the
 
						 * last spriteset defined. */
 
						SpriteID sprite = _cur_grffile->spriteset_start + GB(group->dts->ground.sprite, 0, 14) * num_sprite_sets;
 
						SB(group->dts->ground.sprite, 0, SPRITE_WIDTH, sprite);
 
						ClrBit(group->dts->ground.pal, 15);
 
						uint spriteset = GB(group->dts->ground.sprite, 0, 14);
 
						if (num_spriteset_ents == 0 || spriteset >= num_spritesets) {
 
							grfmsg(1, "NewSpriteGroup: Spritelayout uses undefined custom spriteset %d", spriteset);
 
							group->dts->ground.sprite = SPR_IMG_QUERY;
 
							group->dts->ground.pal = PAL_NONE;
 
						} else {
 
							SpriteID sprite = _cur_grffile->spriteset_start + spriteset * num_spriteset_ents;
 
							SB(group->dts->ground.sprite, 0, SPRITE_WIDTH, sprite);
 
							ClrBit(group->dts->ground.pal, 15);
 
						}
 
					}
 

	
 
					group->dts->seq = CallocT<DrawTileSeqStruct>(num_building_sprites + 1);
 

	
 
					for (i = 0; i < num_building_sprites; i++) {
 
						DrawTileSeqStruct *seq = const_cast<DrawTileSeqStruct*>(&group->dts->seq[i]);
 
@@ -2944,15 +2953,22 @@ static void NewSpriteGroup(byte *buf, si
 

	
 
						MapSpriteMappingRecolour(&seq->image);
 

	
 
						if (HasBit(seq->image.pal, 15)) {
 
							/* Bit 31 set means this is a custom sprite, so rewrite it to the
 
							 * last spriteset defined. */
 
							SpriteID sprite = _cur_grffile->spriteset_start + GB(seq->image.sprite, 0, 14) * num_sprite_sets;
 
							SB(seq->image.sprite, 0, SPRITE_WIDTH, sprite);
 
							ClrBit(seq->image.pal, 15);
 
							uint spriteset = GB(seq->image.sprite, 0, 14);
 
							if (num_spriteset_ents == 0 || spriteset >= num_spritesets) {
 
								grfmsg(1, "NewSpriteGroup: Spritelayout uses undefined custom spriteset %d", spriteset);
 
								seq->image.sprite = SPR_IMG_QUERY;
 
								seq->image.pal = PAL_NONE;
 
							} else {
 
								SpriteID sprite = _cur_grffile->spriteset_start + spriteset * num_spriteset_ents;
 
								SB(seq->image.sprite, 0, SPRITE_WIDTH, sprite);
 
								ClrBit(seq->image.pal, 15);
 
							}
 
						}
 

	
 
						if (type > 0) {
 
							seq->delta_z = grf_load_byte(&buf);
 
							if ((byte)seq->delta_z == 0x80) continue;
 
						}
src/newgrf_house.cpp
Show inline comments
 
@@ -469,17 +469,17 @@ void DrawNewHouseTile(TileInfo *ti, Hous
 
		if (draw_old_one) DrawFoundation(ti, FOUNDATION_LEVELED);
 
	}
 

	
 
	NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile));
 

	
 
	group = SpriteGroup::Resolve(hs->spritegroup, &object);
 
	const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
 
	if (group == NULL || group->type != SGT_TILELAYOUT || tlgroup->num_building_stages == 0) {
 
	if (group == NULL || group->type != SGT_TILELAYOUT) {
 
		return;
 
	} else {
 
		/* 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);
 
		DrawTileLayout(ti, tlgroup, stage, house_id);
 
	}
 
}
 

	
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -250,17 +250,17 @@ bool DrawNewIndustryTile(TileInfo *ti, I
 
		if (draw_old_one) DrawFoundation(ti, FOUNDATION_LEVELED);
 
	}
 

	
 
	NewIndustryTileResolver(&object, gfx, ti->tile, i);
 

	
 
	group = SpriteGroup::Resolve(inds->grf_prop.spritegroup, &object);
 
	const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group;
 
	if (group == NULL || group->type != SGT_TILELAYOUT || tlgroup->num_building_stages == 0) {
 
	if (group == NULL || group->type != SGT_TILELAYOUT) {
 
		return false;
 
	} else {
 
		/* 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);
 
		IndustryDrawTileLayout(ti, tlgroup, i->random_colour, stage, gfx);
 
		return true;
 
	}
 
}
0 comments (0 inline, 0 general)