Unit/Race: made use of std::array

This commit is contained in:
Charles Dang 2018-04-24 16:35:28 +11:00
parent d2b3a25b9e
commit 098bc1c0e8
2 changed files with 8 additions and 6 deletions

View file

@ -50,6 +50,7 @@ static const config& empty_topics()
unit_race::unit_race()
: cfg_()
, id_()
, name_()
, plural_name_()
, description_()
, ntraits_(0)
@ -58,10 +59,9 @@ unit_race::unit_race()
, global_traits_(true)
, undead_variation_()
{
name_[MALE] = "";
name_[FEMALE] = "";
name_generator_[MALE].reset(new name_generator());
name_generator_[FEMALE].reset(new name_generator());
for(auto& generator : name_generator_) {
generator.reset(new name_generator());
}
}
unit_race::unit_race(const config& cfg)

View file

@ -16,6 +16,8 @@
#include "config.hpp"
#include "utils/name_generator.hpp"
#include <array>
#include <memory>
class unit_race
@ -71,11 +73,11 @@ private:
std::string id_;
std::string icon_;
t_string name_[NUM_GENDERS];
std::array<t_string, NUM_GENDERS> name_;
t_string plural_name_;
t_string description_;
unsigned int ntraits_;
std::shared_ptr<name_generator> name_generator_[NUM_GENDERS];
std::array<std::shared_ptr<name_generator>, NUM_GENDERS> name_generator_;
config::const_child_itors traits_;
config::const_child_itors topics_;