mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-12 01:24:54 +00:00
(svn r22457) -Codechange: Make the NewGRFSpriteLayout a direct member of TileLayoutSpriteGroup instead of allocating it separately.
This commit is contained in:
parent
7415b9cca2
commit
e55f849a29
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -35,11 +35,6 @@ RandomizedSpriteGroup::~RandomizedSpriteGroup()
|
||||
free((void*)this->groups);
|
||||
}
|
||||
|
||||
TileLayoutSpriteGroup::~TileLayoutSpriteGroup()
|
||||
{
|
||||
delete this->dts;
|
||||
}
|
||||
|
||||
TemporaryStorageArray<int32, 0x110> _temp_store;
|
||||
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user