Fix #12147: reset all saved settings to their default before loading a game (#12210)

This commit is contained in:
Patric Stout
2024-03-02 16:05:43 +01:00
committed by GitHub
parent aff09306de
commit 8f22066b9a
3 changed files with 39 additions and 4 deletions

View File

@@ -187,10 +187,20 @@ struct PATSChunkHandler : ChunkHandler {
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(this->GetSettingTable(), &_settings_game, _settings_sl_compat);
const auto settings_table = this->GetSettingTable();
/* Reset all settings to their default, so any settings missing in the savegame
* are their default, and not "value of last game". AfterLoad might still fix
* up values to become non-default, depending on the saveload version. */
for (auto &desc : settings_table) {
const SettingDesc *sd = GetSettingDesc(desc);
if (sd->flags & SF_NOT_IN_SAVE) continue;
if ((sd->flags & SF_NO_NETWORK_SYNC) && _networking && !_network_server) continue;
sd->ResetToDefault(&_settings_game);
}
LoadSettings(settings_table, &_settings_game, _settings_sl_compat);
}
void LoadCheck(size_t) const override