Skip to content

Commit

Permalink
Fixes trying to use null armor data on sort screen (#64078)
Browse files Browse the repository at this point in the history
* Fixes trying to use null armor data

* clang keeps me honest
  • Loading branch information
bombasticSlacks authored Mar 10, 2023
1 parent 1ee8304 commit 63db8fa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ std::vector<std::string> clothing_properties(
std::vector<std::string> props;
bodypart_id used_bp = bp;
if( bp == bodypart_id( "bp_null" ) ) {
// if the armor has no protection data
if( worn_item.find_armor_data()->sub_data.empty() ) {
props.push_back( string_format( "<color_c_red>%s</color>",
_( "Item provides no protection" ) ) );
return props;
}

// if there is only one data entry for the armor
if( worn_item.find_armor_data()->sub_data.size() > 1 ) {
props.push_back( string_format( "<color_c_red>%s</color>",
Expand Down Expand Up @@ -326,10 +333,11 @@ std::vector<std::string> clothing_protection( const item &worn_item, const int w

// if bp is null its gonna be impossible to really get good info
if( bp == bodypart_id( "bp_null" ) ) {
if( worn_item.find_armor_data()->sub_data.size() > 1 ) {
return prot;
} else {
// if we have exactly one entry for armor we can use that data
if( worn_item.find_armor_data()->sub_data.size() == 1 ) {
used_bp = *worn_item.get_covered_body_parts().begin();
} else {
return prot;
}
}

Expand Down

0 comments on commit 63db8fa

Please sign in to comment.