forked from mirror/OpenTTD
(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:
@@ -154,6 +154,14 @@ static void ReadSprite(SpriteID id, void *buffer)
|
|||||||
byte type;
|
byte type;
|
||||||
byte* dest;
|
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]);
|
FioSeekToFile(_sprite_file_pos[id]);
|
||||||
|
|
||||||
type = FioReadByte();
|
type = FioReadByte();
|
||||||
|
Reference in New Issue
Block a user