diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1139,8 +1139,9 @@ static ChangeInfoResult StationChangeInf dts->ground.pal = grf_load_word(&buf); if (dts->ground.sprite == 0) continue; if (HasBit(dts->ground.pal, 15)) { + /* Use sprite from Action 1 */ ClrBit(dts->ground.pal, 15); - SetBit(dts->ground.sprite, SPRITE_MODIFIER_USE_OFFSET); + SetBit(dts->ground.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); } MapSpriteMappingRecolour(&dts->ground); @@ -1160,10 +1161,11 @@ static ChangeInfoResult StationChangeInf dtss->image.sprite = grf_load_word(&buf); dtss->image.pal = grf_load_word(&buf); - /* Remap flags as ours collide */ if (HasBit(dtss->image.pal, 15)) { ClrBit(dtss->image.pal, 15); - SetBit(dtss->image.sprite, SPRITE_MODIFIER_USE_OFFSET); + } else { + /* Use sprite from Action 1 (yes, this is inverse to above) */ + SetBit(dtss->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); } MapSpriteMappingRecolour(&dtss->image); @@ -2937,6 +2939,7 @@ static void NewSpriteGroup(byte *buf, si SpriteID sprite = _cur_grffile->spriteset_start + spriteset * num_spriteset_ents; SB(group->dts->ground.sprite, 0, SPRITE_WIDTH, sprite); ClrBit(group->dts->ground.pal, 15); + SetBit(group->dts->ground.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); } } @@ -2964,6 +2967,7 @@ static void NewSpriteGroup(byte *buf, si SpriteID sprite = _cur_grffile->spriteset_start + spriteset * num_spriteset_ents; SB(seq->image.sprite, 0, SPRITE_WIDTH, sprite); ClrBit(seq->image.pal, 15); + SetBit(seq->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); } } diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -339,14 +339,15 @@ void DrawTileSeq(const TileInfo *ti, con if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue; SpriteID image = dtss->image.sprite; - SpriteID pal = dtss->image.pal; /* 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; - if (IS_CUSTOM_SPRITE(image)) image += stage; + if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { + image += stage; + } - pal = SpriteLayoutPaletteTransform(image, pal, default_palette); + SpriteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette); if ((byte)dtss->delta_z != 0x80) { AddSortableSpriteToDraw( diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -415,7 +415,7 @@ static void DrawTileLayout(const TileInf SpriteID image = dts->ground.sprite; SpriteID pal = dts->ground.pal; - if (IS_CUSTOM_SPRITE(image)) image += stage; + if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) image += stage; if (GB(image, 0, SPRITE_WIDTH) != 0) { DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette)); diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -173,7 +173,7 @@ static void IndustryDrawTileLayout(const SpriteID image = dts->ground.sprite; SpriteID pal = dts->ground.pal; - if (IS_CUSTOM_SPRITE(image)) image += stage; + if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) image += stage; if (GB(image, 0, SPRITE_WIDTH) != 0) { /* If the ground sprite is the default flat water sprite, draw also canal/river borders diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -900,7 +900,7 @@ bool DrawStationTile(int x, int y, RailT SpriteID image = sprites->ground.sprite; SpriteID pal = sprites->ground.pal; - if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { + if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); image += rti->custom_ground_offset; } else { diff --git a/src/sprite.cpp b/src/sprite.cpp --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -36,7 +36,7 @@ void DrawCommonTileSeq(const TileInfo *t /* 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; - if (newgrf_offset == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { + if (newgrf_offset == 0 || !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { image += orig_offset; } else { image += newgrf_offset; @@ -75,7 +75,7 @@ void DrawCommonTileSeqInGUI(int x, int y foreach_draw_tile_seq(dtss, dts->seq) { SpriteID image = dtss->image.sprite; - if (newgrf_offset == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { + if (newgrf_offset == 0 || !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { image += orig_offset; } else { image += newgrf_offset; diff --git a/src/sprite.h b/src/sprite.h --- a/src/sprite.h +++ b/src/sprite.h @@ -20,15 +20,6 @@ #define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START) #define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner])) -/** - * Whether a sprite comes from the original graphics files or a new grf file - * (either supplied by OpenTTD or supplied by the user). - * - * @param sprite The sprite to check - * @return True if it is a new sprite, or false if it is original. - */ -#define IS_CUSTOM_SPRITE(sprite) ((sprite) >= SPR_SIGNALS_BASE) - /* The following describes bunch of sprites to be drawn together in a single 3D * bounding box. Used especially for various multi-sprite buildings (like * depots or stations): */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2427,7 +2427,7 @@ static void DrawTile_Station(TileInfo *t } else { SpriteID image = t->ground.sprite; SpriteID pal = t->ground.pal; - if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { + if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) { image += GetCustomStationGroundRelocation(statspec, st, ti->tile); image += custom_ground_offset; } else { diff --git a/src/table/sprites.h b/src/table/sprites.h --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -1419,7 +1419,7 @@ enum AnimCursors { enum SpriteSetup { TRANSPARENT_BIT = 31, ///< toggles transparency in the sprite RECOLOUR_BIT = 30, ///< toggles recolouring in the sprite - OFFSET_BIT = 29, + CUSTOM_BIT = 29, OPAQUE_BIT = 28, PALETTE_WIDTH = 24, ///< number of bits of the sprite containing the recolour palette @@ -1435,7 +1435,8 @@ enum SpriteSetup { * @see SpriteSetup */ enum Modifiers { - SPRITE_MODIFIER_USE_OFFSET = OFFSET_BIT, + /** Set when a sprite originates from an Action 1 */ + SPRITE_MODIFIER_CUSTOM_SPRITE = CUSTOM_BIT, /** Set when a sprite must not ever be displayed transparently */ SPRITE_MODIFIER_OPAQUE = OPAQUE_BIT, /** when a sprite is to be displayed transparently, this bit needs to be set. */