mail[Wesnoth-commits] r33874 - /trunk/src/unit_types.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on March 20, 2009 - 08:06:
Author: silene
Date: Fri Mar 20 08:06:47 2009
New Revision: 33874

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33874&view=rev
Log:
Partly removed config::get_children.

Modified:
    trunk/src/unit_types.cpp

Modified: trunk/src/unit_types.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.cpp?rev=33874&r1=33873&r2=33874&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Fri Mar 20 08:06:47 2009
@@ -698,18 +698,17 @@
        {
                possibleTraits_.add_child("trait", **i);
        }
-       const config::child_list& variations = cfg.get_children("variation");
-       for(config::child_list::const_iterator var = variations.begin(); var 
!= variations.end(); ++var) {
-               const config& var_cfg = **var;
+       foreach (const config &var_cfg, cfg.child_range("variation"))
+       {
                if(utils::string_bool(var_cfg["inherit"])) {
                        config nvar_cfg(cfg);
                        nvar_cfg.merge_with(var_cfg);
                        nvar_cfg.clear_children("variation");
-                       
variations_.insert(std::pair<std::string,unit_type*>(nvar_cfg["variation_name"],
-                                                                             
                   new unit_type(nvar_cfg,mv_types,races,traits)));
+                       
variations_.insert(std::make_pair(nvar_cfg["variation_name"],
+                               new unit_type(nvar_cfg, mv_types, races, 
traits)));
                } else {
-                       
variations_.insert(std::pair<std::string,unit_type*>((**var)["variation_name"],
-                                                                             
                   new unit_type(**var,mv_types,races,traits)));
+                       
variations_.insert(std::make_pair(var_cfg["variation_name"],
+                               new unit_type(var_cfg, mv_types, races, 
traits)));
                }
        }
 
@@ -749,10 +748,9 @@
        }
 
        // Insert any traits that are just for this unit type
-       const config::child_list& unit_traits = cfg.get_children("trait");
-       for(i=unit_traits.begin(); i != unit_traits.end(); ++i)
+       foreach (const config &trait, cfg.child_range("trait"))
        {
-               possibleTraits_.add_child("trait", **i);
+               possibleTraits_.add_child("trait", trait);
        }
 
        zoc_ = utils::string_bool(cfg["zoc"], level_ > 0);
@@ -1024,11 +1022,11 @@
 bool unit_type::has_ability(const std::string& ability) const
 {
        const config* abil = cfg_.child("abilities");
-       if(abil) {
-               return (abil->get_children(ability).size() > 0);
-       }
-       return false;
-}
+       if (!abil) return false;
+       config::const_child_itors a = abil->child_range(ability);
+       return a.first != a.second;
+}
+
 bool unit_type::has_ability_by_id(const std::string& ability) const
 {
        const config* abil = cfg_.child("abilities");




Related Messages


Powered by MHonArc, Updated Fri Mar 20 08:20:31 2009