mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-07 06:39:08 +00:00
(svn r2847) Don't remember the size of sprites during initialisation. Since the sprite loading was altered this is no longer necessary.
While here remove another write-only variable (_spritecache_size) and fix a comment (sprite replaces a lowercase letter instead of uppercase)
This commit is contained in:
parent
bed459d5d3
commit
8f398f2f50
@ -32,7 +32,6 @@ static Sprite _cur_sprite;
|
|||||||
|
|
||||||
|
|
||||||
static void* _sprite_ptr[MAX_SPRITES];
|
static void* _sprite_ptr[MAX_SPRITES];
|
||||||
static uint16 _sprite_size[MAX_SPRITES];
|
|
||||||
static uint32 _sprite_file_pos[MAX_SPRITES];
|
static uint32 _sprite_file_pos[MAX_SPRITES];
|
||||||
|
|
||||||
#if defined(WANT_NEW_LRU)
|
#if defined(WANT_NEW_LRU)
|
||||||
@ -49,7 +48,6 @@ typedef struct MemBlock {
|
|||||||
|
|
||||||
static uint _sprite_lru_counter;
|
static uint _sprite_lru_counter;
|
||||||
static MemBlock *_spritecache_ptr;
|
static MemBlock *_spritecache_ptr;
|
||||||
static uint32 _spritecache_size;
|
|
||||||
static int _compact_cache_counter;
|
static int _compact_cache_counter;
|
||||||
|
|
||||||
typedef struct MD5File {
|
typedef struct MD5File {
|
||||||
@ -133,12 +131,12 @@ static void* AllocSprite(size_t);
|
|||||||
|
|
||||||
static void* ReadSprite(SpriteID id)
|
static void* ReadSprite(SpriteID id)
|
||||||
{
|
{
|
||||||
uint num = _sprite_size[id];
|
uint num;
|
||||||
byte type;
|
byte type;
|
||||||
|
|
||||||
DEBUG(spritecache, 9) ("load sprite %d", id);
|
DEBUG(spritecache, 9) ("load sprite %d", id);
|
||||||
|
|
||||||
if (_sprite_file_pos[id] == 0) {
|
if (_sprite_file_pos[id] == 0 && id != 0) {
|
||||||
error(
|
error(
|
||||||
"Tried to load non-existing sprite #%d.\n"
|
"Tried to load non-existing sprite #%d.\n"
|
||||||
"Probable cause: Wrong/missing NewGRFs",
|
"Probable cause: Wrong/missing NewGRFs",
|
||||||
@ -148,6 +146,7 @@ static void* ReadSprite(SpriteID id)
|
|||||||
|
|
||||||
FioSeekToFile(_sprite_file_pos[id]);
|
FioSeekToFile(_sprite_file_pos[id]);
|
||||||
|
|
||||||
|
num = FioReadWord();
|
||||||
type = FioReadByte();
|
type = FioReadByte();
|
||||||
if (type == 0xFF) {
|
if (type == 0xFF) {
|
||||||
byte* dest = AllocSprite(num);
|
byte* dest = AllocSprite(num);
|
||||||
@ -195,14 +194,10 @@ static void* ReadSprite(SpriteID id)
|
|||||||
|
|
||||||
static bool LoadNextSprite(int load_index, byte file_index)
|
static bool LoadNextSprite(int load_index, byte file_index)
|
||||||
{
|
{
|
||||||
uint16 size;
|
uint32 file_pos = FioGetPos() | (file_index << 24);
|
||||||
uint32 file_pos;
|
uint16 size = FioReadWord();
|
||||||
|
|
||||||
size = FioReadWord();
|
if (size == 0) return false;
|
||||||
if (size == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
file_pos = FioGetPos() | (file_index << 24);
|
|
||||||
|
|
||||||
ReadSpriteHeaderSkipData(size, load_index);
|
ReadSpriteHeaderSkipData(size, load_index);
|
||||||
|
|
||||||
@ -234,7 +229,6 @@ static bool LoadNextSprite(int load_index, byte file_index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_sprite_size[load_index] = size;
|
|
||||||
_sprite_file_pos[load_index] = file_pos;
|
_sprite_file_pos[load_index] = file_pos;
|
||||||
|
|
||||||
_sprite_ptr[load_index] = NULL;
|
_sprite_ptr[load_index] = NULL;
|
||||||
@ -629,7 +623,7 @@ static const SpriteID _openttd_grf_indexes[] = {
|
|||||||
SPR_OPENTTD_BASE+11, SPR_OPENTTD_BASE+57, // more icons
|
SPR_OPENTTD_BASE+11, SPR_OPENTTD_BASE+57, // more icons
|
||||||
648, 648, // nordic char: æ
|
648, 648, // nordic char: æ
|
||||||
616, 616, // nordic char: Æ
|
616, 616, // nordic char: Æ
|
||||||
666, 666, // nordic char: Ř
|
666, 666, // nordic char: ø
|
||||||
634, 634, // nordic char: Ø
|
634, 634, // nordic char: Ø
|
||||||
SPR_OPENTTD_BASE+62, SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT, // more icons
|
SPR_OPENTTD_BASE+62, SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT, // more icons
|
||||||
0xffff,
|
0xffff,
|
||||||
@ -800,7 +794,6 @@ static void GfxInitSpriteMem(void *ptr, uint32 size)
|
|||||||
{
|
{
|
||||||
// initialize sprite cache heap
|
// initialize sprite cache heap
|
||||||
_spritecache_ptr = ptr;
|
_spritecache_ptr = ptr;
|
||||||
_spritecache_size = size;
|
|
||||||
|
|
||||||
// A big free block
|
// A big free block
|
||||||
_spritecache_ptr->size = (size - sizeof(MemBlock)) | S_FREE_MASK;
|
_spritecache_ptr->size = (size - sizeof(MemBlock)) | S_FREE_MASK;
|
||||||
|
Loading…
Reference in New Issue
Block a user