From 56a83026425c1fb9ef202b190c299409de03c935 Mon Sep 17 00:00:00 2001 From: tron Date: Thu, 17 Feb 2005 15:53:47 +0000 Subject: [PATCH] (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. --- spritecache.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spritecache.c b/spritecache.c index ada918bb34..0235bf1862 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();