diff options
author | frosch <frosch@openttd.org> | 2008-11-22 16:04:11 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-11-22 16:04:11 +0000 |
commit | 259a073f0c16dccdace6dced05d955e15de080d9 (patch) | |
tree | 3eae77104f99b355105a041898cd4174c1d8031f /src/newgrf_house.cpp | |
parent | f0286cb1e57a53b5be8565a325fdd7383cf6fc6f (diff) | |
download | openttd-259a073f0c16dccdace6dced05d955e15de080d9.tar.xz |
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
-Fix [FS#2419]: The modifiers were not applied in all cases.
Diffstat (limited to 'src/newgrf_house.cpp')
-rw-r--r-- | src/newgrf_house.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 79bb20259..f112936f0 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -426,12 +426,24 @@ static void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte st const DrawTileSprites *dts = group->g.layout.dts; const DrawTileSeqStruct *dtss; + const HouseSpec *hs = GetHouseSpecs(house_id); + SpriteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOR_START; + if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) { + uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile); + if (callback != CALLBACK_FAILED) { + /* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ + palette = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; + } + } + SpriteID image = dts->ground.sprite; SpriteID pal = dts->ground.pal; if (IS_CUSTOM_SPRITE(image)) image += stage; - if (GB(image, 0, SPRITE_WIDTH) != 0) DrawGroundSprite(image, pal); + if (GB(image, 0, SPRITE_WIDTH) != 0) { + DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette)); + } foreach_draw_tile_seq(dtss, dts->seq) { if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue; @@ -444,21 +456,7 @@ static void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte st if (IS_CUSTOM_SPRITE(image)) image += stage; - if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOR)) { - if (pal == 0) { - const HouseSpec *hs = GetHouseSpecs(house_id); - pal = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOR_START; - if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) { - uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile); - if (callback != CALLBACK_FAILED) { - /* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ - pal = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; - } - } - } - } else { - pal = PAL_NONE; - } + pal = SpriteLayoutPaletteTransform(image, pal, palette); if ((byte)dtss->delta_z != 0x80) { AddSortableSpriteToDraw( |