diff options
author | rubidium <rubidium@openttd.org> | 2007-07-26 14:07:11 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-26 14:07:11 +0000 |
commit | 02ab86631e59bc247b9f01c21b69e6f6b99a0d3f (patch) | |
tree | f9ea4c50fe8ce5b57839ce0b5407aac9a6f2b452 /src/viewport.cpp | |
parent | d031da78d8271b8d57a0e2cd33b6c7d6e4231421 (diff) | |
download | openttd-02ab86631e59bc247b9f01c21b69e6f6b99a0d3f.tar.xz |
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r-- | src/viewport.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index 289e12900..528d51abc 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -478,8 +478,18 @@ static void AddCombinedSprite(SpriteID image, SpriteID pal, int x, int y, byte z AddChildSpriteScreen(image, pal, pt.x - vd->parent_list[-1]->left, pt.y - vd->parent_list[-1]->top); } - -void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z) +/** Draw a (transparent) sprite at given coordinates + * @param image the image to combine and draw, + * @param pal the provided palette, + * @param x position x of the sprite, + * @param y position y of the sprite, + * @param w width of the sprite, + * @param h height of the sprite, + * @param dz delta z, difference of elevation between sprite and parent sprite, + * @param z elevation of the sprite, + * @param transparent if true, switch the palette between the provided palette and the transparent palette + */ +void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z, bool transparent) { ViewportDrawer *vd = _cur_vd; ParentSpriteToDraw *ps; @@ -488,6 +498,12 @@ void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, assert((image & SPRITE_MASK) < MAX_SPRITES); + /* make the sprites transparent with the right palette */ + if (transparent) { + SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); + pal = PALETTE_TO_TRANSPARENT; + } + if (vd->combine_sprites == 2) { AddCombinedSprite(image, pal, x, y, z); return; |