MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SurveySettingsTable

Function SurveySettingsTable

src/survey.cpp:146–157  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

144 * @param skip_if_default If true, skip any settings that are on their default value.
145 */
146static 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.

Callers 1

SurveySettingsFunction · 0.85

Calls 5

GetSettingDescFunction · 0.85
SlIsObjectCurrentlyValidFunction · 0.85
GetNameMethod · 0.45
IsDefaultValueMethod · 0.45
FormatValueMethod · 0.45

Tested by

no test coverage detected