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
This commit is contained in:
parent
056b6606b2
commit
1534058519
2 changed files with 11 additions and 6 deletions
14
src/unit.cpp
14
src/unit.cpp
|
@ -490,6 +490,14 @@ void unit::set_game_context(unit_map *unitmap)
|
|||
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 @@ void unit::read(const config& cfg, bool use_traits, game_state* state)
|
|||
} 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"
|
||||
|
|
|
@ -316,8 +316,7 @@ public:
|
|||
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,
|
||||
|
|
Loading…
Add table
Reference in a new issue