summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-01-17 01:01:56 +0000
committerfrosch <frosch@openttd.org>2010-01-17 01:01:56 +0000
commitd9d75c83d5b0839d335db453b4482fcaf306bac7 (patch)
treead207b20db255982fe6d12d77b480c3d918ad5be
parent707cf045f8703700887757ecfa4e309b61e2fd4f (diff)
downloadopenttd-d9d75c83d5b0839d335db453b4482fcaf306bac7.tar.xz
(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().
-rw-r--r--src/newgrf.cpp10
-rw-r--r--src/newgrf_commons.cpp7
-rw-r--r--src/newgrf_house.cpp2
-rw-r--r--src/newgrf_industrytiles.cpp2
-rw-r--r--src/newgrf_station.cpp2
-rw-r--r--src/sprite.cpp4
-rw-r--r--src/sprite.h9
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/table/sprites.h5
9 files changed, 20 insertions, 23 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 45d9fab37..5e4a5abdc 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -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);
}
}
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index f5be80d3b..5d6abd15a 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -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(
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 37a85fb4f..ab28d5093 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -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));
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 63a555ce5..ac1d3be8e 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -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
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 992d5d8aa..94adbe869 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -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 {
diff --git a/src/sprite.cpp b/src/sprite.cpp
index 574cc1d31..5dd7d7f00 100644
--- a/src/sprite.cpp
+++ b/src/sprite.cpp
@@ -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;
diff --git a/src/sprite.h b/src/sprite.h
index 5251f7a3b..9144fe979 100644
--- 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
index 41c21751e..3285482b4 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -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 {
diff --git a/src/table/sprites.h b/src/table/sprites.h
index aa0a033a8..4198e8b8a 100644
--- 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. */