mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 02:06:23 +00:00
Use config::clear over assignment to default-constructed object
This commit is contained in:
parent
de576cd83a
commit
85179772a6
@ -48,7 +48,7 @@ void configuration::init(const config &game_config)
|
||||
default_config_ = ais.child("default_config");
|
||||
if (!default_config_) {
|
||||
ERR_AI_CONFIGURATION << "Missing AI [default_config]. Therefore, default_config_ set to empty." << std::endl;
|
||||
default_config_ = config();
|
||||
default_config_.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
|
||||
LOG_AI_CONFIGURATION << "side "<< side <<": parsing AI configuration from config" << std::endl;
|
||||
|
||||
//leave only the [ai] children
|
||||
cfg = config();
|
||||
cfg.clear();
|
||||
for (const config &aiparam : original_cfg.child_range("ai")) {
|
||||
cfg.add_child("ai",aiparam);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ void carryover_info::transfer_to(config& level)
|
||||
}
|
||||
|
||||
next_scenario_ = "";
|
||||
variables_ = config();
|
||||
variables_.clear();
|
||||
wml_menu_items_.clear();
|
||||
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ random_map::random_map(const config& data)
|
||||
, generator_name_(generate_whole_scenario_ ? data_["scenario_generation"] : data_["map_generation"])
|
||||
{
|
||||
if(!data.has_child("generator")) {
|
||||
data_ = config();
|
||||
generator_data_= config();
|
||||
data_.clear();
|
||||
generator_data_.clear();
|
||||
data_["description"] = "Error: Random map found with missing generator information. Scenario should have a [generator] child.";
|
||||
data_["error_message"] = "missing [generator] tag";
|
||||
} else {
|
||||
@ -165,8 +165,8 @@ random_map::random_map(const config& data)
|
||||
}
|
||||
|
||||
if(!data.has_attribute("scenario_generation") && !data.has_attribute("map_generation")) {
|
||||
data_ = config();
|
||||
generator_data_= config();
|
||||
data_.clear();
|
||||
generator_data_.clear();
|
||||
data_["description"] = "Error: Random map found with missing generator information. Scenario should have a [generator] child.";
|
||||
data_["error_message"] = "couldn't find 'scenario_generation' or 'map_generation' attribute";
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ static void set_global_variable(persist_context &ctx, const vconfig &pcfg)
|
||||
}
|
||||
catch(const invalid_variablename_exception&)
|
||||
{
|
||||
val = config();
|
||||
val.clear();
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < arraylen; i++)
|
||||
|
@ -577,7 +577,7 @@ const config& options()
|
||||
// It may be an invalid config, which would cause problems in
|
||||
// multiplayer_create, so let's replace it with an empty but valid
|
||||
// config
|
||||
option_values = config();
|
||||
option_values.clear();
|
||||
} else {
|
||||
option_values = preferences::get_child("options");
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ void saved_game::expand_scenario()
|
||||
set_defaults();
|
||||
} else {
|
||||
this->starting_pos_type_ = STARTINGPOS_INVALID;
|
||||
this->starting_pos_ = config();
|
||||
this->starting_pos_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -482,7 +482,7 @@ void saved_game::set_scenario(config scenario)
|
||||
void saved_game::remove_snapshot()
|
||||
{
|
||||
this->starting_pos_type_ = STARTINGPOS_NONE;
|
||||
this->starting_pos_ = config();
|
||||
this->starting_pos_.clear();
|
||||
}
|
||||
|
||||
config& saved_game::get_starting_pos()
|
||||
@ -523,7 +523,7 @@ void saved_game::convert_to_start_save()
|
||||
has_carryover_expanded_ = false;
|
||||
|
||||
replay_data_ = replay_recorder_base();
|
||||
replay_start_ = config();
|
||||
replay_start_.clear();
|
||||
|
||||
remove_snapshot();
|
||||
}
|
||||
@ -643,14 +643,14 @@ void saved_game::set_data(config& cfg)
|
||||
carryover_.swap(caryover_sides_start);
|
||||
has_carryover_expanded_ = false;
|
||||
} else {
|
||||
carryover_ = config();
|
||||
carryover_.clear();
|
||||
has_carryover_expanded_ = false;
|
||||
}
|
||||
|
||||
if(config& replay_start = cfg.child("replay_start")) {
|
||||
replay_start_.swap(replay_start);
|
||||
} else {
|
||||
replay_start_ = config();
|
||||
replay_start_.clear();
|
||||
}
|
||||
|
||||
replay_data_ = replay_recorder_base();
|
||||
@ -670,7 +670,7 @@ void saved_game::set_data(config& cfg)
|
||||
this->starting_pos_.swap(scenario);
|
||||
} else {
|
||||
this->starting_pos_type_ = STARTINGPOS_NONE;
|
||||
this->starting_pos_ = config();
|
||||
this->starting_pos_.clear();
|
||||
}
|
||||
|
||||
LOG_NG << "scenario: '" << carryover_["next_scenario"].str() << "'\n";
|
||||
|
@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE ( test_config_attribute_value )
|
||||
BOOST_CHECK_EQUAL(x_str, "123456789123");
|
||||
|
||||
// blank != "" test.
|
||||
c = config();
|
||||
c.clear();
|
||||
BOOST_CHECK(!cc["x"].empty());
|
||||
BOOST_CHECK(cc["x"].empty());
|
||||
BOOST_CHECK(cc["x"].blank());
|
||||
|
@ -619,7 +619,7 @@ void manager::send_network_data()
|
||||
wb_cfg["side"] = static_cast<int>(team_index+1);
|
||||
wb_cfg["to_sides"] = resources::gameboard->teams().at(team_index).allied_human_teams();
|
||||
|
||||
buf_cfg = config();
|
||||
buf_cfg.clear();
|
||||
|
||||
resources::controller->send_to_wesnothd(packet, "whiteboard");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user