1
0
Fork 0

(svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game

release/1.4
rubidium 2013-07-12 18:54:27 +00:00
parent 11f756ac97
commit 81ce9ad189
4 changed files with 22 additions and 0 deletions

View File

@ -47,6 +47,7 @@
/* Load default data and store the name in the settings */ /* Load default data and store the name in the settings */
config->Change(info->GetName(), -1, false, true); config->Change(info->GetName(), -1, false, true);
} }
config->AnchorUnchangeableSettings();
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE); Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Company *c = Company::Get(company); Company *c = Company::Get(company);

View File

@ -71,6 +71,8 @@
GameInfo *info = config->GetInfo(); GameInfo *info = config->GetInfo();
if (info == NULL) return; if (info == NULL) return;
config->AnchorUnchangeableSettings();
Backup<CompanyByte> cur_company(_current_company, FILE_LINE); Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
cur_company.Change(OWNER_DEITY); cur_company.Change(OWNER_DEITY);

View File

@ -84,6 +84,15 @@ void ScriptConfig::ClearConfigList()
this->settings.clear(); this->settings.clear();
} }
void ScriptConfig::AnchorUnchangeableSettings()
{
for (ScriptConfigItemList::const_iterator it = this->GetConfigList()->begin(); it != this->GetConfigList()->end(); it++) {
if (((*it).flags & SCRIPTCONFIG_INGAME) == 0) {
this->SetSetting((*it).name, this->GetSetting((*it).name));
}
}
}
int ScriptConfig::GetSetting(const char *name) const int ScriptConfig::GetSetting(const char *name) const
{ {
SettingValueList::const_iterator it = this->settings.find(name); SettingValueList::const_iterator it = this->settings.find(name);

View File

@ -107,6 +107,16 @@ public:
SSS_FORCE_GAME, ///< Get the Script config from the current game SSS_FORCE_GAME, ///< Get the Script config from the current game
}; };
/**
* As long as the default of a setting has not been changed, the value of
* the setting is not stored. This to allow changing the difficulty setting
* without having to reset the script's config. However, when a setting may
* not be changed in game, we must "anchor" this value to what the setting
* would be at the time of starting. Otherwise changing the difficulty
* setting would change the setting's value (which isn't allowed).
*/
void AnchorUnchangeableSettings();
/** /**
* Get the value of a setting for this config. It might fallback to his * Get the value of a setting for this config. It might fallback to his
* 'info' to find the default value (if not set or if not-custom difficulty * 'info' to find the default value (if not set or if not-custom difficulty