* Convert a settings table to JSON. * * @param survey The JSON object. * @param table The settings table to convert. * @param object The object to get the settings from. * @param skip_if_default If true, skip any settings that are on their default value. */
| 144 | * @param skip_if_default If true, skip any settings that are on their default value. |
| 145 | */ |
| 146 | static void SurveySettingsTable(nlohmann::json &survey, const SettingTable &table, void *object, bool skip_if_default) |
| 147 | { |
| 148 | for (auto &desc : table) { |
| 149 | const SettingDesc *sd = GetSettingDesc(desc); |
| 150 | /* Skip any old settings we no longer save/load. */ |
| 151 | if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue; |
| 152 | |
| 153 | const auto &name = sd->GetName(); |
| 154 | if (skip_if_default && sd->IsDefaultValue(object)) continue; |
| 155 | survey[name] = sd->FormatValue(object); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Convert settings to JSON. |
no test coverage detected