Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: regression introduced with magazine reload fix #6176

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/character_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,19 @@ bool list_ammo( const Character &who, item &base, std::vector<item_reload_option
: ammo->typeId();
const bool can_reload_with = e->can_reload_with( id );
if( can_reload_with ) {
// Skip if is magazine inside gun/mod, but gun/mod can't fire it (e.g 300 Blackout on STANAG on AR-15)
if( e->is_magazine() && e->parent_item() ) {
auto ammo_type = ( ammo->is_ammo_container() || ammo->is_container() )
? ammo->contents.front().ammo_type()
: ammo->ammo_type();
const std::set<ammotype> &supported_ammo = e->parent_item()->ammo_types();
const bool gun_supports = std::ranges::any_of( supported_ammo, [&]( const ammotype & at ) {
return at == ammo_type;
} );
if( !gun_supports ) {
continue;
}
}
// Speedloaders require an empty target.
if( include_potential || !ammo->has_flag( flag_SPEEDLOADER ) || e->ammo_remaining() < 1 ) {
ammo_match_found = true;
Expand Down
Loading