From cb88a7a232117a5bcff2c96441c2bcd3997986d9 Mon Sep 17 00:00:00 2001 From: josteph Date: Wed, 27 Jun 2018 10:18:03 +0000 Subject: [PATCH] Help: Use `female_name` and `name` as fallback when `male_name` is empty and don't list hidden traits. This algorithm was lifted from help::generate_trait_topics(). Fixes #3284 (cherry-picked from commit a4b0de5ece5a9bf1edac3b6f49dfac647ff1194f) --- src/help/help_topic_generators.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/help/help_topic_generators.cpp b/src/help/help_topic_generators.cpp index 35795211272..52cc4e930ed 100644 --- a/src/help/help_topic_generators.cpp +++ b/src/help/help_topic_generators.cpp @@ -215,6 +215,7 @@ std::string terrain_topic_generator::operator()() const { //Typedef to help with formatting list of traits +// Maps localized trait name to trait help topic ID typedef std::pair trait_data; //Helper function for printing a list of trait data @@ -393,8 +394,12 @@ std::string unit_topic_generator::operator()() const { std::vector random_traits; int must_have_nameless_traits = 0; - for (const config & trait : traits) { - const std::string trait_name = trait["male_name"]; + for(const config& trait : traits) { + std::string trait_name = trait["male_name"].str(); + if (trait_name.empty()) trait_name = trait["female_name"].str(); + if (trait_name.empty()) trait_name = trait["name"].str(); + if (trait_name.empty()) continue; // Hidden trait + std::string lang_trait_name = translation::gettext(trait_name.c_str()); if (lang_trait_name.empty() && trait["availability"].str() == "musthave") { ++must_have_nameless_traits;