diff --git a/src/help/help_impl.cpp b/src/help/help_impl.cpp index 3cff5de6500..87da47abe99 100644 --- a/src/help/help_impl.cpp +++ b/src/help/help_impl.cpp @@ -640,7 +640,7 @@ std::vector generate_trait_topics(const bool sort_generated) const unit_type &type = i.second; if (description_type(type) == FULL_DESCRIPTION) { config::const_child_itors traits = type.possible_traits(); - if (traits.first != traits.second && type.num_traits() > 0) { + if (traits.first != traits.second) { for (const config & trait : traits) { const std::string trait_id = trait["id"]; trait_list.insert(std::make_pair(trait_id, trait)); diff --git a/src/help/help_topic_generators.cpp b/src/help/help_topic_generators.cpp index 781a43dea3d..ea9fea3f5a0 100644 --- a/src/help/help_topic_generators.cpp +++ b/src/help/help_topic_generators.cpp @@ -264,7 +264,7 @@ std::string unit_topic_generator::operator()() const { male_type.big_profile() : male_type.small_profile(); const std::string &female_portrait = female_type.small_profile().empty() ? female_type.big_profile() : female_type.small_profile(); - + const bool has_male_portrait = !male_portrait.empty() && male_portrait != male_type.image() && male_portrait != "unit_image"; const bool has_female_portrait = !female_portrait.empty() && female_portrait != male_portrait && female_portrait != female_type.image() && female_portrait != "unit_image"; @@ -296,7 +296,7 @@ std::string unit_topic_generator::operator()() const { std::vector adv_units = reverse ? type_.advances_from() : type_.advances_to(); bool first = true; - + for (const std::string &adv : adv_units) { const unit_type *type = unit_types.find(adv, unit_type::HELP_INDEXED); if (!type || type->hide_help()) { @@ -392,7 +392,7 @@ std::string unit_topic_generator::operator()() const { // Print the possible traits of the unit, cross-reference them // to their respective topics. config::const_child_itors traits = type_.possible_traits(); - if (traits.first != traits.second && type_.num_traits() > 0) { + if (traits.first != traits.second) { std::vector must_have_traits; std::vector random_traits; @@ -404,7 +404,7 @@ std::string unit_topic_generator::operator()() const { } bool line1 = !must_have_traits.empty(); - bool line2 = !random_traits.empty() && type_.num_traits() - must_have_traits.size() > 0; + bool line2 = !random_traits.empty() && type_.num_traits() > must_have_traits.size(); if (line1) { std::string traits_label = _("Traits"); diff --git a/src/units/types.cpp b/src/units/types.cpp index 84cafe8393e..f09bad5eed3 100644 --- a/src/units/types.cpp +++ b/src/units/types.cpp @@ -209,12 +209,6 @@ void unit_type::build_full(const movement_type_map &mv_types, } } - // Insert any traits that are just for this unit type - for (const config &trait : cfg_.child_range("trait")) - { - possible_traits_.add_child("trait", trait); - } - zoc_ = cfg_["zoc"].to_bool(level_ > 0); const config::attribute_value & alpha_blend = cfg_["alpha"]; @@ -340,6 +334,12 @@ void unit_type::build_help_index(const movement_type_map &mv_types, { possible_traits_.add_child("trait", t); } + // Insert any traits that are just for this unit type + for (const config &trait : cfg_.child_range("trait")) + { + possible_traits_.add_child("trait", trait); + } + for (const config &var_cfg : cfg_.child_range("variation")) { const std::string& var_id = var_cfg["variation_id"].empty() ?