mail[Wesnoth-commits] r20112 - in /trunk/src: race.cpp race.hpp unit.cpp unit.hpp unit_types.cpp


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

Header


Content

Posted by alinktomine on September 05, 2007 - 06:01:
Author: alink
Date: Wed Sep  5 06:00:36 2007
New Revision: 20112

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20112&view=rev
Log:
Give an "id" key to [race] (which also still have the "name" key)
The data is not yet adapted, and currently used as test-case to the 
transition 
system which create an id from name if id is missing
The help also still use id and not name (but they are currently identical)

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

Modified: trunk/src/race.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/race.cpp?rev=20112&r1=20111&r2=20112&view=diff
==============================================================================
--- trunk/src/race.cpp (original)
+++ trunk/src/race.cpp Wed Sep  5 06:00:36 2007
@@ -96,7 +96,7 @@
 
        // Getting here means that the maximum length was reached when
        // generating the name, hence the ending of the name has to be
-       // made valid. Otherwise weird names like Unárierinil- and
+       // made valid. Otherwise weird names like Un�rierinil- and
        // Thramboril-G may occur.
 
        // Strip characters from the end until the last prefix of the
@@ -136,6 +136,12 @@
 unit_race::unit_race(const config& cfg) : name_(cfg["name"]), 
ntraits_(atoi(cfg["num_traits"].c_str())),
                                                                              
    traits_(&cfg.get_children("trait")), 
global_traits_(!utils::string_bool(cfg["ignore_global_traits"]))
 {
+       id_ = cfg["id"];
+       if(id_.empty()) {
+               // This code is only for compatibility with old race defs.
+               id_ = (cfg["name"]);
+       }
+       
        names_[MALE] = utils::split(cfg["male_names"]);
        names_[FEMALE] = utils::split(cfg["female_names"]);
 

Modified: trunk/src/race.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/race.hpp?rev=20112&r1=20111&r2=20112&view=diff
==============================================================================
--- trunk/src/race.hpp (original)
+++ trunk/src/race.hpp Wed Sep  5 06:00:36 2007
@@ -32,6 +32,7 @@
        unit_race();
        unit_race(const config& cfg);
 
+       const std::string& id() const {return id_;};
        const t_string& name() const;
 
        std::string generate_name(GENDER gender) const;
@@ -42,6 +43,7 @@
        unsigned int num_traits() const;
 
 private:
+       std::string id_;
        t_string name_;
        unsigned int ntraits_;
        std::vector<std::string> names_[NUM_GENDERS];

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=20112&r1=20111&r2=20112&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Wed Sep  5 06:00:36 2007
@@ -909,7 +909,7 @@
                }
        }
 
-       if(race.empty() == false && race_->name() != race) {
+       if(race.empty() == false && race_->id() != race) {
                return false;
        }
 
@@ -1561,7 +1561,7 @@
 
        cfg["advances_to"] = utils::join(advances_to_);
 
-       cfg["race"] = race_->name();
+       cfg["race"] = race_->id();
        cfg["name"] = name_;
        cfg["language_name"] = language_name_;
        cfg["undead_variation"] = undead_variation_;

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=20112&r1=20111&r2=20112&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Wed Sep  5 06:00:36 2007
@@ -262,7 +262,7 @@
 
        const std::string& usage() const { return cfg_["usage"]; }
        unit_type::ALIGNMENT alignment() const { return alignment_; }
-       const std::string& race() const { return race_->name(); }
+       const std::string& race() const { return race_->id(); }
 
        const unit_animation* choose_animation(const game_display& disp, 
const gamemap::location& loc,const std::string& event,const int 
damage=0,const unit_animation::hit_type hit_type = 
unit_animation::INVALID,const attack_type* attack=NULL,const attack_type* 
second_attack = NULL, int swing_num =0) const;
 

Modified: trunk/src/unit_types.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.cpp?rev=20112&r1=20111&r2=20112&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Wed Sep  5 06:00:36 2007
@@ -1007,7 +1007,7 @@
                return empty_string;
        }
 
-       return race_->name();
+       return race_->id();
 }
 
 // Allow storing "advances from" info for convenience in Help.
@@ -1077,7 +1077,7 @@
        for(i = cfg.child_range("race"); i.first != i.second; ++i.first)
        {
                const unit_race race(**i.first);
-               
races.insert(std::pair<std::string,unit_race>(race.name(),race));
+               
races.insert(std::pair<std::string,unit_race>(race.id(),race));
                increment_set_config_progress();
        }
 




Related Messages


Powered by MHonArc, Updated Wed Sep 05 08:00:56 2007