diff options
author | rubidium <rubidium@openttd.org> | 2009-12-16 11:35:05 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-16 11:35:05 +0000 |
commit | d46127a7237ddd815872941c36bbbd6f7f379852 (patch) | |
tree | 48f7bee7b00d55ba274d1ef309dce019ea2f763c /src | |
parent | f0728ca1d16b88a9327313e115554e3c6ff0a93f (diff) | |
download | openttd-d46127a7237ddd815872941c36bbbd6f7f379852.tar.xz |
(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)
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf.cpp | 14 | ||||
-rw-r--r-- | src/newgrf_house.cpp | 9 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_spritegroup.h | 2 |
4 files changed, 14 insertions, 15 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 651c5e369..ab03023e6 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2896,13 +2896,13 @@ static void NewSpriteGroup(byte *buf, size_t len) 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 @@ static void NewSpriteGroup(byte *buf, size_t len) 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); + group->dts->seq = CallocT<DrawTileSeqStruct>(num_building_sprites + 1); - for (i = 0; i < num_sprites; i++) { + 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 @@ static void NewSpriteGroup(byte *buf, size_t len) 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); } diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 681abe4dc..6028dcc4c 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -439,14 +439,13 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id) 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); } } diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 08ecac408..5da0fbd05 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -254,12 +254,12 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus 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; } diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 056f95e35..2b337bb2f 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -270,7 +270,7 @@ struct TileLayoutSpriteGroup : SpriteGroup { 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; }; |