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.
This commit is contained in:
Patric Stout
2021-07-09 21:16:03 +02:00
committed by GitHub
parent d9ca9ca555
commit 8f5d0ecde3
21 changed files with 3925 additions and 3534 deletions

View File

@@ -17,6 +17,7 @@
#include "../linkgraph/linkgraphschedule.h"
#include "../network/network.h"
#include "../settings_internal.h"
#include "../settings_table.h"
#include "../safeguards.h"
@@ -165,7 +166,6 @@ public:
SaveLoadTable GetLinkGraphJobDesc()
{
static std::vector<SaveLoad> saveloads;
static const char *prefix = "linkgraph.";
static const SaveLoad job_desc[] = {
SLE_VAR(LinkGraphJob, join_date, SLE_INT32),
@@ -184,7 +184,7 @@ SaveLoadTable GetLinkGraphJobDesc()
/* Build the SaveLoad array on first call and don't touch it later on */
if (saveloads.size() == 0) {
GetSettingSaveLoadByPrefix(prefix, saveloads);
GetSaveLoadFromSettingTable(_linkgraph_settings, saveloads);
for (auto &sl : saveloads) {
sl.address_proc = proc;

View File

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