Use BOOST_FOREACH directly instead of #define foreach BOOST_FOREACH

The define is extremely unreliable, will break compile with boost >=
1.50 and upstream can't fix issues with it, see
https://svn.boost.org/trac/boost/ticket/6131
This commit is contained in:
Sergey Popov 2012-07-07 00:49:45 +00:00
parent f0455a9ef9
commit 6b6eafb213
201 changed files with 1324 additions and 1236 deletions

View file

@ -22,10 +22,11 @@
#include "construct_dialog.hpp"
#include "display.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "marked-up_text.hpp"
#include <boost/foreach.hpp>
/**
* @namespace about
* Display credits %about all contributors.
@ -52,7 +53,7 @@ static void add_lines(std::vector<std::string> &res, config const &c) {
}
std::vector<std::string> lines = utils::split(c["text"], '\n');
foreach (std::string &line, lines)
BOOST_FOREACH(std::string &line, lines)
{
if (line.size() > 1 && line[0] == '+')
line = "+ " + line.substr(1);
@ -67,7 +68,7 @@ static void add_lines(std::vector<std::string> &res, config const &c) {
}
}
foreach (const config &entry, c.child_range("entry")) {
BOOST_FOREACH(const config &entry, c.child_range("entry")) {
res.push_back("- "+ entry["name"].str());
}
}
@ -80,7 +81,7 @@ std::vector<std::string> get_text(const std::string &campaign)
config::child_itors about_entries = about_list.child_range("about");
if (!campaign.empty()) {
foreach (const config &about, about_entries) {
BOOST_FOREACH(const config &about, about_entries) {
// just finished a particular campaign
if (campaign == about["id"]) {
add_lines(res, about);
@ -88,7 +89,7 @@ std::vector<std::string> get_text(const std::string &campaign)
}
}
foreach (const config &about, about_entries) {
BOOST_FOREACH(const config &about, about_entries) {
add_lines(res, about);
}
@ -101,7 +102,7 @@ void set_about(const config &cfg)
images.clear();
images_default = "";
foreach (const config &about, cfg.child_range("about"))
BOOST_FOREACH(const config &about, cfg.child_range("about"))
{
about_list.add_child("about", about);
const std::string &im = about["images"];
@ -114,7 +115,7 @@ void set_about(const config &cfg)
}
}
foreach (const config &campaign, cfg.child_range("campaign"))
BOOST_FOREACH(const config &campaign, cfg.child_range("campaign"))
{
config::const_child_itors abouts = campaign.child_range("about");
if (abouts.first == abouts.second) continue;
@ -126,7 +127,7 @@ void set_about(const config &cfg)
temp["id"] = id;
std::string campaign_images;
foreach (const config &about, abouts)
BOOST_FOREACH(const config &about, abouts)
{
const std::string &subtitle = about["title"];
if (!subtitle.empty())
@ -139,12 +140,12 @@ void set_about(const config &cfg)
text << '\n';
}
foreach (const std::string &line, utils::split(about["text"], '\n'))
BOOST_FOREACH(const std::string &line, utils::split(about["text"], '\n'))
{
text << " " << line << '\n';
}
foreach (const config &entry, about.child_range("entry"))
BOOST_FOREACH(const config &entry, about.child_range("entry"))
{
text << " " << entry["name"] << '\n';
}

View file

@ -21,7 +21,6 @@
#include "actions.hpp"
#include "attack_prediction.hpp"
#include "foreach.hpp"
#include "game_display.hpp"
#include "game_events.hpp"
#include "game_preferences.hpp"
@ -39,6 +38,8 @@
#include "tod_manager.hpp"
#include "whiteboard/manager.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_engine("engine");
#define DBG_NG LOG_STREAM(debug, log_engine)
#define LOG_NG LOG_STREAM(info, log_engine)
@ -204,7 +205,7 @@ map_location unit_creator::find_location(const config &cfg, const unit* pass_che
placements.push_back("map");
placements.push_back("recall");
foreach(std::string place, placements) {
BOOST_FOREACH(std::string place, placements) {
map_location loc;
bool pass((place == "leader_passable") || (place == "map_passable"));
@ -415,7 +416,7 @@ const std::vector<const unit*> get_recalls_for_location(int side, const map_loca
leader_in_place= true;
else continue;
foreach (const unit& recall_unit, recall_list)
BOOST_FOREACH(const unit& recall_unit, recall_list)
{
//Only units which match the leaders recall filter are valid.
scoped_recall_unit this_unit("this_unit", t.save_id(), &recall_unit - &recall_list[0]);
@ -433,7 +434,7 @@ const std::vector<const unit*> get_recalls_for_location(int side, const map_loca
}
if (!(recall_loc_is_castle && leader_in_place)) {
foreach (const unit &recall, recall_list)
BOOST_FOREACH(const unit &recall, recall_list)
{
result.push_back(&recall);
}
@ -544,7 +545,7 @@ std::string find_recruit_location(const int side, map_location& recruit_location
bool can_recruit_unit = is_on_team_list;
if (!can_recruit_unit) {
foreach (const std::string &recruitable, leader->recruits()) {
BOOST_FOREACH(const std::string &recruitable, leader->recruits()) {
if (recruitable == unit_type) {
can_recruit_unit = true;
break;
@ -1955,7 +1956,7 @@ bool get_village(const map_location& loc, int side, int *action_timebonus)
// Simple algorithm: no maximum number of patients per healer.
void reset_resting(unit_map& units, int side)
{
foreach (unit &u, units) {
BOOST_FOREACH(unit &u, units) {
if (u.side() == side)
u.set_resting(true);
}
@ -1976,7 +1977,7 @@ void calculate_healing(int side, bool update_display)
std::list<unit_healing_struct> l;
// We look for all allied units, then we see if our healer is near them.
foreach (unit &u, units) {
BOOST_FOREACH(unit &u, units) {
if (u.get_state("unhealable") || u.incapacitated())
continue;
@ -2393,13 +2394,13 @@ namespace {
// Clear the fog.
pathfind::vision_path sight(*resources::game_map, viewer, view_loc, jamming_map);
foreach (const pathfind::paths::step &dest, sight.destinations) {
BOOST_FOREACH(const pathfind::paths::step &dest, sight.destinations) {
if ( clear_shroud_loc(view_team, dest.curr, viewer, seen_units,
petrified_units, known_units) )
cleared_something = true;
}
//TODO guard with game_config option
foreach (const map_location &dest, sight.edges) {
BOOST_FOREACH(const map_location &dest, sight.edges) {
if ( clear_shroud_loc(view_team, dest, viewer, seen_units,
petrified_units, known_units) )
cleared_something = true;
@ -2428,7 +2429,7 @@ namespace {
{
team& viewer_tm = (*resources::teams)[side - 1];
foreach (const unit &u, *resources::units)
BOOST_FOREACH(const unit &u, *resources::units)
{
if (!viewer_tm.is_enemy(u.side())) continue;
if (u.jamming() < 1) continue;
@ -2437,7 +2438,7 @@ namespace {
if (current < u.jamming()) jamming_map[u.get_location()] = u.jamming();
pathfind::jamming_path jamming(*resources::game_map, u, u.get_location());
foreach (const pathfind::paths::step& st, jamming.destinations) {
BOOST_FOREACH(const pathfind::paths::step& st, jamming.destinations) {
current = jamming_map[st.curr];
if (current < st.move_left) jamming_map[st.curr] = st.move_left;
}
@ -2469,7 +2470,7 @@ void recalculate_fog(int side)
// So they are commented out for now.
//std::set<map_location> visible_locs;
//// Loop through all units, looking for those that are visible.
//foreach (const unit &u, *resources::units) {
//BOOST_FOREACH(const unit &u, *resources::units) {
// const map_location & u_location = u.get_location();
//
// if ( !tm.fogged(u_location) )
@ -2483,7 +2484,7 @@ void recalculate_fog(int side)
std::map<map_location, int> jamming_map;
calculate_jamming(side, jamming_map);
foreach (const unit &u, *resources::units)
BOOST_FOREACH(const unit &u, *resources::units)
{
if (u.side() == side) {
clear_shroud_unit(u.get_location(), u, tm, jamming_map);
@ -2521,7 +2522,7 @@ bool clear_shroud(int side, bool reset_fog)
std::map<map_location, int> jamming_map;
calculate_jamming(side, jamming_map);
foreach (const unit &u, *resources::units)
BOOST_FOREACH(const unit &u, *resources::units)
{
if (u.side() == side) {
result |= clear_shroud_unit(u.get_location(), u, tm, jamming_map);
@ -3083,10 +3084,10 @@ public:
NULL, &newly_seen_units, &petrified_units);
// Raise sighted events.
foreach (const map_location &here, newly_seen_units) {
BOOST_FOREACH(const map_location &here, newly_seen_units) {
game_events::raise(sighted_str, here, hex);
}
foreach (const map_location &here, petrified_units) {
BOOST_FOREACH(const map_location &here, petrified_units) {
game_events::raise(sighted_str, here, hex);
}
@ -3097,7 +3098,7 @@ public:
sighted_ = !newly_seen_units.empty();
else {
// Check whether any sighted unit is an enemy.
foreach(const map_location &here, newly_seen_units) {
BOOST_FOREACH(const map_location &here, newly_seen_units) {
if ( current_team_->is_enemy(units.find(here)->side()) ) {
sighted_ = true;
break;
@ -3141,7 +3142,7 @@ public:
game_display &disp = *resources::screen;
unit_map &units = *resources::units;
foreach (const map_location & reveal, to_reveal_) {
BOOST_FOREACH(const map_location & reveal, to_reveal_) {
unit_map::iterator ambusher = units.find(reveal);
if ( ambusher != units.end() ) {
ambusher->set_state(unit::STATE_UNCOVERED, true); // (Needed in case we backtracked.)
@ -3614,7 +3615,7 @@ public:
if ( ambushed_ ) {
// Suppress the message for observers if the ambusher(s) cannot be seen.
bool show_message = playing_team_is_viewing;
foreach (const map_location &ambush, to_reveal_) {
BOOST_FOREACH(const map_location &ambush, to_reveal_) {
if ( !disp.fogged(ambush) )
show_message = true;
}
@ -3637,7 +3638,7 @@ public:
if ( playing_team_is_viewing && saw_units() ) {
// Count the number of allies and enemies sighted.
int friends = 0, enemies = 0;
foreach (const map_location &loc, seen_units_) {
BOOST_FOREACH(const map_location &loc, seen_units_) {
DBG_NG << "Processing unit at " << loc << "...\n";
const unit_map::const_iterator seen_it = units.find(loc);

View file

@ -16,13 +16,14 @@
#include "addon/info.hpp"
#include "addon/manager.hpp"
#include "foreach.hpp"
#include "game_config.hpp"
#include "gettext.hpp"
#include "image.hpp"
#include "log.hpp"
#include "serialization/string_utils.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_addons_client("addons-client");
#define ERR_AC LOG_STREAM(err , log_addons_client)
#define LOG_AC LOG_STREAM(info, log_addons_client)
@ -44,7 +45,7 @@ namespace {
return;
}
foreach(const std::string& dep, base_deps) {
BOOST_FOREACH(const std::string& dep, base_deps) {
if(base_id == dep) {
// TODO: make it possible to report this to the UI so it can be fixed by the add-on maintainer
ERR_AC << dep << " depends upon itself; breaking circular dependency\n";
@ -77,7 +78,7 @@ void addon_info::read(const config& cfg)
const config::const_child_itors& locales = cfg.child_range("translation");
foreach(const config& locale, locales) {
BOOST_FOREACH(const config& locale, locales) {
this->locales.push_back(locale["language"].str());
}
@ -97,7 +98,7 @@ void addon_info::write(config& cfg) const
cfg["uploads"] = this->uploads;
cfg["type"] = get_addon_type_string(this->type);
foreach(const std::string& locale_id, this->locales) {
BOOST_FOREACH(const std::string& locale_id, this->locales) {
cfg.add_child("translation")["language"] = locale_id;
}
@ -187,7 +188,7 @@ void read_addons_list(const config& cfg, addons_list& dest)
/** @todo FIXME: get rid of this legacy "campaign"/"campaigns" silliness */
const config::const_child_itors &addon_cfgs = cfg.child_range("campaign");
foreach(const config& addon_cfg, addon_cfgs) {
BOOST_FOREACH(const config& addon_cfg, addon_cfgs) {
const std::string& id = addon_cfg["name"].str();
if(dest.find(id) != dest.end()) {
ERR_AC << "add-ons list has multiple entries for '" << id << "', not good; ignoring them\n";

View file

@ -20,7 +20,6 @@
#include "addon/manager_ui.hpp"
#include "dialogs.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "formatter.hpp"
#include "game_display.hpp"
#include "game_preferences.hpp"
@ -43,6 +42,8 @@
#include "formula_string_utils.hpp"
#include "addon/client.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_config("config");
#define ERR_CFG LOG_STREAM(err , log_config)
#define LOG_CFG LOG_STREAM(info, log_config)
@ -335,11 +336,11 @@ static void unarchive_dir(const std::string& path, const config& cfg)
make_directory(dir);
foreach (const config &d, cfg.child_range("dir")) {
BOOST_FOREACH(const config &d, cfg.child_range("dir")) {
unarchive_dir(dir, d);
}
foreach (const config &f, cfg.child_range("file")) {
BOOST_FOREACH(const config &f, cfg.child_range("file")) {
unarchive_file(dir, f);
}
}

View file

@ -42,6 +42,7 @@
#include "wml_separators.hpp"
#include <boost/scoped_ptr.hpp>
#include <boost/foreach.hpp>
#include "addon/client.hpp"
@ -128,7 +129,7 @@ bool do_resolve_addon_dependencies(display& disp, addons_client& client, const a
std::vector<std::string> missing_deps;
std::vector<std::string> broken_deps;
foreach(const std::string& dep, deps) {
BOOST_FOREACH(const std::string& dep, deps) {
if(!is_addon_installed(dep)) {
if(addons.find(dep) != addons.end()) {
missing_deps.push_back(dep);
@ -149,7 +150,7 @@ bool do_resolve_addon_dependencies(display& disp, addons_client& client, const a
broken_deps.size());
broken_deps_report += "\n";
foreach(const std::string& broken_dep_id, broken_deps) {
BOOST_FOREACH(const std::string& broken_dep_id, broken_deps) {
broken_deps_report += "\n " + utils::unicode_bullet + " " + make_addon_title(broken_dep_id);
}
@ -177,7 +178,7 @@ bool do_resolve_addon_dependencies(display& disp, addons_client& client, const a
cursor_setter.reset(new cursor::setter(cursor::WAIT));
foreach(const std::string& dep, missing_deps) {
BOOST_FOREACH(const std::string& dep, missing_deps) {
const addon_info& addon = addon_at(dep, addons);
const std::string& display_size = size_display_string(addon.size);
@ -225,7 +226,7 @@ bool do_resolve_addon_dependencies(display& disp, addons_client& client, const a
std::vector<std::string> failed_titles;
foreach(const std::string& dep, missing_deps) {
BOOST_FOREACH(const std::string& dep, missing_deps) {
const addon_info& addon = addon_at(dep, addons);
config archive;
@ -460,7 +461,7 @@ sorted_addon_pointer_list sort_addons_list(addons_list& addons)
{
sorted_addon_pointer_list res;
foreach(const addons_list::value_type& entry, addons) {
BOOST_FOREACH(const addons_list::value_type& entry, addons) {
res.insert(&entry);
}
@ -538,7 +539,7 @@ void show_addons_manager_dialog(display& disp, addons_client& client, addons_lis
const sorted_addon_pointer_list& sorted_addons = sort_addons_list(addons);
foreach(const sorted_addon_pointer_list::value_type& sorted_entry, sorted_addons) {
BOOST_FOREACH(const sorted_addon_pointer_list::value_type& sorted_entry, sorted_addons) {
const addons_list::value_type& entry = *sorted_entry;
const addon_info& addon = entry.second;
tracking[addon.id] = get_addon_tracking_info(addon);
@ -634,7 +635,7 @@ void show_addons_manager_dialog(display& disp, addons_client& client, addons_lis
utils::string_map i18n_syms;
// Enter publish and remote deletion options
foreach(const std::string& pub_id, can_publish_ids) {
BOOST_FOREACH(const std::string& pub_id, can_publish_ids) {
i18n_syms["addon_title"] = make_addon_title(pub_id);
static const std::string publish_icon = "icons/icon-addon-publish.png";
@ -643,7 +644,7 @@ void show_addons_manager_dialog(display& disp, addons_client& client, addons_lis
options.push_back(IMAGE_PREFIX + publish_icon + COLUMN_SEPARATOR + font::GOOD_TEXT + text);
filter_options.push_back(text);
}
foreach(const std::string& del_id, can_delete_ids) {
BOOST_FOREACH(const std::string& del_id, can_delete_ids) {
i18n_syms["addon_title"] = make_addon_title(del_id);
static const std::string delete_icon = "icons/icon-addon-delete.png";
@ -793,7 +794,7 @@ void show_addons_manager_dialog(display& disp, addons_client& client, addons_lis
ids_to_install.push_back(option_ids[result]);
}
foreach(const std::string& id, ids_to_install) {
BOOST_FOREACH(const std::string& id, ids_to_install) {
const addon_info& addon = addon_at(id, addons);
if(!(do_check_before_overwriting_addon(disp.video(), addon) && do_resolve_addon_dependencies(disp, client, addons, addon, wml_changed))) {
@ -956,7 +957,7 @@ bool uninstall_local_addons(display& disp)
remove_names.clear();
foreach(const std::string& id, remove_ids) {
BOOST_FOREACH(const std::string& id, remove_ids) {
remove_names.push_back(make_addon_title(id));
}
@ -973,7 +974,7 @@ bool uninstall_local_addons(display& disp)
std::vector<std::string> failed_names, skipped_names, succeeded_names;
foreach(const std::string& id, remove_ids) {
BOOST_FOREACH(const std::string& id, remove_ids) {
const std::string& name = make_addon_title(id);
if(have_addon_pbl_info(id) || have_addon_in_vcs_tree(id)) {

View file

@ -17,7 +17,8 @@
#include "global.hpp"
#include "addon/validation.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include <boost/foreach.hpp>
const unsigned short default_campaignd_port = 15002;
@ -42,10 +43,10 @@ bool addon_name_legal(const std::string& name)
bool check_names_legal(const config& dir)
{
foreach (const config &path, dir.child_range("file")) {
BOOST_FOREACH(const config &path, dir.child_range("file")) {
if (!addon_name_legal(path["name"])) return false;
}
foreach (const config &path, dir.child_range("dir")) {
BOOST_FOREACH(const config &path, dir.child_range("dir")) {
if (!addon_name_legal(path["name"])) return false;
if (!check_names_legal(path)) return false;
}

View file

@ -27,11 +27,11 @@
#include "stage.hpp"
#include "../manager.hpp"
#include "../../actions.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/foreach.hpp>
namespace ai {
@ -60,7 +60,7 @@ void ai_composite::on_create()
cfg_["id"]<<"]"<<std::endl;
// init the composite ai stages
foreach(const config &cfg_element, cfg_.child_range("stage")){
BOOST_FOREACH(const config &cfg_element, cfg_.child_range("stage")){
add_stage(cfg_element);
}
@ -115,7 +115,7 @@ bool ai_composite::add_stage(const config &cfg)
std::vector< stage_ptr > stages;
create_stage(stages,cfg);
int j=0;
foreach (stage_ptr b, stages ){
BOOST_FOREACH(stage_ptr b, stages ){
stages_.push_back(b);
j++;
}
@ -128,7 +128,7 @@ bool ai_composite::add_goal(const config &cfg)
std::vector< goal_ptr > goals;
create_goal(goals,cfg);
int j=0;
foreach (goal_ptr b, goals ){
BOOST_FOREACH(goal_ptr b, goals ){
get_goals().push_back(b);
j++;
}
@ -137,7 +137,7 @@ bool ai_composite::add_goal(const config &cfg)
void ai_composite::play_turn(){
foreach(stage_ptr &s, stages_){
BOOST_FOREACH(stage_ptr &s, stages_){
s->play_stage();
}
}
@ -206,7 +206,7 @@ config ai_composite::to_config() const
config cfg;
//serialize the composite ai stages
foreach(const stage_ptr &s, stages_){
BOOST_FOREACH(const stage_ptr &s, stages_){
cfg.add_child("stage",s->to_config());
}

View file

@ -265,7 +265,7 @@ public:
, facets_()
, default_()
{
foreach (const config &cfg_element, this->cfg_.child_range("facet") ){
BOOST_FOREACH(const config &cfg_element, this->cfg_.child_range("facet") ){
add_facet(-1,cfg_element);
}
@ -291,7 +291,7 @@ public:
{
std::vector<aspect_ptr> facets_base;
engine::parse_aspect_from_config(*this,cfg,this->get_id(),std::back_inserter(facets_base));
foreach (aspect_ptr a, facets_base ){
BOOST_FOREACH(aspect_ptr a, facets_base ){
typename aspect_type<T>::typesafe_ptr b = boost::dynamic_pointer_cast< typesafe_aspect<T> > (a);
facets.push_back(b);
}
@ -301,7 +301,7 @@ public:
virtual void recalculate() const
{
///@todo 1.9 optimize in case of an aspect which returns variant
foreach (const typename aspect_type<T>::typesafe_ptr &f, make_pair(facets_.rbegin(),facets_.rend())) {
BOOST_FOREACH(const typename aspect_type<T>::typesafe_ptr &f, make_pair(facets_.rbegin(),facets_.rend())) {
if (f->active()) {
this->value_ = boost::shared_ptr<T>(f->get_ptr());
this->valid_ = true;
@ -316,7 +316,7 @@ public:
virtual config to_config() const
{
config cfg = aspect::to_config();
foreach (const typename aspect_type<T>::typesafe_ptr f, facets_) {
BOOST_FOREACH(const typename aspect_type<T>::typesafe_ptr f, facets_) {
cfg.add_child("facet",f->to_config());
}
if (default_) {
@ -334,7 +334,7 @@ public:
std::vector< aspect_ptr > facets;
engine::parse_aspect_from_config(*this,cfg,this->get_id(),std::back_inserter(facets));
int j=0;
foreach (aspect_ptr a, facets ){
BOOST_FOREACH(aspect_ptr a, facets ){
typename aspect_type<T>::typesafe_ptr b = boost::dynamic_pointer_cast< typesafe_aspect<T> > (a);
facets_.insert(facets_.begin()+pos+j,b);
j++;

View file

@ -23,12 +23,12 @@
#include "property_handler.hpp"
#include "../../config.hpp"
#include "../../log.hpp"
#include "../../foreach.hpp"
#include "../formula/ai.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <boost/foreach.hpp>
namespace pathfind {
@ -124,7 +124,7 @@ std::vector<component*> component::get_children(const std::string &type)
std::vector<std::string> component::get_children_types()
{
std::vector<std::string> types;
foreach (property_handler_map::value_type &ph, property_handlers_) {
BOOST_FOREACH(property_handler_map::value_type &ph, property_handlers_) {
types.push_back(ph.first);
}
return types;
@ -240,9 +240,9 @@ static void print_component(component *root, const std::string &type, std::strin
s << offset_str << type<<"["<<root->get_id() <<"] "<<root->get_engine()<<" "<<root->get_name()<< std::endl;
foreach (std::string t, t_list) {
BOOST_FOREACH(std::string t, t_list) {
std::vector<component*> c_list = root->get_children(t);
foreach (component *c, c_list) {
BOOST_FOREACH(component *c, c_list) {
print_component(c,t,s,offset+1);
}
}

View file

@ -21,7 +21,6 @@
#include "engine.hpp"
#include "contexts.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
namespace ai {

View file

@ -24,7 +24,6 @@
#include "engine_default.hpp"
#include "rca.hpp"
#include "stage.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
namespace ai {

View file

@ -25,7 +25,6 @@
#include "../formula/candidates.hpp"
#include "../formula/stage_side_formulas.hpp"
#include "../formula/stage_unit_formulas.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
namespace ai {

View file

@ -24,7 +24,6 @@
#include "../../log.hpp"
#include "../lua/lua_object.hpp"
#include "../../gamestatus.hpp"
#include "../../foreach.hpp"
#include "../../resources.hpp"
#include "../../scripting/lua.hpp"
#include "../../terrain_filter.hpp"
@ -34,6 +33,7 @@
#include "../../variable.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
namespace ai {
@ -128,7 +128,7 @@ void target_unit_goal::add_targets(std::back_insert_iterator< std::vector< targe
if (!criteria) return;
//find the enemy leaders and explicit targets
foreach (const unit &u, *resources::units) {
BOOST_FOREACH(const unit &u, *resources::units) {
if (u.matches_filter(vconfig(criteria), u.get_location())) {
LOG_AI_GOAL << "found explicit target unit at ... " << u.get_location() << " with value: " << value() << "\n";
*target_list = target(u.get_location(), value(), target::EXPLICIT);
@ -173,7 +173,7 @@ void target_location_goal::add_targets(std::back_insert_iterator< std::vector< t
std::set<map_location> items;
filter_ptr_->get_locations(items);
foreach (const map_location &loc, items)
BOOST_FOREACH(const map_location &loc, items)
{
LOG_AI_GOAL << "found explicit target location ... " << loc << " with value: " << value() << std::endl;
*target_list = target(loc, value(), target::EXPLICIT);
@ -252,7 +252,7 @@ void protect_goal::add_targets(std::back_insert_iterator< std::vector< target >
std::set<map_location> items;
if (protect_unit_) {
foreach (const unit &u, units)
BOOST_FOREACH(const unit &u, units)
{
if (protect_only_own_unit_ && u.side() != get_side()) {
continue;
@ -268,9 +268,9 @@ void protect_goal::add_targets(std::back_insert_iterator< std::vector< target >
}
DBG_AI_GOAL << "side " << get_side() << ": seaching for threats in "+goal_type+" goal" << std::endl;
// Look for directions to protect a specific location or specific unit.
foreach (const map_location &loc, items)
BOOST_FOREACH(const map_location &loc, items)
{
foreach (const unit &u, units)
BOOST_FOREACH(const unit &u, units)
{
int distance = distance_between(u.get_location(), loc);
if (current_team().is_enemy(u.side()) && distance < radius_ &&
@ -325,7 +325,7 @@ void lua_goal::add_targets(std::back_insert_iterator< std::vector< target > > ta
handler_->handle(c, true, l_obj);
std::vector < target > targets = *(l_obj->get());
foreach (target tg, targets)
BOOST_FOREACH(target tg, targets)
{
*target_list = tg;
}

View file

@ -23,9 +23,9 @@
#define AI_COMPOSITE_PROPERTY_HANDLER_HPP_INCLUDED
#include <boost/function.hpp>
#include <boost/foreach.hpp>
#include "config.hpp"
#include "foreach.hpp"
#include "ai/composite/component.hpp"
namespace ai{
@ -134,7 +134,7 @@ public:
std::vector<component*> handle_get_children()
{
std::vector<component*> children;
foreach (t_ptr v, values_) {
BOOST_FOREACH(t_ptr v, values_) {
children.push_back(&*v);
}
return children;
@ -149,7 +149,7 @@ private:
t_ptr_vector values;
factory_(values,cfg);
int j=0;
foreach (t_ptr b, values ){
BOOST_FOREACH(t_ptr b, values ){
values_.insert(values_.begin()+pos+j,b);
j++;
}
@ -200,7 +200,7 @@ public:
//* is a special case - 'delete all facets'
if (child.id == "*") {
bool b = false;
foreach(typename aspect_map::value_type a, aspects_) {
BOOST_FOREACH(typename aspect_map::value_type a, aspects_) {
b |= a.second->delete_all_facets();
}
return b;
@ -212,7 +212,7 @@ public:
std::vector<component*> handle_get_children()
{
std::vector<component*> children;
foreach(typename aspect_map::value_type a, aspects_) {
BOOST_FOREACH(typename aspect_map::value_type a, aspects_) {
children.push_back(&*a.second);
}
return children;

View file

@ -22,7 +22,6 @@
#include "engine.hpp"
#include "stage.hpp"
#include "../contexts.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../resources.hpp"
#include "../../tod_manager.hpp"

View file

@ -22,12 +22,13 @@
#include "configuration.hpp"
#include "../filesystem.hpp"
#include "../foreach.hpp"
#include "../log.hpp"
#include "../serialization/parser.hpp"
#include "../serialization/preprocessor.hpp"
#include "../team.hpp"
#include <boost/foreach.hpp>
#include <vector>
namespace ai {
@ -93,7 +94,7 @@ void configuration::init(const config &game_config)
}
foreach (const config &ai_configuration, ais.child_range("ai")) {
BOOST_FOREACH(const config &ai_configuration, ais.child_range("ai")) {
const std::string &id = ai_configuration["id"];
if (id.empty()){
@ -118,7 +119,7 @@ void configuration::init(const config &game_config)
void configuration::add_era_ai_from_config(const config &era)
{
era_ai_configurations_.clear();
foreach (const config &ai_configuration, era.child_range("ai")) {
BOOST_FOREACH(const config &ai_configuration, era.child_range("ai")) {
const std::string &id = ai_configuration["id"];
if (id.empty()){
@ -196,7 +197,7 @@ bool configuration::upgrade_aspect_config_from_1_07_02_to_1_07_03(side_number /*
config aspect_config;
aspect_config["id"] = id;
foreach (const config &aiparam, cfg.child_range("ai")) {
BOOST_FOREACH(const config &aiparam, cfg.child_range("ai")) {
const config &_aspect = aiparam.find_child("aspect","id",id);
if (_aspect) {
aspect_config.append(_aspect);
@ -216,7 +217,7 @@ bool configuration::upgrade_aspect_config_from_1_07_02_to_1_07_03(side_number /*
if (aspect_was_attribute) {
facet_config["value"] = aiparam[id];
} else {
foreach (const config &value, aiparam.child_range(id)) {
BOOST_FOREACH(const config &value, aiparam.child_range(id)) {
facet_config.add_child("value",value);
}
}
@ -242,7 +243,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
//leave only the [ai] children
cfg = config();
foreach (const config &aiparam, original_cfg.child_range("ai")) {
BOOST_FOREACH(const config &aiparam, original_cfg.child_range("ai")) {
cfg.add_child("ai",aiparam);
}
@ -264,7 +265,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
//find version
int version = 10600;
foreach (const config &aiparam, cfg.child_range("ai")) {
BOOST_FOREACH(const config &aiparam, cfg.child_range("ai")) {
if (const config::attribute_value *a = aiparam.get("version")){
int v = a->to_int(version);
if (version<v) {
@ -290,7 +291,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
config parsed_cfg = config();
LOG_AI_CONFIGURATION << "side "<< side <<": merging AI configurations"<< std::endl;
foreach (const config &aiparam, cfg.child_range("ai")) {
BOOST_FOREACH(const config &aiparam, cfg.child_range("ai")) {
parsed_cfg.append(aiparam);
}
@ -302,7 +303,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
parsed_cfg.merge_children_by_attribute("aspect","id");
LOG_AI_CONFIGURATION << "side "<< side <<": removing duplicate [default] tags from aspects"<< std::endl;
foreach (config &aspect_cfg, parsed_cfg.child_range("aspect")) {
BOOST_FOREACH(config &aspect_cfg, parsed_cfg.child_range("aspect")) {
if (!aspect_cfg.child("default")) {
WRN_AI_CONFIGURATION << "side "<< side <<": aspect with id=["<<aspect_cfg["id"]<<"] lacks default config facet!" <<std::endl;
continue;
@ -341,7 +342,7 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side
if (cfg["ai_algorithm"]=="idle_ai") {
is_idle_ai = true;
} else {
foreach (config &aiparam, cfg.child_range("ai")) {
BOOST_FOREACH(config &aiparam, cfg.child_range("ai")) {
if (aiparam["ai_algorithm"]=="idle_ai") {
is_idle_ai = true;
break;
@ -360,8 +361,8 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side
config fallback_stage_cfg_ai;
foreach (config &aiparam, cfg.child_range("ai")) {
foreach (const well_known_aspect &wka, well_known_aspects) {
BOOST_FOREACH(config &aiparam, cfg.child_range("ai")) {
BOOST_FOREACH(const well_known_aspect &wka, well_known_aspects) {
if (wka.was_an_attribute_) {
aiparam.remove_attribute(wka.name_);
} else {
@ -370,7 +371,7 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side
}
foreach (const config &aitarget, aiparam.child_range("target")) {
BOOST_FOREACH(const config &aitarget, aiparam.child_range("target")) {
config aigoal;
transfer_turns_and_time_of_day_data(aiparam,aigoal);
@ -388,14 +389,14 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side
aiparam.clear_children("target");
foreach (config &ai_protect_unit, aiparam.child_range("protect_unit")) {
BOOST_FOREACH(config &ai_protect_unit, aiparam.child_range("protect_unit")) {
transfer_turns_and_time_of_day_data(aiparam,ai_protect_unit);
upgrade_protect_goal_config_from_1_07_02_to_1_07_03(side,ai_protect_unit,parsed_cfg,true);
}
aiparam.clear_children("protect_unit");
foreach (config &ai_protect_location, aiparam.child_range("protect_location")) {
BOOST_FOREACH(config &ai_protect_location, aiparam.child_range("protect_location")) {
transfer_turns_and_time_of_day_data(aiparam,ai_protect_location);
upgrade_protect_goal_config_from_1_07_02_to_1_07_03(side,ai_protect_location,parsed_cfg,false);
}
@ -423,19 +424,19 @@ bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side
fallback_stage_cfg_ai.clear_children("aspect");
//move [stage]s to root of the config
foreach (const config &aistage, fallback_stage_cfg_ai.child_range("stage")) {
BOOST_FOREACH(const config &aistage, fallback_stage_cfg_ai.child_range("stage")) {
parsed_cfg.add_child("stage",aistage);
}
fallback_stage_cfg_ai.clear_children("stage");
//move [goal]s to root of the config
foreach (const config &aigoal, fallback_stage_cfg_ai.child_range("goal")) {
BOOST_FOREACH(const config &aigoal, fallback_stage_cfg_ai.child_range("goal")) {
parsed_cfg.add_child("goal",aigoal);
}
fallback_stage_cfg_ai.clear_children("goal");
//move [modify_ai]'s to root of the config
foreach (const config &aimodifyai, fallback_stage_cfg_ai.child_range("modify_ai")) {
BOOST_FOREACH(const config &aimodifyai, fallback_stage_cfg_ai.child_range("modify_ai")) {
parsed_cfg.add_child("modify_ai",aimodifyai);
}
fallback_stage_cfg_ai.clear_children("modify_ai");
@ -452,12 +453,12 @@ void configuration::upgrade_aspect_configs_from_1_07_02_to_1_07_03(side_number s
{
config cfg;
foreach (const config &aiparam, ai_parameters) {
BOOST_FOREACH(const config &aiparam, ai_parameters) {
cfg.add_child("ai",aiparam);
}
DBG_AI_CONFIGURATION << "side "<< side <<": upgrading aspects from syntax of 1.7.2 to 1.7.3, old-style config is:" << std::endl << cfg << std::endl;
foreach (const well_known_aspect &wka, well_known_aspects) {
BOOST_FOREACH(const well_known_aspect &wka, well_known_aspects) {
upgrade_aspect_config_from_1_07_02_to_1_07_03(side, cfg,parsed_cfg,wka.name_,wka.was_an_attribute_);
}
}

View file

@ -41,6 +41,8 @@
#include "../resources.hpp"
#include "../tod_manager.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_ai("ai/general");
#define DBG_AI LOG_STREAM(debug, log_ai)
#define LOG_AI LOG_STREAM(info, log_ai)
@ -221,19 +223,19 @@ readonly_context_impl::readonly_context_impl(side_context &context, const config
void readonly_context_impl::on_readonly_context_create() {
//init the composite ai engines
foreach(const config &cfg_element, cfg_.child_range("engine")){
BOOST_FOREACH(const config &cfg_element, cfg_.child_range("engine")){
engine::parse_engine_from_config(*this,cfg_element,std::back_inserter(engines_));
}
// init the composite ai aspects
foreach(const config &cfg_element, cfg_.child_range("aspect")){
BOOST_FOREACH(const config &cfg_element, cfg_.child_range("aspect")){
std::vector<aspect_ptr> aspects;
engine::parse_aspect_from_config(*this,cfg_element,cfg_element["id"],std::back_inserter(aspects));
add_aspects(aspects);
}
// init the composite ai goals
foreach(const config &cfg_element, cfg_.child_range("goal")){
BOOST_FOREACH(const config &cfg_element, cfg_.child_range("goal")){
engine::parse_goal_from_config(*this,cfg_element,std::back_inserter(get_goals()));
}
}
@ -253,13 +255,13 @@ config readwrite_context_impl::to_readwrite_context_config() const
config readonly_context_impl::to_readonly_context_config() const
{
config cfg;
foreach(const engine_ptr e, engines_) {
BOOST_FOREACH(const engine_ptr e, engines_) {
cfg.add_child("engine",e->to_config());
}
foreach(const aspect_map::value_type a, aspects_) {
BOOST_FOREACH(const aspect_map::value_type a, aspects_) {
cfg.add_child("aspect",a.second->to_config());
}
foreach(const goal_ptr g, goals_) {
BOOST_FOREACH(const goal_ptr g, goals_) {
cfg.add_child("goal",g->to_config());
}
return cfg;
@ -364,7 +366,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
}
for(std::map<map_location,pathfind::paths>::iterator m = res.begin(); m != res.end(); ++m) {
foreach (const pathfind::paths::step &dest, m->second.destinations)
BOOST_FOREACH(const pathfind::paths::step &dest, m->second.destinations)
{
const map_location& src = m->first;
const map_location& dst = dest.curr;
@ -404,7 +406,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
void readonly_context_impl::add_aspects(std::vector< aspect_ptr > &aspects )
{
foreach (aspect_ptr a, aspects) {
BOOST_FOREACH(aspect_ptr a, aspects) {
const std::string id = a->get_id();
known_aspect_map::iterator i = known_aspects_.find(id);
if (i != known_aspects_.end()) {
@ -1052,7 +1054,7 @@ double readonly_context_impl::power_projection(const map_location& loc, const mo
// The 0.5 power avoids underestimating too much the damage of a wounded unit.
int hp = int(sqrt(double(un.hitpoints()) / un.max_hitpoints()) * 1000);
int most_damage = 0;
foreach (const attack_type &att, un.attacks())
BOOST_FOREACH(const attack_type &att, un.attacks())
{
int damage = att.damage() * att.num_attacks() * (100 + tod_modifier);
if (damage > most_damage) {
@ -1167,7 +1169,7 @@ const map_location& readonly_context_impl::suitable_keep(const map_location& lea
map_location const* best_occupied_keep = &map_location::null_location;
double move_left_at_best_occupied_keep = 0.0;
foreach (const pathfind::paths::step &dest, leader_paths.destinations)
BOOST_FOREACH(const pathfind::paths::step &dest, leader_paths.destinations)
{
const map_location &loc = dest.curr;
if (keeps().find(loc)!=keeps().end()){

View file

@ -26,7 +26,6 @@
#include "../../array.hpp"
#include "../../dialogs.hpp"
#include "../../foreach.hpp"
#include "../../game_events.hpp"
#include "../../log.hpp"
#include "../../mouse_handler_base.hpp"
@ -37,6 +36,8 @@
#include "../../pathfind/pathfind.hpp"
#include <boost/foreach.hpp>
#include <iterator>
#include <algorithm>
#include <fstream>
@ -140,7 +141,7 @@ void ai_default_recruitment_stage::recruit_situation_change_observer::set_valid(
void ai_default_recruitment_stage::on_create() {
stage::on_create();
foreach (const config &c, cfg_.child_range("limit")) {
BOOST_FOREACH(const config &c, cfg_.child_range("limit")) {
if (c.has_attribute("type") && c.has_attribute("max") ) {
maximum_counts_.insert(std::make_pair(c["type"],lexical_cast_default<int>(c["max"],0)));
}
@ -189,7 +190,7 @@ bool ai_default_recruitment_stage::recruit_usage(const std::string& usage)
bool found = false;
// Find an available unit that can be recruited,
// matches the desired usage type, and comes in under budget.
foreach (const std::string &name, current_team().recruits())
BOOST_FOREACH(const std::string &name, current_team().recruits())
{
const unit_type *ut = unit_types.find(name);
if (!ut) continue;
@ -431,7 +432,7 @@ int ai_default_recruitment_stage::get_combat_score(const unit_type& ut) const
team &enemy_team = (*resources::teams)[j->side() - 1];
const std::set<std::string> &recruits = enemy_team.recruits();
foreach (const std::string &rec, recruits) {
BOOST_FOREACH(const std::string &rec, recruits) {
get_combat_score_vs(ut,rec,score,weighting,0,0);
}
continue;
@ -673,7 +674,7 @@ public:
double best_combat_score_of_advancement = 0;
bool best_combat_score_of_advancement_found = false;
int best_cost = recall_cost;
foreach (const std::string &i, u.advances_to()) {
BOOST_FOREACH(const std::string &i, u.advances_to()) {
const unit_type *ut = unit_types.find(i);
if (!ut) {
continue;

View file

@ -25,7 +25,6 @@
#include "../manager.hpp"
#include "../../attack_prediction.hpp"
#include "foreach.hpp"
#include "../../game_config.hpp"
#include "../../log.hpp"
#include "../../map.hpp"

View file

@ -22,7 +22,6 @@
#include "contexts.hpp"
#include "../../actions.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../resources.hpp"

View file

@ -32,7 +32,6 @@
#include "../../callable_objects.hpp"
#include "../../game_display.hpp"
#include "../../foreach.hpp"
#include "../../formula_debugger.hpp"
#include "../../log.hpp"
#include "../../menu_events.hpp"
@ -42,6 +41,8 @@
#include "../../tod_manager.hpp"
#include "../../pathfind/pathfind.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_formula_ai("ai/engine/fai");
#define DBG_AI LOG_STREAM(debug, log_formula_ai)
#define LOG_AI LOG_STREAM(info, log_formula_ai)
@ -548,7 +549,7 @@ template<typename Container>
variant villages_from_set(const Container& villages,
const std::set<map_location>* exclude=NULL) {
std::vector<variant> vars;
foreach(const map_location& loc, villages) {
BOOST_FOREACH(const map_location& loc, villages) {
if(exclude && exclude->count(loc)) {
continue;
}
@ -617,7 +618,7 @@ variant formula_ai::get_value(const std::string& key) const
{
const std::vector<std::string> &rp = get_recruitment_pattern();
std::vector<variant> vars;
foreach (const std::string &i, rp) {
BOOST_FOREACH(const std::string &i, rp) {
vars.push_back(variant(i));
}
return variant(&vars);
@ -751,7 +752,7 @@ variant formula_ai::get_value(const std::string& key) const
std::vector<variant> v;
tmp.push_back( v );
}
foreach (const unit &u, units) {
BOOST_FOREACH(const unit &u, units) {
tmp[u.side() - 1].push_back(variant(new unit_callable(u)));
}
for( size_t i = 0; i<tmp.size(); ++i)
@ -924,7 +925,7 @@ void formula_ai::on_create(){
//make sure we don't run out of refcount
vars_.add_ref();
foreach (const config &func, cfg_.child_range("function"))
BOOST_FOREACH(const config &func, cfg_.child_range("function"))
{
const t_string &name = func["name"];
const t_string &inputs = func["inputs"];
@ -947,7 +948,7 @@ void formula_ai::on_create(){
if (const config &ai_vars = cfg_.child("vars"))
{
variant var;
foreach (const config::attribute &i, ai_vars.attribute_range()) {
BOOST_FOREACH(const config::attribute &i, ai_vars.attribute_range()) {
var.serialize_from_string(i.second);
vars_.add(i.first, var);
}

View file

@ -19,10 +19,11 @@
#include "ai.hpp"
#include "candidates.hpp"
#include "foreach.hpp"
#include "../../log.hpp"
#include "../../resources.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_formula_ai("ai/engine/fai");
#define ERR_AI LOG_STREAM(err, log_formula_ai)
@ -32,7 +33,7 @@ namespace game_logic {
void candidate_action_manager::load_config(const config& cfg, ai::formula_ai* ai, function_symbol_table* function_table)
{
// register candidate actions
foreach (const config &rc_action, cfg.child_range("register_candidate_action"))
BOOST_FOREACH(const config &rc_action, cfg.child_range("register_candidate_action"))
{
candidate_action_ptr new_ca = load_candidate_action_from_config(rc_action,ai,function_table);
@ -67,7 +68,7 @@ bool candidate_action_manager::evaluate_candidate_actions(ai::formula_ai* ai, un
{
evaluated_candidate_actions_.clear();
foreach(candidate_action_ptr cm, candidate_actions_)
BOOST_FOREACH(candidate_action_ptr cm, candidate_actions_)
{
cm->evaluate(ai, units);
evaluated_candidate_actions_.insert(cm);
@ -116,7 +117,7 @@ candidate_action_with_filters::candidate_action_with_filters(
const config & filter_params = cfg.child("filter");
if( filter_params ) {
foreach( const config::attribute filter_param, filter_params.attribute_range() )
BOOST_FOREACH( const config::attribute filter_param, filter_params.attribute_range() )
{
game_logic::const_formula_ptr filter_formula(
new game_logic::formula(filter_param.second, function_table));

View file

@ -24,7 +24,6 @@
#include "../../attack_prediction.hpp"
#include "../../filesystem.hpp"
#include "../../foreach.hpp"
#include "../../game_display.hpp"
#include "../../log.hpp"
#include "../../map_label.hpp"
@ -36,6 +35,7 @@
#include "../../unit.hpp"
#include "../../pathfind/pathfind.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_formula_ai("ai/engine/fai");
#define LOG_AI LOG_STREAM(info, log_formula_ai)
@ -355,7 +355,7 @@ private:
if( scores[current_side][i] > 98 )
continue;
foreach( int side , enemies) {
BOOST_FOREACH( int side , enemies) {
int diff = scores[current_side][i] - scores[side][i];
if ( diff > enemy_tollerancy) {
valid = false;
@ -365,7 +365,7 @@ private:
}
if( valid ) {
foreach( int side , allies) {
BOOST_FOREACH( int side , allies) {
if ( scores[current_side][i] - scores[side][i] > ally_tollerancy ) {
valid = false;
break;
@ -563,7 +563,7 @@ private:
visited_locs.erase(starting_loc);
std::vector<variant> res;
foreach( const map_location& ml, visited_locs) {
BOOST_FOREACH( const map_location& ml, visited_locs) {
res.push_back( variant(new location_callable( ml ) ) );
}
@ -842,7 +842,7 @@ private:
ai::attack_analysis* analysis = convert_variant<ai::attack_analysis>(attack);
//unit_map units_with_moves(*resources::units);
//typedef std::pair<map_location, map_location> mv;
//foreach (const mv &m, analysis->movements) {
//BOOST_FOREACH(const mv &m, analysis->movements) {
// units_with_moves.move(m.first, m.second);
//}
@ -1631,7 +1631,7 @@ private:
std::vector<attack_type> attacks = attacker.attacks();
foreach(const attack_type &attack, attacks) {
BOOST_FOREACH(const attack_type &attack, attacks) {
const int dmg = round_damage(attack.damage(), defender.damage_from(attack), 100) * attack.num_attacks();
if (attack.range() == "melee") {
highest_melee_damage = std::max(highest_melee_damage, dmg);

View file

@ -22,7 +22,6 @@
#include "stage_side_formulas.hpp"
#include "ai.hpp"
#include "../../foreach.hpp"
#include "../../formula.hpp"
#include "../../formula_function.hpp"
#include "../../log.hpp"

View file

@ -35,7 +35,6 @@
#include "../../actions.hpp"
#include "../../attack_prediction.hpp"
#include "../../filesystem.hpp"
#include "../../foreach.hpp"
#include "../../game_display.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"

View file

@ -26,11 +26,12 @@
#include "formula/ai.hpp"
#include "registry.hpp"
#include "../game_events.hpp"
#include "../foreach.hpp"
#include "../log.hpp"
#include "../serialization/string_utils.hpp"
#include "composite/component.hpp"
#include <boost/foreach.hpp>
#include <map>
#include <stack>
#include <vector>
@ -86,7 +87,7 @@ void holder::init( side_number side )
if (this->ai_) {
ai_->on_create();
foreach (config &mod_ai, cfg_.child_range("modify_ai")) {
BOOST_FOREACH(config &mod_ai, cfg_.child_range("modify_ai")) {
if (!mod_ai.has_attribute("side")) {
mod_ai["side"] = side;
}
@ -146,8 +147,8 @@ void holder::modify_ai_config_old( const config::const_child_itors &ai_parameter
cfg_.merge_children_by_attribute("aspect","id");
} else {
// else run 'add_facet' command on each [aspect][facet]
foreach (const config &cfg_a, cfg.child_range("aspect")) {
foreach (const config &cfg_f, cfg_a.child_range("facet")) {
BOOST_FOREACH(const config &cfg_a, cfg.child_range("aspect")) {
BOOST_FOREACH(const config &cfg_f, cfg_a.child_range("facet")) {
readonly_context_->add_facet(cfg_a["id"],cfg_f);
}
}

View file

@ -22,7 +22,6 @@
#include "../manager.hpp"
#include "../../actions.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../team.hpp"

View file

@ -25,7 +25,6 @@
#include "../composite/rca.hpp"
#include "../composite/stage.hpp"
#include "../../gamestatus.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../resources.hpp"
@ -33,6 +32,7 @@
#include "../../wml_exception.hpp"
#include "../../pathfind/pathfind.hpp"
#include <boost/foreach.hpp>
#include <numeric>
@ -306,7 +306,7 @@ bool recruitment_phase::recruit_usage(const std::string& usage)
bool found = false;
// Find an available unit that can be recruited,
// matches the desired usage type, and comes in under budget.
foreach (const std::string &name, current_team().recruits())
BOOST_FOREACH(const std::string &name, current_team().recruits())
{
const unit_type *ut = unit_types.find(name);
if (!ut) continue;
@ -686,7 +686,7 @@ double move_leader_to_goals_phase::evaluate()
possible_moves.insert(std::pair<map_location,pathfind::paths>(leader->get_location(), leader_paths));
map_location loc;
foreach (const map_location &l, route.steps)
BOOST_FOREACH(const map_location &l, route.steps)
{
if (leader_paths.destinations.contains(l) &&
power_projection(l, get_enemy_dstsrc()) < leader->hitpoints() * max_risk)
@ -779,7 +779,7 @@ double move_leader_to_keep_phase::evaluate()
// The leader can't move to his keep, try to move to the closest location
// to the keep where there are no enemies in range.
int current_distance = distance_between(leader->get_location(), keep);
foreach (const pathfind::paths::step &dest, leader_paths.destinations)
BOOST_FOREACH(const pathfind::paths::step &dest, leader_paths.destinations)
{
if (!units_.find(dest.curr).valid()){
const int new_distance = distance_between(dest.curr,keep);
@ -1728,12 +1728,12 @@ double retreat_phase::evaluate()
}*/
//int leader_adj_count = 0;
std::vector<map_location> leaders_adj_v;
foreach(unit_map::const_iterator leader, leaders){
BOOST_FOREACH(unit_map::const_iterator leader, leaders){
map_location tmp_leader_adj[6];
get_adjacent_tiles(leader->get_location(), tmp_leader_adj);
foreach(map_location &loc, tmp_leader_adj){
BOOST_FOREACH(map_location &loc, tmp_leader_adj){
bool found = false;
foreach(map_location &new_loc, leaders_adj_v){
BOOST_FOREACH(map_location &new_loc, leaders_adj_v){
if(new_loc == loc){
found = true;
break;
@ -1974,7 +1974,7 @@ double passive_leader_shares_keep_phase::evaluate()
}
std::vector<unit_map::unit_iterator> ai_leaders = resources::units->find_leaders(get_side());
bool allied_leaders_available = false;
foreach(team &tmp_team, *resources::teams){
BOOST_FOREACH(team &tmp_team, *resources::teams){
if(!current_team().is_enemy(tmp_team.side())){
std::vector<unit_map::unit_iterator> allied_leaders = resources::units->find_leaders(get_side());
if (!allied_leaders.empty()){
@ -2001,7 +2001,7 @@ void passive_leader_shares_keep_phase::execute()
calculate_moves(*resources::units, possible_moves, friends_srcdst, friends_dstsrc, false, true);
//check for each ai leader if he should move away from his keep
foreach(unit_map::unit_iterator &ai_leader, ai_leaders){
BOOST_FOREACH(unit_map::unit_iterator &ai_leader, ai_leaders){
//only if leader is on a keep
if (!resources::game_map->is_keep(ai_leader->get_location())) {
continue;
@ -2059,7 +2059,7 @@ void passive_leader_shares_keep_phase::execute()
}
ai_leader->remove_movement_ai();
}
foreach(unit_map::unit_iterator &leader, ai_leaders){
BOOST_FOREACH(unit_map::unit_iterator &leader, ai_leaders){
leader->remove_movement_ai();
}
//ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented" << std::endl;

View file

@ -25,7 +25,6 @@
#include "../actions.hpp"
#include "../../game_display.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../map_label.hpp"
@ -36,6 +35,7 @@
#include "../../terrain_filter.hpp"
#include "../../tod_manager.hpp"
#include <boost/foreach.hpp>
namespace ai {
@ -89,7 +89,7 @@ void global_fallback_phase::execute()
LOG_AI << "start" << std::endl;
const int ticks = SDL_GetTicks();
double res_sum = 0;
foreach( unit &u, *resources::units)
BOOST_FOREACH( unit &u, *resources::units)
{
if (u.side()!=get_side())
{

View file

@ -22,7 +22,6 @@
#include "../composite/ai.hpp"
#include "../actions.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../resources.hpp"

View file

@ -25,7 +25,6 @@
#include "../composite/rca.hpp"
#include "../composite/stage.hpp"
#include "../../gamestatus.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../resources.hpp"
@ -33,6 +32,7 @@
#include "../../wml_exception.hpp"
#include "../../pathfind/pathfind.hpp"
#include <boost/foreach.hpp>
#include <numeric>
#include <string>
@ -206,7 +206,7 @@ class fake_team
int get_current_qty(const std::string &name) const
{
int counter = 0;
foreach(unit &un, *resources::units){
BOOST_FOREACH(unit &un, *resources::units){
if(un.side() == side() && un.type_id() == name) // @todo: is type_id good?
{
counter++;
@ -345,7 +345,7 @@ static int compare_unit_types(const unit_type& a, const unit_type& b)
const int hitpoints_const = 100;
double score = 0;
double total_weight = 0;
foreach(const unit &enemy_unit, *resources::units)
BOOST_FOREACH(const unit &enemy_unit, *resources::units)
{
if(enemy_unit.can_recruit() || !t.is_enemy(enemy_unit.side()))
{
@ -358,13 +358,13 @@ static int compare_unit_types(const unit_type& a, const unit_type& b)
score += compare_unit_types(info, *enemy_info) * weight;
}
foreach(fake_team &enemy_team, fake_teams)
BOOST_FOREACH(fake_team &enemy_team, fake_teams)
{
if(!t.is_enemy(enemy_team.side()))
{
continue;
}
foreach(const potential_recruit &enemy_unit, enemy_team.extra_units())
BOOST_FOREACH(const potential_recruit &enemy_unit, enemy_team.extra_units())
{
const unit_type *enemy_info = enemy_unit.type();
VALIDATE(enemy_info, "Unknown unit type : " + enemy_unit.id() + " while updating recruit quality.");
@ -386,7 +386,7 @@ static int compare_unit_types(const unit_type& a, const unit_type& b)
/*static void update_recruit_qualities(fake_team &t, std::vector<fake_team> &fake_teams)
{
foreach ( potential_recruit &recruit, t.recruit_list() )
BOOST_FOREACH( potential_recruit &recruit, t.recruit_list() )
{
double score = get_unit_quality(*recruit.type(),t,fake_teams);
recruit.set_quality(score);
@ -425,11 +425,11 @@ static std::vector<potential_recruit> ai_choose_best_recruits(fake_team &t, int
}
std::map<std::string, int> current_units;
foreach (const potential_recruit &i, t.extra_units())
BOOST_FOREACH(const potential_recruit &i, t.extra_units())
{
current_units[(i.id())]++;
}
foreach (const unit &i, *resources::units)
BOOST_FOREACH(const unit &i, *resources::units)
{
if (i.side()==t.side())
{
@ -440,7 +440,7 @@ static std::vector<potential_recruit> ai_choose_best_recruits(fake_team &t, int
double max_quality = recruit_list[0].quality();
int max_cost = recruit_list[0].cost();
std::vector<const potential_recruit*> sorted = std::vector<const potential_recruit*>();
foreach(const potential_recruit &i, recruit_list)
BOOST_FOREACH(const potential_recruit &i, recruit_list)
{
if(i.cost() > max_cost)
{
@ -457,7 +457,7 @@ static std::vector<potential_recruit> ai_choose_best_recruits(fake_team &t, int
potential_recruit_sorter sorter(max_cost, max_quality, quality_factor);
std::sort(sorted.begin(), sorted.end(), sorter);
int recruited = 0;
foreach(const potential_recruit *i, sorted)
BOOST_FOREACH(const potential_recruit *i, sorted)
{
if(recruited < max_units_to_recruit)
{
@ -488,7 +488,7 @@ static std::vector<potential_recruit> ai_choose_best_recruits(fake_team &t, int
static void ai_choose_recruits(fake_team &t, int max_units_to_recruit, double quality_factor, bool counter_recruit)
{
std::vector<potential_recruit> recruits = ai_choose_best_recruits(t, max_units_to_recruit, quality_factor, counter_recruit);
foreach(potential_recruit &i, recruits) {
BOOST_FOREACH(potential_recruit &i, recruits) {
t.fake_recruit(i);
}
@ -554,7 +554,7 @@ static void get_recruit_qualities(std::vector<potential_recruit> &recruit_list,
//DBG_AI << "start of get_recruit_qualities" << std::endl;
typedef std::map<const unit_type*, std::vector<double> > unit_map;
unit_map enemies;
foreach(unit &un, *resources::units){
BOOST_FOREACH(unit &un, *resources::units){
if(t.is_enemy(un.side()) && !un.can_recruit()){
enemies[un.type()].push_back(
static_cast<double>(un.hitpoints())
@ -562,10 +562,10 @@ static void get_recruit_qualities(std::vector<potential_recruit> &recruit_list,
}
}
DBG_AI << "before extra_units of fake_teams: enemies.size() = " << enemies.size() << std::endl;
foreach(fake_team &tmp_t, fake_teams)
BOOST_FOREACH(fake_team &tmp_t, fake_teams)
{
if (t.is_enemy(tmp_t.side())) {
foreach(potential_recruit &rec, tmp_t.extra_units())
BOOST_FOREACH(potential_recruit &rec, tmp_t.extra_units())
{
enemies[rec.type()].push_back(1.0);
}
@ -573,10 +573,10 @@ static void get_recruit_qualities(std::vector<potential_recruit> &recruit_list,
}
DBG_AI << "after extra_units of fake_teams: enemies.size() = " << enemies.size() << std::endl;
foreach(potential_recruit &rec, recruit_list) {
BOOST_FOREACH(potential_recruit &rec, recruit_list) {
double score = 0;
double weighting = 0;
foreach(unit_map::value_type &enemy, enemies) {
BOOST_FOREACH(unit_map::value_type &enemy, enemies) {
double hitpoints_sum = std::accumulate(enemy.second.begin(),enemy.second.end(),0);
score += compare_unit_types(*rec.type(), *enemy.first) * hitpoints_sum;
weighting += hitpoints_sum;
@ -621,14 +621,14 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
{
std::vector<defender_pair_type*> defenders;
std::vector<enemy_pair_type*> enemies;
foreach(unit &un, *resources::units)
BOOST_FOREACH(unit &un, *resources::units)
{
if(t.is_enemy(un.side()))
{
// const unit_type &enemy_type = *un.type();
//enemy_pair_type *pair = new enemy_pair_type(new unit_data(un.id(), un.type()));
enemy_pair_type *pair = new enemy_pair_type(un.type());
foreach(unit &defender, *resources::units)
BOOST_FOREACH(unit &defender, *resources::units)
{
if(!t.is_enemy(defender.side())){
//int score = compare_unit_types(*defender.type(), enemy_type);
@ -639,9 +639,9 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
//}
}
}
foreach(fake_team &tmp_t, fake_teams){
BOOST_FOREACH(fake_team &tmp_t, fake_teams){
if(!t.is_enemy(tmp_t.side())){
foreach(potential_recruit &rec, tmp_t.extra_units()){
BOOST_FOREACH(potential_recruit &rec, tmp_t.extra_units()){
// int score = compare_unit_types(*rec.type(), enemy_type);
// if(score >= 0){
//pair->add_defender(new unit_data(rec.id(), rec.type()));
@ -657,7 +657,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
//const unit_type &defender_type = *un.type();
//defender_pair_type *pair = new defender_pair_type(new unit_data(un.id(), un.type()));
defender_pair_type *pair = new defender_pair_type(un.type());
foreach(unit &enemy, *resources::units)
BOOST_FOREACH(unit &enemy, *resources::units)
{
//int score = compare_unit_types(defender_type, *enemy.type());
//if(score >= 0)
@ -666,9 +666,9 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
pair->add_enemy(enemy.type());
//}
}
foreach(fake_team &tmp_t, fake_teams){
BOOST_FOREACH(fake_team &tmp_t, fake_teams){
if(t.is_enemy(tmp_t.side())){
foreach(potential_recruit &rec, tmp_t.extra_units()){
BOOST_FOREACH(potential_recruit &rec, tmp_t.extra_units()){
//int score = compare_unit_types(defender_type, *rec.type());
//if(score >= 0){
//pair->add_enemy(new unit_data(rec.id(), rec.type()));
@ -680,14 +680,14 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
defenders.push_back(pair);
}
}
foreach(fake_team &tmp_t, fake_teams)
BOOST_FOREACH(fake_team &tmp_t, fake_teams)
{
foreach(potential_recruit &rec, tmp_t.extra_units()){
BOOST_FOREACH(potential_recruit &rec, tmp_t.extra_units()){
if(t.is_enemy(tmp_t.side())){
//const unit_type &enemy_type = *rec.type();
//enemy_pair_type *pair = new enemy_pair_type(new unit_data(rec.id(), rec.type()));
enemy_pair_type *pair = new enemy_pair_type(rec.type());
foreach(unit &defender, *resources::units){
BOOST_FOREACH(unit &defender, *resources::units){
if(t.is_enemy(defender.side())){
continue;
}
@ -698,11 +698,11 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
//}
}
//HIER
foreach(fake_team &sub_t, fake_teams){
BOOST_FOREACH(fake_team &sub_t, fake_teams){
if(t.is_enemy(sub_t.side())){
continue;
}
foreach(potential_recruit &sub_rec, sub_t.extra_units()){
BOOST_FOREACH(potential_recruit &sub_rec, sub_t.extra_units()){
//int score = compare_unit_types(*sub_rec.type(), enemy_type);
//if(score >= 0){
//pair->add_defender(new unit_data(sub_rec.id(), sub_rec.type()));
@ -715,7 +715,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
//const unit_type &defender_type = *rec.type();
//defender_pair_type *pair = new defender_pair_type(new unit_data(rec.id(), rec.type()));
defender_pair_type *pair = new defender_pair_type(rec.type());
foreach(unit &enemy, *resources::units)
BOOST_FOREACH(unit &enemy, *resources::units)
{
if(!t.is_enemy(enemy.side())){
continue;
@ -726,11 +726,11 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
pair->add_enemy(rec.type());
// }
}
foreach(fake_team &sub_t, fake_teams){
BOOST_FOREACH(fake_team &sub_t, fake_teams){
if(!t.is_enemy(sub_t.side())){
continue;
}
foreach(potential_recruit &sub_rec, sub_t.extra_units()){
BOOST_FOREACH(potential_recruit &sub_rec, sub_t.extra_units()){
// int score = compare_unit_types(defender_type, *sub_rec.type());
// if(score >= 0){
//pair->add_enemy(new unit_data(sub_rec.id(), sub_rec.type()));
@ -744,17 +744,17 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
}
double min_score = 0;
double max_score = 0;
foreach(enemy_pair_type *pair, enemies)
BOOST_FOREACH(enemy_pair_type *pair, enemies)
{
// if(pair->defenders.size() == 0)
// {
// pair->score = -10000;
// }else{
//foreach(unit_data *defender, pair->defenders)
foreach(unit_type *defender, pair->defenders)
//BOOST_FOREACH(unit_data *defender, pair->defenders)
BOOST_FOREACH(unit_type *defender, pair->defenders)
{
unsigned int defender_enemies = 0;
foreach(defender_pair_type *defender_p, defenders)
BOOST_FOREACH(defender_pair_type *defender_p, defenders)
{
//if(defender->id == defender_p->defender->id){
if(defender->type_name()() == defender_p->defender->type_name()){
@ -778,7 +778,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
}
double score = 0;
score -= max_score - min_score;
foreach(enemy_pair_type *pair, enemies)
BOOST_FOREACH(enemy_pair_type *pair, enemies)
{
score += pair->score;
}
@ -798,16 +798,16 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
typedef std::map<const unit_type*, std::vector<double> > unit_map;
unit_map enemies;
unit_map defenders;
foreach(unit &un, *resources::units){
BOOST_FOREACH(unit &un, *resources::units){
if(t.is_enemy(un.side())){
enemies[un.type()].push_back((double)un.hitpoints() / (double)un.max_hitpoints());
}else{
defenders[un.type()].push_back(un.hitpoints() / un.max_hitpoints());
}
}
foreach(fake_team &tmp_t, fake_teams)
BOOST_FOREACH(fake_team &tmp_t, fake_teams)
{
foreach(potential_recruit &rec, tmp_t.extra_units())
BOOST_FOREACH(potential_recruit &rec, tmp_t.extra_units())
{
if(t.is_enemy(tmp_t.side())){
enemies[rec.type()].push_back(1.0);
@ -817,13 +817,13 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
}
}
double result = 0;
foreach(unit_map::value_type &defender, defenders)
BOOST_FOREACH(unit_map::value_type &defender, defenders)
{
double defenders_score = 0;
foreach(unit_map::value_type &enemy, enemies)
BOOST_FOREACH(unit_map::value_type &enemy, enemies)
{
double hitpoints_sum = 0;
foreach(double i, enemy.second)
BOOST_FOREACH(double i, enemy.second)
{
hitpoints_sum += i;
}
@ -831,7 +831,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
}
double hitpoints_sum = 0;
foreach(double i, defender.second)
BOOST_FOREACH(double i, defender.second)
{
hitpoints_sum += i;
}
@ -842,7 +842,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
return result;
// vector<defender_pair> defenders;
// vector<enemy_pair> enemies;
// //foreach(unit &un, *resources::units)
// //BOOST_FOREACH(unit &un, *resources::units)
// //{
// // if(t.is_enemy(un.side()))
// // {
@ -851,14 +851,14 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// // defenders.push_back(un.id());
// // }
// //}
// foreach(unit &un, *resources::units)
// BOOST_FOREACH(unit &un, *resources::units)
// {
// if(t.is_enemy(un.side()))
// {
// const unit_type &enemy_type = un.type();
// enemy_pair pair;
// pair.enemy = new unit_data(un.id(), enemy_type);
// foreach(unit &defender, *resources::units)
// BOOST_FOREACH(unit &defender, *resources::units)
// {
// int score = compare_unit_types(defender.type(), enemy_type);
// if(score >= 0)
@ -873,7 +873,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// const unit_type &defender_type = un.type();
// defender_pair pair;
// pair.defender = new unit_data(defender.id(), defender_type);
// foreach(unit &enemy, *resources::units)
// BOOST_FOREACH(unit &enemy, *resources::units)
// {
// int score = compare_unit_types(defender_type, enemy.type());
// if(score >= 0)
@ -885,10 +885,10 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// enemies.push_back(pair);
// }
// }
// foreach(fake_team &tmp_t, fake_teams)
// BOOST_FOREACH(fake_team &tmp_t, fake_teams)
// {
// if(t.is_enemy(tmp_t.side())){
// foreach(potential_recruit &rec, tmp_t.extra_units())
// BOOST_FOREACH(potential_recruit &rec, tmp_t.extra_units())
// {
//
// }
@ -898,7 +898,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
//
// }
// //std::vector<unit> no_defense_enemies;
// foreach(enemy_pair &pair, enemies)
// BOOST_FOREACH(enemy_pair &pair, enemies)
// {
// if(pair.defenders.size() == 0)
// {
@ -906,11 +906,11 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
//
// pair.score = 0;
// }else{
// foreach(unit_data &defender, pair.defenders)
// BOOST_FOREACH(unit_data &defender, pair.defenders)
// {
// //unit_type &defender = defender_data.type;
// unsigned int defender_enemies = 0;
// foreach(defender_pair &defender_p, defenders)
// BOOST_FOREACH(defender_pair &defender_p, defenders)
// {
// if(defender.id == defender_p.defender.id){
// defender_enemies = defender_p.enemies.size();
@ -924,7 +924,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// }
// //enemy_pair *worst_pair = &enemies[0];
// double total_score = 0;
// foreach(enemy_pair &pair, enemies)
// BOOST_FOREACH(enemy_pair &pair, enemies)
// {
// total_score += pair.score;
// }
@ -936,7 +936,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// //unit &worst_def_unit;
// vector<defender_pair> defenders;
// vector<enemy_pair> enemies;
// /*foreach(unit &un, *resources::units)
// /*BOOST_FOREACH(unit &un, *resources::units)
// {
// if(t.is_enemy(un.side()))
// {
@ -945,14 +945,14 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// defenders.push_back(un.id());
// }
// }*/
// foreach(unit &un, *resources::units)
// BOOST_FOREACH(unit &un, *resources::units)
// {
// if(t.is_enemy(un.side()))
// {
// const unit_type &enemy_type = un.type();
// enemy_pair pair;
// pair.enemy = un;
// foreach(unit &defender, *resources::units)
// BOOST_FOREACH(unit &defender, *resources::units)
// {
// int score = compare_unit_types(defender.type(), enemy_type);
// if(score >= 0)
@ -967,7 +967,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// const unit_type &defender_type = un.type();
// defender_pair pair;
// pair.defender = un;
// foreach(unit &enemy, *resources::units)
// BOOST_FOREACH(unit &enemy, *resources::units)
// {
// int score = compare_unit_types(defender_type, enemy.type());
// if(score >= 0)
@ -980,7 +980,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// }
// }
// //std::vector<unit> no_defense_enemies;
// foreach(enemy_pair &pair, enemies)
// BOOST_FOREACH(enemy_pair &pair, enemies)
// {
// if(pair.defenders.size() == 0)
// {
@ -988,10 +988,10 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// return pair.enemy;
// //pair.score = 0;
// }else{
// foreach(unit &defender, pair.defenders)
// BOOST_FOREACH(unit &defender, pair.defenders)
// {
// unsigned int defender_enemies = 0;
// foreach(defender_pair &defender_p, defenders)
// BOOST_FOREACH(defender_pair &defender_p, defenders)
// {
// if(defender.id() == defender_p.defender.id()){
// defender_enemies = defender_p.enemies.size();
@ -1004,7 +1004,7 @@ static void get_recruit_quality(potential_recruit &rec, fake_team &t, std::vecto
// }
// }
// enemy_pair *worst_pair = &enemies[0];
// foreach(enemy_pair &pair, enemies)
// BOOST_FOREACH(enemy_pair &pair, enemies)
// {
// if(pair.score < worst_pair.score)
// {
@ -1039,16 +1039,16 @@ void testing_recruitment_phase::do_recruit(int max_units_to_recruit, double qual
for(int recruited_amount = 0; recruited_amount < max_units_to_recruit; recruited_amount++)
{
foreach(fake_team &t, fake_teams)
BOOST_FOREACH(fake_team &t, fake_teams)
{
t.reset();
}
std::vector<potential_recruit> ai_recruit_list = ai_t->recruit_list();
foreach(potential_recruit &recruit_type, ai_recruit_list)
BOOST_FOREACH(potential_recruit &recruit_type, ai_recruit_list)
{
foreach(fake_team &t, fake_teams)
BOOST_FOREACH(fake_team &t, fake_teams)
{
t.reset();
}
@ -1063,7 +1063,7 @@ void testing_recruitment_phase::do_recruit(int max_units_to_recruit, double qual
}
LOG_AI << "Pretend that we recruited: " << recruit_type.id() << std::endl;
ai_t->fake_recruit(recruit_type);
foreach(fake_team &t, fake_teams)
BOOST_FOREACH(fake_team &t, fake_teams)
{
if(ai_t->side() == t.side())
{

View file

@ -23,7 +23,6 @@
#include "../configuration.hpp"
#include "../manager.hpp"
#include "../composite/ai.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
namespace ai {

View file

@ -25,10 +25,10 @@
#include "../composite/engine.hpp"
#include "../composite/property_handler.hpp"
#include "../gamestate_observer.hpp"
#include "../../foreach.hpp"
#include "../../log.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace ai {
@ -49,7 +49,7 @@ candidate_action_evaluation_loop::candidate_action_evaluation_loop( ai_context &
void candidate_action_evaluation_loop::on_create()
{
//init the candidate actions
foreach(const config &cfg_element, cfg_.child_range("candidate_action")){
BOOST_FOREACH(const config &cfg_element, cfg_.child_range("candidate_action")){
engine::parse_candidate_action_from_config(*this,cfg_element,back_inserter(candidate_actions_));
}
@ -69,7 +69,7 @@ void candidate_action_evaluation_loop::create_candidate_action(std::vector<candi
config candidate_action_evaluation_loop::to_config() const
{
config cfg = stage::to_config();
foreach(candidate_action_ptr ca, candidate_actions_){
BOOST_FOREACH(candidate_action_ptr ca, candidate_actions_){
cfg.add_child("candidate_action",ca->to_config());
}
return cfg;
@ -88,7 +88,7 @@ bool candidate_action_evaluation_loop::do_play_stage()
{
LOG_AI_TESTING_RCA_DEFAULT << "Starting candidate action evaluation loop for side "<< get_side() << std::endl;
foreach(candidate_action_ptr ca, candidate_actions_){
BOOST_FOREACH(candidate_action_ptr ca, candidate_actions_){
ca->enable();
}
@ -103,7 +103,7 @@ bool candidate_action_evaluation_loop::do_play_stage()
candidate_action_ptr best_ptr;
//Evaluation
foreach(candidate_action_ptr ca_ptr, candidate_actions_){
BOOST_FOREACH(candidate_action_ptr ca_ptr, candidate_actions_){
if (!ca_ptr->is_enabled()){
DBG_AI_TESTING_RCA_DEFAULT << "Skipping disabled candidate action: "<< *ca_ptr << std::endl;
continue;

View file

@ -20,11 +20,12 @@
#include "arrow.hpp"
#include "foreach.hpp"
#include "game_display.hpp"
#include "log.hpp"
#include "resources.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_arrows("arrows");
#define ERR_ARR LOG_STREAM(err, log_arrows)
#define WRN_ARR LOG_STREAM(warn, log_arrows)
@ -293,7 +294,7 @@ void arrow::invalidate_arrow_path(arrow_path_t const& path)
{
if(!SCREEN) return;
foreach(map_location const& loc, path)
BOOST_FOREACH(map_location const& loc, path)
{
SCREEN->invalidate(loc);
}

View file

@ -20,13 +20,14 @@
#include "builder.hpp"
#include "foreach.hpp"
#include "loadscreen.hpp"
#include "log.hpp"
#include "map.hpp"
#include "serialization/string_utils.hpp"
#include "image.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)
#define WRN_NG LOG_STREAM(warn, log_engine)
@ -65,12 +66,12 @@ void terrain_builder::tile::rebuild_cache(const std::string& tod, logs* log)
sorted_images = true;
}
foreach(const rule_image_rand& ri, images){
BOOST_FOREACH(const rule_image_rand& ri, images){
bool is_background = ri->is_background();
imagelist& img_list = is_background ? images_background : images_foreground;
foreach(const rule_image_variant& variant, ri->variants){
BOOST_FOREACH(const rule_image_variant& variant, ri->variants){
if(!variant.tods.empty() && variant.tods.find(tod) == variant.tods.end())
continue;
@ -251,12 +252,12 @@ bool terrain_builder::update_animation(const map_location &loc)
tile& btile = tile_map_[loc];
foreach(animated<image::locator>& a, btile.images_background) {
BOOST_FOREACH(animated<image::locator>& a, btile.images_background) {
if(a.need_update())
changed = true;
a.update_last_draw_time();
}
foreach(animated<image::locator>& a, btile.images_foreground) {
BOOST_FOREACH(animated<image::locator>& a, btile.images_foreground) {
if(a.need_update())
changed = true;
a.update_last_draw_time();
@ -327,7 +328,7 @@ static std::vector<std::string> get_variations(const std::string& base, const st
}
std::vector<std::string> vars = utils::split(variations, ';', 0);
foreach(const std::string& v, vars){
BOOST_FOREACH(const std::string& v, vars){
res.push_back(base);
std::string::size_type pos = 0;
while ((pos = res.back().find("@V", pos)) != std::string::npos) {
@ -346,21 +347,21 @@ bool terrain_builder::load_images(building_rule &rule)
// Parse images and animations data
// If one is not valid, return false.
foreach(terrain_constraint &constraint, rule.constraints)
BOOST_FOREACH(terrain_constraint &constraint, rule.constraints)
{
foreach(rule_image& ri, constraint.images)
BOOST_FOREACH(rule_image& ri, constraint.images)
{
foreach(rule_image_variant& variant, ri.variants)
BOOST_FOREACH(rule_image_variant& variant, ri.variants)
{
std::vector<std::string> var_strings = get_variations(variant.image_string, variant.variations);
foreach(const std::string& var, var_strings)
BOOST_FOREACH(const std::string& var, var_strings)
{
/** @todo improve this, 99% of terrains are not animated. */
std::vector<std::string> frames = utils::parenthetical_split(var,',');
animated<image::locator> res;
foreach(const std::string& frame, frames)
BOOST_FOREACH(const std::string& frame, frames)
{
const std::vector<std::string> items = utils::split(frame, ':');
const std::string& str = items.front();
@ -500,7 +501,7 @@ void terrain_builder::replace_rotate_tokens(std::string &s, int angle,
void terrain_builder::replace_rotate_tokens(rule_image &image, int angle,
const std::vector<std::string> &replacement)
{
foreach(rule_image_variant& variant, image.variants) {
BOOST_FOREACH(rule_image_variant& variant, image.variants) {
replace_rotate_tokens(variant, angle, replacement);
}
}
@ -508,7 +509,7 @@ void terrain_builder::replace_rotate_tokens(rule_image &image, int angle,
void terrain_builder::replace_rotate_tokens(rule_imagelist &list, int angle,
const std::vector<std::string> &replacement)
{
foreach (rule_image &img, list) {
BOOST_FOREACH(rule_image &img, list) {
replace_rotate_tokens(img, angle, replacement);
}
}
@ -516,16 +517,16 @@ void terrain_builder::replace_rotate_tokens(rule_imagelist &list, int angle,
void terrain_builder::replace_rotate_tokens(building_rule &rule, int angle,
const std::vector<std::string> &replacement)
{
foreach (terrain_constraint &cons, rule.constraints)
BOOST_FOREACH(terrain_constraint &cons, rule.constraints)
{
// Transforms attributes
foreach (std::string &flag, cons.set_flag) {
BOOST_FOREACH(std::string &flag, cons.set_flag) {
replace_rotate_tokens(flag, angle, replacement);
}
foreach (std::string &flag, cons.no_flag) {
BOOST_FOREACH(std::string &flag, cons.no_flag) {
replace_rotate_tokens(flag, angle, replacement);
}
foreach (std::string &flag, cons.has_flag) {
BOOST_FOREACH(std::string &flag, cons.has_flag) {
replace_rotate_tokens(flag, angle, replacement);
}
replace_rotate_tokens(cons.images, angle, replacement);
@ -542,7 +543,7 @@ void terrain_builder::rotate_rule(building_rule &ret, int angle,
return;
}
foreach (terrain_constraint &cons, ret.constraints) {
BOOST_FOREACH(terrain_constraint &cons, ret.constraints) {
rotate(cons, angle);
}
@ -550,7 +551,7 @@ void terrain_builder::rotate_rule(building_rule &ret, int angle,
int minx = INT_MAX;
int miny = INT_MAX;
foreach (const terrain_constraint &cons, ret.constraints) {
BOOST_FOREACH(const terrain_constraint &cons, ret.constraints) {
minx = std::min<int>(cons.loc.x, minx);
miny = std::min<int>(2 * cons.loc.y + (cons.loc.x & 1), miny);
}
@ -560,7 +561,7 @@ void terrain_builder::rotate_rule(building_rule &ret, int angle,
if(!(miny & 1) && (minx & 1) && (minx > 0))
miny -= 2;
foreach (terrain_constraint &cons, ret.constraints) {
BOOST_FOREACH(terrain_constraint &cons, ret.constraints) {
cons.loc.legacy_sum_assign(map_location(-minx, -((miny - 1) / 2)));
}
@ -582,7 +583,7 @@ terrain_builder::rule_image_variant::rule_image_variant(const std::string &image
void terrain_builder::add_images_from_config(rule_imagelist& images, const config &cfg, bool global, int dx, int dy)
{
foreach (const config &img, cfg.child_range("image"))
BOOST_FOREACH(const config &img, cfg.child_range("image"))
{
int layer = img["layer"];
@ -607,7 +608,7 @@ void terrain_builder::add_images_from_config(rule_imagelist& images, const confi
images.push_back(rule_image(layer, basex - dx, basey - dy, global, center_x, center_y));
// Adds the other variants of the image
foreach (const config &variant, img.child_range("variant"))
BOOST_FOREACH(const config &variant, img.child_range("variant"))
{
const std::string &name = variant["name"];
const std::string &variations = img["variations"];
@ -632,7 +633,7 @@ terrain_builder::terrain_constraint &terrain_builder::add_constraints(
const t_translation::t_match& type, const config& global_images)
{
terrain_constraint *cons = NULL;
foreach (terrain_constraint &c, constraints) {
BOOST_FOREACH(terrain_constraint &c, constraints) {
if (c.loc == loc) {
cons = &c;
break;
@ -770,7 +771,7 @@ void terrain_builder::parse_config(const config &cfg, bool local)
log_scope("terrain_builder::parse_config");
// Parses the list of building rules (BRs)
foreach (const config &br, cfg.child_range("terrain_graphics"))
BOOST_FOREACH(const config &br, cfg.child_range("terrain_graphics"))
{
building_rule pbr; // Parsed Building rule
pbr.local = local;
@ -789,7 +790,7 @@ void terrain_builder::parse_config(const config &cfg, bool local)
parse_mapstring(br["map"], pbr, anchors, br);
// Parses the terrain constraints (TCs)
foreach (const config &tc, br.child_range("tile"))
BOOST_FOREACH(const config &tc, br.child_range("tile"))
{
// Adds the terrain constraint to the current built terrain's list
// of terrain constraints, if it does not exist.
@ -832,7 +833,7 @@ void terrain_builder::parse_config(const config &cfg, bool local)
const std::vector<std::string> global_has_flag = utils::split(br["has_flag"]);
const std::vector<std::string> global_set_no_flag = utils::split(br["set_no_flag"]);
foreach (terrain_constraint &constraint, pbr.constraints)
BOOST_FOREACH(terrain_constraint &constraint, pbr.constraints)
{
constraint.set_flag.insert(constraint.set_flag.end(),
global_set_flag.begin(), global_set_flag.end());
@ -926,7 +927,7 @@ bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
}
}
foreach (const terrain_constraint &cons, rule.constraints)
BOOST_FOREACH(const terrain_constraint &cons, rule.constraints)
{
// Translated location
const map_location tloc = loc.legacy_sum(cons.loc);
@ -944,13 +945,13 @@ bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
const std::set<std::string> &flags = tile_map_[tloc].flags;
foreach (const std::string &s, cons.no_flag) {
BOOST_FOREACH(const std::string &s, cons.no_flag) {
// If a flag listed in "no_flag" is present, the rule does not match
if (flags.find(s) != flags.end()) {
return false;
}
}
foreach (const std::string &s, cons.has_flag) {
BOOST_FOREACH(const std::string &s, cons.has_flag) {
// If a flag listed in "has_flag" is not present, this rule does not match
if (flags.find(s) == flags.end()) {
return false;
@ -965,7 +966,7 @@ void terrain_builder::apply_rule(const terrain_builder::building_rule &rule, con
{
unsigned int rand_seed = get_noise(loc, rule.get_hash());
foreach (const terrain_constraint &constraint, rule.constraints)
BOOST_FOREACH(const terrain_constraint &constraint, rule.constraints)
{
const map_location tloc = loc.legacy_sum(constraint.loc);
if(!tile_map_.on_map(tloc)) {
@ -974,12 +975,12 @@ void terrain_builder::apply_rule(const terrain_builder::building_rule &rule, con
tile& btile = tile_map_[tloc];
foreach (const rule_image &img, constraint.images) {
BOOST_FOREACH(const rule_image &img, constraint.images) {
btile.images.push_back(tile::rule_image_rand(&img, rand_seed));
}
// Sets flags
foreach (const std::string &flag, constraint.set_flag) {
BOOST_FOREACH(const std::string &flag, constraint.set_flag) {
btile.flags.insert(flag);
}
@ -1002,9 +1003,9 @@ unsigned int terrain_builder::building_rule::get_hash() const
if(hash_ != DUMMY_HASH)
return hash_;
foreach(const terrain_constraint &constraint, constraints) {
foreach(const rule_image& ri, constraint.images) {
foreach(const rule_image_variant& variant, ri.variants) {
BOOST_FOREACH(const terrain_constraint &constraint, constraints) {
BOOST_FOREACH(const rule_image& ri, constraint.images) {
BOOST_FOREACH(const rule_image_variant& variant, ri.variants) {
// we will often hash the same string, but that seems fast enough
hash_ += hash_str(variant.image_string);
}
@ -1032,7 +1033,7 @@ void terrain_builder::build_terrains()
}
}
foreach (const building_rule &rule, building_rules_)
BOOST_FOREACH(const building_rule &rule, building_rules_)
{
// Find the constraint that contains the less terrain of all terrain rules.
// We will keep a track of the matching terrains of this constraint
@ -1041,7 +1042,7 @@ void terrain_builder::build_terrains()
t_translation::t_list min_types;
const terrain_constraint *min_constraint = NULL;
foreach (const terrain_constraint &constraint, rule.constraints)
BOOST_FOREACH(const terrain_constraint &constraint, rule.constraints)
{
const t_translation::t_match& match = constraint.terrain_types_match;
t_translation::t_list matching_types;

View file

@ -21,7 +21,6 @@
*/
#include "filesystem.hpp"
#include "foreach.hpp"
#include "log.hpp"
#include "network_worker.hpp"
#include "serialization/binary_or_text.hpp"
@ -35,6 +34,7 @@
#include <csignal>
#include <boost/foreach.hpp>
#include <boost/iostreams/filter/gzip.hpp>
// the fork execute is unix specific only tested on Linux quite sure it won't
@ -202,7 +202,7 @@ namespace {
void find_translations(const config& cfg, config& campaign)
{
foreach (const config &dir, cfg.child_range("dir"))
BOOST_FOREACH(const config &dir, cfg.child_range("dir"))
{
if (dir["name"] == "LC_MESSAGES") {
config &language = campaign.add_child("translation");
@ -249,7 +249,7 @@ namespace {
LOG_CS << "Encoding all stored addons. Number of addons: "
<< std::distance(camps.first, camps.second) << '\n';
foreach (const config &cm, camps)
BOOST_FOREACH(const config &cm, camps)
{
LOG_CS << "Encoding " << cm["name"] << '\n';
std::string filename = cm["filename"], newfilename = filename + ".new";
@ -345,7 +345,7 @@ namespace {
} catch(bad_lexical_cast) {}
std::string name = req["name"], lang = req["language"];
foreach (const config &i, campaigns().child_range("campaign"))
BOOST_FOREACH(const config &i, campaigns().child_range("campaign"))
{
if (!name.empty() && name != i["name"]) continue;
std::string tm = i["timestamp"];
@ -353,7 +353,7 @@ namespace {
if (after_flag && (tm.empty() || lexical_cast_default<time_t>(tm, 0) <= after)) continue;
if (!lang.empty()) {
bool found = false;
foreach (const config &j, i.child_range("translation")) {
BOOST_FOREACH(const config &j, i.child_range("translation")) {
if (j["language"] == lang) {
found = true;
break;
@ -364,7 +364,7 @@ namespace {
campaign_list.add_child("campaign", i);
}
foreach (config &j, campaign_list.child_range("campaign")) {
BOOST_FOREACH(config &j, campaign_list.child_range("campaign")) {
j["passphrase"] = t_string();
j["upload_ip"] = t_string();
j["email"] = t_string();
@ -402,7 +402,7 @@ namespace {
std::string lc_name(name.size(), ' ');
std::transform(name.begin(), name.end(), lc_name.begin(), tolower);
config *campaign = NULL;
foreach (config &c, campaigns().child_range("campaign")) {
BOOST_FOREACH(config &c, campaigns().child_range("campaign")) {
if (utils::lowercase(c["name"]) == lc_name) {
campaign = &c;
break;

View file

@ -21,13 +21,14 @@
#include "global.hpp"
#include "cavegen.hpp"
#include "foreach.hpp"
#include "log.hpp"
#include "map.hpp"
#include "pathfind/pathfind.hpp"
#include "serialization/string_utils.hpp"
#include "util.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_engine("engine");
#define LOG_NG LOG_STREAM(info, log_engine)
@ -149,7 +150,7 @@ void cave_map_generator::build_chamber(map_location loc, std::set<map_location>&
void cave_map_generator::generate_chambers()
{
foreach (const config &ch, cfg_.child_range("chamber"))
BOOST_FOREACH(const config &ch, cfg_.child_range("chamber"))
{
// If there is only a chance of the chamber appearing, deal with that here.
if (ch.has_attribute("chance") && (rand() % 100) < ch["chance"].to_int()) {
@ -197,7 +198,7 @@ void cave_map_generator::generate_chambers()
chambers_.push_back(new_chamber);
foreach (const config &p, ch.child_range("passage"))
BOOST_FOREACH(const config &p, ch.child_range("passage"))
{
const std::string &dst = p["destination"];
@ -222,7 +223,7 @@ void cave_map_generator::place_chamber(const chamber& c)
if (c.items == NULL || c.locs.empty()) return;
size_t index = 0;
foreach (const config::any_child &it, c.items->all_children_range())
BOOST_FOREACH(const config::any_child &it, c.items->all_children_range())
{
config cfg = it.cfg;
config &filter = cfg.child("filter");

View file

@ -14,12 +14,12 @@
*/
#include "commandline_options.hpp"
#include "foreach.hpp"
#include "serialization/string_utils.hpp"
#include "util.hpp"
#include "lua/llimits.h"
#include <boost/version.hpp>
#include <boost/foreach.hpp>
namespace po = boost::program_options;
@ -386,7 +386,7 @@ commandline_options::commandline_options ( int argc, char** argv ) :
void commandline_options::parse_log_domains_(const std::string &domains_string, const int severity)
{
const std::vector<std::string> domains = utils::split(domains_string, ',');
foreach (const std::string& domain, domains)
BOOST_FOREACH(const std::string& domain, domains)
{
if (!log)
log = std::vector<boost::tuple<int, std::string> >();
@ -408,7 +408,7 @@ std::vector<boost::tuple<unsigned int,std::string> > commandline_options::parse_
{
std::vector<boost::tuple<unsigned int,std::string> > vec;
boost::tuple<unsigned int,std::string> elem;
foreach(const std::string &s, strings)
BOOST_FOREACH(const std::string &s, strings)
{
const std::vector<std::string> tokens = utils::split(s, separator);
if (tokens.size()!=2)
@ -427,7 +427,7 @@ std::vector<boost::tuple<unsigned int,std::string,std::string> > commandline_opt
{
std::vector<boost::tuple<unsigned int,std::string,std::string> > vec;
boost::tuple<unsigned int,std::string,std::string> elem;
foreach(const std::string &s, strings)
BOOST_FOREACH(const std::string &s, strings)
{
const std::vector<std::string> tokens = utils::split(s, separator);
if (tokens.size()!=3)

View file

@ -22,10 +22,10 @@
#include "global.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "log.hpp"
#include "serialization/string_utils.hpp"
#include "util.hpp"
#include <boost/foreach.hpp>
#include "utils/const_clone.tpp"
#include <cstdlib>
@ -333,7 +333,7 @@ void config::append_children(const config &cfg)
{
check_valid(cfg);
foreach (const any_child &value, cfg.all_children_range()) {
BOOST_FOREACH(const any_child &value, cfg.all_children_range()) {
add_child(value.key, value.cfg);
}
}
@ -341,7 +341,7 @@ void config::append_children(const config &cfg)
void config::append(const config &cfg)
{
append_children(cfg);
foreach (const attribute &v, cfg.values) {
BOOST_FOREACH(const attribute &v, cfg.values) {
values[v.first] = v.second;
}
}
@ -353,7 +353,7 @@ void config::merge_children(const std::string& key)
if (child_count(key) < 2) return;
config merged_children;
foreach (const config &cfg, child_range(key)) {
BOOST_FOREACH(const config &cfg, child_range(key)) {
merged_children.append(cfg);
}
@ -369,7 +369,7 @@ void config::merge_children_by_attribute(const std::string& key, const std::stri
typedef std::map<std::string, config> config_map;
config_map merged_children_map;
foreach (const config &cfg, child_range(key)) {
BOOST_FOREACH(const config &cfg, child_range(key)) {
const std::string &value = cfg[attribute];
config_map::iterator m = merged_children_map.find(value);
if ( m!=merged_children_map.end() ) {
@ -380,7 +380,7 @@ void config::merge_children_by_attribute(const std::string& key, const std::stri
}
clear_children(key);
foreach (const config_map::value_type &i, merged_children_map) {
BOOST_FOREACH(const config_map::value_type &i, merged_children_map) {
add_child(key,i.second);
}
}
@ -570,7 +570,7 @@ void config::clear_children(const std::string& key)
ordered_children.erase(std::remove_if(ordered_children.begin(),
ordered_children.end(), remove_ordered(i)), ordered_children.end());
foreach (config *c, i->second) {
BOOST_FOREACH(config *c, i->second) {
delete c;
}
@ -606,7 +606,7 @@ void config::recursive_clear_value(const std::string& key)
values.erase(key);
foreach (const any_child &value, all_children_range()) {
BOOST_FOREACH(const any_child &value, all_children_range()) {
const_cast<config *>(&value.cfg)->recursive_clear_value(key);
}
}
@ -617,7 +617,7 @@ std::vector<config::child_pos>::iterator config::remove_child(
/* Find the position with the correct index and decrement all the
indices in the ordering that are above this index. */
unsigned found = 0;
foreach (child_pos &p, ordered_children)
BOOST_FOREACH(child_pos &p, ordered_children)
{
if (p.pos != pos) continue;
if (p.index == index)
@ -701,7 +701,7 @@ void config::merge_attributes(const config &cfg)
check_valid(cfg);
assert(this != &cfg);
foreach (const attribute &v, cfg.values) {
BOOST_FOREACH(const attribute &v, cfg.values) {
std::string key = v.first;
if (key.substr(0,7) == "add_to_") {
@ -985,21 +985,21 @@ void config::apply_diff(const config& diff, bool track /* = false */)
if (track) values[diff_track_attribute] = "modified";
if (const config &inserts = diff.child("insert")) {
foreach (const attribute &v, inserts.attribute_range()) {
BOOST_FOREACH(const attribute &v, inserts.attribute_range()) {
values[v.first] = v.second;
}
}
if (const config &deletes = diff.child("delete")) {
foreach (const attribute &v, deletes.attribute_range()) {
BOOST_FOREACH(const attribute &v, deletes.attribute_range()) {
values.erase(v.first);
}
}
foreach (const config &i, diff.child_range("change_child"))
BOOST_FOREACH(const config &i, diff.child_range("change_child"))
{
const size_t index = lexical_cast<size_t>(i["index"].str());
foreach (const any_child &item, i.all_children_range())
BOOST_FOREACH(const any_child &item, i.all_children_range())
{
if (item.key.empty()) {
continue;
@ -1014,19 +1014,19 @@ void config::apply_diff(const config& diff, bool track /* = false */)
}
}
foreach (const config &i, diff.child_range("insert_child"))
BOOST_FOREACH(const config &i, diff.child_range("insert_child"))
{
const size_t index = lexical_cast<size_t>(i["index"].str());
foreach (const any_child &item, i.all_children_range()) {
BOOST_FOREACH(const any_child &item, i.all_children_range()) {
config& inserted = add_child_at(item.key, item.cfg, index);
if (track) inserted[diff_track_attribute] = "new";
}
}
foreach (const config &i, diff.child_range("delete_child"))
BOOST_FOREACH(const config &i, diff.child_range("delete_child"))
{
const size_t index = lexical_cast<size_t>(i["index"].str());
foreach (const any_child &item, i.all_children_range()) {
BOOST_FOREACH(const any_child &item, i.all_children_range()) {
if (!track) {
remove_child(item.key, index);
} else {
@ -1043,18 +1043,18 @@ void config::apply_diff(const config& diff, bool track /* = false */)
void config::clear_diff_track(const config& diff)
{
remove_attribute(diff_track_attribute);
foreach (const config &i, diff.child_range("delete_child"))
BOOST_FOREACH(const config &i, diff.child_range("delete_child"))
{
const size_t index = lexical_cast<size_t>(i["index"].str());
foreach (const any_child &item, i.all_children_range()) {
BOOST_FOREACH(const any_child &item, i.all_children_range()) {
remove_child(item.key, index);
}
}
foreach (const config &i, diff.child_range("change_child"))
BOOST_FOREACH(const config &i, diff.child_range("change_child"))
{
const size_t index = lexical_cast<size_t>(i["index"].str());
foreach (const any_child &item, i.all_children_range())
BOOST_FOREACH(const any_child &item, i.all_children_range())
{
if (item.key.empty()) {
continue;
@ -1068,7 +1068,7 @@ void config::clear_diff_track(const config& diff)
itor->second[index]->clear_diff_track(item.cfg);
}
}
foreach (const any_child &value, all_children_range()) {
BOOST_FOREACH(const any_child &value, all_children_range()) {
const_cast<config *>(&value.cfg)->remove_attribute(diff_track_attribute);
}
}
@ -1109,20 +1109,20 @@ bool config::matches(const config &filter) const
{
check_valid(filter);
foreach (const attribute &i, filter.attribute_range())
BOOST_FOREACH(const attribute &i, filter.attribute_range())
{
const attribute_value *v = get(i.first);
if (!v || *v != i.second) return false;
}
foreach (const any_child &i, filter.all_children_range())
BOOST_FOREACH(const any_child &i, filter.all_children_range())
{
if (i.key == "not") {
if (matches(i.cfg)) return false;
continue;
}
bool found = false;
foreach (const config &j, child_range(i.key)) {
BOOST_FOREACH(const config &j, child_range(i.key)) {
if (j.matches(i.cfg)) {
found = true;
break;
@ -1146,11 +1146,11 @@ std::ostream& operator << (std::ostream& outstream, const config& cfg)
{
static int i = 0;
i++;
foreach (const config::attribute &val, cfg.attribute_range()) {
BOOST_FOREACH(const config::attribute &val, cfg.attribute_range()) {
for (int j = 0; j < i-1; j++){ outstream << char(9); }
outstream << val.first << " = " << val.second << '\n';
}
foreach (const config::any_child &child, cfg.all_children_range())
BOOST_FOREACH(const config::any_child &child, cfg.all_children_range())
{
for (int j = 0; j < i - 1; ++j) outstream << char(9);
outstream << "[" << child.key << "]\n";
@ -1179,7 +1179,7 @@ std::string config::hash() const
hash_str[hash_length] = 0;
i = 0;
foreach (const attribute &val, values)
BOOST_FOREACH(const attribute &val, values)
{
for (c = val.first.begin(); c != val.first.end(); ++c) {
hash_str[i] ^= *c;
@ -1192,10 +1192,10 @@ std::string config::hash() const
}
}
foreach (const any_child &ch, all_children_range())
BOOST_FOREACH(const any_child &ch, all_children_range())
{
std::string child_hash = ch.cfg.hash();
foreach (char c, child_hash) {
BOOST_FOREACH(char c, child_hash) {
hash_str[i] ^= c;
++i;
if(i == hash_length) {

View file

@ -17,7 +17,6 @@
#include "config_cache.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "game_config.hpp"
#include "game_display.hpp"
@ -29,6 +28,7 @@
#include "serialization/parser.hpp"
#include "version.hpp"
#include <boost/foreach.hpp>
#include <boost/algorithm/string/replace.hpp>
static lg::log_domain log_cache("cache");
@ -113,7 +113,7 @@ namespace game_config {
config_writer writer(*stream, gzip, game_config::cache_compression_level);
// write all defines to stream
foreach (const preproc_map::value_type &define, defines_map) {
BOOST_FOREACH(const preproc_map::value_type &define, defines_map) {
define.second.write(writer, define.first);
}
}
@ -262,7 +262,7 @@ namespace game_config {
// use static preproc_define::read_pair(config) to make a object
// and pass that object config_cache_transaction::insert_to_active method
foreach (const config::any_child &value, cfg.all_children_range()) {
BOOST_FOREACH(const config::any_child &value, cfg.all_children_range()) {
config_cache_transaction::instance().insert_to_active(
preproc_define::read_pair(value.cfg));
}
@ -271,7 +271,7 @@ namespace game_config {
void config_cache::read_defines_queue()
{
const config_cache_transaction::filenames& files = config_cache_transaction::instance().get_define_files();
foreach (const std::string &path, files) {
BOOST_FOREACH(const std::string &path, files) {
read_defines_file(path);
}
}
@ -394,7 +394,7 @@ namespace game_config {
std::insert_iterator<preproc_map>(temp,temp.begin()),
&compare_define);
foreach (const preproc_map::value_type &def, temp) {
BOOST_FOREACH(const preproc_map::value_type &def, temp) {
insert_to_active(def);
}

View file

@ -18,11 +18,12 @@
#include "dialogs.hpp"
#include "display.hpp"
#include "foreach.hpp"
#include "game_preferences.hpp"
#include "log.hpp"
#include "mouse_handler_base.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_display("display");
#define ERR_DP LOG_STREAM(err, log_display)
@ -144,7 +145,7 @@ bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse
int dx = 0, dy = 0;
int scroll_threshold = (preferences::mouse_scroll_enabled())
? preferences::mouse_scroll_threshold() : 0;
foreach (const theme::menu& m, get_display().get_theme().menus()) {
BOOST_FOREACH(const theme::menu& m, get_display().get_theme().menus()) {
if (point_in_rect(mousex, mousey, m.get_location())) {
scroll_threshold = 0;
}

View file

@ -22,7 +22,6 @@
#include "actions.hpp"
#include "dialogs.hpp"
#include "foreach.hpp"
#include "game_events.hpp"
#include "game_display.hpp"
#include "game_preferences.hpp"
@ -49,6 +48,7 @@
#include "gui/dialogs/game_save.hpp"
#include "gui/dialogs/transient_message.hpp"
#include <boost/foreach.hpp>
//#ifdef _WIN32
//#include "locale.h"
@ -95,7 +95,7 @@ int advance_unit_dialog(const map_location &loc)
}
bool always_display = false;
foreach (const config &mod, u->get_modification_advances())
BOOST_FOREACH(const config &mod, u->get_modification_advances())
{
if (mod["always_display"].to_bool()) always_display = true;
sample_units.push_back(::get_advanced_unit(*u, u->type_id()));
@ -999,7 +999,7 @@ const unit_types_preview_pane::details unit_types_preview_pane::get_details() co
}
//FIXME: This probably must be move into a unit_type function
foreach (const config &tr, t->possible_traits())
BOOST_FOREACH(const config &tr, t->possible_traits())
{
if (tr["availability"] != "musthave") continue;
std::string gender_string = (!t->genders().empty() && t->genders().front()== unit_race::FEMALE) ? "female_name" : "male_name";
@ -1028,7 +1028,7 @@ const unit_types_preview_pane::details unit_types_preview_pane::get_details() co
// Check if AMLA color is needed
// FIXME: not sure if it's fully accurate (but not very important for unit_type)
// xp_color also need a simpler function for doing this
foreach (const config &adv, t->modification_advancements())
BOOST_FOREACH(const config &adv, t->modification_advancements())
{
if (!adv["strict_amla"].to_bool() || !t->can_advance()) {
det.xp_color = "<170,0,255>"; // from unit::xp_color()

View file

@ -21,7 +21,6 @@
#include "builder.hpp"
#include "cursor.hpp"
#include "display.hpp"
#include "foreach.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "halo.hpp"
@ -41,6 +40,8 @@
#include "SDL_image.h"
#include <boost/foreach.hpp>
#ifdef __SUNPRO_CC
// GCC doesn't have hypot in cmath so include it for Sun Studio
#include <math.h>
@ -795,7 +796,7 @@ std::vector<surface> display::get_fog_shroud_images(const map_location& loc, ima
// now get the surfaces
std::vector<surface> res;
foreach(std::string& name, names) {
BOOST_FOREACH(std::string& name, names) {
const surface surf(image::get_image(name, image_type));
if (surf)
res.push_back(surf);
@ -994,8 +995,8 @@ void display::drawing_buffer_commit()
* layergroup > location > layer > 'tblit' > surface
*/
foreach(const tblit &blit, drawing_buffer_) {
foreach(const surface& surf, blit.surf()) {
BOOST_FOREACH(const tblit &blit, drawing_buffer_) {
BOOST_FOREACH(const surface& surf, blit.surf()) {
// Note that dstrect can be changed by sdl_blit
// and so a new instance should be initialized
// to pass to each call to sdl_blit.
@ -2100,7 +2101,7 @@ void display::redraw_everything()
int ticks3 = SDL_GetTicks();
LOG_DP << "invalidate and draw: " << (ticks3 - ticks2) << " and " << (ticks2 - ticks1) << "\n";
foreach (boost::function<void(display&)> f, redraw_observers_) {
BOOST_FOREACH(boost::function<void(display&)> f, redraw_observers_) {
f(*this);
}
@ -2189,7 +2190,7 @@ void display::draw_invalidated() {
SDL_Rect clip_rect = get_clip_rect();
surface screen = get_screen_surface();
clip_rect_setter set_clip_rect(screen, &clip_rect);
foreach (const map_location& loc, invalidated_) {
BOOST_FOREACH(const map_location& loc, invalidated_) {
int xpos = get_location_x(loc);
int ypos = get_location_y(loc);
@ -2209,7 +2210,7 @@ void display::draw_invalidated() {
}
invalidated_hexes_ += invalidated_.size();
foreach (const map_location& loc, invalidated_) {
BOOST_FOREACH(const map_location& loc, invalidated_) {
unit_map::iterator u_it = units_->find(loc);
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
if (u_it != units_->end()
@ -2264,7 +2265,7 @@ void display::draw_hex(const map_location& loc) {
// Paint arrows
arrows_map_t::const_iterator arrows_in_hex = arrows_map_.find(loc);
if(arrows_in_hex != arrows_map_.end()) {
foreach(arrow* const a, arrows_in_hex->second) {
BOOST_FOREACH(arrow* const a, arrows_in_hex->second) {
a->draw_hex(loc);
}
}
@ -2593,7 +2594,7 @@ bool display::invalidate(const std::set<map_location>& locs)
if(invalidateAll_)
return false;
bool ret = false;
foreach (const map_location& loc, locs) {
BOOST_FOREACH(const map_location& loc, locs) {
#ifdef _OPENMP
#pragma omp critical(invalidated_)
#endif //_OPENMP
@ -2643,7 +2644,7 @@ bool display::invalidate_locations_in_rect(const SDL_Rect& rect)
return false;
bool result = false;
foreach (const map_location &loc, hexes_under_rect(rect)) {
BOOST_FOREACH(const map_location &loc, hexes_under_rect(rect)) {
result |= invalidate(loc);
}
return result;
@ -2654,7 +2655,7 @@ void display::invalidate_animations()
new_animation_frame();
animate_map_ = preferences::animate_map();
if (animate_map_) {
foreach (const map_location &loc, get_visible_hexes())
BOOST_FOREACH(const map_location &loc, get_visible_hexes())
{
if (shrouded(loc)) continue;
if (builder_->update_animation(loc)) {
@ -2664,11 +2665,11 @@ void display::invalidate_animations()
}
}
}
foreach (unit& u, *units_) {
BOOST_FOREACH(unit& u, *units_) {
u.refresh();
}
std::vector<unit*> unit_list;
foreach (unit &u, *units_) {
BOOST_FOREACH(unit &u, *units_) {
unit_list.push_back(&u);
}
bool new_inval;
@ -2686,7 +2687,7 @@ void display::invalidate_animations()
void display::add_arrow(arrow& arrow)
{
const arrow_path_t & arrow_path = arrow.get_path();
foreach (const map_location& loc, arrow_path)
BOOST_FOREACH(const map_location& loc, arrow_path)
{
arrows_map_[loc].push_back(&arrow);
}
@ -2695,7 +2696,7 @@ void display::add_arrow(arrow& arrow)
void display::remove_arrow(arrow& arrow)
{
const arrow_path_t & arrow_path = arrow.get_path();
foreach (const map_location& loc, arrow_path)
BOOST_FOREACH(const map_location& loc, arrow_path)
{
arrows_map_[loc].remove(&arrow);
}
@ -2704,12 +2705,12 @@ void display::remove_arrow(arrow& arrow)
void display::update_arrow(arrow & arrow)
{
const arrow_path_t & previous_path = arrow.get_previous_path();
foreach (const map_location& loc, previous_path)
BOOST_FOREACH(const map_location& loc, previous_path)
{
arrows_map_[loc].remove(&arrow);
}
const arrow_path_t & arrow_path = arrow.get_path();
foreach (const map_location& loc, arrow_path)
BOOST_FOREACH(const map_location& loc, arrow_path)
{
arrows_map_[loc].push_back(&arrow);
}

View file

@ -21,12 +21,13 @@
#include "editor/action/action.hpp"
#include "editor/map/map_context.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "util.hpp"
#include "resources.hpp"
#include <boost/foreach.hpp>
namespace editor {
int editor_action::next_id_ = 1;
@ -77,25 +78,25 @@ void editor_action_whole_map::perform_without_undo(map_context& mc) const {
editor_action_chain::editor_action_chain(const editor::editor_action_chain &other)
: editor_action(), actions_()
{
foreach (editor_action* a, other.actions_) {
BOOST_FOREACH(editor_action* a, other.actions_) {
actions_.push_back(a->clone());
}
}
editor_action_chain& editor_action_chain::operator=(const editor_action_chain& other)
{
if (this == &other) return *this;
foreach (editor_action* a, actions_) {
BOOST_FOREACH(editor_action* a, actions_) {
delete a;
}
actions_.clear();
foreach (editor_action* a, other.actions_) {
BOOST_FOREACH(editor_action* a, other.actions_) {
actions_.push_back(a->clone());
}
return *this;
}
editor_action_chain::~editor_action_chain()
{
foreach (editor_action* a, actions_) {
BOOST_FOREACH(editor_action* a, actions_) {
delete a;
}
}
@ -105,7 +106,7 @@ editor_action_chain* editor_action_chain::clone() const
}
int editor_action_chain::action_count() const {
int count = 0;
foreach (const editor_action* a, actions_) {
BOOST_FOREACH(const editor_action* a, actions_) {
if (a) {
count += a->action_count();
}
@ -135,7 +136,7 @@ editor_action* editor_action_chain::pop_first_action() {
}
editor_action_chain* editor_action_chain::perform(map_context& mc) const {
util::unique_ptr<editor_action_chain> undo(new editor_action_chain());
foreach (editor_action* a, actions_) {
BOOST_FOREACH(editor_action* a, actions_) {
if (a != NULL) {
undo->append_action(a->perform(mc));
}
@ -145,7 +146,7 @@ editor_action_chain* editor_action_chain::perform(map_context& mc) const {
}
void editor_action_chain::perform_without_undo(map_context& mc) const
{
foreach (editor_action* a, actions_) {
BOOST_FOREACH(editor_action* a, actions_) {
if (a != NULL) {
a->perform_without_undo(mc);
}
@ -259,7 +260,7 @@ editor_action_select* editor_action_select::clone() const
}
void editor_action_select::extend(const editor_map& map, const std::set<map_location>& locs)
{
foreach (const map_location& loc, locs) {
BOOST_FOREACH(const map_location& loc, locs) {
LOG_ED << "Checking " << loc << "\n";
if (map.in_selection(loc)) {
LOG_ED << "Extending by " << loc << "\n";
@ -270,7 +271,7 @@ void editor_action_select::extend(const editor_map& map, const std::set<map_loca
editor_action* editor_action_select::perform(map_context& mc) const
{
std::set<map_location> undo_locs;
foreach (const map_location& loc, area_) {
BOOST_FOREACH(const map_location& loc, area_) {
if (!mc.get_map().in_selection(loc)) {
undo_locs.insert(loc);
mc.add_changed_location(loc);
@ -281,7 +282,7 @@ editor_action* editor_action_select::perform(map_context& mc) const
}
void editor_action_select::perform_without_undo(map_context& mc) const
{
foreach (const map_location& loc, area_) {
BOOST_FOREACH(const map_location& loc, area_) {
mc.get_map().add_to_selection(loc);
mc.add_changed_location(loc);
}
@ -293,7 +294,7 @@ editor_action_deselect* editor_action_deselect::clone() const
}
void editor_action_deselect::extend(const editor_map& map, const std::set<map_location>& locs)
{
foreach (const map_location& loc, locs) {
BOOST_FOREACH(const map_location& loc, locs) {
LOG_ED << "Checking " << loc << "\n";
if (!map.in_selection(loc)) {
LOG_ED << "Extending by " << loc << "\n";
@ -304,7 +305,7 @@ void editor_action_deselect::extend(const editor_map& map, const std::set<map_lo
editor_action* editor_action_deselect::perform(map_context& mc) const
{
std::set<map_location> undo_locs;
foreach (const map_location& loc, area_) {
BOOST_FOREACH(const map_location& loc, area_) {
if (mc.get_map().in_selection(loc)) {
undo_locs.insert(loc);
mc.add_changed_location(loc);
@ -315,7 +316,7 @@ editor_action* editor_action_deselect::perform(map_context& mc) const
}
void editor_action_deselect::perform_without_undo(map_context& mc) const
{
foreach (const map_location& loc, area_) {
BOOST_FOREACH(const map_location& loc, area_) {
mc.get_map().remove_from_selection(loc);
mc.add_changed_location(loc);
}

View file

@ -32,7 +32,6 @@
#include "gui/widgets/window.hpp"
#include "../clipboard.hpp"
#include "../foreach.hpp"
#include "../game_preferences.hpp"
#include "../gettext.hpp"
#include "../preferences_display.hpp"
@ -42,6 +41,7 @@
#include "halo.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace {
static std::vector<std::string> saved_windows_;
@ -82,7 +82,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
// TODO enable if you can say what the purpose of the code is. I think it is old stuff and deserves to be removed.
/* theme& theme = gui().get_theme();
const theme::menu* default_tool_menu = NULL;
foreach (const theme::menu& m, theme.menus()) {
BOOST_FOREACH(const theme::menu& m, theme.menus()) {
if (m.get_id() == "draw_button_editor") {
default_tool_menu = &m;
break;
@ -121,7 +121,7 @@ void editor_controller::init_tods(const config& game_config)
ERR_ED << "No editor time-of-day defined\n";
return;
}
foreach (const config &i, cfg.child_range("time")) {
BOOST_FOREACH(const config &i, cfg.child_range("time")) {
tods_.push_back(time_of_day(i));
}
}
@ -133,7 +133,7 @@ void editor_controller::init_music(const config& game_config)
ERR_ED << "No editor music defined\n";
return;
}
foreach (const config &i, cfg.child_range("music")) {
BOOST_FOREACH(const config &i, cfg.child_range("music")) {
sound::play_music_config(i);
}
sound::commit_music_changes();

View file

@ -15,7 +15,6 @@
#include "context_manager.hpp"
#include "display.hpp"
#include "foreach.hpp"
#include "filesystem.hpp"
#include "filechooser.hpp"
#include "formula_string_utils.hpp"
@ -34,6 +33,7 @@
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include <boost/foreach.hpp>
namespace {
static std::vector<std::string> saved_windows_;
@ -91,7 +91,7 @@ void context_manager::set_update_transitions_hotkey(hotkey::HOTKEY_COMMAND i) {
size_t context_manager::modified_maps(std::string& message) {
std::vector<std::string> modified;
foreach (map_context* mc, map_contexts_) {
BOOST_FOREACH(map_context* mc, map_contexts_) {
if (mc->modified()) {
if (!mc->get_filename().empty()) {
modified.push_back(mc->get_filename());
@ -100,7 +100,7 @@ size_t context_manager::modified_maps(std::string& message) {
}
}
}
foreach (std::string& str, modified) {
BOOST_FOREACH(std::string& str, modified) {
message += "\n" + str;
}
return modified.size();
@ -125,10 +125,10 @@ context_manager::context_manager(editor_display& gui, const config& game_config)
context_manager::~context_manager()
{
foreach (map_generator* m, map_generators_) {
BOOST_FOREACH(map_generator* m, map_generators_) {
delete m;
}
foreach (map_context* mc, map_contexts_) {
BOOST_FOREACH(map_context* mc, map_contexts_) {
delete mc;
}
}
@ -270,7 +270,7 @@ void context_manager::refresh_after_action(bool drag_part)
get_map_context().set_needs_terrain_rebuild(false);
gui_.invalidate_all();
} else {
foreach (const map_location& loc, changed_locs) {
BOOST_FOREACH(const map_location& loc, changed_locs) {
gui_.rebuild_terrain(loc);
}
gui_.invalidate(changed_locs);
@ -380,7 +380,7 @@ void context_manager::save_map_as_dialog()
void context_manager::init_map_generators(const config& game_config)
{
foreach (const config &i, game_config.child_range("multiplayer"))
BOOST_FOREACH(const config &i, game_config.child_range("multiplayer"))
{
if (i["map_generation"] == "default") {
const config &generator_cfg = i.child("generator");
@ -448,7 +448,7 @@ void context_manager::create_default_context()
map_context* mc = new map_context(editor_map(game_config_, 44, 33, t_translation::GRASS_LAND, gui_));
add_map_context(mc);
} else {
foreach(const std::string& filename, saved_windows_) {
BOOST_FOREACH(const std::string& filename, saved_windows_) {
map_context* mc = new map_context(game_config_, filename, gui_);
add_map_context(mc);
}

View file

@ -20,12 +20,12 @@
#include "display.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "map_exception.hpp"
#include "map_label.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace editor {
@ -63,7 +63,7 @@ editor_map::editor_map(const config& terrain_cfg, const config& level, const dis
{
labels_.read(level);
foreach (const config& side, level.child_range("side"))
BOOST_FOREACH(const config& side, level.child_range("side"))
{
team t;
t.build(side, *this, 100);
@ -72,7 +72,7 @@ editor_map::editor_map(const config& terrain_cfg, const config& level, const dis
//TODO alternative? : gamestatus::teambuilder
teams_.push_back(t);
foreach (const config &a_unit, side.child_range("unit")) {
BOOST_FOREACH(const config &a_unit, side.child_range("unit")) {
map_location loc(a_unit, NULL);
units_.add(loc, unit(a_unit, true));
}
@ -168,7 +168,7 @@ void editor_map::sanity_check()
++errors;
}
}
foreach (const map_location& loc, selection_) {
BOOST_FOREACH(const map_location& loc, selection_) {
if (!on_board_with_border(loc)) {
ERR_ED << "Off-map tile in selection: " << loc << "\n";
}

View file

@ -19,7 +19,6 @@
#include "display.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "map_exception.hpp"
#include "map_label.hpp"
@ -31,6 +30,7 @@
#include "formula_string_utils.hpp"
#include <boost/regex.hpp>
#include <boost/foreach.hpp>
namespace editor {
@ -166,7 +166,7 @@ void map_context::draw_terrain(t_translation::t_terrain terrain,
if (!one_layer_only) {
terrain = map_.get_terrain_info(terrain).terrain_with_default_base();
}
foreach (const map_location& loc, locs) {
BOOST_FOREACH(const map_location& loc, locs) {
draw_terrain_actual(terrain, loc, one_layer_only);
}
}
@ -419,7 +419,7 @@ void map_context::trim_stack(action_stack& stack)
void map_context::clear_stack(action_stack& stack)
{
foreach (editor_action* a, stack) {
BOOST_FOREACH(editor_action* a, stack) {
delete a;
}
stack.clear();

View file

@ -16,9 +16,10 @@
#include "map_fragment.hpp"
#include "foreach.hpp"
#include "util.hpp"
#include <boost/foreach.hpp>
namespace editor {
map_fragment::map_fragment()
@ -44,7 +45,7 @@ void map_fragment::add_tile(const gamemap& map, const map_location& loc)
void map_fragment::add_tiles(const gamemap& map, const std::set<map_location>& locs)
{
foreach (const map_location& loc, locs) {
BOOST_FOREACH(const map_location& loc, locs) {
add_tile(map, loc);
}
}
@ -57,7 +58,7 @@ std::set<map_location> map_fragment::get_area() const
std::set<map_location> map_fragment::get_offset_area(const map_location& loc) const
{
std::set<map_location> result;
foreach (const tile_info& i, items_) {
BOOST_FOREACH(const tile_info& i, items_) {
result.insert(i.offset.vector_sum(loc));
}
return result;
@ -65,14 +66,14 @@ std::set<map_location> map_fragment::get_offset_area(const map_location& loc) co
void map_fragment::paste_into(gamemap& map, const map_location& loc) const
{
foreach (const tile_info& i, items_) {
BOOST_FOREACH(const tile_info& i, items_) {
map.set_terrain(i.offset.vector_sum(loc), i.terrain);
}
}
void map_fragment::shift(const map_location& offset)
{
foreach (tile_info& ti, items_) {
BOOST_FOREACH(tile_info& ti, items_) {
ti.offset.vector_sum_assign(offset);
}
}
@ -80,7 +81,7 @@ void map_fragment::shift(const map_location& offset)
map_location map_fragment::center_of_mass() const
{
map_location sum(0, 0);
foreach (const tile_info& ti, items_) {
BOOST_FOREACH(const tile_info& ti, items_) {
sum.vector_sum_assign(ti.offset);
}
sum.x /= static_cast<int>(items_.size());
@ -92,7 +93,7 @@ void map_fragment::center_by_mass()
{
shift(center_of_mass().vector_negation());
area_.clear();
foreach (tile_info& ti, items_) {
BOOST_FOREACH(tile_info& ti, items_) {
area_.insert(ti.offset);
}
}
@ -100,7 +101,7 @@ void map_fragment::center_by_mass()
void map_fragment::rotate_60_cw()
{
area_.clear();
foreach (tile_info& ti, items_) {
BOOST_FOREACH(tile_info& ti, items_) {
map_location l(0,0);
int x = ti.offset.x;
int y = ti.offset.y;
@ -120,7 +121,7 @@ void map_fragment::rotate_60_cw()
void map_fragment::rotate_60_ccw()
{
area_.clear();
foreach (tile_info& ti, items_) {
BOOST_FOREACH(tile_info& ti, items_) {
map_location l(0,0);
int x = ti.offset.x;
int y = ti.offset.y;
@ -139,7 +140,7 @@ void map_fragment::rotate_60_ccw()
void map_fragment::flip_horizontal()
{
foreach (tile_info& ti, items_) {
BOOST_FOREACH(tile_info& ti, items_) {
ti.offset.x = -ti.offset.x;
}
center_by_mass();
@ -147,7 +148,7 @@ void map_fragment::flip_horizontal()
void map_fragment::flip_vertical()
{
foreach (tile_info& ti, items_) {
BOOST_FOREACH(tile_info& ti, items_) {
ti.offset.y = -ti.offset.y;
if (ti.offset.x % 2) {
ti.offset.y--;
@ -166,11 +167,11 @@ std::string map_fragment::dump() const
{
std::stringstream ss;
ss << "MF: ";
foreach (const tile_info& ti, items_) {
BOOST_FOREACH(const tile_info& ti, items_) {
ss << "(" << ti.offset << ")";
}
ss << " -- ";
foreach (const map_location& loc, area_) {
BOOST_FOREACH(const map_location& loc, area_) {
ss << "(" << loc << ")";
}
return ss.str();

View file

@ -17,7 +17,6 @@
#include "editor_palettes.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "marked-up_text.hpp"
#include "tooltips.hpp"
@ -26,6 +25,8 @@
#include "wml_separators.hpp"
#include <boost/foreach.hpp>
namespace editor {
//TODO move to the palette
@ -129,7 +130,7 @@ void editor_palette<Item>::set_group(const std::string& id)
assert(!id.empty());
bool found = false;
foreach (const item_group& group, groups_) {
BOOST_FOREACH(const item_group& group, groups_) {
if (group.id == id)
found = true;
}

View file

@ -21,9 +21,10 @@
#include "terrain_palettes.hpp"
#include "../../foreach.hpp"
#include "../../gettext.hpp"
#include <boost/foreach.hpp>
namespace {
static std::string selected_terrain;
static t_translation::t_terrain fg_terrain;
@ -71,7 +72,7 @@ void terrain_palette::setup(const config& cfg)
// Get the available groups and add them to the structure
std::set<std::string> group_names;
foreach (const config &g, cfg.child_range("editor_group"))
BOOST_FOREACH(const config &g, cfg.child_range("editor_group"))
{
if (group_names.find(g["id"]) == group_names.end()) {
config item;
@ -89,12 +90,12 @@ void terrain_palette::setup(const config& cfg)
}
std::map<std::string, item_group*> id_to_group;
foreach (item_group& group, groups_) {
BOOST_FOREACH(item_group& group, groups_) {
id_to_group.insert(std::make_pair(group.id, &group));
}
// add the groups for all terrains to the map
foreach (const t_translation::t_terrain& t, items) {
BOOST_FOREACH(const t_translation::t_terrain& t, items) {
const terrain_type& t_info = map().get_terrain_info(t);
DBG_ED << "Palette: processing terrain " << t_info.name()
@ -113,7 +114,7 @@ void terrain_palette::setup(const config& cfg)
item_map_[get_id(t)] = t;
foreach (const std::string& k, keys) {
BOOST_FOREACH(const std::string& k, keys) {
group_map_[k].push_back(get_id(t));
nmax_items_ = std::max(nmax_items_, group_map_[k].size());
std::map<std::string, item_group*>::iterator i = id_to_group.find(k);

View file

@ -21,11 +21,12 @@
#include "unit_palette.hpp"
#include "../../foreach.hpp"
#include "../../gettext.hpp"
#include "../../unit_types.hpp"
#include <boost/foreach.hpp>
namespace editor {
//TODO
@ -41,7 +42,7 @@ void unit_palette::update_report()
void unit_palette::setup(const config& /*cfg*/)
{
foreach (const unit_type_data::unit_type_map::value_type &i, unit_types.types())
BOOST_FOREACH(const unit_type_data::unit_type_map::value_type &i, unit_types.types())
{
item_map_.insert(std::pair<std::string, unit_type>(i.second.id(), i.second));
group_map_[i.second.race()].push_back(i.second.id());
@ -57,7 +58,7 @@ void unit_palette::setup(const config& /*cfg*/)
}
}
foreach (const race_map::value_type &i, unit_types.races())
BOOST_FOREACH(const race_map::value_type &i, unit_types.races())
{
config cfg;
cfg["id"] = i.second.id();

View file

@ -17,9 +17,10 @@
#include "brush.hpp"
#include "editor/editor_common.hpp"
#include "foreach.hpp"
#include "pathutils.hpp"
#include <boost/foreach.hpp>
namespace editor {
/*WIKI
@ -74,11 +75,11 @@ brush::brush(const config& cfg)
if (radius > 0) {
std::vector<map_location> in_radius;
get_tiles_in_radius(map_location(0, 0), radius, in_radius);
foreach (map_location& loc, in_radius) {
BOOST_FOREACH(map_location& loc, in_radius) {
add_relative_location(loc.x, loc.y);
}
}
foreach (const config &relative, cfg.child_range("relative"))
BOOST_FOREACH(const config &relative, cfg.child_range("relative"))
{
int x = relative["x"];
int y = relative["y"];
@ -97,7 +98,7 @@ void brush::add_relative_location(int relative_x, int relative_y)
std::set<map_location> brush::project(const map_location& hotspot) const
{
std::set<map_location> result;
foreach (const map_location& relative, relative_tiles_) {
BOOST_FOREACH(const map_location& relative, relative_tiles_) {
result.insert(relative.vector_sum(hotspot));
}
return result;

View file

@ -14,13 +14,13 @@
*/
#include "editor_toolkit.hpp"
#include "foreach.hpp"
#include "config.hpp"
#include "editor/action/mouse/mouse_action.hpp"
#include "editor/action/mouse/mouse_action_map_label.hpp"
#include "editor/action/mouse/mouse_action_unit.hpp"
#include <boost/foreach.hpp>
namespace editor {
@ -45,7 +45,7 @@ editor_toolkit::editor_toolkit(editor_display& gui, const CKey& key, const confi
editor_toolkit::~editor_toolkit()
{
//TODO ask someone about that
// foreach (const mouse_action_map::value_type a, mouse_actions_) {
// BOOST_FOREACH(const mouse_action_map::value_type a, mouse_actions_) {
// delete a.second;
// }
//delete palette_manager_.get();
@ -55,7 +55,7 @@ editor_toolkit::~editor_toolkit()
void editor_toolkit::init_brushes(const config& game_config)
{
foreach (const config &i, game_config.child_range("brush")) {
BOOST_FOREACH(const config &i, game_config.child_range("brush")) {
brushes_.push_back(brush(i));
}
if (brushes_.empty()) {
@ -93,7 +93,7 @@ void editor_toolkit::init_mouse_actions(const config& game_config)
// mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_PASTE,
// new mouse_action_paste(clipboard_, key_, *palette_manager_->empty_palette_.get())));
foreach (const theme::menu& menu, gui_.get_theme().menus()) {
BOOST_FOREACH(const theme::menu& menu, gui_.get_theme().menus()) {
if (menu.items().size() == 1) {
hotkey::HOTKEY_COMMAND hk = hotkey::get_hotkey(menu.items().front()).get_id();
mouse_action_map::iterator i = mouse_actions_.find(hk);
@ -102,7 +102,7 @@ void editor_toolkit::init_mouse_actions(const config& game_config)
}
}
}
foreach (const config &c, game_config.child_range("editor_tool_hint")) {
BOOST_FOREACH(const config &c, game_config.child_range("editor_tool_hint")) {
mouse_action_map::iterator i =
mouse_actions_.find(hotkey::get_hotkey(c["id"]).get_id());
if (i != mouse_actions_.end()) {
@ -187,7 +187,7 @@ void editor_toolkit::adjust_size()
void editor_toolkit::redraw_toolbar()
{
foreach (mouse_action_map::value_type a, mouse_actions_) {
BOOST_FOREACH(mouse_action_map::value_type a, mouse_actions_) {
if (a.second->toolbar_button() != NULL) {
SDL_Rect r = a.second->toolbar_button()->location(gui_.screen_area());
SDL_Rect outline = create_rect(r.x - 2, r.y - 2, r.h + 4, r.w + 4);

View file

@ -56,7 +56,6 @@ BPath be_path;
#include "config.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "game_config.hpp"
#include "game_preferences.hpp"
#include "log.hpp"
@ -65,6 +64,8 @@ BPath be_path;
#include "serialization/string_utils.hpp"
#include "version.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_filesystem("filesystem");
#define DBG_FS LOG_STREAM(debug, log_filesystem)
#define LOG_FS LOG_STREAM(info, log_filesystem)
@ -1008,7 +1009,7 @@ void binary_paths_manager::set_paths(const config& cfg)
cleanup();
init_binary_paths();
foreach (const config &bp, cfg.child_range("binary_path"))
BOOST_FOREACH(const config &bp, cfg.child_range("binary_path"))
{
std::string path = bp["path"].str();
if (path.find("..") != std::string::npos) {
@ -1055,7 +1056,7 @@ const std::vector<std::string>& get_binary_paths(const std::string& type)
init_binary_paths();
foreach (const std::string &path, binary_paths)
BOOST_FOREACH(const std::string &path, binary_paths)
{
res.push_back(get_user_data_dir() + "/" + path + type + "/");
@ -1096,7 +1097,7 @@ std::string get_binary_file_location(const std::string& type, const std::string&
return std::string();
}
foreach (const std::string &path, get_binary_paths(type))
BOOST_FOREACH(const std::string &path, get_binary_paths(type))
{
const std::string file = path + filename;
DBG_FS << " checking '" << path << "'\n";
@ -1124,7 +1125,7 @@ std::string get_binary_dir_location(const std::string &type, const std::string &
return std::string();
}
foreach (const std::string &path, get_binary_paths(type))
BOOST_FOREACH(const std::string &path, get_binary_paths(type))
{
const std::string file = path + filename;
DBG_FS << " checking '" << path << "'\n";
@ -1307,7 +1308,7 @@ std::string normalize_path(const std::string &p1)
p4 << drive;
#endif
foreach (const std::string &s, components)
BOOST_FOREACH(const std::string &s, components)
{
p4 << '/' << s;
}

View file

@ -21,7 +21,6 @@
#include "config.hpp"
#include "filesystem.hpp"
#include "font.hpp"
#include "foreach.hpp"
#include "game_config.hpp"
#include "log.hpp"
#include "marked-up_text.hpp"
@ -32,6 +31,8 @@
#include "serialization/preprocessor.hpp"
#include "serialization/string_utils.hpp"
#include <boost/foreach.hpp>
#include <list>
#include <set>
#include <stack>
@ -355,10 +356,10 @@ void manager::init() const
#endif
#if CAIRO_HAS_WIN32_FONT
foreach(const std::string& path, get_binary_paths("fonts")) {
BOOST_FOREACH(const std::string& path, get_binary_paths("fonts")) {
std::vector<std::string> files;
get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
foreach(const std::string& file, files)
BOOST_FOREACH(const std::string& file, files)
if(file.substr(file.length() - 4) == ".ttf" || file.substr(file.length() - 4) == ".ttc")
AddFontResource(file.c_str());
}
@ -372,10 +373,10 @@ void manager::deinit() const
#endif
#if CAIRO_HAS_WIN32_FONT
foreach(const std::string& path, get_binary_paths("fonts")) {
BOOST_FOREACH(const std::string& path, get_binary_paths("fonts")) {
std::vector<std::string> files;
get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
foreach(const std::string& file, files)
BOOST_FOREACH(const std::string& file, files)
if(file.substr(file.length() - 4) == ".ttf" || file.substr(file.length() - 4) == ".ttc")
RemoveFontResource(file.c_str());
}
@ -425,7 +426,7 @@ static void set_font_list(const std::vector<subset_descriptor>& fontlist)
const subset_id subset = font_names.size();
font_names.push_back(itor->name);
foreach (const subset_descriptor::range &cp_range, itor->present_codepoints) {
BOOST_FOREACH(const subset_descriptor::range &cp_range, itor->present_codepoints) {
char_blocks.insert(cp_range.first, cp_range.second, subset);
}
}
@ -582,7 +583,7 @@ void text_surface::measure() const
w_ = 0;
h_ = 0;
foreach (text_chunk const &chunk, chunks_)
BOOST_FOREACH(text_chunk const &chunk, chunks_)
{
TTF_Font* ttfont = get_font(font_id(chunk.subset, font_size_));
if(ttfont == NULL)
@ -628,7 +629,7 @@ std::vector<surface> const &text_surface::get_surfaces() const
if(width() > max_text_line_width)
return surfs_;
foreach (text_chunk const &chunk, chunks_)
BOOST_FOREACH(text_chunk const &chunk, chunks_)
{
TTF_Font* ttfont = get_font(font_id(chunk.subset, font_size_));
if (ttfont == NULL)
@ -1261,7 +1262,7 @@ bool load_font_config()
return false;
std::set<std::string> known_fonts;
foreach (const config &font, fonts_config.child_range("font")) {
BOOST_FOREACH(const config &font, fonts_config.child_range("font")) {
known_fonts.insert(font["name"]);
}

View file

@ -1,12 +0,0 @@
#ifndef FOREACH_HPP
#define FOREACH_HPP
#include <boost/foreach.hpp>
#ifdef __CDT_PARSER__
#define foreach(a, b) for(a : b)
#else
#define foreach BOOST_FOREACH
#endif
#endif

View file

@ -17,11 +17,12 @@
#include <set>
#include <sstream>
#include "foreach.hpp"
#include "formula_callable.hpp"
#include "formula_function.hpp"
#include "map_utils.hpp"
#include <boost/foreach.hpp>
namespace game_logic
{
@ -117,7 +118,7 @@ private:
std::stringstream s;
s << '[';
bool first_item = true;
foreach(expression_ptr a , items_) {
BOOST_FOREACH(expression_ptr a , items_) {
if (!first_item) {
s << ',';
} else {
@ -468,7 +469,7 @@ public:
std::stringstream s;
s << "{where:(";
s << body_->str();
foreach (const expr_table::value_type &a, *clauses_) {
BOOST_FOREACH(const expr_table::value_type &a, *clauses_) {
s << ", [" << a.first << "] -> ["<< a.second->str()<<"]";
}
s << ")}";

View file

@ -16,14 +16,14 @@
#include "global.hpp"
//#include "foreach.hpp"
#include "callable_objects.hpp"
#include "foreach.hpp"
#include "formula_debugger.hpp"
#include "formula_function.hpp"
#include "game_display.hpp"
#include "log.hpp"
#include <boost/foreach.hpp>
#ifdef HAVE_VISUAL_LEAK_DETECTOR
#include "vld.h"
#endif
@ -46,7 +46,7 @@ std::string function_expression::str() const
s << get_name();
s << '(';
bool first_arg = true;
foreach(expression_ptr a , args()) {
BOOST_FOREACH(expression_ptr a , args()) {
if (!first_arg) {
s << ',';
} else {
@ -451,7 +451,7 @@ private:
std::string result;
foreach(expression_ptr arg, args()) {
BOOST_FOREACH(expression_ptr arg, args()) {
result += arg->evaluate(variables, fdb).string_cast();
}

View file

@ -13,7 +13,6 @@
#include <sstream>
#include "foreach.hpp"
#include "formula_tokenizer.hpp"
namespace formula_tokenizer

View file

@ -41,6 +41,7 @@
#include <fstream>
#include <libintl.h>
#include <boost/foreach.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
@ -222,7 +223,7 @@ static int process_command_args(const commandline_options& cmdline_opts) {
int read = 0;
// use static preproc_define::read_pair(config) to make a object
foreach ( const config::any_child &value, cfg.all_children_range() ) {
BOOST_FOREACH( const config::any_child &value, cfg.all_children_range() ) {
const preproc_map::value_type def = preproc_define::read_pair( value.cfg );
input_macros[def.first] = def.second;
++read;
@ -249,7 +250,7 @@ static int process_command_args(const commandline_options& cmdline_opts) {
if ( cmdline_opts.preprocess_defines ) {
// add the specified defines
foreach ( const std::string &define, *cmdline_opts.preprocess_defines ) {
BOOST_FOREACH( const std::string &define, *cmdline_opts.preprocess_defines ) {
if (define.empty()){
std::cerr << "empty define supplied\n";
continue;
@ -456,7 +457,7 @@ static int do_gameloop(int argc, char** argv)
const config &cfg = game->game_config().child("titlescreen_music");
if (cfg) {
sound::play_music_repeatedly(game_config::title_music);
foreach (const config &i, cfg.child_range("music")) {
BOOST_FOREACH(const config &i, cfg.child_range("music")) {
sound::play_music_config(i);
}
sound::commit_music_changes();

View file

@ -18,7 +18,6 @@
#include "color_range.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "util.hpp"
@ -29,6 +28,8 @@
#include "revision.hpp"
#endif /* HAVE_REVISION */
#include <boost/foreach.hpp>
static lg::log_domain log_engine("engine");
#define DBG_NG LOG_STREAM(debug, log_engine)
#define ERR_NG LOG_STREAM(err, log_engine)
@ -267,7 +268,7 @@ namespace game_config
}
server_list.clear();
foreach (const config &server, v.child_range("server"))
BOOST_FOREACH(const config &server, v.child_range("server"))
{
server_info sinf;
sinf.name = server["name"].str();
@ -278,7 +279,7 @@ namespace game_config
void add_color_info(const config &v)
{
foreach (const config &teamC, v.child_range("color_range"))
BOOST_FOREACH(const config &teamC, v.child_range("color_range"))
{
const config::attribute_value *a1 = teamC.get("id"),
*a2 = teamC.get("rgb");
@ -312,9 +313,9 @@ namespace game_config
DBG_NG << str.str() << '\n';
}
foreach (const config &cp, v.child_range("color_palette"))
BOOST_FOREACH(const config &cp, v.child_range("color_palette"))
{
foreach (const config::attribute &rgb, cp.attribute_range())
BOOST_FOREACH(const config::attribute &rgb, cp.attribute_range())
{
std::vector<Uint32> temp;
if(!string2rgb(rgb.second, temp)) {

View file

@ -51,6 +51,8 @@
#include "wml_exception.hpp"
#include "gui/dialogs/mp_host_game_prompt.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_config("config");
#define ERR_CONFIG LOG_STREAM(err, log_config)
#define WRN_CONFIG LOG_STREAM(warn, log_config)
@ -489,7 +491,7 @@ bool game_controller::play_multiplayer_mode()
}
int side_num = 1;
foreach (config &s, level.child_range("side"))
BOOST_FOREACH(config &s, level.child_range("side"))
{
std::map<int,std::string>::const_iterator type = side_types.find(side_num),
controller = side_controllers.find(side_num),
@ -518,7 +520,7 @@ bool game_controller::play_multiplayer_mode()
faction_excepts.clear();
}
unsigned j = 0;
foreach (const config &faction, era_cfg.child_range("multiplayer_side"))
BOOST_FOREACH(const config &faction, era_cfg.child_range("multiplayer_side"))
{
if (faction["random_faction"].to_bool()) continue;
const std::string &faction_id = faction["id"];
@ -684,7 +686,7 @@ bool game_controller::load_game()
}
if(state_.classification().campaign_type == "multiplayer") {
foreach (config &side, state_.snapshot.child_range("side"))
BOOST_FOREACH(config &side, state_.snapshot.child_range("side"))
{
if (side["controller"] == "network")
side["controller"] = "human";
@ -694,10 +696,10 @@ bool game_controller::load_game()
}
if (load.cancel_orders()) {
foreach (config &side, state_.snapshot.child_range("side"))
BOOST_FOREACH(config &side, state_.snapshot.child_range("side"))
{
if (side["controller"] != "human") continue;
foreach (config &unit, side.child_range("unit"))
BOOST_FOREACH(config &unit, side.child_range("unit"))
{
unit["goto_x"] = -999;
unit["goto_y"] = -999;
@ -721,7 +723,7 @@ void game_controller::set_tutorial()
void game_controller::mark_completed_campaigns(std::vector<config> &campaigns)
{
foreach (config &campaign, campaigns) {
BOOST_FOREACH(config &campaign, campaigns) {
campaign["completed"] = preferences::is_campaign_completed(campaign["id"]);
}
}
@ -1219,7 +1221,7 @@ void game_controller::load_game_cfg(const bool force)
game_config_.splice_children(core_terrain_rules, "terrain_graphics");
config& hashes = game_config_.add_child("multiplayer_hashes");
foreach (const config &ch, game_config_.child_range("multiplayer")) {
BOOST_FOREACH(const config &ch, game_config_.child_range("multiplayer")) {
hashes[ch["id"]] = ch.hash();
}

View file

@ -15,7 +15,6 @@
#include "game_controller_abstract.hpp"
#include "foreach.hpp"
#include "game_display.hpp"
#include "gettext.hpp"
#include "hotkeys.hpp"
@ -24,6 +23,8 @@
#include "preferences.hpp"
#include <boost/foreach.hpp>
#include <iostream>
game_controller_abstract::game_controller_abstract(const commandline_options &cmdline_opts) :
@ -80,7 +81,7 @@ bool game_controller_abstract::init_language()
language_def locale;
if(cmdline_opts_.language) {
std::vector<language_def> langs = get_languages();
foreach(const language_def & def, langs) {
BOOST_FOREACH(const language_def & def, langs) {
if(def.localename == *cmdline_opts_.language) {
locale = def;
break;

View file

@ -34,7 +34,6 @@
Growl_Delegate growl_obj;
#endif
#include "foreach.hpp"
#include "game_preferences.hpp"
#include "halo.hpp"
#include "log.hpp"
@ -47,6 +46,8 @@ Growl_Delegate growl_obj;
#include "sound.hpp"
#include "whiteboard/manager.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_display("display");
#define ERR_DP LOG_STREAM(err, log_display)
#define LOG_DP LOG_STREAM(info, log_display)
@ -289,7 +290,7 @@ void game_display::draw_invalidated()
halo::unrender(invalidated_);
display::draw_invalidated();
foreach(unit* temp_unit, fake_units_) {
BOOST_FOREACH(unit* temp_unit, fake_units_) {
const map_location& loc = temp_unit->get_location();
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
if (invalidated_.find(loc) != invalidated_.end()
@ -435,7 +436,7 @@ void game_display::draw_sidebar()
// We display the unit the mouse is over if it is over a unit,
// otherwise we display the unit that is selected.
foreach (const std::string &name, reports::report_list()) {
BOOST_FOREACH(const std::string &name, reports::report_list()) {
draw_report(name);
}
invalidateGameStatus_ = false;
@ -630,7 +631,7 @@ void game_display::highlight_reach(const pathfind::paths &paths_list)
void game_display::highlight_another_reach(const pathfind::paths &paths_list)
{
// Fold endpoints of routes into reachability map.
foreach (const pathfind::paths::step &dest, paths_list.destinations) {
BOOST_FOREACH(const pathfind::paths::step &dest, paths_list.destinations) {
reach_map_[dest.curr]++;
}
reach_map_changed_ = true;
@ -737,11 +738,11 @@ void game_display::invalidate_animations_location(const map_location& loc) {
void game_display::invalidate_animations()
{
display::invalidate_animations();
foreach(unit* temp_unit, fake_units_) {
BOOST_FOREACH(unit* temp_unit, fake_units_) {
temp_unit->refresh();
}
std::vector<unit*> unit_list;
foreach (unit *u, fake_units_) {
BOOST_FOREACH(unit *u, fake_units_) {
unit_list.push_back(u);
}
bool new_inval;
@ -888,7 +889,7 @@ void game_display::parse_team_overlays()
{
const team& curr_team = (*teams_)[playing_team()];
const team& prev_team = (*teams_)[playing_team()-1 < teams_->size() ? playing_team()-1 : teams_->size()-1];
foreach (const game_display::overlay_map::value_type i, overlays_) {
BOOST_FOREACH(const game_display::overlay_map::value_type i, overlays_) {
const overlay& ov = i.second;
if (!ov.team_name.empty() &&
((ov.team_name.find(curr_team.team_name()) + 1) != 0) !=
@ -1294,7 +1295,7 @@ void game_display::prune_chat_messages(bool remove_all)
}
}
foreach (const chat_message &cm, chat_messages_) {
BOOST_FOREACH(const chat_message &cm, chat_messages_) {
font::move_floating_label(cm.speaker_handle, 0, - movement);
font::move_floating_label(cm.handle, 0, - movement);
}

View file

@ -23,7 +23,6 @@
#include "actions.hpp"
#include "ai/manager.hpp"
#include "dialogs.hpp"
#include "foreach.hpp"
#include "game_display.hpp"
#include "game_events.hpp"
#include "game_preferences.hpp"
@ -60,6 +59,8 @@
#include <iomanip>
#include <iostream>
#include <boost/foreach.hpp>
static lg::log_domain log_engine("engine");
#define DBG_NG LOG_STREAM(debug, log_engine)
#define LOG_NG LOG_STREAM(info, log_engine)
@ -341,7 +342,7 @@ namespace game_events {
std::vector<std::pair<int,int> > counts = (*u).has_attribute("count")
? utils::parse_ranges((*u)["count"]) : default_counts;
int match_count = 0;
foreach (const unit &i, *resources::units)
BOOST_FOREACH(const unit &i, *resources::units)
{
if(i.hitpoints() > 0 && unit_matches_filter(i, *u)) {
++match_count;
@ -396,7 +397,7 @@ namespace game_events {
const vconfig::child_list& variables = cond.get_children("variable");
backwards_compat = backwards_compat && variables.empty();
foreach (const vconfig &values, variables)
BOOST_FOREACH(const vconfig &values, variables)
{
const std::string name = values["name"];
config::attribute_value value = resources::state_of_game->get_variable_const(name);
@ -573,7 +574,7 @@ namespace {
const std::vector<game_events::event_handler>& handlers,
const std::string& msg) {
foreach(const game_events::event_handler& h, handlers){
BOOST_FOREACH(const game_events::event_handler& h, handlers){
const config& cfg = h.get_config();
ss << "name=" << cfg["name"] << ", with id=" << cfg["id"] << "; ";
}
@ -587,7 +588,7 @@ namespace {
std::stringstream ss;
log_handler(ss, active_, "active");
log_handler(ss, insert_buffer_, "insert buffered");
foreach(const std::string& h, remove_buffer_){
BOOST_FOREACH(const std::string& h, remove_buffer_){
ss << "id=" << h << "; ";
}
DBG_EH << "remove buffered handlers are now " << ss.str() << "\n";
@ -615,7 +616,7 @@ namespace {
const config & cfg = new_handler.get_config();
std::string id = cfg["id"];
if(!id.empty()) {
foreach( game_events::event_handler const & eh, active_) {
BOOST_FOREACH( game_events::event_handler const & eh, active_) {
config const & temp_config( eh.get_config());
if(id == temp_config["id"]) {
DBG_EH << "ignoring event handler for name=" << cfg["name"] <<
@ -682,12 +683,12 @@ namespace {
return;
// Commit any event removals
foreach(std::string const & i , remove_buffer_ ){
BOOST_FOREACH(std::string const & i , remove_buffer_ ){
remove_event_handler( i ); }
remove_buffer_.clear();
// Commit any spawned events-within-events
foreach( game_events::event_handler const & i , insert_buffer_ ){
BOOST_FOREACH( game_events::event_handler const & i , insert_buffer_ ){
add_event_handler( i ); }
insert_buffer_.clear();
@ -725,12 +726,12 @@ static void toggle_shroud(const bool remove, const vconfig& cfg)
const terrain_filter filter(cfg, *resources::units);
filter.get_locations(locs, true);
foreach (const int &side_num, sides)
BOOST_FOREACH(const int &side_num, sides)
{
index = side_num - 1;
team &t = (*resources::teams)[index];
foreach (map_location const &loc, locs)
BOOST_FOREACH(map_location const &loc, locs)
{
if (remove) {
t.clear_shroud(loc);
@ -775,7 +776,7 @@ static void toggle_fog(const bool clear, const vconfig& cfg, const bool affect_n
t_filter.get_locations(locs, true);
// Loop through sides.
foreach (const int &side_num, sides)
BOOST_FOREACH(const int &side_num, sides)
{
team &t = (*resources::teams)[side_num-1];
if ( !clear )
@ -790,7 +791,7 @@ static void toggle_fog(const bool clear, const vconfig& cfg, const bool affect_n
t.add_fog_override(locs);
else
// Simply clear fog from the locations.
foreach (const map_location &hex, locs)
BOOST_FOREACH(const map_location &hex, locs)
t.clear_fog(hex);
}
@ -814,7 +815,7 @@ WML_HANDLER_FUNCTION(tunnel, /*event_info*/, cfg)
const bool remove = cfg["remove"].to_bool(false);
if (remove) {
const std::vector<std::string> ids = utils::split(cfg["id"]);
foreach(const std::string &id, ids) {
BOOST_FOREACH(const std::string &id, ids) {
resources::tunnels->remove(id);
}
} else if (cfg.get_children("source").empty() ||
@ -985,7 +986,7 @@ WML_HANDLER_FUNCTION(modify_ai, /*event_info*/, cfg)
side_filter ssf(cfg);
sides = ssf.get_teams();
}
foreach (const int &side_num, sides)
BOOST_FOREACH(const int &side_num, sides)
{
ai::manager::modify_active_ai_for_side(side_num,cfg.get_parsed_config());
}
@ -1010,7 +1011,7 @@ WML_HANDLER_FUNCTION(modify_side, /*event_info*/, cfg)
std::vector<int> sides = game_events::get_sides_vector(cfg);
size_t team_index;
foreach (const int &side_num, sides)
BOOST_FOREACH(const int &side_num, sides)
{
team_index = side_num - 1;
LOG_NG << "modifying side: " << side_num << "\n";
@ -1282,7 +1283,7 @@ WML_HANDLER_FUNCTION(move_units_fake, /*event_info*/, cfg)
size_t longest_path = 0;
foreach(const vconfig& config, unit_cfgs) {
BOOST_FOREACH(const vconfig& config, unit_cfgs) {
const std::vector<std::string> xvals = utils::split(config["x"]);
const std::vector<std::string> yvals = utils::split(config["y"]);
int skip_steps = config["skip_steps"];
@ -1548,7 +1549,7 @@ WML_HANDLER_FUNCTION(set_variable, /*event_info*/, cfg)
variable_info vi(array_name, true, variable_info::TYPE_ARRAY);
bool first = true;
foreach (const config &cfg, vi.as_array())
BOOST_FOREACH(const config &cfg, vi.as_array())
{
std::string current_string = cfg[key_name];
if (remove_empty && current_string.empty()) continue;
@ -1676,7 +1677,7 @@ WML_HANDLER_FUNCTION(set_variables, /*event_info*/, cfg)
dest.vars->merge_with(data);
}
} else if(mode == "insert" || dest.explicit_index) {
foreach (const config &child, data.child_range(dest.key))
BOOST_FOREACH(const config &child, data.child_range(dest.key))
{
dest.vars->add_child_at(dest.key, child, dest.index++);
}
@ -1706,7 +1707,7 @@ WML_HANDLER_FUNCTION(role, /*event_info*/, cfg)
item["type"] = *ti;
}
unit_map::iterator itor;
foreach (unit &u, *resources::units) {
BOOST_FOREACH(unit &u, *resources::units) {
if (game_events::unit_matches_filter(u, filter)) {
u.set_role(cfg["role"]);
found = true;
@ -1719,7 +1720,7 @@ WML_HANDLER_FUNCTION(role, /*event_info*/, cfg)
std::set<std::string> player_ids;
std::vector<std::string> sides = utils::split(cfg["side"]);
const bool has_any_sides = !sides.empty();
foreach(std::string const& side_str, sides) {
BOOST_FOREACH(std::string const& side_str, sides) {
size_t side_num = lexical_cast_default<size_t>(side_str,0);
if(side_num > 0 && side_num <= resources::teams->size()) {
player_ids.insert((resources::teams->begin() + (side_num - 1))->save_id());
@ -1786,7 +1787,7 @@ void change_terrain(const map_location &loc, const t_translation::t_terrain &t,
game_map->set_terrain(loc, new_t);
screen_needs_rebuild = true;
foreach (const t_translation::t_terrain &ut, game_map->underlying_union_terrain(loc)) {
BOOST_FOREACH(const t_translation::t_terrain &ut, game_map->underlying_union_terrain(loc)) {
preferences::encountered_terrains().insert(ut);
}
}
@ -1918,7 +1919,7 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg)
const map_location cfg_loc = cfg_to_loc(cfg);
//TODO fendrin: comment this monster
foreach (unit_map::const_unit_iterator leader, leaders) {
BOOST_FOREACH(unit_map::const_unit_iterator leader, leaders) {
DBG_NG << "...considering " + leader->id() + " as the recalling leader...\n";
map_location loc = cfg_loc;
if ( (leader_filter.null() || leader->matches_filter(leader_filter, leader->get_location())) &&
@ -1977,7 +1978,7 @@ WML_HANDLER_FUNCTION(object, event_info, cfg)
map_location loc;
if(!filter.null()) {
foreach (const unit &u, *resources::units) {
BOOST_FOREACH(const unit &u, *resources::units) {
if (game_events::unit_matches_filter(u, filter)) {
loc = u.get_location();
break;
@ -2031,7 +2032,7 @@ WML_HANDLER_FUNCTION(object, event_info, cfg)
}
}
foreach (const vconfig &cmd, cfg.get_children(command_type)) {
BOOST_FOREACH(const vconfig &cmd, cfg.get_children(command_type)) {
handle_event_commands(event_info, cmd);
}
}
@ -2132,13 +2133,13 @@ WML_HANDLER_FUNCTION(kill, event_info, cfg)
//Find all the dead units first, because firing events ruins unit_map iteration
std::vector<unit *> dead_men_walking;
foreach(unit & u, *resources::units){
BOOST_FOREACH(unit & u, *resources::units){
if(game_events::unit_matches_filter(u, cfg)){
dead_men_walking.push_back(&u);
}
}
foreach(unit * un, dead_men_walking) {
BOOST_FOREACH(unit * un, dead_men_walking) {
map_location loc(un->get_location());
bool fire_event = false;
game_events::entity_location death_loc(*un);
@ -2271,7 +2272,7 @@ WML_HANDLER_FUNCTION(set_menu_item, /*event_info*/, cfg)
WML_HANDLER_FUNCTION(clear_menu_item, /*event_info*/, cfg)
{
const std::string ids = cfg["id"].str();
foreach(const std::string& id, utils::split(ids, ',', utils::STRIP_SPACES)) {
BOOST_FOREACH(const std::string& id, utils::split(ids, ',', utils::STRIP_SPACES)) {
if(id.empty()) {
WRN_NG << "[clear_menu_item] has been given an empty id=, ignoring\n";
continue;
@ -2572,7 +2573,7 @@ WML_HANDLER_FUNCTION(redraw, /*event_info*/, cfg)
if (clear_shroud_bool) {
side_filter filter(cfg);
foreach(const int side, filter.get_teams()){
BOOST_FOREACH(const int side, filter.get_teams()){
clear_shroud(side);
}
screen.recalculate_minimap();
@ -2609,7 +2610,7 @@ WML_HANDLER_FUNCTION(heal_unit, event_info, cfg)
const vconfig healers_filter = cfg.child("filter_second");
std::vector<unit*> healers;
if (!healers_filter.null()) {
foreach (unit& u, *units) {
BOOST_FOREACH(unit& u, *units) {
if (game_events::unit_matches_filter(u, healers_filter) && u.has_ability_type("heals")) {
healers.push_back(&u);
}
@ -2978,7 +2979,7 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
return;
}
foreach (const vconfig &cmd, option_events[option_chosen]) {
BOOST_FOREACH(const vconfig &cmd, option_events[option_chosen]) {
handle_event_commands(event_info, cmd);
}
}
@ -3001,7 +3002,7 @@ WML_HANDLER_FUNCTION(time_area, /*event_info*/, cfg)
if(remove) {
const std::vector<std::string> id_list =
utils::split(ids, ',', utils::STRIP_SPACES | utils::REMOVE_EMPTY);
foreach(const std::string& id, id_list) {
BOOST_FOREACH(const std::string& id, id_list) {
resources::tod_manager->remove_time_area(id);
LOG_NG << "event WML removed time_area '" << id << "'\n";
}
@ -3142,7 +3143,7 @@ static void commit_wmi_commands() {
mref->command["first_time_only"] = false;
if(has_current_handler) {
foreach(game_events::event_handler& hand, event_handlers) {
BOOST_FOREACH(game_events::event_handler& hand, event_handlers) {
if(hand.is_menu_item() && hand.matches_name(mref->name)) {
LOG_NG << "changing command for " << mref->name << " to:\n" << *wcc.second;
hand = game_events::event_handler(mref->command, true);
@ -3174,14 +3175,14 @@ static bool process_event(game_events::event_handler& handler, const game_events
vconfig filters(handler.get_config());
foreach (const vconfig &condition, filters.get_children("filter_condition"))
BOOST_FOREACH(const vconfig &condition, filters.get_children("filter_condition"))
{
if (!game_events::conditional_passed(condition)) {
return false;
}
}
foreach (const vconfig &f, filters.get_children("filter"))
BOOST_FOREACH(const vconfig &f, filters.get_children("filter"))
{
if (unit1 == units->end() || !game_events::unit_matches_filter(*unit1, f)) {
return false;
@ -3191,7 +3192,7 @@ static bool process_event(game_events::event_handler& handler, const game_events
}
}
foreach (const vconfig &f, filters.get_children("filter_side"))
BOOST_FOREACH(const vconfig &f, filters.get_children("filter_side"))
{
side_filter ssf(f);
const int current_side = resources::controller->current_side();
@ -3200,7 +3201,7 @@ static bool process_event(game_events::event_handler& handler, const game_events
vconfig::child_list special_filters = filters.get_children("filter_attack");
bool special_matches = special_filters.empty();
foreach (const vconfig &f, special_filters)
BOOST_FOREACH(const vconfig &f, special_filters)
{
if (unit1 != units->end() && game_events::matches_special_filter(ev.data.child("first"), f)) {
special_matches = true;
@ -3213,7 +3214,7 @@ static bool process_event(game_events::event_handler& handler, const game_events
return false;
}
foreach (const vconfig &f, filters.get_children("filter_second"))
BOOST_FOREACH(const vconfig &f, filters.get_children("filter_second"))
{
if (unit2 == units->end() || !game_events::unit_matches_filter(*unit2, f)) {
return false;
@ -3225,7 +3226,7 @@ static bool process_event(game_events::event_handler& handler, const game_events
special_filters = filters.get_children("filter_second_attack");
special_matches = special_filters.empty();
foreach (const vconfig &f, special_filters)
BOOST_FOREACH(const vconfig &f, special_filters)
{
if (unit2 != units->end() && game_events::matches_special_filter(ev.data.child("second"), f)) {
special_matches = true;
@ -3420,17 +3421,17 @@ namespace game_events {
: variable_manager()
{
assert(!manager_running);
foreach (const config &ev, cfg.child_range("event")) {
BOOST_FOREACH(const config &ev, cfg.child_range("event")) {
event_handlers.add_event_handler(game_events::event_handler(ev));
}
foreach (const std::string &id, utils::split(cfg["unit_wml_ids"])) {
BOOST_FOREACH(const std::string &id, utils::split(cfg["unit_wml_ids"])) {
unit_wml_ids.insert(id);
}
resources::lua_kernel = new LuaKernel(cfg);
manager_running = true;
foreach (static_wml_action_map::value_type &action, static_wml_actions) {
BOOST_FOREACH(static_wml_action_map::value_type &action, static_wml_actions) {
resources::lua_kernel->set_wml_action(action.first, action.second);
}
@ -3443,7 +3444,7 @@ namespace game_events {
}
int wmi_count = 0;
typedef std::pair<std::string, wml_menu_item *> item;
foreach (const item &itor, resources::state_of_game->wml_menu_items) {
BOOST_FOREACH(const item &itor, resources::state_of_game->wml_menu_items) {
if (!itor.second->command.empty()) {
event_handlers.add_event_handler(game_events::event_handler(itor.second->command, true));
}
@ -3457,7 +3458,7 @@ namespace game_events {
void write_events(config& cfg)
{
assert(manager_running);
foreach (const game_events::event_handler &eh, event_handlers) {
BOOST_FOREACH(const game_events::event_handler &eh, event_handlers) {
if (eh.disabled() || eh.is_menu_item()) continue;
cfg.add_child("event", eh.get_config());
}
@ -3530,7 +3531,7 @@ namespace game_events {
if(std::find(unit_wml_ids.begin(),unit_wml_ids.end(),type) != unit_wml_ids.end()) return;
unit_wml_ids.insert(type);
}
foreach (const config &new_ev, cfgs) {
BOOST_FOREACH(const config &new_ev, cfgs) {
if(type.empty() && new_ev["id"].empty())
{
WRN_NG << "attempt to add an [event] with empty id=, ignoring \n";
@ -3572,7 +3573,7 @@ namespace game_events {
if(!lg::debug.dont_log("event_handler")) {
std::stringstream ss;
foreach(const game_events::queued_event& ev, events_queue) {
BOOST_FOREACH(const game_events::queued_event& ev, events_queue) {
ss << "name=" << ev.name << "; ";
}
DBG_EH << "processing queued events: " << ss.str() << "\n";
@ -3599,7 +3600,7 @@ namespace game_events {
bool init_event_vars = true;
foreach(game_events::event_handler& handler, event_handlers) {
BOOST_FOREACH(game_events::event_handler& handler, event_handlers) {
if(!handler.matches_name(event_name))
continue;
// Set the variables for the event

View file

@ -17,7 +17,6 @@
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "foreach.hpp"
#include "game_display.hpp"
#include "game_preferences.hpp"
#include "gamestatus.hpp"
@ -31,6 +30,8 @@
#include "unit_map.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
static lg::log_domain log_config("config");
#define ERR_CFG LOG_STREAM(err , log_config)
@ -112,9 +113,9 @@ manager::manager() :
message = foobar
[/line]
*/
foreach (const config::any_child &h, history.all_children_range())
BOOST_FOREACH(const config::any_child &h, history.all_children_range())
{
foreach (const config &l, h.cfg.child_range("line")) {
BOOST_FOREACH(const config &l, h.cfg.child_range("line")) {
history_map[h.key].push_back(l["message"]);
}
}
@ -142,10 +143,10 @@ manager::~manager()
*/
config history;
typedef std::pair<std::string, std::vector<std::string> > hack;
foreach(const hack& history_id, history_map) {
BOOST_FOREACH(const hack& history_id, history_map) {
config history_id_cfg; // [history_id]
foreach(const std::string& line, history_id.second) {
BOOST_FOREACH(const std::string& line, history_id.second) {
config cfg; // [line]
cfg["message"] = line;
@ -314,7 +315,7 @@ const std::vector<game_config::server_info>& server_list()
std::vector<game_config::server_info> &game_servers = game_config::server_list;
VALIDATE(!game_servers.empty(), _("No server has been defined."));
pref_servers.insert(pref_servers.begin(), game_servers.begin(), game_servers.end());
foreach (const config &server, get_prefs()->child_range("server")) {
BOOST_FOREACH(const config &server, get_prefs()->child_range("server")) {
game_config::server_info sinf;
sinf.name = server["name"].str();
sinf.address = server["address"].str();
@ -955,8 +956,8 @@ void encounter_start_units(unit_map& units){
}
void encounter_recallable_units(std::vector<team>& teams){
foreach(const team& t, teams) {
foreach(const unit& u, t.recall_list()) {
BOOST_FOREACH(const team& t, teams) {
BOOST_FOREACH(const unit& u, t.recall_list()) {
encountered_units_set.insert(u.type_id());
}
}

View file

@ -19,7 +19,6 @@
#include "display.hpp"
#include "filesystem.hpp"
#include "filechooser.hpp"
#include "foreach.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/simple_item_selector.hpp"
@ -30,6 +29,7 @@
#include "widgets/slider.hpp"
#include "formula_string_utils.hpp"
#include <boost/foreach.hpp>
namespace preferences {
@ -1071,7 +1071,7 @@ const config* preferences_dialog::get_advanced_pref() const
void preferences_dialog::set_advanced_menu()
{
std::vector<std::string> advanced_items;
foreach (const config &adv, adv_preferences_cfg_)
BOOST_FOREACH(const config &adv, adv_preferences_cfg_)
{
std::ostringstream str;
std::string field = preferences::get(adv["field"]);
@ -1096,7 +1096,7 @@ void preferences_dialog::sort_advanced_preferences()
{
adv_preferences_cfg_.clear();
foreach(const config& adv, game_cfg_.child_range("advanced_preference")) {
BOOST_FOREACH(const config& adv, game_cfg_.child_range("advanced_preference")) {
adv_preferences_cfg_.push_back(adv);
}

View file

@ -25,7 +25,6 @@
#include "actions.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "game_preferences.hpp"
@ -43,6 +42,7 @@
#include "whiteboard/side_actions.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#ifndef _MSC_VER
#include <sys/time.h>
@ -86,7 +86,7 @@ carryover::carryover(const config& side)
std::vector<std::string> temp_recruits = utils::split(side["previous_recruits"], ',');
previous_recruits_.insert(temp_recruits.begin(), temp_recruits.end());
foreach(const config& u, side.child_range("unit")){
BOOST_FOREACH(const config& u, side.child_range("unit")){
recall_list_.push_back(unit(u));
}
}
@ -143,7 +143,7 @@ void carryover::transfer_all_recruits_to(config& side_cfg){
}
void carryover::transfer_all_recalls_to(config& side_cfg){
foreach(unit& u, recall_list_){
BOOST_FOREACH(unit& u, recall_list_){
config& new_unit = side_cfg.add_child("unit");
u.write(new_unit);
}
@ -183,7 +183,7 @@ void carryover::initialize_team(config& side_cfg){
const std::string carryover::to_string(){
std::string side = "";
side.append("Side " + save_id_ + ": gold " + str_cast<int>(gold_) + " recruits " + get_recruits(false) + " units ");
foreach(const unit& u, recall_list_){
BOOST_FOREACH(const unit& u, recall_list_){
side.append(u.name() + ", ");
}
return side;
@ -198,7 +198,7 @@ void carryover::to_config(config& cfg){
side["current_player"] = current_player_;
side["name"] = name_;
side["previous_recruits"] = get_recruits(false);
foreach(unit& u, recall_list_){
BOOST_FOREACH(unit& u, recall_list_){
config& unit_cfg = side.add_child("unit");
u.write(unit_cfg);
}
@ -210,7 +210,7 @@ carryover_info::carryover_info(const config& cfg)
{
if(cfg.empty()) { return; }
end_level_.read(cfg.child("end_level_data"));
foreach(const config& side, cfg.child_range("side")){
BOOST_FOREACH(const config& side, cfg.child_range("side")){
this->carryover_sides_.push_back(carryover(side));
}
}
@ -229,7 +229,7 @@ const end_level_data& carryover_info::get_end_level() const{
}
void carryover_info::transfer_from(const team& t, int carryover_gold){
foreach(carryover& side, carryover_sides_){
BOOST_FOREACH(carryover& side, carryover_sides_){
if(side.get_save_id() == t.save_id()){
side.update_carryover(t, carryover_gold, end_level_.carryover_add);
return;
@ -240,7 +240,7 @@ void carryover_info::transfer_from(const team& t, int carryover_gold){
}
void carryover_info::transfer_all_to(config& side_cfg){
foreach(carryover& side, carryover_sides_){
BOOST_FOREACH(carryover& side, carryover_sides_){
if(side.get_save_id() == side_cfg["save_id"]){
side.transfer_all_gold_to(side_cfg);
side.transfer_all_recalls_to(side_cfg);
@ -252,7 +252,7 @@ void carryover_info::transfer_all_to(config& side_cfg){
const config carryover_info::to_config() {
config cfg;
foreach(carryover& c, carryover_sides_){
BOOST_FOREACH(carryover& c, carryover_sides_){
c.to_config(cfg);
}
config& end_level = cfg.add_child("end_level_data");
@ -261,7 +261,7 @@ const config carryover_info::to_config() {
}
carryover* carryover_info::get_side(std::string save_id){
foreach(carryover& side, carryover_sides_){
BOOST_FOREACH(carryover& side, carryover_sides_){
if(side.get_save_id() == save_id){
return &side;
}
@ -393,9 +393,9 @@ void write_players(game_state& gamestate, config& cfg, const bool use_snapshot,
tags.push_back("side");
tags.push_back("player"); //merge [player] tags for backwards compatibility of saves
foreach (const std::string& side_tag, tags)
BOOST_FOREACH(const std::string& side_tag, tags)
{
foreach (config &carryover_side, source->child_range(side_tag))
BOOST_FOREACH(config &carryover_side, source->child_range(side_tag))
{
config *scenario_side = NULL;
@ -441,13 +441,13 @@ void write_players(game_state& gamestate, config& cfg, const bool use_snapshot,
(*scenario_side)["color"] = carryover_side["color"];
//add recallable units
foreach (const config &u, carryover_side.child_range("unit")) {
BOOST_FOREACH(const config &u, carryover_side.child_range("unit")) {
scenario_side->add_child("unit", u);
}
}
}
} else {
foreach(const config &snapshot_side, source->child_range("side")) {
BOOST_FOREACH(const config &snapshot_side, source->child_range("side")) {
//take all side tags and add them as players (assuming they only contain carryover information)
cfg.add_child("player", snapshot_side);
}
@ -522,7 +522,7 @@ game_state::game_state(const config& cfg, bool show_replay) :
//See also playcampaign::play_game, where after finishing the scenario the replay
//will be saved.
if(!starting_pos.empty()) {
foreach (const config &p, cfg.child_range("player")) {
BOOST_FOREACH(const config &p, cfg.child_range("player")) {
config& cfg_player = starting_pos.add_child("player");
cfg_player.merge_with(p);
}
@ -618,7 +618,7 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
std::string leader;
std::string leader_image;
//foreach (const config &p, cfg_save.child_range("player"))
//BOOST_FOREACH(const config &p, cfg_save.child_range("player"))
//{
// if (p["canrecruit"].to_bool(false))) {
// leader = p["save_id"];
@ -631,7 +631,7 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
//{
if (const config &snapshot = *(has_snapshot ? &cfg_snapshot : &cfg_replay_start))
{
foreach (const config &side, snapshot.child_range("side"))
BOOST_FOREACH(const config &side, snapshot.child_range("side"))
{
if (side["controller"] != "human") {
continue;
@ -648,7 +648,7 @@ void extract_summary_from_config(config& cfg_save, config& cfg_summary)
break;
}
foreach (const config &u, side.child_range("unit"))
BOOST_FOREACH(const config &u, side.child_range("unit"))
{
if (u["canrecruit"].to_bool()) {
leader = u["id"].str();
@ -1016,7 +1016,7 @@ protected:
// can be recruited for the player, add them.
if (!player_cfg_) return;
if (const config::attribute_value *v = player_cfg_->get("previous_recruits")) {
foreach (const std::string &rec, utils::split(*v)) {
BOOST_FOREACH(const std::string &rec, utils::split(*v)) {
DBG_NG_TC << "adding previous recruit: " << rec << '\n';
t_->add_recruit(rec);
}
@ -1093,7 +1093,7 @@ protected:
} else
handle_leader(side_cfg_);
}
foreach (const config &l, side_cfg_.child_range("leader")) {
BOOST_FOREACH(const config &l, side_cfg_.child_range("leader")) {
handle_leader(l);
}
}
@ -1107,13 +1107,13 @@ protected:
//only relevant in start-of-scenario saves, that's why !shapshot
//units that are in '[scenario][side]' are 'first'
//for create-or-recall semantics to work: for each unit with non-empty id, unconditionally put OTHER, later, units with same id directly to recall list, not including them in unit_configs_
foreach(const config &u, (*player_cfg_).child_range("unit")) {
BOOST_FOREACH(const config &u, (*player_cfg_).child_range("unit")) {
handle_unit(u,"player_cfg");
}
} else {
//units in [side]
foreach (const config &su, side_cfg_.child_range("unit")) {
BOOST_FOREACH(const config &su, side_cfg_.child_range("unit")) {
handle_unit(su, "side_cfg");
}
}
@ -1138,7 +1138,7 @@ protected:
"allow_changes", "faction_name", "user_description", "faction" };
log_step("place units");
foreach (const config *u, unit_configs_) {
BOOST_FOREACH(const config *u, unit_configs_) {
unit_creator uc(*t_,map_.starting_position(side_));
uc
.allow_add_to_recall(true)
@ -1149,7 +1149,7 @@ protected:
.allow_show(false);
config cfg = *u;
foreach (const char *attr, side_attrs) {
BOOST_FOREACH(const char *attr, side_attrs) {
cfg.remove_attribute(attr);
}
uc.add_unit(cfg);
@ -1189,7 +1189,7 @@ void game_state::build_team_stage_two(team_builder_ptr tb_ptr)
void game_state::set_menu_items(const config::const_child_itors &menu_items)
{
clear_wmi(wml_menu_items);
foreach (const config &item, menu_items)
BOOST_FOREACH(const config &item, menu_items)
{
std::string id = item["id"];
wml_menu_item*& mref = wml_menu_items[id];

View file

@ -24,7 +24,6 @@
#include "config.hpp"
#include "../../image.hpp"
#include "foreach.hpp"
#include "formatter.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/formula.hpp"
@ -33,6 +32,8 @@
#include "../../text.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace {
@ -1474,7 +1475,7 @@ void tcanvas::parse_cfg(const config& cfg)
log_scope2(log_gui_parse, "Canvas: parsing config.");
shapes_.clear();
foreach(const config::any_child& shape, cfg.all_children_range()) {
BOOST_FOREACH(const config::any_child& shape, cfg.all_children_range()) {
const std::string &type = shape.key;
const config &data = shape.cfg;
@ -1493,7 +1494,7 @@ void tcanvas::parse_cfg(const config& cfg)
} else if(type == "pre_commit") {
/* note this should get split if more preprocessing is used. */
foreach(const config::any_child& function,
BOOST_FOREACH(const config::any_child& function,
data.all_children_range()) {
if(function.key == "blur") {

View file

@ -17,7 +17,6 @@
#include "gui/auxiliary/event/dispatcher_private.hpp"
#include "foreach.hpp"
#include "gui/auxiliary/log.hpp"
namespace gui2 {

View file

@ -18,7 +18,6 @@
#include "gui/auxiliary/event/handler.hpp"
#include "clipboard.hpp"
#include "foreach.hpp"
#include "gui/auxiliary/event/dispatcher.hpp"
#include "gui/auxiliary/timer.hpp"
#include "gui/auxiliary/log.hpp"
@ -28,6 +27,8 @@
#include "hotkeys.hpp"
#include "video.hpp"
#include <boost/foreach.hpp>
#include <cassert>
/**
@ -429,7 +430,7 @@ void thandler::disconnect(tdispatcher* dispatcher)
}
/***** Set proper state for the other dispatchers. *****/
foreach(tdispatcher* dispatcher, dispatchers_) {
BOOST_FOREACH(tdispatcher* dispatcher, dispatchers_) {
dynamic_cast<twidget&>(*dispatcher).set_dirty();
}
@ -448,7 +449,7 @@ void thandler::disconnect(tdispatcher* dispatcher)
void thandler::activate()
{
foreach(tdispatcher* dispatcher, dispatchers_) {
BOOST_FOREACH(tdispatcher* dispatcher, dispatchers_) {
dispatcher->fire(SDL_ACTIVATE
, dynamic_cast<twidget&>(*dispatcher)
, NULL);
@ -472,7 +473,7 @@ void thandler::draw(const bool force)
*
* For now we use a hack, but would be nice to rewrite it for 1.9/1.11.
*/
foreach(tdispatcher* dispatcher, dispatchers_) {
BOOST_FOREACH(tdispatcher* dispatcher, dispatchers_) {
if(!first) {
/*
* This leaves glitches on window borders if the window beneath it
@ -503,7 +504,7 @@ void thandler::video_resize(const tpoint& new_size)
{
DBG_GUI_E << "Firing: " << SDL_VIDEO_RESIZE << ".\n";
foreach(tdispatcher* dispatcher, dispatchers_) {
BOOST_FOREACH(tdispatcher* dispatcher, dispatchers_) {
dispatcher->fire(SDL_VIDEO_RESIZE
, dynamic_cast<twidget&>(*dispatcher)
, new_size);

View file

@ -16,10 +16,10 @@
#ifndef GUI_WIDGETS_AUXILIARY_NOTIFIER_HPP_INCLUDED
#define GUI_WIDGETS_AUXILIARY_NOTIFIER_HPP_INCLUDED
#include "foreach.hpp"
#include "gui/auxiliary/notifiee.hpp"
#include <boost/foreach.hpp>
#include <cassert>
#include <map>
@ -47,7 +47,7 @@ public:
~tnotifier()
{
typedef std::pair<tnotifiee<tfunctor>* const, tfunctor> thack;
foreach(thack& item, notifiees_) {
BOOST_FOREACH(thack& item, notifiees_) {
assert(item.first);
assert((*item.first).notifier_ == this);

View file

@ -18,10 +18,11 @@
#include "gui/auxiliary/tips.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "game_preferences.hpp"
#include "serialization/string_utils.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
ttip::ttip(const t_string& text
@ -39,7 +40,7 @@ std::vector<ttip> load(const config& cfg)
{
std::vector<ttip> result;
foreach(const config &tip, cfg.child_range("tip")) {
BOOST_FOREACH(const config &tip, cfg.child_range("tip")) {
result.push_back(ttip(tip["text"]
, tip["source"]
, tip["encountered_units"]));
@ -54,11 +55,11 @@ std::vector<ttip> shuffle(const std::vector<ttip>& tips)
const std::set<std::string>& units = preferences::encountered_units();
foreach(const ttip& tip, tips) {
BOOST_FOREACH(const ttip& tip, tips) {
if(tip.unit_filter_.empty()) {
result.push_back(tip);
} else {
foreach(const std::string& unit, tip.unit_filter_) {
BOOST_FOREACH(const std::string& unit, tip.unit_filter_) {
if(units.find(unit) != units.end()) {
result.push_back(tip);
break;

View file

@ -17,9 +17,10 @@
#define GUI_AUXILIARY_WIDGET_DEFINITION_HPP_INCLUDED
#include "config.hpp"
#include "foreach.hpp"
#include "gui/auxiliary/canvas.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
/**
@ -98,7 +99,7 @@ struct tcontrol_definition
void load_resolutions(const config &cfg)
{
config::const_child_itors itors = cfg.child_range("resolution");
foreach(const config &resolution, itors) {
BOOST_FOREACH(const config &resolution, itors) {
resolutions.push_back(new T(resolution));
}
}

View file

@ -18,7 +18,6 @@
#include "gui/auxiliary/window_builder.hpp"
#include "asserts.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/window_builder/helper.hpp"
@ -47,6 +46,7 @@
#include "formula_string_utils.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -90,7 +90,7 @@ twindow *build(CVideo &video, const twindow_builder::tresolution *definition)
, definition->helptip);
assert(window);
foreach(const twindow_builder::tresolution::tlinked_group& lg,
BOOST_FOREACH(const twindow_builder::tresolution::tlinked_group& lg,
definition->linked_groups) {
if(window->has_linked_size_group(lg.id)) {
@ -162,7 +162,7 @@ tbuilder_widget_ptr create_builder_widget(const config& cfg)
std::string
, boost::function<tbuilder_widget_ptr(config)> >
thack;
foreach(const thack& item, builder_widget_lookup()) {
BOOST_FOREACH(const thack& item, builder_widget_lookup()) {
if(item.first == "window" || item.first == "tooltip") {
continue;
}
@ -262,7 +262,7 @@ const std::string& twindow_builder::read(const config& cfg)
config::const_child_itors cfgs = cfg.child_range("resolution");
VALIDATE(cfgs.first != cfgs.second, _("No resolution defined."));
foreach (const config &i, cfgs) {
BOOST_FOREACH(const config &i, cfgs) {
resolutions.push_back(tresolution(i));
}
@ -410,7 +410,7 @@ twindow_builder::tresolution::tresolution(const config& cfg) :
definition = "default";
}
foreach (const config &lg, cfg.child_range("linked_group")) {
BOOST_FOREACH(const config &lg, cfg.child_range("linked_group")) {
tlinked_group linked_group;
linked_group.id = lg["id"].str();
linked_group.fixed_width = lg["fixed_width"].to_bool();
@ -515,13 +515,13 @@ tbuilder_grid::tbuilder_grid(const config& cfg) :
*/
log_scope2(log_gui_parse, "Window builder: parsing a grid");
foreach (const config &row, cfg.child_range("row"))
BOOST_FOREACH(const config &row, cfg.child_range("row"))
{
unsigned col = 0;
row_grow_factor.push_back(row["grow_factor"]);
foreach (const config &c, row.child_range("column"))
BOOST_FOREACH(const config &c, row.child_range("column"))
{
flags.push_back(implementation::read_flags(c));
border_size.push_back(c["border_size"]);

View file

@ -18,11 +18,12 @@
#include "gui/auxiliary/window_builder/helper.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/widgets/grid.hpp"
#include "gui/widgets/window.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -60,7 +61,7 @@ unsigned get_h_align(const std::string& h_align)
unsigned get_border(const std::vector<std::string>& border)
{
unsigned result = 0;
foreach (const std::string& s, border) {
BOOST_FOREACH(const std::string& s, border) {
if (s == "all") {
return tgrid::BORDER_ALL;
} else if (s == "top") {

View file

@ -17,7 +17,6 @@
#include "gui/auxiliary/window_builder/horizontal_listbox.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/listbox.hpp"
@ -29,6 +28,8 @@
#endif
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -53,12 +54,12 @@ tbuilder_horizontal_listbox::tbuilder_horizontal_listbox(const config& cfg)
const config &data = cfg.child("list_data");
if (!data) return;
foreach(const config &row, data.child_range("row")) {
BOOST_FOREACH(const config &row, data.child_range("row")) {
unsigned col = 0;
foreach(const config &c, row.child_range("column")) {
BOOST_FOREACH(const config &c, row.child_range("column")) {
list_data.push_back(string_map());
foreach (const config::attribute &i, c.attribute_range()) {
BOOST_FOREACH(const config::attribute &i, c.attribute_range()) {
list_data.back()[i.first] = i.second;
}
++col;

View file

@ -17,7 +17,6 @@
#include "gui/auxiliary/window_builder/listbox.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/listbox.hpp"
@ -33,6 +32,8 @@
#include "gui/widgets/settings.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -69,12 +70,12 @@ tbuilder_listbox::tbuilder_listbox(const config& cfg)
return;
}
foreach(const config& row, data.child_range("row")) {
BOOST_FOREACH(const config& row, data.child_range("row")) {
unsigned col = 0;
foreach(const config& c, row.child_range("column")) {
BOOST_FOREACH(const config& c, row.child_range("column")) {
list_data.push_back(string_map());
foreach(const config::attribute& i, c.attribute_range()) {
BOOST_FOREACH(const config::attribute& i, c.attribute_range()) {
list_data.back()[i.first] = i.second;
}
++col;

View file

@ -18,13 +18,14 @@
#include "gui/auxiliary/window_builder/multi_page.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/multi_page.hpp"
#include "gui/widgets/multi_page.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -46,12 +47,12 @@ tbuilder_multi_page::tbuilder_multi_page(const config& cfg)
return;
}
foreach(const config &row, d.child_range("row")) {
BOOST_FOREACH(const config &row, d.child_range("row")) {
unsigned col = 0;
foreach(const config &column, row.child_range("column")) {
BOOST_FOREACH(const config &column, row.child_range("column")) {
data.push_back(string_map());
foreach(const config::attribute &i, column.attribute_range()) {
BOOST_FOREACH(const config::attribute &i, column.attribute_range()) {
data.back()[i.first] = i.second;
}
++col;

View file

@ -18,12 +18,13 @@
#include "gui/auxiliary/window_builder/slider.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/widgets/slider.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -44,7 +45,7 @@ tbuilder_slider::tbuilder_slider(const config& cfg)
return;
}
foreach(const config& label, labels.child_range("value")) {
BOOST_FOREACH(const config& label, labels.child_range("value")) {
value_labels_.push_back(label["label"]);
}
}

View file

@ -18,13 +18,14 @@
#include "gui/auxiliary/window_builder/stacked_widget.hpp"
#include "config.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/stacked_widget.hpp"
#include "gui/widgets/stacked_widget.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -35,7 +36,7 @@ tbuilder_stacked_widget::tbuilder_stacked_widget(const config& cfg)
{
const config &s = cfg.child("stack");
VALIDATE(s, _("No stack defined."));
foreach(const config &layer, s.child_range("layer")) {
BOOST_FOREACH(const config &layer, s.child_range("layer")) {
stack.push_back(new tbuilder_grid(layer));
}
}

View file

@ -17,7 +17,6 @@
#include "gui/auxiliary/window_builder/tree_view.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/log.hpp"
#include "gui/auxiliary/widget_definition/tree_view.hpp"
@ -25,6 +24,8 @@
#include "gui/widgets/tree_view.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
namespace implementation {
@ -39,7 +40,7 @@ tbuilder_tree_view::tbuilder_tree_view(const config& cfg)
, nodes()
{
foreach(const config &node, cfg.child_range("node")) {
BOOST_FOREACH(const config &node, cfg.child_range("node")) {
nodes.push_back(tnode(node));
}

View file

@ -17,16 +17,17 @@
#include "gui/dialogs/addon/description.hpp"
#include "foreach.hpp"
#include "formula_string_utils.hpp"
#include "gettext.hpp"
#include "gui/widgets/settings.hpp"
#include "language.hpp"
#include <boost/foreach.hpp>
namespace {
std::string langcode_to_string(const std::string& lcode)
{
foreach(const language_def& ld, get_languages()) {
BOOST_FOREACH(const language_def& ld, get_languages()) {
if(ld.localename == lcode || ld.localename.substr(0, 2) == lcode) {
return ld.language;
}
@ -177,7 +178,7 @@ taddon_description::taddon_description(const addon_info& addon, const addon_trac
std::string languages;
foreach(const std::string& lc, addon.locales) {
BOOST_FOREACH(const std::string& lc, addon.locales) {
const std::string& langlabel = langcode_to_string(lc);
if(!langlabel.empty()) {
if(!languages.empty()) {

View file

@ -16,7 +16,6 @@
#include "gui/dialogs/addon/uninstall_list.hpp"
#include "addon/info.hpp"
#include "foreach.hpp"
#include "gui/widgets/grid.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
@ -27,6 +26,8 @@
#include "gui/widgets/toggle_button.hpp"
#include "gui/widgets/window.hpp"
#include <boost/foreach.hpp>
#include <algorithm>
namespace gui2 {
@ -63,7 +64,7 @@ void taddon_uninstall_list::pre_show(CVideo& /*video*/, twindow& window)
this->names_.clear();
this->selections_.clear();
foreach(const std::string& id, this->ids_) {
BOOST_FOREACH(const std::string& id, this->ids_) {
this->names_.push_back(make_addon_title(id));
this->selections_[id] = false;
@ -100,7 +101,7 @@ std::vector<std::string> taddon_uninstall_list::selected_addons() const
std::vector<std::string> retv;
typedef std::map<std::string, bool> selections_map_type;
foreach(const selections_map_type::value_type& entry, this->selections_) {
BOOST_FOREACH(const selections_map_type::value_type& entry, this->selections_) {
if(entry.second) {
retv.push_back(entry.first);
}

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/addon_list.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/auxiliary/filter.hpp"
#include "gui/widgets/button.hpp"
@ -34,6 +33,7 @@
#include "serialization/string_utils.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -189,7 +189,7 @@ void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
* @todo do we really want to keep the length limit for the various
* items?
*/
foreach(const config &c, cfg_.child_range("campaign")) {
BOOST_FOREACH(const config &c, cfg_.child_range("campaign")) {
std::map<std::string, string_map> data;
string_map item;

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/campaign_difficulty.hpp"
#include "foreach.hpp"
#include "gui/auxiliary/old_markup.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
@ -27,6 +26,8 @@
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
/*WIKI
@ -69,7 +70,7 @@ tcampaign_difficulty::tcampaign_difficulty(
, items_()
, default_difficulty_(default_difficulty)
{
foreach(const std::string& it, items) {
BOOST_FOREACH(const std::string& it, items) {
items_.push_back(tlegacy_menu_item(it));
}
}
@ -81,7 +82,7 @@ void tcampaign_difficulty::pre_show(CVideo& /*video*/, twindow& window)
std::map<std::string, string_map> data;
foreach(const tlegacy_menu_item& item, items_) {
BOOST_FOREACH(const tlegacy_menu_item& item, items_) {
if(item.is_default()) {
index_ = list.get_item_count();
}

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/campaign_selection.hpp"
#include "foreach.hpp"
#include "gui/dialogs/helper.hpp"
#include "gui/widgets/image.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
@ -34,6 +33,7 @@
#include "serialization/string_utils.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -140,7 +140,7 @@ void tcampaign_selection::pre_show(CVideo& /*video*/, twindow& window)
&window, "campaign_details", false);
unsigned id = 0;
foreach(const config &campaign, campaigns_) {
BOOST_FOREACH(const config &campaign, campaigns_) {
/*** Add tree item ***/
tree_group_field["label"] = campaign["icon"];
@ -206,7 +206,7 @@ void tcampaign_selection::pre_show(CVideo& /*video*/, twindow& window)
tmulti_page& multi_page = find_widget<tmulti_page>(
&window, "campaign_details", false);
foreach (const config &c, campaigns_) {
BOOST_FOREACH(const config &c, campaigns_) {
/*** Add list item ***/
string_map list_item;

View file

@ -28,7 +28,6 @@
#include "gui/widgets/window.hpp"
#include "gui/widgets/slider.hpp"
#include "../../foreach.hpp"
#include "../../gamestatus.hpp"
#include "../../log.hpp"
#include "../../resources.hpp"
@ -38,6 +37,7 @@
#include <vector>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/foreach.hpp>
static lg::log_domain log_chat_log("chat_log");
#define DBG_CHAT_LOG LOG_STREAM(debug, log_chat_log)
@ -119,7 +119,7 @@ public:
std::stringstream str;
LOG_CHAT_LOG << "entering tchat_log::model::add_row_to_chat_message_list\n";
if (first<last) {
foreach (const chat_msg &t, make_pair(chat_log_history.begin()+first,chat_log_history.begin()+last))
BOOST_FOREACH(const chat_msg &t, make_pair(chat_log_history.begin()+first,chat_log_history.begin()+last))
{
std::string prefix("/me");
bool me = false;

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/data_manage.hpp"
#include "foreach.hpp"
#include "formula_string_utils.hpp"
#include "game_config.hpp"
#include "game_preferences.hpp"
@ -43,6 +42,7 @@
#include <cctype>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -101,7 +101,7 @@ void tdata_manage::fill_game_list(twindow& window
tlistbox& list = find_widget<tlistbox>(&window, "persist_list", false);
list.clear();
foreach(const savegame::save_info game, games) {
BOOST_FOREACH(const savegame::save_info game, games) {
std::map<std::string, string_map> data;
string_map item;
@ -142,7 +142,7 @@ bool tdata_manage::filter_text_changed(ttext_* textbox, const std::string& text)
find_widget<tlabel>(*it, "filename", false);
bool found = false;
foreach (const std::string& word, words){
BOOST_FOREACH(const std::string& word, words){
found = std::search(filename_label.label().str().begin()
, filename_label.label().str().end()
, word.begin(), word.end()

View file

@ -25,6 +25,7 @@
#include "gui/widgets/progress_bar.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <ctime>
@ -156,7 +157,7 @@ void tdebug_clock::update_time(const bool force)
}
if(clock_) {
foreach(tcanvas& canvas, clock_->canvas()) {
BOOST_FOREACH(tcanvas& canvas, clock_->canvas()) {
canvas.set_variable("hour", variant(hour_stamp));
canvas.set_variable("minute", variant(minute_stamp));
canvas.set_variable("second", variant(second_stamp));

View file

@ -17,16 +17,17 @@
#include "gui/dialogs/dialog.hpp"
#include "foreach.hpp"
#include "gui/dialogs/field.hpp"
#include "gui/widgets/integer_selector.hpp"
#include "video.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
tdialog::~tdialog()
{
foreach(tfield_* field, fields_) {
BOOST_FOREACH(tfield_* field, fields_) {
delete field;
}
}
@ -193,7 +194,7 @@ twindow* tdialog::build_window(CVideo& video) const
void tdialog::init_fields(twindow& window)
{
foreach(tfield_* field, fields_) {
BOOST_FOREACH(tfield_* field, fields_) {
field->attach_to_window(window);
field->widget_init(window);
}
@ -207,7 +208,7 @@ void tdialog::init_fields(twindow& window)
void tdialog::finalize_fields(twindow& window, const bool save_fields)
{
foreach(tfield_* field, fields_) {
BOOST_FOREACH(tfield_* field, fields_) {
if(save_fields) {
field->widget_finalize(window);
}

View file

@ -17,7 +17,7 @@
#include "gui/dialogs/editor_set_starting_position.hpp"
#include "foreach.hpp"
#include <boost/foreach.hpp>
#include "formatter.hpp"
#include "formula_string_utils.hpp"
#include "gettext.hpp"

View file

@ -21,10 +21,10 @@
#include "gui/widgets/button.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "../../foreach.hpp"
#include "../../formula_debugger.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -73,7 +73,7 @@ void tformula_debugger::pre_show(CVideo& /*video*/, twindow& window)
std::stringstream stack_text;
std::string indent = " ";
int c = 0;
foreach (const game_logic::debug_info &i, fdb_.get_call_stack()) {
BOOST_FOREACH(const game_logic::debug_info &i, fdb_.get_call_stack()) {
for(int d = 0; d < c; ++d) {
stack_text << indent;
}
@ -92,7 +92,7 @@ void tformula_debugger::pre_show(CVideo& /*video*/, twindow& window)
&window, "execution", false, true);
std::stringstream execution_text;
foreach (const game_logic::debug_info &i, fdb_.get_execution_trace()) {
BOOST_FOREACH(const game_logic::debug_info &i, fdb_.get_execution_trace()) {
for(int d = 0; d < i.level(); ++d) {
execution_text << indent;
}

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/game_load.hpp"
#include "foreach.hpp"
#include "formula_string_utils.hpp"
#include "gettext.hpp"
#include "game_config.hpp"
@ -43,6 +42,7 @@
#include <cctype>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -153,7 +153,7 @@ void tgame_load::fill_game_list(twindow& window
tlistbox& list = find_widget<tlistbox>(&window, "savegame_list", false);
list.clear();
foreach(const savegame::save_info game, games) {
BOOST_FOREACH(const savegame::save_info game, games) {
std::map<std::string, string_map> data;
string_map item;
@ -195,7 +195,7 @@ bool tgame_load::filter_text_changed(ttext_* textbox, const std::string& text)
find_widget<tlabel>(*it, "filename", false);
bool found = false;
foreach (const std::string& word, words){
BOOST_FOREACH(const std::string& word, words){
found = std::search(filename_label.label().str().begin()
, filename_label.label().str().end()
, word.begin(), word.end()

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/game_save.hpp"
#include "foreach.hpp"
#include "gettext.hpp"
#include "gui/dialogs/field.hpp"
#include "gui/widgets/button.hpp"

View file

@ -27,7 +27,6 @@
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "../../foreach.hpp"
#include "../../gamestatus.hpp"
#include "../../resources.hpp"
#include "../../team.hpp"
@ -36,6 +35,7 @@
#include <vector>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/foreach.hpp>
namespace gui2 {
@ -189,11 +189,11 @@ public:
? resources::state_of_game->get_variables()
: config();
foreach( const config::attribute &a, vars.attribute_range()) {
BOOST_FOREACH( const config::attribute &a, vars.attribute_range()) {
model_.add_row_to_stuff_list(a.first,a.first);
}
foreach( const config::any_child &c, vars.all_children_range()) {
BOOST_FOREACH( const config::any_child &c, vars.all_children_range()) {
model_.add_row_to_stuff_list("["+c.key+"]","["+c.key+"]");
}
@ -214,7 +214,7 @@ public:
? resources::state_of_game->get_variables()
: config();
foreach( const config::attribute &a, vars.attribute_range()) {
BOOST_FOREACH( const config::attribute &a, vars.attribute_range()) {
if (selected==i) {
model_.set_inspect_window_text(a.second);
return;
@ -222,7 +222,7 @@ public:
i++;
}
foreach( const config::any_child &c, vars.all_children_range()) {
BOOST_FOREACH( const config::any_child &c, vars.all_children_range()) {
if (selected==i) {
model_.set_inspect_window_text(c.cfg.debug());
return;
@ -268,7 +268,7 @@ public:
<< '/' << i->max_experience() << " xp; "
<< i->hitpoints() << '/' << i->max_hitpoints()
<< " hp; ";
foreach (const std::string &str, i->get_traits_list()) {
BOOST_FOREACH(const std::string &str, i->get_traits_list()) {
s << str <<" ";
}
@ -371,9 +371,9 @@ public:
: std::vector<unit>();
std::stringstream s;
foreach (const unit &u, recall_list) {
BOOST_FOREACH(const unit &u, recall_list) {
s << "id=["<<u.id() << "] "<<u.type_id() << "; L"<<u.level()<<"; " << u.experience() <<"/" << u.max_experience()<< " xp "<< std::endl;
foreach (const std::string &str, u.get_traits_list() ) {
BOOST_FOREACH(const std::string &str, u.get_traits_list() ) {
s << "\t" << str<< std::endl;
}
s << std::endl << std::endl;
@ -388,7 +388,7 @@ public:
: std::vector<unit>();
config c;
foreach (const unit &u, recall_list) {
BOOST_FOREACH(const unit &u, recall_list) {
config c_unit;
u.write(c_unit);
c.add_child("unit",c_unit);
@ -423,7 +423,7 @@ public:
<< i->max_experience() << " xp; "
<< i->hitpoints() << '/'
<< i->max_hitpoints()<<" hp.\n";
foreach (const std::string &str, i->get_traits_list() ) {
BOOST_FOREACH(const std::string &str, i->get_traits_list() ) {
s << "\t" << str<< std::endl;
}
s << std::endl << std::endl;
@ -457,7 +457,7 @@ public:
boost::shared_ptr<single_mode_controller>(new variable_mode_controller("variables",model_)));
sm_controllers_.push_back(
boost::shared_ptr<single_mode_controller>(new unit_mode_controller("units",model_)));
//foreach team
//BOOST_FOREACHteam
int sides = resources::teams
? static_cast<int>((*resources::teams).size())
: 0;
@ -481,7 +481,7 @@ public:
void show_stuff_types_list()
{
model_.clear_stuff_types_list();
foreach (boost::shared_ptr<single_mode_controller> sm_controller, sm_controllers_ ) {
BOOST_FOREACH(boost::shared_ptr<single_mode_controller> sm_controller, sm_controllers_ ) {
model_.add_row_to_stuff_types_list(sm_controller->name(),sm_controller->name());
}
}

View file

@ -17,7 +17,6 @@
#include "gui/dialogs/language_selection.hpp"
#include "foreach.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
@ -28,6 +27,8 @@
#include "language.hpp"
#include "preferences.hpp"
#include <boost/foreach.hpp>
namespace gui2 {
/*WIKI
@ -65,7 +66,7 @@ void tlanguage_selection::pre_show(CVideo& /*video*/, twindow& window)
const std::vector<language_def>& languages = get_languages();
const language_def& current_language = get_language();
foreach(const language_def& lang, languages) {
BOOST_FOREACH(const language_def& lang, languages) {
string_map item;
item.insert(std::make_pair("label", lang.language));

View file

@ -18,7 +18,6 @@
#include "config.hpp"
#include "game_preferences.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "formula_string_utils.hpp"
#include "gettext.hpp"
#include "network.hpp"
@ -27,6 +26,8 @@
#include "map_exception.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
#include <iterator>
static lg::log_domain log_config("config");
@ -89,7 +90,7 @@ void room_info::remove_member(const std::string& user)
void room_info::process_room_members(const config& data)
{
members_.clear();
foreach (const config& m, data.child_range("member")) {
BOOST_FOREACH(const config& m, data.child_range("member")) {
members_.insert(m["name"]);
}
}
@ -255,7 +256,7 @@ game_info::game_info(const config& game, const config& game_config)
if (const config& hashes = game_config.child("multiplayer_hashes")) {
std::string hash = game["hash"];
bool hash_found = false;
foreach (const config::attribute &i, hashes.attribute_range()) {
BOOST_FOREACH(const config::attribute &i, hashes.attribute_range()) {
if (i.first == game["mp_scenario"] && i.second == hash) {
hash_found = true;
break;
@ -358,7 +359,7 @@ game_filter_stack::game_filter_stack()
game_filter_stack::~game_filter_stack()
{
foreach (game_filter_base* f, filters_) {
BOOST_FOREACH(game_filter_base* f, filters_) {
delete f;
}
}
@ -370,7 +371,7 @@ void game_filter_stack::append(game_filter_base *f)
void game_filter_stack::clear()
{
foreach (game_filter_base* f, filters_) {
BOOST_FOREACH(game_filter_base* f, filters_) {
delete f;
}
filters_.clear();
@ -378,7 +379,7 @@ void game_filter_stack::clear()
bool game_filter_and_stack::match(const game_info &game) const
{
foreach (game_filter_base* f, filters_) {
BOOST_FOREACH(game_filter_base* f, filters_) {
if (!f->match(game)) return false;
}
return true;

View file

@ -18,7 +18,6 @@
#include "config.hpp"
#include "game_preferences.hpp"
#include "filesystem.hpp"
#include "foreach.hpp"
#include "formula_string_utils.hpp"
#include "gettext.hpp"
#include "network.hpp"
@ -27,6 +26,8 @@
#include "map_exception.hpp"
#include "wml_exception.hpp"
#include <boost/foreach.hpp>
#include <iterator>
static lg::log_domain log_config("config");
@ -66,7 +67,7 @@ lobby_info::~lobby_info()
void lobby_info::delete_games()
{
foreach (const game_info_map::value_type& v, games_by_id_) {
BOOST_FOREACH(const game_info_map::value_type& v, games_by_id_) {
delete v.second;
}
}
@ -76,7 +77,7 @@ namespace {
std::string dump_games_map(const lobby_info::game_info_map& games)
{
std::stringstream ss;
foreach (const lobby_info::game_info_map::value_type& v, games) {
BOOST_FOREACH(const lobby_info::game_info_map::value_type& v, games) {
const game_info& game = *v.second;
ss << "G" << game.id << "(" << game.name << ") " << game.display_status_string() << " ";
}
@ -87,7 +88,7 @@ std::string dump_games_map(const lobby_info::game_info_map& games)
std::string dump_games_config(const config& gamelist)
{
std::stringstream ss;
foreach (const config& c, gamelist.child_range("game")) {
BOOST_FOREACH(const config& c, gamelist.child_range("game")) {
ss << "g" << c["id"] << "(" << c["name"] << ") " << c[config::diff_track_attribute] << " ";
}
ss << "\n";
@ -103,7 +104,7 @@ void lobby_info::process_gamelist(const config &data)
gamelist_initialized_ = true;
delete_games();
games_by_id_.clear();
foreach (const config& c, gamelist_.child("gamelist").child_range("game")) {
BOOST_FOREACH(const config& c, gamelist_.child("gamelist").child_range("game")) {
game_info* game = new game_info(c, game_config_);
games_by_id_[game->id] = game;
}
@ -180,10 +181,10 @@ void lobby_info::process_userlist()
{
SCOPE_LB;
users_.clear();
foreach (const config& c, gamelist_.child_range("user")) {
BOOST_FOREACH(const config& c, gamelist_.child_range("user")) {
users_.push_back(user_info(c));
}
foreach (user_info& ui, users_) {
BOOST_FOREACH(user_info& ui, users_) {
if (ui.game_id != 0) {
game_info* g = get_game_by_id(ui.game_id);
if (g == NULL) {
@ -235,7 +236,7 @@ const game_info* lobby_info::get_game_by_id(int id) const
room_info* lobby_info::get_room(const std::string &name)
{
foreach (room_info& r, rooms_) {
BOOST_FOREACH(room_info& r, rooms_) {
if (r.name() == name) return &r;
}
return NULL;
@ -243,7 +244,7 @@ room_info* lobby_info::get_room(const std::string &name)
const room_info* lobby_info::get_room(const std::string &name) const
{
foreach (const room_info& r, rooms_) {
BOOST_FOREACH(const room_info& r, rooms_) {
if (r.name() == name) return &r;
}
return NULL;
@ -301,7 +302,7 @@ void lobby_info::make_games_vector()
games_filtered_.clear();
games_visibility_.clear();
games_.clear();
foreach (const game_info_map::value_type& v, games_by_id_) {
BOOST_FOREACH(const game_info_map::value_type& v, games_by_id_) {
games_.push_back(v.second);
}
}
@ -310,7 +311,7 @@ void lobby_info::apply_game_filter()
{
games_filtered_.clear();
games_visibility_.clear();
foreach (game_info* g, games_) {
BOOST_FOREACH(game_info* g, games_) {
game_info& gi = *g;
bool show = game_filter_.match(gi);
if (game_filter_invert_) {
@ -325,7 +326,7 @@ void lobby_info::apply_game_filter()
void lobby_info::update_user_statuses(int game_id, const room_info *room)
{
foreach (user_info& user, users_) {
BOOST_FOREACH(user_info& user, users_) {
user.update_state(game_id, room);
}
}
@ -365,7 +366,7 @@ struct user_sorter_relation_name
void lobby_info::sort_users(bool by_name, bool by_relation)
{
users_sorted_.clear();
foreach (user_info& u, users_) {
BOOST_FOREACH(user_info& u, users_) {
users_sorted_.push_back(&u);
}
if (by_name) {

Some files were not shown because too many files have changed in this diff Show more