Skip to content

Commit

Permalink
Unit/Race: made use of std::array
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Apr 24, 2018
1 parent d2b3a25 commit 098bc1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/units/race.cpp
Expand Up @@ -50,6 +50,7 @@ static const config& empty_topics()
unit_race::unit_race()
: cfg_()
, id_()
, name_()
, plural_name_()
, description_()
, ntraits_(0)
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/units/race.hpp
Expand Up @@ -16,6 +16,8 @@

#include "config.hpp"
#include "utils/name_generator.hpp"

#include <array>
#include <memory>

class unit_race
Expand Down Expand Up @@ -71,11 +73,11 @@ class unit_race

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_;
Expand Down

0 comments on commit 098bc1c

Please sign in to comment.