@@ -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;
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)) {
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);
seq->image.sprite = SPR_IMG_QUERY;
seq->image.pal = PAL_NONE;
if (type > 0) {
seq->delta_z = grf_load_byte(&buf);
if ((byte)seq->delta_z == 0x80) continue;
@@ -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;
/* Limit the building stage to the number of stages supplied. */
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);
@@ -250,17 +250,17 @@ bool DrawNewIndustryTile(TileInfo *ti, I
NewIndustryTileResolver(&object, gfx, ti->tile, i);
group = SpriteGroup::Resolve(inds->grf_prop.spritegroup, &object);
return false;
byte stage = GetIndustryConstructionStage(ti->tile);
IndustryDrawTileLayout(ti, tlgroup, i->random_colour, stage, gfx);
return true;
Status change: