Merge pull request #122 from Rift-Walker/config_edits

Config edits
This commit is contained in:
lipk 2014-03-21 10:46:05 +01:00
commit eb48917ce5
13 changed files with 36 additions and 59 deletions

View file

@ -1564,7 +1564,7 @@ void get_villages_phase::dispatch_complex(
}
}
// End of loop no optimal found, assign the best
std::copy(best_result.begin(), best_result.end(), std::back_inserter(moves));
moves.insert(moves.end(), best_result.begin(), best_result.end());
// Clean up the reachmap for dispatched units.
for(std::vector<std::pair<map_location, map_location> >::const_iterator
@ -1594,7 +1594,7 @@ void get_villages_phase::dispatch_complex(
}
}
if(result.size() == max_result) {
std::copy(result.begin(), result.end(), std::back_inserter(moves));
moves.insert(moves.end(), result.begin(), result.end());
reachmap.clear();
return;
}
@ -1604,7 +1604,7 @@ void get_villages_phase::dispatch_complex(
}
}
// End of loop no optimal found, assign the best
std::copy(best_result.begin(), best_result.end(), std::back_inserter(moves));
moves.insert(moves.end(), best_result.begin(), best_result.end());
// clean up the reachmap we need to test whether the leader is still there
// and if so remove him manually to get him dispatched.
@ -1637,7 +1637,7 @@ void get_villages_phase::dispatch_complex(
}
}
if(result.size() == max_result) {
std::copy(result.begin(), result.end(), std::back_inserter(moves));
moves.insert(moves.end(), result.begin(), result.end());
reachmap.clear();
return;
}
@ -1647,7 +1647,7 @@ void get_villages_phase::dispatch_complex(
}
}
// End of loop no optimal found, assigne the best
std::copy(best_result.begin(), best_result.end(), std::back_inserter(moves));
moves.insert(moves.end(), best_result.begin(), best_result.end());
// clean up the reachmap we need to test whether the leader is still there
// and if so remove him manually to get him dispatched.

View file

