Mercurial > hg > openttd
changeset 13976:9e8eabc11352 draft
(svn r18514) -Codechange: make it a bit clearer that for tile layouts num_sprites (as in number of sprite sets) is not the same as num_sprites (as in number of building sprites)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 16 Dec 2009 11:35:05 +0000 |
parents | e8007147592b |
children | bb2258bdc43d |
files | src/newgrf.cpp src/newgrf_house.cpp src/newgrf_industrytiles.cpp src/newgrf_spritegroup.h |
diffstat | 4 files changed, 15 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2896,13 +2896,13 @@ case GSF_TOWNHOUSE: case GSF_INDUSTRYTILES: { - byte sprites = _cur_grffile->spriteset_numents; - byte num_sprites = max((uint8)1, type); + byte num_sprite_sets = _cur_grffile->spriteset_numents; + byte num_building_sprites = max((uint8)1, type); uint i; TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup(); act_group = group; - group->num_sprites = sprites; + group->num_building_stages = num_sprite_sets; group->dts = CallocT<DrawTileSprites>(1); /* Groundsprite */ @@ -2915,14 +2915,14 @@ 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) * sprites; + 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); } - group->dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1); - - for (i = 0; i < num_sprites; i++) { + 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]); seq->image.sprite = grf_load_word(&buf); @@ -2935,7 +2935,7 @@ if (HasBit(seq->image.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(seq->image.sprite, 0, 14) * sprites; + 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); }
--- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -439,14 +439,13 @@ NewHouseResolver(&object, house_id, ti->tile, Town::GetByTile(ti->tile)); group = SpriteGroup::Resolve(hs->spritegroup, &object); - if (group == NULL || group->type != SGT_TILELAYOUT) { - /* XXX: This is for debugging purposes really, and shouldn't stay. */ - DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE); + const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group; + if (group == NULL || group->type != SGT_TILELAYOUT || tlgroup->num_building_stages == 0) { + return; } else { - const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group; /* Limit the building stage to the number of stages supplied. */ byte stage = GetHouseBuildingStage(ti->tile); - stage = Clamp(stage - 4 + tlgroup->num_sprites, 0, tlgroup->num_sprites - 1); + stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1); DrawTileLayout(ti, tlgroup, stage, house_id); } }
--- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -254,12 +254,12 @@ group = SpriteGroup::Resolve(inds->grf_prop.spritegroup, &object); const TileLayoutSpriteGroup *tlgroup = (const TileLayoutSpriteGroup *)group; - if (group == NULL || group->type != SGT_TILELAYOUT || tlgroup->num_sprites == 0) { + if (group == NULL || group->type != SGT_TILELAYOUT || tlgroup->num_building_stages == 0) { return false; } else { /* Limit the building stage to the number of stages supplied. */ byte stage = GetIndustryConstructionStage(ti->tile); - stage = Clamp(stage - 4 + tlgroup->num_sprites, 0, tlgroup->num_sprites - 1); + stage = Clamp(stage - 4 + tlgroup->num_building_stages, 0, tlgroup->num_building_stages - 1); IndustryDrawTileLayout(ti, tlgroup, i->random_colour, stage, gfx); return true; }
--- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -270,7 +270,7 @@ TileLayoutSpriteGroup() : SpriteGroup(SGT_TILELAYOUT) {} ~TileLayoutSpriteGroup(); - byte num_sprites; ///< Number of sprites in the spriteset, used for loading stages + byte num_building_stages; ///< Number of building stages to show for this house/industry tile struct DrawTileSprites *dts; };