summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-02-17 15:53:47 +0000
committertron <tron@openttd.org>2005-02-17 15:53:47 +0000
commitf7991303e80c08f2b5518db3ca01e869ec78fcb4 (patch)
tree19eeb087f2a26dda19aab503f1871dd22346a849
parentfe6f9e9a658be8198b3ee149d8f50c6e2900111d (diff)
downloadopenttd-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.c8
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();