Changeset - r14280:9e2593121da6
[Not reviewed]
master
0 9 0
frosch - 14 years ago 2010-01-17 01:01:56
frosch@openttd.org
(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().
9 files changed with 20 insertions and 23 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -1136,14 +1136,15 @@ static ChangeInfoResult StationChangeInf
 

	
 
					dts->seq = NULL;
 
					dts->ground.sprite = grf_load_word(&buf);
 
					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);
 

	
 
					while (buf < *bufp + len) {
 
						/* no relative bounding box support */
 
@@ -1157,16 +1158,17 @@ static ChangeInfoResult StationChangeInf
 
						dtss->size_x = grf_load_byte(&buf);
 
						dtss->size_y = grf_load_byte(&buf);
 
						dtss->size_z = grf_load_byte(&buf);
 
						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);
 
					}
 
				}
 
				break;
 
@@ -2934,12 +2936,13 @@ static void NewSpriteGroup(byte *buf, si
 
							group->dts->ground.sprite = SPR_IMG_QUERY;
 
							group->dts->ground.pal = PAL_NONE;
 
						} else {
 
							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);
 
						}
 
					}
 

	
 
					group->dts->seq = CallocT<DrawTileSeqStruct>(num_building_sprites + 1);
 

	
 
					for (i = 0; i < num_building_sprites; i++) {
 
@@ -2961,12 +2964,13 @@ static void NewSpriteGroup(byte *buf, si
 
								seq->image.sprite = SPR_IMG_QUERY;
 
								seq->image.pal = PAL_NONE;
 
							} else {
 
								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);
 
							}
 
						}
 

	
 
						if (type > 0) {
 
							seq->delta_z = grf_load_byte(&buf);
 
							if ((byte)seq->delta_z == 0x80) continue;
src/newgrf_commons.cpp
Show inline comments
 
@@ -336,20 +336,21 @@ void DrawTileSeq(const TileInfo *ti, con
 
{
 
	const DrawTileSeqStruct *dtss;
 
	foreach_draw_tile_seq(dtss, dts->seq) {
 
		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(
 
				image, pal,
 
				ti->x + dtss->delta_x, ti->y + dtss->delta_y,
 
				dtss->size_x, dtss->size_y,
src/newgrf_house.cpp
Show inline comments
 
@@ -412,13 +412,13 @@ 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));
 
	}
 

	
 
	DrawTileSeq(ti, dts, TO_HOUSES, stage, palette);
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -170,13 +170,13 @@ static void IndustryDrawTileLayout(const
 
{
 
	const DrawTileSprites *dts = group->dts;
 

	
 
	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
 
		 * Do not do this if the tile's WaterClass is 'land'. */
 
		if (image == SPR_FLAT_WATER_TILE && IsIndustryTileOnWater(ti->tile)) {
 
			DrawWaterClassGround(ti);
src/newgrf_station.cpp
Show inline comments
 
@@ -897,13 +897,13 @@ bool DrawStationTile(int x, int y, RailT
 
	} else {
 
		sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis];
 
	}
 

	
 
	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 {
 
		image += rti->total_offset;
 
	}
 

	
src/sprite.cpp
Show inline comments
 
@@ -33,13 +33,13 @@ void DrawCommonTileSeq(const TileInfo *t
 
	foreach_draw_tile_seq(dtss, dts->seq) {
 
		SpriteID image = dtss->image.sprite;
 

	
 
		/* 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;
 
		}
 

	
 
		SpriteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette);
 
@@ -72,13 +72,13 @@ void DrawCommonTileSeqInGUI(int x, int y
 
{
 
	const DrawTileSeqStruct *dtss;
 
	Point child_offset = {0, 0};
 

	
 
	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;
 
		}
 

	
 
		SpriteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette);
src/sprite.h
Show inline comments
 
@@ -17,21 +17,12 @@
 

	
 
#include "table/sprites.h"
 

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

	
 
/** A tile child sprite and palette to draw for stations etc, with 3D bounding box */
 
struct DrawTileSeqStruct {
src/station_cmd.cpp
Show inline comments
 
@@ -2424,13 +2424,13 @@ static void DrawTile_Station(TileInfo *t
 
				DrawClearLandTile(ti, 3);
 
			}
 
		}
 
	} 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 {
 
			image += total_offset;
 
		}
 
		DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette));
src/table/sprites.h
Show inline comments
 
@@ -1416,13 +1416,13 @@ enum AnimCursors {
 
 * <li> PALETTE_SPRITE_WIDTH and PALETTE_SPRITE_START determine the position and number of
 
 * bits used for the recolouring process. For transparency, it must be 0x322.</li></ul>
 
 */
 
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
 
	SPRITE_WIDTH = 24,          ///< number of bits for the sprite number
 
};
 

	
 
@@ -1432,13 +1432,14 @@ enum SpriteSetup {
 
 * the palette used for recolouring. This palette is stored
 
 * in the bits marked by PALETTE_SPRITE_MASK.
 
 * @note Do not modify this enum. Alter SpriteSetup instead
 
 * @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. */
 
	PALETTE_MODIFIER_TRANSPARENT  = TRANSPARENT_BIT,
 
	/** this bit is set when a recolouring process is in action */
 
	PALETTE_MODIFIER_COLOUR       = RECOLOUR_BIT,
0 comments (0 inline, 0 general)