Author: soliton
Date: Sat Oct 24 18:09:16 2009
New Revision: 39433

URL: http://svn.gna.org/viewcvs/wesnoth?rev=39433&view=rev
Log:
default to true for generate_name

made it so we don't generate names if there already is one
put the name generation logic inside generate_name() so it's used uniformly 
everywhere

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=39433&r1=39432&r2=39433&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sat Oct 24 18:09:16 2009
@@ -490,6 +490,14 @@
        game_events::add_events(cfg_.child_range("event"), type_);
 }
 
+void unit::generate_name(rand_rng::simple_rng* rng)
+{
+       if (!name_.empty() || !utils::string_bool(cfg_["generate_name"], true)) 
return;
+
+       name_ = race_->generate_name(gender_, rng);
+       cfg_["generate_name"] = "no";
+}
+
 // Apply mandatory traits (e.g. undead, mechanical) to a unit and then
 // fill out with avaiable (leaders have a restircted set of available traits)
 // traits until no more are available or the unit has its maximum number
@@ -1521,10 +1529,8 @@
        } else if(cfg["type"]=="") {
                alignment_ = unit_type::NEUTRAL;
        }
-       if(utils::string_bool(cfg["generate_name"])) {
-               generate_name(state ? &(state->rng()) : 0);
-               cfg_["generate_name"] = "";
-       }
+
+       generate_name(state ? &(state->rng()) : 0);
 
        game_events::add_events(cfg_.child_range("event"), type_);
        // Make the default upkeep "full"

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=39433&r1=39432&r2=39433&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Sat Oct 24 18:09:16 2009
@@ -316,8 +316,7 @@
        void remove_temporary_modifications();
        void generate_traits(bool musthaveonly=false, game_state* state = 0);
        void generate_traits_description();
-       void generate_name(rand_rng::simple_rng *rng = 0)
-       { name_ = race_->generate_name(gender_, rng); }
+       void generate_name(rand_rng::simple_rng *rng = 0);
 
        // Only see_all=true use caching
        bool invisible(const map_location& loc,


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

Reply via email to