Mercurial > hg > openttd
changeset 6908:71da5dd33fa4 draft
(svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
author | truelight <truelight@openttd.org> |
---|---|
date | Thu, 14 Jun 2007 14:31:48 +0000 |
parents | 8a7c4b1f39ea |
children | 6d1b28e5f91f |
files | src/gfxinit.cpp src/newgrf.cpp src/spritecache.cpp src/spritecache.h |
diffstat | 4 files changed, 15 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -53,13 +53,15 @@ static uint LoadGrfFile(const char* filename, uint load_index, int file_index) { uint load_index_org = load_index; + uint sprite_id = 0; FioOpenFile(file_index, 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++; + sprite_id++; if (load_index >= MAX_SPRITES) { error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files."); } @@ -73,6 +75,7 @@ static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int file_index) { uint start; + uint sprite_id = 0; FioOpenFile(file_index, filename); @@ -83,14 +86,16 @@ if (start == SKIP) { // skip sprites (amount in second var) SkipSprites(end); + sprite_id += end; } else { // load sprites and use indexes from start to end do { #ifdef NDEBUG - LoadNextSprite(start, file_index); + LoadNextSprite(start, file_index, sprite_id); #else - bool b = LoadNextSprite(start, file_index); + bool b = LoadNextSprite(start, file_index, sprite_id); assert(b); #endif + sprite_id++; } while (++start <= end); } }
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2045,7 +2045,7 @@ ); for (uint16 i = 0; i < num_sets * num_ents; i++) { - LoadNextSprite(_cur_spriteid++, _file_index); + LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line); _nfo_line++; } } @@ -2960,7 +2960,7 @@ } for (; num > 0; num--) { - LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index); + LoadNextSprite(replace == 0 ? _cur_spriteid++ : replace++, _file_index, _nfo_line); _nfo_line++; } } @@ -3358,7 +3358,7 @@ ); 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++; } } @@ -4081,7 +4081,7 @@ for (uint c = 0; c < num_char; c++) { SetUnicodeGlyph(size, base_char + c, _cur_spriteid); - LoadNextSprite(_cur_spriteid++, _file_index); + LoadNextSprite(_cur_spriteid++, _file_index, _nfo_line); _nfo_line++; } }
--- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -241,7 +241,7 @@ } -bool LoadNextSprite(int load_index, byte file_index) +bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id) { SpriteCache *sc; uint32 file_pos = FioGetPos() | (file_index << 24); @@ -256,7 +256,7 @@ sc->file_pos = file_pos; sc->ptr = NULL; sc->lru = 0; - sc->id = load_index; + sc->id = file_sprite_id; const char *fio_grf_name = FioGetFilename(); const char *t = strrchr(fio_grf_name, PATHSEPCHAR);
--- a/src/spritecache.h +++ b/src/spritecache.h @@ -31,7 +31,7 @@ void GfxInitSpriteMem(); 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 SkipSprites(uint count);