@ -1014,9 +1014,8 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
void testing_recruitment_phase::do_recruit(int max_units_to_recruit, double quality_factor)
{
std::vector<fake_team> tmp_fake_teams;
std::vector<fake_team> tmp_fake_teams (resources::teams->begin(), resources::teams->end());
std::vector<fake_team> fake_teams;
std::copy(resources::teams->begin(), resources::teams->end(), std::back_inserter(tmp_fake_teams));
fake_team *ai_t = 0;
for(int i = get_side() - 1
; static_cast<unsigned int>(i) < tmp_fake_teams.size()

View file

@ -437,10 +437,8 @@ config& config::operator=(const config& cfg)
if(this == &cfg) {
return *this;
}
clear();
append_children(cfg);
values.insert(cfg.values.begin(), cfg.values.end());
config tmp(cfg);
swap(tmp);
return *this;
}

View file

@ -371,9 +371,7 @@ namespace game_config {
{
if(active_map_.empty())
{
std::copy(defines_map.begin(),
defines_map.end(),
std::insert_iterator<preproc_map>(active_map_, active_map_.begin()));
active_map_.insert(defines_map.begin(), defines_map.end());
if ( get_state() == NEW)
state_ = ACTIVE;
}

View file

@ -104,14 +104,11 @@ manager::manager() :
preferences::erase("mp_countdown_action_bonus");
}
const std::vector<std::string> v = utils::split(preferences::get("encountered_units"));
std::copy(v.begin(), v.end(),
std::inserter(encountered_units_set, encountered_units_set.begin()));
const std::vector<std::string> v (utils::split(preferences::get("encountered_units")));
encountered_units_set.insert(v.begin(), v.end());
const t_translation::t_list terrain =
t_translation::read_list(preferences::get("encountered_terrain_list"));
std::copy(terrain.begin(), terrain.end(),
std::inserter(encountered_terrains_set, encountered_terrains_set.begin()));
const t_translation::t_list terrain (t_translation::read_list(preferences::get("encountered_terrain_list")));
encountered_terrains_set.insert(terrain.begin(), terrain.end());
if (const config &history = preferences::get_child("history"))
{
@ -135,12 +132,9 @@ manager::manager() :
manager::~manager()
{
std::vector<std::string> v;
std::copy(encountered_units_set.begin(), encountered_units_set.end(), std::back_inserter(v));
std::vector<std::string> v (encountered_units_set.begin(), encountered_units_set.end());
preferences::set("encountered_units", utils::join(v));
t_translation::t_list terrain;
std::copy(encountered_terrains_set.begin(), encountered_terrains_set.end(),
std::back_inserter(terrain));
t_translation::t_list terrain (encountered_terrains_set.begin(), encountered_terrains_set.end());
preferences::set("encountered_terrain_list", t_translation::write_list(terrain));
/* Structure of the history
@ -1053,8 +1047,7 @@ void encounter_recruitable_units(std::vector<team>& teams){
for (std::vector<team>::iterator help_team_it = teams.begin();
help_team_it != teams.end(); ++help_team_it) {
help_team_it->log_recruitable();
std::copy(help_team_it->recruits().begin(), help_team_it->recruits().end(),
std::inserter(encountered_units_set, encountered_units_set.begin()));
encountered_units_set.insert(help_team_it->recruits().begin(), help_team_it->recruits().end());
}
}

View file

@ -999,11 +999,10 @@ void parse_config_internal(const config *help_cfg, const config *section_cfg,
,std::back_inserter(sec.topics),title_less());
}
else {
std::copy(topics.begin(), topics.end(),
std::back_inserter(sec.topics));
std::copy(generated_topics.begin(),
generated_topics.end(),
std::back_inserter(sec.topics));
sec.topics.insert(sec.topics.end(),
topics.begin(), topics.end());
sec.topics.insert(sec.topics.end(),
generated_topics.begin(), generated_topics.end());
}
}
}
@ -2165,7 +2164,7 @@ section& section::operator=(const section &sec)
title = sec.title;
id = sec.id;
level = sec.level;
std::copy(sec.topics.begin(), sec.topics.end(), std::back_inserter(topics));
topics.insert(topics.end(), sec.topics.begin(), sec.topics.end());
std::transform(sec.sections.begin(), sec.sections.end(),
std::back_inserter(sections), create_section());
return *this;

View file

@ -446,7 +446,7 @@ void create::synchronize_selections()
level_type_at_index = engine_.find_level_type_by_id(
engine_.dependency_manager().get_scenario());
engine_.set_current_level_type(level_type_at_index);
init_level_changed(index);
levels_menu_.set_items(engine_.levels_menu_item_names());
levels_menu_.move_selection(index);
@ -513,12 +513,10 @@ std::string create::select_campaign_difficulty()
const std::vector<std::string> difficulties =
utils::split(engine_.current_level().data()["difficulties"]);
if(difficulties.empty() == false) {
if(!difficulties.empty()) {
int difficulty = 0;
if(difficulty_options.size() != difficulties.size()) {
difficulty_options.resize(difficulties.size());
std::copy(difficulties.begin(), difficulties.end(),
difficulty_options.begin());
difficulty_options = difficulties;
}
gui2::tcampaign_difficulty dlg(difficulty_options);

View file

@ -188,20 +188,16 @@ plain_route a_star_search(const map_location& src, const map_location& dst,
if (n.t >= nodes[index(dst)].g) break;
std::vector<map_location> locs;
std::vector<map_location> locs(6);
int i;
if (teleports && !teleports->empty()) {
std::set<map_location> allowed_teleports;
teleports->get_adjacents(allowed_teleports, n.curr);
locs.insert(locs.end(), allowed_teleports.begin(), allowed_teleports.end());
}
i = allowed_teleports.size() +6;
locs = std::vector<map_location>(i);
std::copy(allowed_teleports.begin(), allowed_teleports.end(), locs.begin() + 6);
} else
{ locs = std::vector<map_location>(6); i = 6;}
int i = locs.size();
get_adjacent_tiles(n.curr, &locs[0]);

View file

@ -626,8 +626,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
radius = max_loop_;
}
if(radius > 0) {
std::vector<map_location> xy_vector;
std::copy(match_set.begin(),match_set.end(),std::inserter(xy_vector,xy_vector.end()));
std::vector<map_location> xy_vector (match_set.begin(), match_set.end());
if(cfg_.has_child("filter_radius")) {
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, with_border, r_filter);
@ -635,7 +634,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, with_border);
}
} else {
std::copy(match_set.begin(),match_set.end(),std::inserter(locs,locs.end()));
locs.insert(match_set.begin(), match_set.end());
}
}

View file

@ -288,8 +288,8 @@ void tod_manager::add_time_area(const config& cfg)
area.xsrc = cfg["x"].str();
area.ysrc = cfg["y"].str();
area.currentTime = cfg["current_time"].to_int(0);
std::vector<map_location> const& locs = parse_location_range(area.xsrc, area.ysrc, true);
std::copy(locs.begin(), locs.end(), std::inserter(area.hexes, area.hexes.end()));
std::vector<map_location> const& locs (parse_location_range(area.xsrc, area.ysrc, true));
area.hexes.insert(locs.begin(), locs.end());
time_of_day::parse_times(cfg, area.times);
}

View file

@ -328,8 +328,7 @@ std::vector<unit_map::unit_iterator> unit_map::find_leaders(int side) {
}
std::vector<unit_map::const_unit_iterator> unit_map::find_leaders(int side)const{
const std::vector<unit_map::unit_iterator> &leaders = const_cast<unit_map*>(this)->find_leaders(side);
std::vector<unit_map::const_unit_iterator> const_leaders;
std::copy(leaders.begin(), leaders.end(), std::back_inserter(const_leaders));
std::vector<unit_map::const_unit_iterator> const_leaders (leaders.begin(), leaders.end());
return const_leaders;
}

View file

@ -597,8 +597,7 @@ std::deque<action_ptr> side_actions::actions_of(unit const &target)
typedef container::action_set::index<container::by_unit>::type::iterator unit_iterator;
std::pair<unit_iterator, unit_iterator> action_its = actions_.get<container::by_unit>().equal_range(target.underlying_id());
std::deque<action_ptr> actions;
std::copy(action_its.first, action_its.second, std::back_inserter(actions));
std::deque<action_ptr> actions (action_its.first, action_its.second);
return actions;
}

View file

@ -112,8 +112,7 @@ void textbox::append_text(const std::string& text, bool auto_scroll, const SDL_C
sdl_blit(new_text,NULL,new_surface,&target);
text_image_.assign(new_surface);
text_.resize(text_.size() + wtext.size());
std::copy(wtext.begin(),wtext.end(),text_.end()-wtext.size());
text_.insert(text_.end(), wtext.begin(), wtext.end());
set_dirty(true);
update_text_cache(false);
@ -158,7 +157,7 @@ void textbox::set_cursor_pos(const int cursor_pos)
WRN_DP << "out-of-boundary selection\n";
return;
}
cursor_ = cursor_pos;
update_text_cache(false);
set_dirty(true);