diff options
author | Rubidium <rubidium@openttd.org> | 2021-07-05 20:14:28 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-07-06 21:32:47 +0200 |
commit | 7e7a4aad721f89c98a347a4d2104f6a01e8fbcaa (patch) | |
tree | fccb8282a0afcb99cef9a47231a37be3518e8bcb /src/settings_internal.h | |
parent | 25ca6a75bc83df7224f56fc1ab22c4491f77649e (diff) | |
download | openttd-7e7a4aad721f89c98a347a4d2104f6a01e8fbcaa.tar.xz |
Codechange: split off the settings saveload code from the main settings handling logic
Diffstat (limited to 'src/settings_internal.h')
-rw-r--r-- | src/settings_internal.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/settings_internal.h b/src/settings_internal.h index 0e6637a5b..304f1393a 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -302,6 +302,16 @@ struct NullSettingDesc : SettingDesc { typedef std::variant<IntSettingDesc, BoolSettingDesc, OneOfManySettingDesc, ManyOfManySettingDesc, StringSettingDesc, ListSettingDesc, NullSettingDesc> SettingVariant; +/** + * Helper to convert the type of the iterated settings description to a pointer to it. + * @param desc The type of the iterator of the value in SettingTable. + * @return The actual pointer to SettingDesc. + */ +static constexpr const SettingDesc *GetSettingDesc(const SettingVariant &desc) +{ + return std::visit([](auto&& arg) -> const SettingDesc * { return &arg; }, desc); +} + const SettingDesc *GetSettingFromName(const std::string_view name); void GetSettingSaveLoadByPrefix(const std::string_view prefix, std::vector<SaveLoad> &saveloads); bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame = false); |