Changeset - r17672:2481d27bea50
[Not reviewed]
master
0 7 0
frosch - 14 years ago 2011-05-14 17:33:26
frosch@openttd.org
(svn r22457) -Codechange: Make the NewGRFSpriteLayout a direct member of TileLayoutSpriteGroup instead of allocating it separately.
7 files changed with 20 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -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<DrawTileSeqStruct*>(&group->dts->seq[i]);
 
						DrawTileSeqStruct *seq = const_cast<DrawTileSeqStruct*>(&group->dts.seq[i]);
 

	
 
						seq->image.sprite = buf->ReadWord();
 
						seq->image.pal    = buf->ReadWord();
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -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;
src/newgrf_house.cpp
Show inline comments
 
@@ -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;
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -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;
src/newgrf_object.cpp
Show inline comments
 
@@ -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)) {
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -35,11 +35,6 @@ RandomizedSpriteGroup::~RandomizedSprite
 
	free((void*)this->groups);
 
}
 

	
 
TileLayoutSpriteGroup::~TileLayoutSpriteGroup()
 
{
 
	delete this->dts;
 
}
 

	
 
TemporaryStorageArray<int32, 0x110> _temp_store;
 

	
 

	
src/newgrf_spritegroup.h
Show inline comments
 
@@ -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 {
0 comments (0 inline, 0 general)