Skip to content

Commit cd21ae2

Browse files
committed
add modifications and options to queues
1 parent fe52eba commit cd21ae2

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/gui/dialogs/multiplayer/mp_create_game.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,18 @@ void mp_create_game::quick_mp_setup(saved_game& state, const config presets)
227227
create.active_mods().push_back(mod);
228228
}
229229

230-
if(presets.has_child("options")) {
231-
params.options = presets.mandatory_child("options");
230+
// 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")});
232242
}
233243
}
234244

src/server/wesnothd/server.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,29 @@ void server::handle_join_server_queue(player_iterator p, simple_wml::node& data)
17191719
game.set_attr_int("countdown_reservoir_time", queue.settings["countdown_reservoir_time"].to_int());
17201720
game.set_attr_int("countdown_action_bonus", queue.settings["countdown_action_bonus"].to_int());
17211721

1722+
game.set_attr_dup("modifications", queue.settings["modifications"].str().c_str());
1723+
1724+
// can't directly assign from the config since simple_wml doesn't own the value of the child tag name
1725+
// 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"},
1731+
};
1732+
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());
1740+
}
1741+
}
1742+
1743+
PLAIN_LOG << simple_wml::node_to_string(game);
1744+
17221745
// tell the final player to create and host the game
17231746
send_to_player(p, create_game_doc);
17241747
} else {

0 commit comments

Comments
 (0)