1
0
Fork 0

(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID

release/0.6
truelight 2007-06-14 14:31:48 +00:00
parent a61f0d9049
commit 144035bf5c
4 changed files with 15 additions and 10 deletions

View File

@ -53,13 +53,15 @@ static const SpriteID * const _slopes_spriteindexes[] = {
static uint LoadGrfFile(const char* filename, uint load_index, int file_index) static uint LoadGrfFile(const char* filename, uint load_index, int file_index)
{ {
uint load_index_org = load_index; uint load_index_org = load_index;
uint sprite_id = 0;
FioOpenFile(file_index, filename); FioOpenFile(file_index, filename);
DEBUG(sprite, 2, "Reading grf-file '%s'", filename); DEBUG(sprite, 2, "Reading grf-file '%s'", filename);
while (LoadNextSprite(load_index, file_index)) { while (LoadNextSprite(load_index, file_index, sprite_id)) {
load_index++; load_index++;
sprite_id++;
if (load_index >= MAX_SPRITES) { if (load_index >= MAX_SPRITES) {
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
} }
@ -73,6 +75,7 @@ static uint LoadGrfFile(const char* filename, uint load_index, int file_index)
static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index) static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index)
{ {
uint start; uint start;
uint sprite_id = 0;
FioOpenFile(file_index, filename); FioOpenFile(file_index, filename);
@ -83,14 +86,16 @@ static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int
if (start == SKIP) { // skip sprites (amount in second var) if (start == SKIP) { // skip sprites (amount in second var)
SkipSprites(end); SkipSprites(end);
sprite_id += end;
} else { // load sprites and use indexes from start to end } else { // load sprites and use indexes from start to end
do { do {
#ifdef NDEBUG #ifdef NDEBUG
LoadNextSprite(start, file_index); LoadNextSprite(start, file_index, sprite_id);
#else #else
bool b = LoadNextSprite(start, file_index); bool b = LoadNextSprite(start, file_index, sprite_id);
assert(b); assert(b);
#endif #endif
sprite_id++;
} while (++start <= end); } while (++start <= end);
} }
} }

View File

@ -2045,7 +2045,7 @@ static void NewSpriteSet(byte *buf, int len)
); );
for (uint16 i = 0; i < num_sets * num_ents; i++) { for (uint16 i = 0; i < num_sets * num_ents; i++) {
LoadNextSprite(_cur_spriteid++, _file_index); LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line);
_nfo_line++; _nfo_line++;
} }
} }
@ -2960,7 +2960,7 @@ static void GraphicsNew(byte *buf, int len)
} }
for (; num > 0; num--) { for (; num > 0; num--) {
LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index); LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index, _nfo_line);
_nfo_line++; _nfo_line++;
} }
} }
@ -3358,7 +3358,7 @@ static void SpriteReplace(byte *buf, int len)
); );
for (uint j = 0; j < num_sprites; j++) { for (uint j = 0; j < num_sprites; j++) {
LoadNextSprite(first_sprite + j, _file_index); // XXX LoadNextSprite(first_sprite + j, _file_index, _nfo_line); // XXX
_nfo_line++; _nfo_line++;
} }
} }
@ -4081,7 +4081,7 @@ static void LoadFontGlyph(byte *buf, int len)
for (uint c = 0; c < num_char; c++) { for (uint c = 0; c < num_char; c++) {
SetUnicodeGlyph(size, base_char + c, _cur_spriteid); SetUnicodeGlyph(size, base_char + c, _cur_spriteid);
LoadNextSprite(_cur_spriteid++, _file_index); LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line);
_nfo_line++; _nfo_line++;
} }
} }

View File

@ -241,7 +241,7 @@ static void* ReadSprite(SpriteCache *sc, SpriteID id, bool real_sprite)
} }
bool LoadNextSprite(int load_index, byte file_index) bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id)
{ {
SpriteCache *sc; SpriteCache *sc;
uint32 file_pos = FioGetPos() | (file_index << 24); uint32 file_pos = FioGetPos() | (file_index << 24);
@ -256,7 +256,7 @@ bool LoadNextSprite(int load_index, byte file_index)
sc->file_pos = file_pos; sc->file_pos = file_pos;
sc->ptr = NULL; sc->ptr = NULL;
sc->lru = 0; sc->lru = 0;
sc->id = load_index; sc->id = file_sprite_id;
const char *fio_grf_name = FioGetFilename(); const char *fio_grf_name = FioGetFilename();
const char *t = strrchr(fio_grf_name, PATHSEPCHAR); const char *t = strrchr(fio_grf_name, PATHSEPCHAR);

View File

@ -31,7 +31,7 @@ static inline const byte *GetNonSprite(SpriteID sprite)
void GfxInitSpriteMem(); void GfxInitSpriteMem();
void IncreaseSpriteLRU(); void IncreaseSpriteLRU();
bool LoadNextSprite(int load_index, byte file_index); bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id);
void DupSprite(SpriteID old_spr, SpriteID new_spr); void DupSprite(SpriteID old_spr, SpriteID new_spr);
void SkipSprites(uint count); void SkipSprites(uint count);