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

Method StringToSettings

src/script/script_config.cpp:142–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142void ScriptConfig::StringToSettings(std::string_view value)
143{
144 std::string_view to_process = value;
145 for (;;) {
146 /* Analyze the string ('name=value,name=value\0') */
147 size_t pos = to_process.find_first_of('=');
148 if (pos == std::string_view::npos) return;
149
150 std::string_view item_name = to_process.substr(0, pos);
151
152 to_process.remove_prefix(pos + 1);
153 pos = to_process.find_first_of(',');
154 int item_value = 0;
155 std::from_chars(to_process.data(), to_process.data() + std::min(pos, to_process.size()), item_value);
156
157 this->SetSetting(item_name, item_value);
158
159 if (pos == std::string_view::npos) return;
160 to_process.remove_prefix(pos + 1);
161 }
162}
163
164std::string ScriptConfig::SettingsToString() const
165{

Callers 5

AILoadConfigFunction · 0.80
GameLoadConfigFunction · 0.80
ConStartAIFunction · 0.80
LoadMethod · 0.80
LoadMethod · 0.80

Calls 4

SetSettingMethod · 0.95
substrMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected