diff options
author | dominik <dominik@openttd.org> | 2005-01-28 08:56:43 +0000 |
---|---|---|
committer | dominik <dominik@openttd.org> | 2005-01-28 08:56:43 +0000 |
commit | c8d084a85e4eb2b20055cffc1bcbddf16b5e337f (patch) | |
tree | 5d9b756fe3bff49b8276debff76e632b693e8430 /spritecache.c | |
parent | 3e0dcfd47fede1060313de42ee75c9f882ae3400 (diff) | |
download | openttd-c8d084a85e4eb2b20055cffc1bcbddf16b5e337f.tar.xz |
(svn r1702) - Fix: [ 1110407 ] Game does not crash any more when a newgrf file doesn't exist
Diffstat (limited to 'spritecache.c')
-rw-r--r-- | spritecache.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/spritecache.c b/spritecache.c index 2cec837fc..85a09e940 100644 --- a/spritecache.c +++ b/spritecache.c @@ -893,21 +893,18 @@ static void LoadSpriteTables(void) /* Load newgrf sprites */ - + // in each loading stage, (try to) open each file specified in the config and load information from it. _custom_sprites_base = load_index; - - _loading_stage = 0; - for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++) { - InitNewGRFFile(_newgrf_files[j], load_index); - load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++); + for (_loading_stage = 0; _loading_stage < 2; _loading_stage++) { + for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++) { + if ( !FiosCheckFileExists(_newgrf_files[j]) ) + continue; + if (_loading_stage == 0) + InitNewGRFFile(_newgrf_files[j], load_index); + load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++); + } } - _loading_stage = 1; - load_index = _custom_sprites_base; - for (j = 0; j != lengthof(_newgrf_files) && _newgrf_files[j]; j++) - load_index += LoadNewGrfFile(_newgrf_files[j], load_index, i++); - - // If needed, save the cache to file HandleCachedSpriteHeaders(_cached_filenames[_opt.landscape], false); } else { |