@@ -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