mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-24 16:09:30 +00:00
(svn r1858) Let ReadSprite() handle the subtleties of loading a sprite, not its caller
This commit is contained in:
parent
1b617b28fc
commit
5c946cdbd8
@ -149,13 +149,16 @@ static void ReadSpriteHeaderSkipData(int num, int load_index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadSprite(int num, byte *dest)
|
static void ReadSprite(SpriteID id, byte *dest)
|
||||||
{
|
{
|
||||||
|
uint num = _sprite_size[id];
|
||||||
byte type;
|
byte type;
|
||||||
byte *rel;
|
byte *rel;
|
||||||
int8 i;
|
int8 i;
|
||||||
int dist;
|
int dist;
|
||||||
|
|
||||||
|
FioSeekToFile(_sprite_file_pos[id]);
|
||||||
|
|
||||||
type = FioReadByte();
|
type = FioReadByte();
|
||||||
/* We've decoded special sprites when reading headers. */
|
/* We've decoded special sprites when reading headers. */
|
||||||
if (type != 0xFF) {
|
if (type != 0xFF) {
|
||||||
@ -163,6 +166,7 @@ static void ReadSprite(int num, byte *dest)
|
|||||||
Sprite* sprite = dest;
|
Sprite* sprite = dest;
|
||||||
sprite->info = type;
|
sprite->info = type;
|
||||||
sprite->height = FioReadByte();
|
sprite->height = FioReadByte();
|
||||||
|
if (id == 142) sprite->height = 10; // Compensate for a TTD bug
|
||||||
sprite->width = FioReadWord();
|
sprite->width = FioReadWord();
|
||||||
sprite->x_offs = FioReadWord();
|
sprite->x_offs = FioReadWord();
|
||||||
sprite->y_offs = FioReadWord();
|
sprite->y_offs = FioReadWord();
|
||||||
@ -625,11 +629,7 @@ static byte *LoadSpriteToMem(int sprite)
|
|||||||
|
|
||||||
_sprite_ptr[sprite] = s->data;
|
_sprite_ptr[sprite] = s->data;
|
||||||
|
|
||||||
FioSeekToFile(_sprite_file_pos[sprite]);
|
ReadSprite(sprite, s->data);
|
||||||
ReadSprite(_sprite_size[sprite], s->data);
|
|
||||||
|
|
||||||
// Patch the height to compensate for a TTD bug?
|
|
||||||
if (sprite == 142) s->data[1] = 10;
|
|
||||||
|
|
||||||
// Return sprite ptr
|
// Return sprite ptr
|
||||||
return s->data;
|
return s->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user