From 127b8ba0987362688c69b1e101cec3fcc40834b7 Mon Sep 17 00:00:00 2001 From: "J. Tyne" Date: Sun, 26 Aug 2012 02:01:26 +0000 Subject: [PATCH] Tweak some typedefs to make unit_abilities::effect easier to work with. --- src/actions/heal.cpp | 4 ++-- src/attack_prediction_display.cpp | 2 +- src/unit_abilities.hpp | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/actions/heal.cpp b/src/actions/heal.cpp index dede5a25c18..0c5adeccf00 100644 --- a/src/actions/heal.cpp +++ b/src/actions/heal.cpp @@ -128,8 +128,8 @@ void calculate_healing(int side, bool update_display) unit_abilities::effect heal_effect(heal,0,false); healing = heal_effect.get_composite_value(); - for(std::vector::const_iterator heal_loc = heal_effect.begin(); heal_loc != heal_effect.end(); ++heal_loc) { - healers.push_back(&*units.find(heal_loc->loc)); + BOOST_FOREACH (const unit_abilities::individual_effect &heal_loc, heal_effect ) { + healers.push_back(&*units.find(heal_loc.loc)); } if (!healers.empty()) { diff --git a/src/attack_prediction_display.cpp b/src/attack_prediction_display.cpp index 7ee04f33f92..21f324783d5 100644 --- a/src/attack_prediction_display.cpp +++ b/src/attack_prediction_display.cpp @@ -162,7 +162,7 @@ void battle_prediction_pane::get_unit_strings(const battle_context_unit_stats& s // Get the SET damage modifier, if any. const unit_abilities::individual_effect *set_dmg_effect = NULL; - unit_abilities::effect_list::const_iterator i; + unit_abilities::effect::const_iterator i; for(i = dmg_effect.begin(); i != dmg_effect.end(); ++i) { if(i->type == unit_abilities::SET) { set_dmg_effect = &*i; diff --git a/src/unit_abilities.hpp b/src/unit_abilities.hpp index 8506a7258fb..f8b55571801 100644 --- a/src/unit_abilities.hpp +++ b/src/unit_abilities.hpp @@ -39,21 +39,23 @@ struct individual_effect map_location loc; }; -typedef std::vector effect_list; - class effect { public: effect(const unit_ability_list& list, int def, bool backstab); + // Provide read-only access to the effect list: + typedef std::vector::const_iterator iterator; + typedef std::vector::const_iterator const_iterator; + int get_composite_value() const { return composite_value_; } - effect_list::const_iterator begin() const + const_iterator begin() const { return effect_list_.begin(); } - effect_list::const_iterator end() const + const_iterator end() const { return effect_list_.end(); } private: - effect_list effect_list_; + std::vector effect_list_; int composite_value_; };