mail[Wesnoth-commits] r24584 - in /trunk/src: actions.cpp ai.cpp ai_dfool.cpp ai_python.cpp game_events.cpp unit.cpp unit.hpp


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

Header


Content

Posted by esr on March 12, 2008 - 21:07:
Author: esr
Date: Wed Mar 12 21:07:36 2008
New Revision: 24584

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24584&view=rev
Log:
unit::underlying_description_ -> unit::underlying_id_

Modified:
    trunk/src/actions.cpp
    trunk/src/ai.cpp
    trunk/src/ai_dfool.cpp
    trunk/src/ai_python.cpp
    trunk/src/game_events.cpp
    trunk/src/unit.cpp
    trunk/src/unit.hpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Wed Mar 12 21:07:36 2008
@@ -866,8 +866,8 @@
                return;
        }
 
-       a_id_ = a_->second.underlying_description();
-       d_id_ = d_->second.underlying_description();
+       a_id_ = a_->second.underlying_id();
+       d_id_ = d_->second.underlying_id();
 
        // no attack weapon => stop here and don't attack
        if (attack_with < 0) {

Modified: trunk/src/ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/ai.cpp (original)
+++ trunk/src/ai.cpp Wed Mar 12 21:07:36 2008
@@ -462,7 +462,7 @@
 
                        while(steps.empty() == false && 
(!(info_.units.find(to) == info_.units.end() || from == to))){
                                    LOG_AI << "AI attempting illegal move. 
Attempting to move onto existing unit\n";
-                                   LOG_AI << "\t" << 
info_.units.find(to)->second.underlying_description() <<" already on " << to 
<< "\n";
+                                   LOG_AI << "\t" << 
info_.units.find(to)->second.underlying_id() <<" already on " << to << "\n";
                                    LOG_AI <<"\tremoving 
"<<*(steps.end()-1)<<"\n";
                                    to = *(steps.end()-1);
                                    steps.pop_back();

Modified: trunk/src/ai_dfool.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai_dfool.cpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/ai_dfool.cpp (original)
+++ trunk/src/ai_dfool.cpp Wed Mar 12 21:07:36 2008
@@ -43,7 +43,7 @@
 
     //    for(unit_map::iterator ua = get_info().units.begin(); ua != 
get_info().units.end(); ++ua) {
     //        std::string t = ua->second.get_ai_special();
-    //        LOG_STREAM(info, 
ai)<<"ua:"<<ua->second.underlying_description()<<"\t"<<t<<std::endl;
+    //        LOG_STREAM(info, 
ai)<<"ua:"<<ua->second.underlying_id()<<"\t"<<t<<std::endl;
     //        LOG_STREAM(info, 
ai)<<"\t\t\t"<<ua->first.x<<","<<ua->first.y<<std::endl;
     //    }
 
@@ -57,7 +57,7 @@
     //      unit_map::iterator u = unit(*ui,get_info().units);
     //      if(u!=get_info().units.end()){
     // LOG_STREAM(info, ai)<<"\t"<<u->second.name()<<std::endl;
-    // LOG_STREAM(info, 
ai)<<"\t\t"<<u->second.underlying_description()<<std::endl;
+    // LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_id()<<std::endl;
     // LOG_STREAM(info, ai)<<"\t\t\t"<<u->second.get_ai_special()<<std::endl;
     // LOG_STREAM(info, 
ai)<<"\t\t\t"<<u->first.x<<","<<u->first.y<<std::endl;
     //      }
@@ -68,7 +68,7 @@
       unit_map::iterator u = unit(*ui,get_info().units);
       if(u!=get_info().units.end()){
        //      LOG_STREAM(info, ai)<<"\t"<<u->second.name()<<std::endl;
-       LOG_STREAM(info, 
ai)<<"\t\t"<<u->second.underlying_description()<<std::endl;
+       LOG_STREAM(info, ai)<<"\t\t"<<u->second.underlying_id()<<std::endl;
        //      LOG_STREAM(info, 
ai)<<"\t\t\t"<<u->second.get_ai_special()<<std::endl;
        //      LOG_STREAM(info, 
ai)<<"\t\t\t"<<u->first.x<<","<<u->first.y<<std::endl;
 
@@ -105,16 +105,16 @@
              if(ui!=get_info().units.end()){
                std::string ais=ui->second.get_ai_special();
 
-               //              LOG_STREAM(info, ai)<<"\t match: 
"<<ui->second.underlying_description()<<"\t"<<ais<<":::"<<std::endl;
+               //              LOG_STREAM(info, ai)<<"\t match: 
"<<ui->second.underlying_id()<<"\t"<<ais<<":::"<<std::endl;
 
                bool used=(ais.size() > 0);
                if(used){
-                 //              LOG_STREAM(info, ai)<<"\t\talready 
assigned: "<<ui->second.underlying_description()<<"\t"<<ais<<std::endl;
+                 //              LOG_STREAM(info, ai)<<"\t\talready 
assigned: "<<ui->second.underlying_id()<<"\t"<<ais<<std::endl;
                }else{
                  ui->second.assign_ai_special(order_id);
                  order_units.push_back(*i);
 
-                 //              LOG_STREAM(info, ai)<<"\t\tmatching: 
"<<ui->second.underlying_description()<<" to order: 
"<<order_id<<"\t"<<ui->second.get_ai_special()<<std::endl;
+                 //              LOG_STREAM(info, ai)<<"\t\tmatching: 
"<<ui->second.underlying_id()<<" to order: 
"<<order_id<<"\t"<<ui->second.get_ai_special()<<std::endl;
                }
              }
             }
@@ -163,10 +163,10 @@
            if(type=="set_order"){
              std::string set_id=(**com)["id"];
              std::string a=(u->second.get_ai_special());
-             LOG_STREAM(info, 
ai)<<"\t\t"<<u->second.underlying_description()<<"\t"<<a<<"->"<<set_id<<std::endl;
+             LOG_STREAM(info, 
ai)<<"\t\t"<<u->second.underlying_id()<<"\t"<<a<<"->"<<set_id<<std::endl;
              (u->second.assign_ai_special(set_id));
              a=(u->second.get_ai_special());
-             LOG_STREAM(info, 
ai)<<"\t\t"<<u->second.underlying_description()<<"\t"<<a<<" =?= 
"<<set_id<<std::endl;
+             LOG_STREAM(info, 
ai)<<"\t\t"<<u->second.underlying_id()<<"\t"<<a<<" =?= "<<set_id<<std::endl;
            }
            if(type=="break"){
              com_break=true;
@@ -189,8 +189,8 @@
     for(unit_list::const_iterator i = ul.begin(); i != ul.end(); ++i) {
       //      LOG_STREAM(info, ai)<<"filter2:"<<std::endl;
       unit_map::iterator j = unit(*i,um);
-      //      LOG_STREAM(info, 
ai)<<"j:"<<j->second.underlying_description()<<":"<<j->first.x<<","<<j->first.y<<std::endl;
-      if(j->second.underlying_description().size()>0){
+      //      LOG_STREAM(info, 
ai)<<"j:"<<j->second.underlying_id()<<":"<<j->first.x<<","<<j->first.y<<std::endl;
+      if(j->second.underlying_id().size()>0){
        //      LOG_STREAM(info, ai)<<"filter3:"<<std::endl;
        if(j->second.matches_filter(&filter,j->first)) {
          //      LOG_STREAM(info, ai)<<"filter4:"<<std::endl;
@@ -212,7 +212,7 @@
       bool hidden_by_fog = current_team().fogged(i->first);
       bool hidden = i->second.invisible(i->first, um, get_info().teams);
       if((no_fog || !hidden_by_fog) && !hidden) {
-         visible_units.push_back(i->second.underlying_description());
+         visible_units.push_back(i->second.underlying_id());
       }
     }
 
@@ -224,8 +224,8 @@
     unit_list all;
     const unit_map& um=get_info().units;
     for(unit_map::const_iterator i = um.begin(); i != um.end(); ++i) {
-      //      LOG_STREAM(info, 
ai)<<"all:"<<i->second.underlying_description()<<std::endl;
-      all.push_back(i->second.underlying_description());
+      //      LOG_STREAM(info, 
ai)<<"all:"<<i->second.underlying_id()<<std::endl;
+      all.push_back(i->second.underlying_id());
     }
     return(all);
   }
