summaryrefslogtreecommitdiff
path: root/src/settings_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings_internal.h')
-rw-r--r--src/settings_internal.h10
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);