Skip to content

Commit

Permalink
Back-port @stevecotton's 2127757 which resolved missing traits in Help (
Browse files Browse the repository at this point in the history
  • Loading branch information
Wedge009 committed Oct 21, 2020
1 parent 70267ae commit 1f91612
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/help/help_impl.cpp
Expand Up @@ -684,7 +684,8 @@ std::vector<topic> generate_trait_topics(const bool sort_generated)
for (const unit_type_data::unit_type_map::value_type &i : unit_types.types())
{
const unit_type &type = i.second;
if (description_type(type) == FULL_DESCRIPTION) {
const auto desc_type = description_type(type);
if (desc_type == FULL_DESCRIPTION || desc_type == HIDDEN_BUT_SHOW_MACROS) {
if (config::const_child_itors traits = type.possible_traits()) {
for (const config & trait : traits) {
const std::string trait_id = trait["id"];
Expand Down Expand Up @@ -1020,6 +1021,12 @@ UNIT_DESCRIPTION_TYPE description_type(const unit_type &type)
if (encountered_units.find(type.id()) != encountered_units.end()) {
return FULL_DESCRIPTION;
}

// See the docs of HIDDEN_BUT_SHOW_MACROS
if (type.id() == "Fog Clearer") {
return HIDDEN_BUT_SHOW_MACROS;
}

return NO_DESCRIPTION;
}

Expand Down
15 changes: 14 additions & 1 deletion src/help/help_impl.hpp
Expand Up @@ -244,7 +244,20 @@ void generate_races_sections(const config *help_cfg, section &sec, int level);
void generate_terrain_sections(const config* help_cfg, section &sec, int level);
std::vector<topic> generate_unit_topics(const bool, const std::string& race);
void generate_unit_sections(const config *help_cfg, section &sec, int level, const bool, const std::string& race);
enum UNIT_DESCRIPTION_TYPE {FULL_DESCRIPTION, NO_DESCRIPTION, NON_REVEALING_DESCRIPTION};
enum UNIT_DESCRIPTION_TYPE {
FULL_DESCRIPTION,
/** Ignore this unit for documentation purposes. */
NO_DESCRIPTION,
/**
* Although the unit itself is hidden, traits reachable via this unit are not hidden.
*
* This is a bug workaround - traits are defined by WML macros, and therefore the help
* system has to use a place where that macro is instanciated to provide the documentation.
* None of the normal unit types has the "loyal" trait, but there is a hidden unit which
* does, purely to support the help system.
*/
HIDDEN_BUT_SHOW_MACROS
};
/// Return the type of description that should be shown for a unit of
/// the given kind. This method is intended to filter out information
/// about units that should not be shown, for example due to not being
Expand Down

0 comments on commit 1f91612

Please sign in to comment.