summaryrefslogtreecommitdiff
path: root/src/sprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sprite.cpp')
-rw-r--r--src/sprite.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/sprite.cpp b/src/sprite.cpp
index e9a83052c..ee051dc7e 100644
--- a/src/sprite.cpp
+++ b/src/sprite.cpp
@@ -32,18 +32,29 @@ void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, Transpare
{
bool parent_sprite_encountered = false;
const DrawTileSeqStruct *dtss;
+ bool skip_childs = false;
foreach_draw_tile_seq(dtss, dts->seq) {
SpriteID image = dtss->image.sprite;
+ PaletteID pal = dtss->image.pal;
+
+ if (skip_childs) {
+ if (!dtss->IsParentSprite()) continue;
+ skip_childs = false;
+ }
/* TTD sprite 0 means no sprite */
- if (GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) continue;
+ if (GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
+ skip_childs = dtss->IsParentSprite();
+ continue;
+ }
/* Stop drawing sprite sequence once we meet a sprite that doesn't have to be opaque */
if (IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE)) return;
image += (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? newgrf_offset : orig_offset);
+ if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += newgrf_offset;
- PaletteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette);
+ pal = SpriteLayoutPaletteTransform(image, pal, default_palette);
if (dtss->IsParentSprite()) {
parent_sprite_encountered = true;
@@ -86,15 +97,26 @@ void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig
const DrawTileSeqStruct *dtss;
Point child_offset = {0, 0};
+ bool skip_childs = false;
foreach_draw_tile_seq(dtss, dts->seq) {
SpriteID image = dtss->image.sprite;
+ PaletteID pal = dtss->image.pal;
+
+ if (skip_childs) {
+ if (!dtss->IsParentSprite()) continue;
+ skip_childs = false;
+ }
/* TTD sprite 0 means no sprite */
- if (GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) continue;
+ if (GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
+ skip_childs = dtss->IsParentSprite();
+ continue;
+ }
image += (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? newgrf_offset : orig_offset);
+ if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += newgrf_offset;
- PaletteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette);
+ pal = SpriteLayoutPaletteTransform(image, pal, default_palette);
if (dtss->IsParentSprite()) {
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);