Revert "Save custom options data in a more concise way"
This reverts commit e3db7cc225
. Turns out the
id = value syntax did not work for options in an array since '.' is not a
valid config key name.
This commit is contained in:
parent
2d9e02cffa
commit
1097bad28c
2 changed files with 7 additions and 17 deletions
|
@ -41,15 +41,9 @@ mp_options_helper::mp_options_helper(window& window, ng::create_engine& create_e
|
|||
, options_data_()
|
||||
{
|
||||
for(const auto& c : preferences::options().all_children_range()) {
|
||||
// Parse old [option] tag range syntax.
|
||||
for(const auto& saved_option : c.cfg.child_range("option")) {
|
||||
options_data_[c.cfg["id"]][saved_option["id"]] = saved_option["value"];
|
||||
}
|
||||
|
||||
// Parse new [options] id = value syntax.
|
||||
for(const auto& saved_option : c.cfg.child_or_empty("options").attribute_range()) {
|
||||
options_data_[c.cfg["id"]][saved_option.first] = saved_option.second;
|
||||
}
|
||||
}
|
||||
|
||||
update_all_options();
|
||||
|
@ -331,8 +325,14 @@ config mp_options_helper::get_options_config()
|
|||
for(const auto& source : visible_options_) {
|
||||
config& mod = options.add_child(source.level_type);
|
||||
mod["id"] = source.id;
|
||||
|
||||
#if 0
|
||||
// TODO: enable this as soon as we drop the old mp configure screen.
|
||||
mod.add_child("options", options_data_[source.id]);
|
||||
#else
|
||||
for(const auto& option : options_data_[source.id].attribute_range()) {
|
||||
mod.add_child("option", config {"id", option.first, "value", option.second});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return options;
|
||||
|
|
|
@ -390,7 +390,6 @@ void saved_game::expand_mp_options()
|
|||
|
||||
for(modevents_entry& mod : mods) {
|
||||
if(const config& cfg = this->mp_settings().options.find_child(mod.type, "id", mod.id)) {
|
||||
// Parse old [option] tag range syntax.
|
||||
for(const config& option : cfg.child_range("option")) {
|
||||
try {
|
||||
variable_access_create(option["id"], variables).as_scalar() = option["value"];
|
||||
|
@ -398,15 +397,6 @@ void saved_game::expand_mp_options()
|
|||
ERR_NG << "variable " << option["id"] << "cannot be set to " << option["value"] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse new [options] id = value syntax.
|
||||
for(const auto& option : cfg.child_or_empty("options").attribute_range()) {
|
||||
try {
|
||||
variable_access_create(option.first, variables).as_scalar() = option.second;
|
||||
} catch(const invalid_variablename_exception&) {
|
||||
ERR_NG << "variable " << option.first << "cannot be set to " << option.second << std::endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG_NG << "Couldn't find [" << mod.type << "] with id=" << mod.id << " for [option]s" << std::endl;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue