(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.
This commit is contained in:
tron 2005-02-17 15:53:47 +00:00
parent fe6f9e9a65
commit f7991303e8
1 changed files with 8 additions and 0 deletions

View File

@ -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();