summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gfxinit.cpp11
-rw-r--r--src/newgrf.cpp8
-rw-r--r--src/spritecache.cpp4
-rw-r--r--src/spritecache.h2
4 files changed, 15 insertions, 10 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 2fe58ca0b..6212badfd 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -53,13 +53,15 @@ static const SpriteID * const _slopes_spriteindexes[] = {
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 uint LoadGrfFile(const char* filename, uint load_index, int file_index)
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 @@ static void LoadGrfIndexed(const char* filename, const SpriteID* index_tbl, int
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);
}
}
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 28ba4c4c0..6d9beca75 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2045,7 +2045,7 @@ static void NewSpriteSet(byte *buf, int len)
);
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 @@ static void GraphicsNew(byte *buf, int len)
}
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 @@ static void SpriteReplace(byte *buf, int len)
);
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 @@ static void LoadFontGlyph(byte *buf, int len)
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++;
}
}
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index e9c4e15dd..135c7d834 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -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;
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->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);
diff --git a/src/spritecache.h b/src/spritecache.h
index 1b351bb0a..d264ae210 100644
--- a/src/spritecache.h
+++ b/src/spritecache.h
@@ -31,7 +31,7 @@ static inline const byte *GetNonSprite(SpriteID sprite)
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);