@@ -243,7 +243,7 @@
 
        std::cout<<"known units:\n";
        for(unit_map::const_iterator uu = 
known_units.begin();uu!=known_units.end();uu++){
-         std::cout<<"\t"<<uu->second.underlying_description()<<" 
"<<uu->first<<"\n";
+         std::cout<<"\t"<<uu->second.underlying_id()<<" "<<uu->first<<"\n";
        }
 
        
calculate_moves(known_units,possible_moves,srcdst,dstsrc,false,false,NULL,true);
@@ -273,7 +273,7 @@
          }
        }
 
-       LOG_STREAM(info, ai)<<"\tmoving : "<< 
m->second.underlying_description() <<" "<<" from 
("<<closest_move.first.x<<","<<closest_move.first.y<<")"<<" to 
("<<target.x<<","<<target.y<<")"<<std::endl;
+       LOG_STREAM(info, ai)<<"\tmoving : "<< m->second.underlying_id() <<" 
"<<" from ("<<closest_move.first.x<<","<<closest_move.first.y<<")"<<" to 
("<<target.x<<","<<target.y<<")"<<std::endl;
        LOG_STREAM(info, ai)<<"\tdistance: "<<closest_distance<<"\n";
 
        if(closest_distance != -1) {
@@ -288,8 +288,8 @@
   unit_map::iterator dfool_ai::unit(std::string unit_id, unit_map& um){
     //    LOG_STREAM(info, ai)<<"unit start:"<<unit_id<<std::endl;
     for(unit_map::iterator u = um.begin(); u != um.end(); u++){
-      if(unit_id == u->second.underlying_description()){
-       //      LOG_STREAM(info, ai)<<"unit:"<<unit_id<<" , "<< 
u->second.underlying_description()<<std::endl;
+      if(unit_id == u->second.underlying_id()){
+       //      LOG_STREAM(info, ai)<<"unit:"<<unit_id<<" , "<< 
u->second.underlying_id()<<std::endl;
        return u;
       }
     }
@@ -317,7 +317,7 @@
   }
 
   void unit_memory::add_unit_sighting(unit u, gamemap::location l, size_t t){
-    std::string unit_id= u.underlying_description();
+    std::string unit_id= u.underlying_id();
     // Check if this unit has already been seen
     size_t i,j;
     for(i=0; i < ids_.size();i++){

Modified: trunk/src/ai_python.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai_python.cpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/ai_python.cpp (original)
+++ trunk/src/ai_python.cpp Wed Mar 12 21:07:36 2008
@@ -437,7 +437,7 @@
 static PyObject* unit_get_name(wesnoth_unit* unit, void* /*closure*/)
 {
        u_check;
-       return Py_BuildValue(STRINGVALUE, 
unit->unit_->underlying_description().c_str());
+       return Py_BuildValue(STRINGVALUE, 
unit->unit_->underlying_id().c_str());
 }
 
 static PyObject* unit_is_enemy(wesnoth_unit* unit, void* /*closure*/)

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Wed Mar 12 21:07:36 2008
@@ -2218,7 +2218,7 @@
                                                                citor != 
player->available_units.end(); ++citor) {
                                                        
                                                        const std::string 
desciption =
-                                                               
citor->underlying_description();
+                                                               
citor->underlying_id();
                                                        
if(std::find(desciptions.begin(), desciptions.end(),
                                                                        
desciption) != desciptions.end()) {
                                                                
@@ -2233,16 +2233,16 @@
                                        
                                        // Avoid duplicates in the list.
                                        //! @todo it would be better to 
change available_units from
-                                       //! a vector to a map and use the 
underlying_description
+                                       //! a vector to a map and use the 
underlying_id
                                        //! as key.
-                                       const std::string key = 
u.underlying_description();
+                                       const std::string key = 
u.underlying_id();
                                        for(std::vector<unit>::iterator itor =
                                                        
player->available_units.begin();
                                                        itor != 
player->available_units.end(); ++itor) {
 
                                                LOG_NG << "Replaced unit '"
                                                        << key << "' on the 
recall list\n";
-                                               
if(itor->underlying_description() == key) {
+                                               if(itor->underlying_id() == 
key) {
                                                        
player->available_units.erase(itor);
                                                        break;
                                                }
@@ -2930,12 +2930,12 @@
 {}
 
 entity_location::entity_location(unit_map::iterator itor)
-       : location(itor->first), id_(itor->second.underlying_description())
+       : location(itor->first), id_(itor->second.underlying_id())
 {}
 
 bool entity_location::matches_unit(const unit& u) const
 {
-       return id_ == u.underlying_description();
+       return id_ == u.underlying_id();
 }
 
 bool entity_location::requires_unit() const

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Wed Mar 12 21:07:36 2008
@@ -94,7 +94,7 @@
            name_(o.name_),
            description_(o.description_),
            custom_unit_description_(o.custom_unit_description_),
-           underlying_description_(o.underlying_description_),
+           underlying_id_(o.underlying_id_),
            language_name_(o.language_name_),
            undead_variation_(o.undead_variation_),
            variation_(o.variation_),
@@ -272,14 +272,14 @@
        }
        generate_traits(!use_traits);
        apply_modifications();
-       if(underlying_description_.empty()){
+       if(underlying_id_.empty()){
                char buf[80];
                if(!custom_unit_description_.empty()){
                        snprintf(buf, sizeof(buf), 
"%s-%d-%s",type()->id().c_str(), get_random(), 
custom_unit_description_.c_str());
                } else {
                        snprintf(buf, sizeof(buf), 
"%s-%d",type()->id().c_str(), get_random());
                }
-               underlying_description_ = buf;
+               underlying_id_ = buf;
        }
 
        unrenamable_ = false;
@@ -313,14 +313,14 @@
        }
        generate_traits(!use_traits);
        apply_modifications();
-       if(underlying_description_.empty()){
+       if(underlying_id_.empty()){
                char buf[80];
                if(!custom_unit_description_.empty()){
                        snprintf(buf, sizeof(buf), 
"%s-%d-%s",type()->id().c_str(), get_random(), 
custom_unit_description_.c_str());
                }else{
                        snprintf(buf, sizeof(buf), 
"%s-%d",type()->id().c_str(), get_random());
                }
-               underlying_description_ = buf;
+               underlying_id_ = buf;
        }
 
        unrenamable_ = false;
@@ -883,12 +883,12 @@
        const std::string& defense = t_defense;
        const std::string& mvt_cost = t_movement_cost;
 
-       if(description.empty() == false && description != 
this->underlying_description()) {
+       if(description.empty() == false && description != 
this->underlying_id()) {
                return false;
        }
 
        // Allow 'speaker' as an alternative to description, since people use 
it so often
-       if(speaker.empty() == false && speaker != 
this->underlying_description()) {
+       if(speaker.empty() == false && speaker != this->underlying_id()) {
                return false;
        }
 
@@ -1191,12 +1191,12 @@
        custom_unit_description_ = cfg["user_description"];
        std::string custom_unit_desc = cfg["unit_description"];
 
-       underlying_description_ = cfg["description"];
-       if(underlying_description_.empty()){
+       underlying_id_ = cfg["description"];
+       if(underlying_id_.empty()){
                char buf[80];
                snprintf(buf, sizeof(buf), "%s-%d",cfg["type"].c_str(), state 
?
                        state->get_random() : get_random());
-               underlying_description_ = buf;
+               underlying_id_ = buf;
        }
        if(description_.empty()) {
                description_ = cfg["type"].c_str();
@@ -1484,7 +1484,7 @@
        cfg["overlays"] = utils::join(overlays_);
 
        cfg["user_description"] = custom_unit_description_;
-       cfg["description"] = underlying_description_;
+       cfg["description"] = underlying_id_;
 
        if(can_recruit())
                cfg["canrecruit"] = "yes";

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=24584&r1=24583&r2=24584&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Wed Mar 12 21:07:36 2008
@@ -81,7 +81,7 @@
        void rename(const std::string& name) { if (!unrenamable_) 
custom_unit_description_ = name; }
        //! The unit type name
        const std::string& description() const { return 
(custom_unit_description_); }
-       const std::string& underlying_description() const { return 
underlying_description_; }
+       const std::string& underlying_id() const { return underlying_id_; }
        const t_string& language_name() const { return language_name_; }
        const std::string& undead_variation() const { return 
undead_variation_; }
        //! The unit's profile
@@ -303,7 +303,7 @@
        std::string name_;
        std::string description_;
        std::string custom_unit_description_;
-       std::string underlying_description_;
+       std::string underlying_id_;
        t_string language_name_;
        std::string undead_variation_;
        std::string variation_;




Related Messages


Powered by MHonArc, Updated Wed Mar 12 22:01:47 2008