diff options
author | frosch <frosch@openttd.org> | 2010-06-13 14:15:58 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-06-13 14:15:58 +0000 |
commit | d9b4d92050b90aa1d73d7e5bc3dc54b384b80b5b (patch) | |
tree | bf7bd3cd00819f0d463df43e799fae37af307351 /src | |
parent | 16618e6f16cf2a8fbb165b8c7c6e245e6cd7a298 (diff) | |
download | openttd-d9b4d92050b90aa1d73d7e5bc3dc54b384b80b5b.tar.xz |
(svn r19981) -Add: Read NewGRF configuration during SL_LOAD_CHECK.
Diffstat (limited to 'src')
-rw-r--r-- | src/fios.h | 6 | ||||
-rw-r--r-- | src/fios_gui.cpp | 2 | ||||
-rw-r--r-- | src/saveload/newgrf_sl.cpp | 19 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 5 |
4 files changed, 26 insertions, 6 deletions
diff --git a/src/fios.h b/src/fios.h index a60f9b93c..eb06a0a9e 100644 --- a/src/fios.h +++ b/src/fios.h @@ -20,6 +20,7 @@ #include "date_type.h" #include "settings_type.h" #include "company_base.h" +#include "newgrf_config.h" typedef SmallMap<uint, CompanyProperties *> CompanyPropertiesMap; @@ -39,7 +40,10 @@ struct LoadCheckData { CompanyPropertiesMap companies; ///< Company information. - LoadCheckData() : error_data(NULL) + GRFConfig *grfconfig; ///< NewGrf configuration from save. + GRFListCompatibility grf_compatibility; ///< Summary state of NewGrfs, whether missing files or only compatible found. + + LoadCheckData() : error_data(NULL), grfconfig(NULL) { this->Clear(); } diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index fc5d8b016..0a7f6773b 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -54,6 +54,8 @@ void LoadCheckData::Clear() delete it->second; } companies.Clear(); + + ClearGRFConfigList(&this->grfconfig); } diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index 8dbebcce5..735306c3c 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -14,6 +14,7 @@ #include "../core/bitmath_func.hpp" #include "../core/alloc_func.hpp" #include "../gfx_func.h" +#include "../fios.h" #include "saveload.h" @@ -40,20 +41,30 @@ static void Save_NGRF() } -static void Load_NGRF() +static void Load_NGRF_common(GRFConfig *&grfconfig) { - ClearGRFConfigList(&_grfconfig); + ClearGRFConfigList(&grfconfig); while (SlIterateArray() != -1) { GRFConfig *c = new GRFConfig(); SlObject(c, _grfconfig_desc); if (CheckSavegameVersion(101)) c->windows_paletted = (_use_palette == PAL_WINDOWS); - AppendToGRFConfigList(&_grfconfig, c); + AppendToGRFConfigList(&grfconfig, c); } +} + +static void Load_NGRF() +{ + Load_NGRF_common(_grfconfig); /* Append static NewGRF configuration */ AppendStaticGRFConfigs(&_grfconfig); } +static void Check_NGRF() +{ + Load_NGRF_common(_load_check_data.grfconfig); +} + extern const ChunkHandler _newgrf_chunk_handlers[] = { - { 'NGRF', Save_NGRF, Load_NGRF, NULL, NULL, CH_ARRAY | CH_LAST } + { 'NGRF', Save_NGRF, Load_NGRF, NULL, Check_NGRF, CH_ARRAY | CH_LAST } }; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 1c3687162..c002f87dd 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2123,7 +2123,10 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb, boo _savegame_type = SGT_OTTD; - if (mode != SL_LOAD_CHECK) { + if (mode == SL_LOAD_CHECK) { + /* The only part from AfterLoadGame() we need */ + _load_check_data.grf_compatibility = IsGoodGRFConfigList(_load_check_data.grfconfig); + } else { GamelogStartAction(GLAT_LOAD); /* After loading fix up savegame for any internal changes that |