Author: anonymissimus
Date: Wed Oct 19 01:18:48 2011
New Revision: 51538

URL: http://svn.gna.org/viewcvs/wesnoth?rev=51538&view=rev
Log:
introduce a member variable in class unit holding filter_recall information

Simplifies code and is automatically kept upon unit advancement.

Modified:
    trunk/src/unit.cpp
    trunk/src/unit.hpp

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=51538&r1=51537&r2=51538&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Wed Oct 19 01:18:48 2011
@@ -149,6 +149,7 @@
            known_boolean_states_(o.known_boolean_states_),
            variables_(o.variables_),
            events_(o.events_),
+           filter_recall_(o.filter_recall_),
            emit_zoc_(o.emit_zoc_),
            state_(o.state_),
 
@@ -230,6 +231,7 @@
        known_boolean_states_(known_boolean_state_names_.size(),false),
        variables_(),
        events_(),
+       filter_recall_(),
        emit_zoc_(0),
        state_(STATE_STANDING),
        overlays_(),
@@ -281,11 +283,9 @@
        }
 
        if(vcfg) {
-               config cfilter_recall;
-               const vconfig& vfilter_recall = vcfg->child("filter_recall");
-               if(!vfilter_recall.null())
-                       cfilter_recall = vfilter_recall.get_config();
-               cfg_.add_child("filter_recall", cfilter_recall);
+               const vconfig& filter_recall = vcfg->child("filter_recall");
+               if(!filter_recall.null())
+                       filter_recall_ = filter_recall.get_config();
 
                const vconfig::child_list& events = vcfg->get_children("event");
                foreach(const vconfig& e, events) {
@@ -294,7 +294,7 @@
        }
        else
        {
-               cfg_.add_child("filter_recall", 
cfg.child_or_empty("filter_recall"));
+               filter_recall_ = cfg.child_or_empty("filter_recall");
 
                foreach(const config& unit_event, cfg.child_range("event")) {
                        events_.add_child("event", unit_event);
@@ -592,6 +592,7 @@
        known_boolean_states_(known_boolean_state_names_.size(),false),
        variables_(),
        events_(),
+       filter_recall_(),
        emit_zoc_(0),
        state_(STATE_STANDING),
        overlays_(),
@@ -801,9 +802,6 @@
                        new_cfg[attr] = *v;
                }
        }
-
-       //copy �nformation what this unit is able to recall
-       new_cfg.add_child("filter_recall", 
old_cfg.child_or_empty("filter_recall"));
 
        if(t->movement_type().get_parent()) {
                new_cfg.merge_with(t->movement_type().get_parent()->get_cfg());
@@ -1640,6 +1638,8 @@
        cfg.add_child("variables",variables_);
        cfg.clear_children("events");
        cfg.append(events_);
+       cfg.clear_children("filter_recall");
+       cfg.add_child("filter_recall", filter_recall_);
        cfg.clear_children("status");
        cfg.add_child("status",status_flags);
 

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=51538&r1=51537&r2=51538&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Wed Oct 19 01:18:48 2011
@@ -139,7 +139,7 @@
        const std::vector<std::string>& recruits() const
                { return recruit_list_; }
        void set_recruits(const std::vector<std::string>& recruits);
-       const config& recall_filter() const { return 
cfg_.child("filter_recall"); }
+       const config& recall_filter() const { return filter_recall_; }
 
        bool incapacitated() const { return get_state(STATE_PETRIFIED); }
        int total_movement() const { return max_movement_; }
@@ -417,6 +417,7 @@
        static std::map<std::string, state_t> known_boolean_state_names_;
        config variables_;
        config events_;
+       config filter_recall_;
        bool emit_zoc_;
        STATE state_;
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to