Add generic mechanism to cross-ref settings at load time.

This is useful for loading settings from legacy/special versions,
where the corresponding setting is somewhere else and/or a PATX setting,
with duplicating all the info.
Use this to load SpringPP settings which have a corresponding setting.
This commit is contained in:
Jonathan G Rennison
2015-08-17 20:11:30 +01:00
parent d3bab84374
commit b5c453b21e
4 changed files with 107 additions and 53 deletions

View File

@@ -112,6 +112,7 @@ struct SettingDesc {
SettingDescBase desc; ///< Settings structure (going to configuration file)
SaveLoad save; ///< Internal structure (going to savegame, parts to config)
const char *patx_name; ///< Name to save/load setting from in PATX chunk, if NULL save/load from PATS chunk as normal
const char *xref; ///< Name of SettingDesc to use instead of the contents of this one, useful for loading legacy savegames, if NULL save/load as normal
bool IsEditable(bool do_command = false) const;
SettingType GetType() const;
@@ -126,7 +127,7 @@ struct SettingDesc {
* offset in a certain struct */
typedef SettingDesc SettingDescGlobVarList;
const SettingDesc *GetSettingFromName(const char *name, uint *i);
const SettingDesc *GetSettingFromName(const char *name, uint *i, bool ignore_version = false);
bool SetSettingValue(uint index, int32 value, bool force_newgame = false);
bool SetSettingValue(uint index, const char *value, bool force_newgame = false);
void SetCompanySetting(uint index, int32 value);