Changeset - r2319:0e8ddce44825
[Not reviewed]
master
0 4 0
tron - 19 years ago 2005-08-08 21:35:27
tron@openttd.org
(svn r2845) Remove sprite size caching, it was unused
This makes GetSpriteDimension() superflous, because now it's just a thin wrapper around GetSprite() returning only part of the information, therefore remove it too
4 files changed with 16 insertions and 72 deletions:
0 comments (0 inline, 0 general)
spritecache.c
Show inline comments
 
@@ -15,8 +15,6 @@
 

	
 
#define SPRITE_CACHE_SIZE 1024*1024
 

	
 

	
 
//#define WANT_SPRITESIZES
 
#define WANT_NEW_LRU
 

	
 

	
 
@@ -44,13 +42,6 @@ static uint16 _sprite_lru[MAX_SPRITES];
 
static uint16 _sprite_lru_cur[MAX_SPRITES];
 
#endif
 

	
 
#ifdef WANT_SPRITESIZES
 
static int8 _sprite_xoffs[MAX_SPRITES];
 
static int8 _sprite_yoffs[MAX_SPRITES];
 
static uint16 _sprite_xsize[MAX_SPRITES];
 
static uint8 _sprite_ysize[MAX_SPRITES];
 
#endif
 

	
 
typedef struct MemBlock {
 
	uint32 size;
 
	byte data[VARARRAY_SIZE];
 
@@ -116,14 +107,7 @@ static void ReadSpriteHeaderSkipData(int
 
		return;
 
	}
 

	
 
#ifdef WANT_SPRITESIZES
 
	_cur_sprite.height = FioReadByte();
 
	_cur_sprite.width = FioReadWord();
 
	_cur_sprite.x_offs = FioReadWord();
 
	_cur_sprite.y_offs = FioReadWord();
 
#else
 
	FioSkipBytes(7);
 
#endif
 
	num -= 8;
 
	if (num == 0)
 
		return;
 
@@ -253,14 +237,6 @@ static bool LoadNextSprite(int load_inde
 
	_sprite_size[load_index] = size;
 
	_sprite_file_pos[load_index] = file_pos;
 

	
 
#ifdef WANT_SPRITESIZES
 
	_sprite_xsize[load_index] = _cur_sprite.width;
 
	_sprite_ysize[load_index] = _cur_sprite.height;
 

	
 
	_sprite_xoffs[load_index] = _cur_sprite.x_offs;
 
	_sprite_yoffs[load_index] = _cur_sprite.y_offs;
 
#endif
 

	
 
	_sprite_ptr[load_index] = NULL;
 

	
 
#if defined(WANT_NEW_LRU)
 
@@ -853,27 +829,3 @@ void GfxLoadSprites(void)
 
		GfxInitPalettes();
 
	}
 
}
 

	
 

	
 
const SpriteDimension *GetSpriteDimension(SpriteID sprite)
 
{
 
	static SpriteDimension sd;
 

	
 
#ifdef WANT_SPRITESIZES
 
	sd.xoffs = _sprite_xoffs[sprite];
 
	sd.yoffs = _sprite_yoffs[sprite];
 
	sd.xsize = _sprite_xsize[sprite];
 
	sd.ysize = _sprite_ysize[sprite];
 
#else
 
	const Sprite* p = GetSprite(sprite);
 

	
 
	/* decode sprite header */
 
	sd.xoffs = p->x_offs;
 
	sd.yoffs = p->y_offs;
 
	sd.xsize = p->width;
 
	sd.ysize = p->height;
 
#endif
 

	
 
	return &sd;
 
}
 

	
spritecache.h
Show inline comments
 
@@ -12,12 +12,6 @@ typedef struct Sprite {
 
	byte data[VARARRAY_SIZE];
 
} Sprite;
 

	
 
typedef struct {
 
	int xoffs, yoffs;
 
	int xsize, ysize;
 
} SpriteDimension;
 

	
 
const SpriteDimension *GetSpriteDimension(SpriteID sprite);
 
const void *GetRawSprite(SpriteID sprite);
 

	
 
static inline const Sprite *GetSprite(SpriteID sprite)
vehicle.c
Show inline comments
 
