small connect_engine cleanup

The only attributes that were changed by side_engine::new_config() and
not in the attributes_to_trim list were "user_description" and "name" so
it is cleaner to just explicitly change them than to blacklist
everything else and do a merge.

Also with this it no longer merges subtags, which in particular fixes
This commit is contained in:
gfgtdf 2018-11-10 22:54:06 +01:00
parent 0aaf959260
commit e036cadf0b

View file

@ -51,24 +51,6 @@ static const std::string controller_names[] {
"reserved"
};
static const std::string attributes_to_trim[] {
"side",
"type",
"gender",
"recruit",
"player_id",
"previous_recruits",
"controller",
"current_player",
"team_name",
"user_team_name",
"color",
"gold",
"income",
"allow_changes",
"faction"
};
namespace ng {
connect_engine::connect_engine(saved_game& state, const bool first_scenario, mp_campaign_info* campaign_info)
@ -1175,19 +1157,14 @@ config side_engine::new_config() const
res["income"] = income_;
}
if(parent_.params_.use_map_settings && parent_.params_.saved_game != mp_game_settings::SAVED_GAME_MODE::MIDGAME) {
config trimmed = cfg_;
for(const std::string& attribute : attributes_to_trim) {
trimmed.remove_attribute(attribute);
if(cfg_.has_attribute("name")){
res["name"] = "name";
}
if(controller_ != CNTR_COMPUTER) {
// Only override names for computer controlled players.
trimmed.remove_attribute("user_description");
if(cfg_.has_attribute("user_description") && controller_ == CNTR_COMPUTER){
res["user_description"] = "user_description";
}
res.merge_with(trimmed);
}
return res;