(svn r2845) Remove sprite size caching, it was unused
authortron
Mon, 08 Aug 2005 21:35:27 +0000
changeset 2319 9902d3ffa309
parent 2318 c54eda6b4eff
child 2320 2f9ccbae37c8
(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
spritecache.c
spritecache.h
vehicle.c
viewport.c
--- a/spritecache.c	Mon Aug 08 20:27:05 2005 +0000
+++ b/spritecache.c	Mon Aug 08 21:35:27 2005 +0000
@@ -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_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 @@
 		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 @@
 	_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 @@
 		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;
-}
-
--- a/spritecache.h	Mon Aug 08 20:27:05 2005 +0000
+++ b/spritecache.h	Mon Aug 08 21:35:27 2005 +0000
@@ -12,12 +12,6 @@
 	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)
--- a/vehicle.c	Mon Aug 08 20:27:05 2005 +0000
+++ b/vehicle.c	Mon Aug 08 21:35:27 2005 +0000
@@ -165,20 +165,18 @@
 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
--- a/viewport.c	Mon Aug 08 20:27:05 2005 +0000
+++ b/viewport.c	Mon Aug 08 21:35:27 2005 +0000
@@ -403,12 +403,12 @@
 {
 	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 @@
 {
 	ViewportDrawer *vd = _cur_vd;
 	ParentSpriteToDraw *ps;
-	const SpriteDimension *sd;
+	const Sprite* spr;
 	Point pt;
 
 	assert((image & SPRITE_MASK) < MAX_SPRITES);
@@ -462,11 +462,11 @@
 
 	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;
 	}