diff --git a/src/game_events.cpp b/src/game_events.cpp index 9323e541a6a..292e564e6fd 100644 --- a/src/game_events.cpp +++ b/src/game_events.cpp @@ -3691,13 +3691,13 @@ namespace game_events { return pump(); } - void add_events(const config::child_list& cfgs,const std::string& id) + void add_events(const config::const_child_itors &cfgs, const std::string &id) { if(std::find(unit_wml_ids.begin(),unit_wml_ids.end(),id) == unit_wml_ids.end()) { unit_wml_ids.insert(id); - for(config::child_list::const_iterator new_ev = cfgs.begin(); new_ev != cfgs.end(); ++ new_ev) { + foreach (const config &new_ev, cfgs) { std::vector &temp = (pump_manager::count()) ? new_handlers : event_handlers; - temp.push_back(game_events::event_handler(vconfig(*new_ev, true))); + temp.push_back(game_events::event_handler(vconfig(&new_ev, true))); } } } diff --git a/src/game_events.hpp b/src/game_events.hpp index e2dd335946d..74d1265f4ba 100644 --- a/src/game_events.hpp +++ b/src/game_events.hpp @@ -279,7 +279,7 @@ namespace game_events game_state* get_state_of_game(); void write_events(config& cfg); - void add_events(const config::child_list& cfgs,const std::string& id); + void add_events(const config::const_child_itors &cfgs,const std::string& id); bool unit_matches_filter(unit_map::const_iterator itor, const vconfig filter); diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 60b6a8e6582..45dd62a35d4 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -184,7 +184,7 @@ void play_controller::init(CVideo& video){ // add era events for MP game const config* era_cfg = level_.child("era"); if (era_cfg != NULL) { - game_events::add_events(era_cfg->get_children("event"),"era_events"); + game_events::add_events(era_cfg->child_range("event"), "era_events"); } diff --git a/src/unit.cpp b/src/unit.cpp index 20ecd7547d1..4fbcbe1713e 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -578,7 +578,7 @@ void unit::set_game_context(unit_map* unitmap, const gamemap* map, const gamesta gamestatus_ = game_status; // In case the unit carries EventWML, apply it now - game_events::add_events(cfg_.get_children("event"),type_); + game_events::add_events(cfg_.child_range("event"), type_); } // Apply mandatory traits (e.g. undead, mechanical) to a unit and then @@ -763,7 +763,7 @@ void unit::advance_to(const unit_type* t, bool use_traits, game_state* state) heal_all(); } - game_events::add_events(cfg_.get_children("event"),type_); + game_events::add_events(cfg_.child_range("event"), type_); set_state("poisoned",""); set_state("slowed",""); @@ -1562,7 +1562,7 @@ void unit::read(const config& cfg, bool use_traits, game_state* state) cfg_["generate_name"] = ""; } - game_events::add_events(cfg_.get_children("event"),type_); + game_events::add_events(cfg_.child_range("event"), type_); // Make the default upkeep "full" if(cfg_["upkeep"].empty()) { cfg_["upkeep"] = "full";