diff options
author | Patric Stout <truebrain@openttd.org> | 2021-07-09 21:16:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 21:16:03 +0200 |
commit | 8f5d0ecde39cbaf2ac1a6d27e82239bfc3bf1515 (patch) | |
tree | 232daba5b6f77f8ae33191c0b88dd21ef662a1c1 /src/saveload/settings_sl.cpp | |
parent | d9ca9ca55571829af88429147e20bf0734e07e2d (diff) | |
download | openttd-8f5d0ecde39cbaf2ac1a6d27e82239bfc3bf1515.tar.xz |
Codechange: split settings.ini over several files (#9421)
This reduced the load on compilers, as currently for example MacOS
doesn't like the huge settings-tables.
Additionally, nobody can find settings, as the list is massive and
unordered. By splitting it, it becomes a little bit more sensible.
Diffstat (limited to 'src/saveload/settings_sl.cpp')
-rw-r--r-- | src/saveload/settings_sl.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/saveload/settings_sl.cpp b/src/saveload/settings_sl.cpp index 59b00e0f0..f19ff910c 100644 --- a/src/saveload/settings_sl.cpp +++ b/src/saveload/settings_sl.cpp @@ -151,7 +151,7 @@ struct OPTSChunkHandler : ChunkHandler { * a networking environment. This ensures for example that the local * autosave-frequency stays when joining a network-server */ PrepareOldDiffCustom(); - LoadSettings(_gameopt_settings, &_settings_game, _gameopt_sl_compat); + LoadSettings(_old_gameopt_settings, &_settings_game, _gameopt_sl_compat); HandleOldDiffCustom(true); } }; @@ -159,22 +159,51 @@ struct OPTSChunkHandler : ChunkHandler { struct PATSChunkHandler : ChunkHandler { PATSChunkHandler() : ChunkHandler('PATS', CH_TABLE) {} + /** + * Create a single table with all settings that should be stored/loaded + * in the savegame. + */ + SettingTable GetSettingTable() const + { + static const SettingTable saveload_settings_tables[] = { + _difficulty_settings, + _economy_settings, + _game_settings, + _linkgraph_settings, + _locale_settings, + _pathfinding_settings, + _script_settings, + _world_settings, + }; + static std::vector<SettingVariant> settings_table; + + if (settings_table.empty()) { + for (auto &saveload_settings_table : saveload_settings_tables) { + for (auto &saveload_setting : saveload_settings_table) { + settings_table.push_back(saveload_setting); + } + } + } + + return settings_table; + } + void Load() const override { /* Copy over default setting since some might not get loaded in * a networking environment. This ensures for example that the local * currency setting stays when joining a network-server */ - LoadSettings(_settings, &_settings_game, _settings_sl_compat); + LoadSettings(this->GetSettingTable(), &_settings_game, _settings_sl_compat); } void LoadCheck(size_t) const override { - LoadSettings(_settings, &_load_check_data.settings, _settings_sl_compat); + LoadSettings(this->GetSettingTable(), &_load_check_data.settings, _settings_sl_compat); } void Save() const override { - SaveSettings(_settings, &_settings_game); + SaveSettings(this->GetSettingTable(), &_settings_game); } }; |