Skip to content

Commit

Permalink
Merge pull request #77887 from PatrikLundell/ammo
Browse files Browse the repository at this point in the history
Fix has_ammo and has_ammo_info
  • Loading branch information
Maleclypse authored Nov 15, 2024
2 parents c0dd793 + 538b481 commit 17755a4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10777,8 +10777,9 @@ int item::gun_range( bool with_ammo ) const
range_multiplier *= mod->type->gunmod->range_multiplier;
}
if( with_ammo && has_ammo() ) {
ret += ammo_data()->ammo->range;
range_multiplier *= ammo_data()->ammo->range_multiplier;
const itype *ammo_info = ammo_data();
ret += ammo_info->ammo->range;
range_multiplier *= ammo_info->ammo->range_multiplier;
}
ret *= range_multiplier;
return std::min( std::max( 0, ret ), RANGE_HARD_CAP );
Expand Down Expand Up @@ -11204,7 +11205,7 @@ bool item::has_ammo() const
}

if( is_magazine() ) {
return !contents.empty();
return !contents.empty() && contents.first_ammo().has_ammo();
}

auto mods = is_gun() ? gunmods() : toolmods();
Expand All @@ -11229,7 +11230,7 @@ bool item::has_ammo_data() const
}

if( is_magazine() ) {
return !contents.empty();
return !contents.empty() && contents.first_ammo().has_ammo_data();
}

auto mods = is_gun() ? gunmods() : toolmods();
Expand Down

0 comments on commit 17755a4

Please sign in to comment.