@@ -165,20 +165,18 @@ Vehicle *FindVehicleBetween(TileIndex fr
 
void VehiclePositionChanged(Vehicle *v)
 
{
 
	int img = v->cur_image;
 
	const SpriteDimension *sd;
 
	Point pt = RemapCoords(v->x_pos + v->x_offs, v->y_pos + v->y_offs, v->z_pos);
 
	const Sprite* spr = GetSprite(img);
 

	
 
	sd = GetSpriteDimension(img);
 

	
 
	pt.x += sd->xoffs;
 
	pt.y += sd->yoffs;
 
	pt.x += spr->x_offs;
 
	pt.y += spr->y_offs;
 

	
 
	UpdateVehiclePosHash(v, pt.x, pt.y);
 

	
 
	v->left_coord = pt.x;
 
	v->top_coord = pt.y;
 
	v->right_coord = pt.x + sd->xsize + 2;
 
	v->bottom_coord = pt.y + sd->ysize + 2;
 
	v->right_coord = pt.x + spr->width + 2;
 
	v->bottom_coord = pt.y + spr->height + 2;
 
}
 

	
 
// Called after load to update coordinates
viewport.c
Show inline comments
 
@@ -403,12 +403,12 @@ static void AddCombinedSprite(uint32 ima
 
{
 
	const ViewportDrawer *vd = _cur_vd;
 
	Point pt = RemapCoords(x, y, z);
 
	const SpriteDimension *sd = GetSpriteDimension(image & SPRITE_MASK);
 
	const Sprite* spr = GetSprite(image & SPRITE_MASK);
 

	
 
	if (pt.x + sd->xoffs >= vd->dpi.left + vd->dpi.width ||
 
			pt.x + sd->xoffs + sd->xsize <= vd->dpi.left ||
 
			pt.y + sd->yoffs >= vd->dpi.top + vd->dpi.height ||
 
			pt.y + sd->yoffs + sd->ysize <= vd->dpi.top)
 
	if (pt.x + spr->x_offs >= vd->dpi.left + vd->dpi.width ||
 
			pt.x + spr->x_offs + spr->width <= vd->dpi.left ||
 
			pt.y + spr->y_offs >= vd->dpi.top + vd->dpi.height ||
 
			pt.y + spr->y_offs + spr->height <= vd->dpi.top)
 
		return;
 

	
 
	AddChildSpriteScreen(image, pt.x - vd->parent_list[-1]->left, pt.y - vd->parent_list[-1]->top);
 
@@ -419,7 +419,7 @@ void AddSortableSpriteToDraw(uint32 imag
 
{
 
	ViewportDrawer *vd = _cur_vd;
 
	ParentSpriteToDraw *ps;
 
	const SpriteDimension *sd;
 
	const Sprite* spr;
 
	Point pt;
 

	
 
	assert((image & SPRITE_MASK) < MAX_SPRITES);
 
@@ -462,11 +462,11 @@ void AddSortableSpriteToDraw(uint32 imag
 

	
 
	pt = RemapCoords(x, y, z);
 

	
 
	sd = GetSpriteDimension(image & SPRITE_MASK);
 
	if ((ps->left = (pt.x += sd->xoffs)) >= vd->dpi.left + vd->dpi.width ||
 
			(ps->right = (pt.x + sd->xsize)) <= vd->dpi.left ||
 
			(ps->top = (pt.y += sd->yoffs)) >= vd->dpi.top + vd->dpi.height ||
 
			(ps->bottom = (pt.y + sd->ysize)) <= vd->dpi.top) {
 
	spr = GetSprite(image & SPRITE_MASK);
 
	if ((ps->left   = (pt.x += spr->x_offs)) >= vd->dpi.left + vd->dpi.width ||
 
			(ps->right  = (pt.x +  spr->width )) <= vd->dpi.left ||
 
			(ps->top    = (pt.y += spr->y_offs)) >= vd->dpi.top + vd->dpi.height ||
 
			(ps->bottom = (pt.y +  spr->height)) <= vd->dpi.top) {
 
		return;
 
	}
 

	
0 comments (0 inline, 0 general)