diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3946,34 +3946,33 @@ static void NewSpriteGroup(ByteReader *b act_group = group; /* 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 = new NewGRFSpriteLayout(); /* Groundsprite */ - group->dts->ground.sprite = buf->ReadWord(); - group->dts->ground.pal = buf->ReadWord(); + group->dts.ground.sprite = buf->ReadWord(); + group->dts.ground.pal = buf->ReadWord(); /* Remap transparent/colour modifier bits */ - MapSpriteMappingRecolour(&group->dts->ground); - - if (HasBit(group->dts->ground.pal, 15)) { + 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. */ - uint spriteset = GB(group->dts->ground.sprite, 0, 14); + 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; + 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); - SetBit(group->dts->ground.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); + SB(group->dts.ground.sprite, 0, SPRITE_WIDTH, sprite); + ClrBit(group->dts.ground.pal, 15); + SetBit(group->dts.ground.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); } } - group->dts->Allocate(num_building_sprites); + group->dts.Allocate(num_building_sprites); for (i = 0; i < num_building_sprites; i++) { - DrawTileSeqStruct *seq = const_cast(&group->dts->seq[i]); + DrawTileSeqStruct *seq = const_cast(&group->dts.seq[i]); seq->image.sprite = buf->ReadWord(); seq->image.pal = buf->ReadWord(); diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -264,7 +264,7 @@ uint16 GetAirportTileCallback(CallbackID static void AirportDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *group, byte colour, StationGfx gfx) { - const DrawTileSprites *dts = group->dts; + const DrawTileSprites *dts = &group->dts; SpriteID image = dts->ground.sprite; SpriteID pal = dts->ground.pal; diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -412,7 +412,7 @@ uint16 GetHouseCallback(CallbackID callb static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *group, byte stage, HouseID house_id) { - const DrawTileSprites *dts = group->dts; + const DrawTileSprites *dts = &group->dts; const HouseSpec *hs = HouseSpec::Get(house_id); PaletteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOUR_START; diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -176,7 +176,7 @@ static void NewIndustryTileResolver(Reso static void IndustryDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *group, byte rnd_colour, byte stage, IndustryGfx gfx) { - const DrawTileSprites *dts = group->dts; + const DrawTileSprites *dts = &group->dts; SpriteID image = dts->ground.sprite; PaletteID pal = dts->ground.pal; diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -417,7 +417,7 @@ uint16 GetObjectCallback(CallbackID call */ static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *group, const ObjectSpec *spec) { - const DrawTileSprites *dts = group->dts; + const DrawTileSprites *dts = &group->dts; PaletteID palette = ((spec->flags & OBJECT_FLAG_2CC_COLOUR) ? SPR_2CCMAP_BASE : PALETTE_RECOLOUR_START) + Object::GetByTile(ti->tile)->colour; SpriteID image = dts->ground.sprite; @@ -468,7 +468,7 @@ void DrawNewObjectTileInGUI(int x, int y const SpriteGroup *group = SpriteGroup::Resolve(GetObjectSpriteGroup(spec, NULL), &object); if (group == NULL || group->type != SGT_TILELAYOUT) return; - const DrawTileSprites *dts = ((const TileLayoutSpriteGroup *)group)->dts; + const DrawTileSprites *dts = &((const TileLayoutSpriteGroup *)group)->dts; PaletteID palette; if (Company::IsValidID(_local_company)) { diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -35,11 +35,6 @@ RandomizedSpriteGroup::~RandomizedSprite free((void*)this->groups); } -TileLayoutSpriteGroup::~TileLayoutSpriteGroup() -{ - delete this->dts; -} - TemporaryStorageArray _temp_store; diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -280,10 +280,10 @@ struct ResultSpriteGroup : SpriteGroup { struct TileLayoutSpriteGroup : SpriteGroup { TileLayoutSpriteGroup() : SpriteGroup(SGT_TILELAYOUT) {} - ~TileLayoutSpriteGroup(); + ~TileLayoutSpriteGroup() {} byte num_building_stages; ///< Number of building stages to show for this house/industry tile - NewGRFSpriteLayout *dts; + NewGRFSpriteLayout dts; }; struct IndustryProductionSpriteGroup : SpriteGroup {