mail[Wesnoth-commits] r33884 - in /trunk/src: map.cpp terrain.cpp terrain.hpp


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:07:
Author: silene
Date: Fri Mar 20 08:07:20 2009
New Revision: 33884

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33884&view=rev
Log:
Removed config::child_list from map.cpp.

Modified:
    trunk/src/map.cpp
    trunk/src/terrain.cpp
    trunk/src/terrain.hpp

Modified: trunk/src/map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/map.cpp?rev=33884&r1=33883&r2=33884&view=diff
==============================================================================
--- trunk/src/map.cpp (original)
+++ trunk/src/map.cpp Fri Mar 20 08:07:20 2009
@@ -119,8 +119,8 @@
                usage_(IS_MAP)
 {
        DBG_G << "loading map: '" << data << "'\n";
-       const config::child_list& terrains = cfg.get_children("terrain");
-       create_terrain_maps(terrains,terrainList_,tcodeToTerrain_);
+       const config::const_child_itors &terrains = 
cfg.child_range("terrain");
+       create_terrain_maps(terrains, terrainList_, tcodeToTerrain_);
 
        read(data);
 }
@@ -272,7 +272,7 @@
 
 void gamemap::overlay(const gamemap& m, const config& rules_cfg, int xpos, 
int ypos, bool border)
 {
-       const config::child_list& rules = rules_cfg.get_children("rule");
+       const config::const_child_itors &rules = 
rules_cfg.child_range("rule");
        int actual_border = (m.border_size() == border_size()) && border ? 
border_size() : 0;
 
        const int xstart = std::max<int>(-actual_border, -xpos - 
actual_border);
@@ -293,11 +293,12 @@
                        }
 
                        // See if there is a matching rule
-                       config::child_list::const_iterator rule = 
rules.begin();
-                       for( ; rule != rules.end(); ++rule) {
+                       config::const_child_iterator rule = rules.first;
+                       for( ; rule != rules.second; ++rule)
+                       {
                                static const std::string src_key = "old", 
src_not_key = "old_not",
                                                         dst_key = "new", 
dst_not_key = "new_not";
-                               const config& cfg = **rule;
+                               const config &cfg = *rule;
                                const t_translation::t_list& src = 
t_translation::read_list(cfg[src_key]);
 
                                if(!src.empty() && 
t_translation::terrain_matches(current, src) == false) {
@@ -326,8 +327,9 @@
                        }
 
 
-                       if(rule != rules.end()) {
-                               const config& cfg = **rule;
+                       if (rule != rules.second)
+                       {
+                               const config &cfg = *rule;
                                const t_translation::t_list& terrain = 
t_translation::read_list(cfg["terrain"]);
 
                                tmerge_mode mode = BOTH;

Modified: trunk/src/terrain.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/terrain.cpp?rev=33884&r1=33883&r2=33884&view=diff
==============================================================================
--- trunk/src/terrain.cpp (original)
+++ trunk/src/terrain.cpp Fri Mar 20 08:07:20 2009
@@ -14,7 +14,7 @@
 
 #include "global.hpp"
 
-#include "config.hpp"
+#include "foreach.hpp"
 #include "gettext.hpp"
 #include "terrain.hpp"
 
@@ -226,16 +226,15 @@
        return number_;
 }
 
-void create_terrain_maps(const std::vector<config*>& cfgs,
+void create_terrain_maps(const config::const_child_itors &cfgs,
                          t_translation::t_list& terrain_list,
                          std::map<t_translation::t_terrain, terrain_type>& 
letter_to_terrain)
 {
-       for(std::vector<config*>::const_iterator i = cfgs.begin();
-           i != cfgs.end(); ++i) {
-               terrain_type terrain(**i);
+       foreach (const config &t, cfgs)
+       {
+               terrain_type terrain(t);
                terrain_list.push_back(terrain.number());
-               letter_to_terrain.insert(std::pair<t_translation::t_terrain, 
terrain_type>(
-                                             terrain.number(),terrain));
+               letter_to_terrain.insert(std::make_pair(terrain.number(), 
terrain));
        }
 }
 

Modified: trunk/src/terrain.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/terrain.hpp?rev=33884&r1=33883&r2=33884&view=diff
==============================================================================
--- trunk/src/terrain.hpp (original)
+++ trunk/src/terrain.hpp Fri Mar 20 08:07:20 2009
@@ -14,13 +14,12 @@
 #ifndef TERRAIN_H_INCLUDED
 #define TERRAIN_H_INCLUDED
 
-class config;
+#include "config.hpp"
 #include "tstring.hpp"
 #include "terrain_translation.hpp"
 
 #include <map>
 #include <string>
-#include <vector>
 
 class terrain_type
 {
@@ -115,7 +114,7 @@
        bool hide_in_editor_;
 };
 
-void create_terrain_maps(const std::vector<config*>& cfgs,
+void create_terrain_maps(const config::const_child_itors &cfgs,
                          t_translation::t_list& terrain_list,
                          std::map<t_translation::t_terrain, terrain_type>& 
letter_to_terrain);
 




Related Messages


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