From f522870d8acf3e12ab0845272844561d9195fe4d Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Fri, 5 Oct 2018 01:13:05 +0200 Subject: -options: Restored erroneously-removed game-specific INI option reversion between runs. Fixes MT#06171. [Ryan Holtz] --- src/lib/util/options.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/lib/util/options.cpp') diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp index d323ef11ffe..a7e901bbf70 100644 --- a/src/lib/util/options.cpp +++ b/src/lib/util/options.cpp @@ -1025,3 +1025,29 @@ bool core_options::header_exists(const char *description) const return iter != m_entries.end(); } + +//------------------------------------------------- +// revert - revert options at or below a certain +// priority back to their defaults +//------------------------------------------------- + +void core_options::revert(int priority_hi, int priority_lo) +{ + for (entry::shared_ptr &curentry : m_entries) + curentry->revert(priority_hi, priority_lo); +} + +//------------------------------------------------- +// revert - revert back to our default if we are +// within the given priority range +//------------------------------------------------- + +void core_options::simple_entry::revert(int priority_hi, int priority_lo) +{ + // if our priority is within the range, revert to the default + if (priority() <= priority_hi && priority() >= priority_lo) + { + set_value(std::string(default_value()), priority(), true); + set_priority(OPTION_PRIORITY_DEFAULT); + } +} -- cgit v1.2.3-70-g09d2