Skip to content

Commit

Permalink
Merge pull request #44974 from Robik81/prof_search_fix
Browse files Browse the repository at this point in the history
Fix of proficiency search in crafting menu
  • Loading branch information
ZhilkinSerg authored Oct 20, 2020
2 parents 66360e0 + c0ad219 commit fc4a2a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/recipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,21 @@ std::string recipe::missing_proficiencies_string( const Character *c ) const
return missing;
}

std::string recipe::recipe_proficiencies_string() const
{
std::vector<proficiency_id> profs;

for( const recipe_proficiency &rec : proficiencies ) {
profs.push_back( rec.id );
}
std::string list = enumerate_as_string( profs.begin(),
profs.end(), [&]( const proficiency_id & id ) {
return id->name();
} );

return list;
}

std::set<proficiency_id> recipe::required_proficiencies() const
{
std::set<proficiency_id> ret;
Expand Down
2 changes: 2 additions & 0 deletions src/recipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class recipe
std::string required_proficiencies_string( const Character *c ) const;
std::string used_proficiencies_string( const Character *c ) const;
std::string missing_proficiencies_string( const Character *c ) const;
// Proficiencies for search
std::string recipe_proficiencies_string() const;
// Required proficiencies
std::set<proficiency_id> required_proficiencies() const;
//
Expand Down
3 changes: 1 addition & 2 deletions src/recipe_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ std::vector<const recipe *> recipe_subset::search(
}

case search_type::proficiency:
return lcmatch( r->required_proficiencies_string( nullptr ), txt ) ||
lcmatch( r->used_proficiencies_string( nullptr ), txt );
return lcmatch( r->recipe_proficiencies_string(), txt );

default:
return false;
Expand Down

0 comments on commit fc4a2a8

Please sign in to comment.