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)
This commit is contained in:
parent
a7b7e35add
commit
304e997edd
5 changed files with 14 additions and 6 deletions
|
@ -96,7 +96,7 @@ static wide_string markov_generate_name(const markov_prefix_map& prefixes, size_
|
|||
|
||||
// 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<EFBFBD>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() : ntraits_(0), chain_size_(0), traits_(&empty_traits), gl
|
|||
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"]);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
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 @@ public:
|
|||
unsigned int num_traits() const;
|
||||
|
||||
private:
|
||||
std::string id_;
|
||||
t_string name_;
|
||||
unsigned int ntraits_;
|
||||
std::vector<std::string> names_[NUM_GENDERS];
|
||||
|
|
|
@ -909,7 +909,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location&
|
|||
}
|
||||
}
|
||||
|
||||
if(race.empty() == false && race_->name() != race) {
|
||||
if(race.empty() == false && race_->id() != race) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1561,7 +1561,7 @@ void unit::write(config& cfg) const
|
|||
|
||||
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_;
|
||||
|
|
|
@ -262,7 +262,7 @@ public:
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -1007,7 +1007,7 @@ const std::string& unit_type::race() const
|
|||
return empty_string;
|
||||
}
|
||||
|
||||
return race_->name();
|
||||
return race_->id();
|
||||
}
|
||||
|
||||
// Allow storing "advances from" info for convenience in Help.
|
||||
|
@ -1077,7 +1077,7 @@ void game_data::set_config(const config& cfg)
|
|||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue