help: Handle traits with empty names or descriptions.

Fixes #2108.
This commit is contained in:
josteph 2017-11-02 20:45:47 +00:00 committed by Charles Dang
parent 237b7a00bc
commit 673c1fa4d9
2 changed files with 11 additions and 6 deletions

View file

@ -697,11 +697,19 @@ std::vector<topic> generate_trait_topics(const bool sort_generated)
for (std::map<t_string, const config>::iterator a = trait_list.begin(); a != trait_list.end(); ++a) {
std::string id = "traits_" + a->first;
const config trait = a->second;
std::string name = trait["male_name"].str();
if (name.empty()) name = trait["female_name"].str();
if (name.empty()) name = trait["name"].str();
if (name.empty()) continue; // Hidden trait
std::stringstream text;
if (trait["help_text"].empty()) {
if (!trait["help_text"].empty()) {
text << trait["help_text"];
} else if (!trait["description"].empty()) {
text << trait["description"];
} else {
text << trait["help_text"];
text << _("No description available.");
}
text << "\n\n";
if (trait["availability"] == "musthave") {
@ -709,10 +717,6 @@ std::vector<topic> generate_trait_topics(const bool sort_generated)
} else if (trait["availability"] == "none") {
text << _("Availability: ") << _("Unavailable") << "\n";
}
std::string name = trait["male_name"].str();
if (name.empty()) name = trait["female_name"].str();
if (name.empty()) name = trait["name"].str();
topics.emplace_back(name, id, text.str());
}

View file

@ -224,6 +224,7 @@ static void print_trait_list(std::stringstream & ss, const std::vector<trait_dat
size_t i = 0;
ss << make_link(l[i].first, l[i].second);
// This doesn't skip traits with empty names
for(i++; i < l.size(); i++) {
ss << ", " << make_link(l[i].first,l[i].second);
}