summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spritecache.c48
-rw-r--r--spritecache.h6
-rw-r--r--vehicle.c12
-rw-r--r--viewport.c22
4 files changed, 16 insertions, 72 deletions
diff --git a/spritecache.c b/spritecache.c
index c824e053f..8edbeed09 100644
--- a/spritecache.c
+++ b/spritecache.c
@@ -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 num, int load_index)
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_index, byte file_index)
_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;
-}
-
diff --git a/spritecache.h b/spritecache.h
index 3e24c0f0a..9d25f2bc7 100644
--- a/spritecache.h
+++ b/spritecache.h
@@ -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)
diff --git a/vehicle.c b/vehicle.c
index 2d09e8db7..26be2b995 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -165,20 +165,18 @@ Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z)
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
diff --git a/viewport.c b/viewport.c
index a7c82edf0..c3cc10834 100644
--- a/viewport.c
+++ b/viewport.c
@@ -403,12 +403,12 @@ static void AddCombinedSprite(uint32 image, int x, int y, byte z)
{
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 image, int x, int y, int w, int h, byte dz,
{
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 image, int x, int y, int w, int h, byte dz,
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;
}