diff options
author | tron <tron@openttd.org> | 2005-02-17 15:53:47 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-02-17 15:53:47 +0000 |
commit | f7991303e80c08f2b5518db3ca01e869ec78fcb4 (patch) | |
tree | 19eeb087f2a26dda19aab503f1871dd22346a849 | |
parent | fe6f9e9a658be8198b3ee149d8f50c6e2900111d (diff) | |
download | openttd-f7991303e80c08f2b5518db3ca01e869ec78fcb4.tar.xz |
(svn r1882) Add a basic check if a non-existent sprite gets accessed.
Now ottd bails out with an error message instead of segfaulting.
This is far from perfect, some checks after loading a savegame should be added.
-rw-r--r-- | spritecache.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spritecache.c b/spritecache.c index ada918bb3..0235bf186 100644 --- a/spritecache.c +++ b/spritecache.c @@ -154,6 +154,14 @@ static void ReadSprite(SpriteID id, void *buffer) byte type; byte* dest; + if (_sprite_file_pos[id] == 0) { + error( + "Tried to load non-existing sprite #%d.\n" + "Probable cause: Wrong/missing NewGRFs", + id + ); + } + FioSeekToFile(_sprite_file_pos[id]); type = FioReadByte(); |