(svn r18842) -Codechange: Rename SPRITE_MODIFIER_USE_OFFSET to SPRITE_MODIFIER_CUSTOM_SPRITE, invert its meaning, and also use it for industry/house layouts instead of IS_CUSTOM_SPRITE().

pull/155/head
frosch 15 years ago
parent 7b6c5faf11
commit 9bbabadd29

@ -1139,8 +1139,9 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, byte
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 StationChangeInfo(uint stid, int numinfo, int prop, byte
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, size_t len)
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, size_t len)
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);
}
}

@ -339,14 +339,15 @@ void DrawTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOpt
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(

@ -415,7 +415,7 @@ static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *grou
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));

@ -173,7 +173,7 @@ static void IndustryDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGro
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

@ -900,7 +900,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
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 {

@ -36,7 +36,7 @@ void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, Transpare
/* 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, const DrawTileSprites *dts, int32 orig
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;

@ -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): */

@ -2427,7 +2427,7 @@ static void DrawTile_Station(TileInfo *ti)
} 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 {

@ -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. */

Loading…
Cancel
Save