Skip to content

Commit d457a91

Browse files
committed
address review comments
1 parent cd21ae2 commit d457a91

2 files changed

Lines changed: 18 additions & 23 deletions

File tree

src/gui/dialogs/multiplayer/mp_create_game.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,8 @@ void mp_create_game::quick_mp_setup(saved_game& state, const config presets)
228228
}
229229

230230
// handle potential option sources
231-
if(presets.has_child("multiplayer")) {
232-
params.options.append_children(config{"multiplayer", presets.mandatory_child("multiplayer")});
233-
}
234-
if(presets.has_child("era")) {
235-
params.options.append_children(config{"era", presets.mandatory_child("era")});
236-
}
237-
if(presets.has_child("modification")) {
238-
params.options.append_children(config{"modification", presets.mandatory_child("modification")});
239-
}
240-
if(presets.has_child("campaign")) {
241-
params.options.append_children(config{"campaign", presets.mandatory_child("campaign")});
231+
if(presets.has_child("options")) {
232+
params.options = presets.mandatory_child("options");
242233
}
243234
}
244235

src/server/wesnothd/server.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,20 +1723,24 @@ void server::handle_join_server_queue(player_iterator p, simple_wml::node& data)
17231723

17241724
// can't directly assign from the config since simple_wml doesn't own the value of the child tag name
17251725
// so need this workaround otherwise it tries to send for example: []...[/] instead of [multiplayer]...[/multiplayer]
1726-
static std::map<std::string, std::string> from_types = {
1727-
{"multiplayer", "multiplayer"},
1728-
{"era", "era"},
1729-
{"modification", "modification"},
1730-
{"campaign", "campaign"},
1726+
static std::set<std::string> from_types = {
1727+
"multiplayer",
1728+
"era",
1729+
"modification",
1730+
"campaign",
17311731
};
17321732
for(const config& qoptions : queue.settings.child_range("options")) {
1733-
simple_wml::node& options = game.add_child(from_types[qoptions["from_type"].str()].c_str());
1734-
options.set_attr_dup("id", qoptions["from_id"].str().c_str());
1735-
1736-
for(const config& qoption : qoptions.child_range("option")) {
1737-
simple_wml::node& option = options.add_child("option");
1738-
option.set_attr_dup("id", qoption["id"].str().c_str());
1739-
option.set_attr_dup("value", qoption["value"].str().c_str());
1733+
auto type = from_types.find(qoptions["from_type"].str());
1734+
if(type != from_types.end()) {
1735+
simple_wml::node& options = game.add_child("options");
1736+
simple_wml::node& option_type = options.add_child(type->c_str());
1737+
option_type.set_attr_dup("id", qoptions["from_id"].str().c_str());
1738+
1739+
for(const config& qoption : qoptions.child_range("option")) {
1740+
simple_wml::node& option = option_type.add_child("option");
1741+
option.set_attr_dup("id", qoption["id"].str().c_str());
1742+
option.set_attr_dup("value", qoption["value"].str().c_str());
1743+
}
17401744
}
17411745
}
17421746

0 commit comments

Comments
 (0)