diff options
author | frosch <frosch@openttd.org> | 2011-05-14 17:33:26 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-05-14 17:33:26 +0000 |
commit | e55f849a29e45227fbe9611badbdf846bbd8d866 (patch) | |
tree | f9198d1166861918462580b815d154a49eff7621 | |
parent | 7415b9cca278e86db5ba00b84aa535057279ef37 (diff) | |
download | openttd-e55f849a29e45227fbe9611badbdf846bbd8d866.tar.xz |
(svn r22457) -Codechange: Make the NewGRFSpriteLayout a direct member of TileLayoutSpriteGroup instead of allocating it separately.
-rw-r--r-- | src/newgrf.cpp | 25 | ||||
-rw-r--r-- | src/newgrf_airporttiles.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_house.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_object.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_spritegroup.cpp | 5 | ||||
-rw-r--r-- | src/newgrf_spritegroup.h | 4 |
7 files changed, 19 insertions, 25 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 0b89b81e0..f5acb8625 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3946,34 +3946,33 @@ static void NewSpriteGroup(ByteReader *buf) 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); + MapSpriteMappingRecolour(&group->dts.ground); - if (HasBit(group->dts->ground.pal, 15)) { + 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<DrawTileSeqStruct*>(&group->dts->seq[i]); + DrawTileSeqStruct *seq = const_cast<DrawTileSeqStruct*>(&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 index 5a1ba24c1..329c66075 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -264,7 +264,7 @@ uint16 GetAirportTileCallback(CallbackID callback, uint32 param1, uint32 param2, 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 index 44e0347ac..f9fb4b16b 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -412,7 +412,7 @@ uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, House 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 index 994d068f6..9d38ab5af 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -176,7 +176,7 @@ static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIn 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 index d33bc38aa..4c3b7c3e1 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -417,7 +417,7 @@ uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, cons */ 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 ObjectSpec *spec, uint8 view) 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 index 6b041f0e6..b36df7016 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -35,11 +35,6 @@ RandomizedSpriteGroup::~RandomizedSpriteGroup() free((void*)this->groups); } -TileLayoutSpriteGroup::~TileLayoutSpriteGroup() -{ - delete this->dts; -} - TemporaryStorageArray<int32, 0x110> _temp_store; diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 3d4134af3..89be1dc08 100644 --- 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 { |