From b0ab5c7d9459ff7ec8e52152d6abaf5f313cf1ea Mon Sep 17 00:00:00 2001 From: Efstratios Karatzas Date: Sun, 3 Mar 2024 17:22:10 -0800 Subject: [PATCH] fix: empty underslung gun doesnt prevent going into firing mode UI Without this fix having an empty underbarrel mod/gun like the grenade launcher prevents the player from activating the firing ui via 'f'. This is especially troublesome as most players, including myself, only know how to change firing modes via this UI. This effectively prevents players from switching firing mode to the main weapon. --- src/avatar_action.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 5f578adf3dc1..340d0425c349 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -675,12 +675,13 @@ bool avatar_action::can_fire_weapon( avatar &you, const map &m, const item &weap std::vector messages; - const gun_mode &mode = weapon.gun_current_mode(); - bool check_common = ranged::gunmode_checks_common( you, m, messages, mode ); - bool check_weapon = ranged::gunmode_checks_weapon( you, m, messages, mode ); - bool can_use_mode = check_common && check_weapon; - if( can_use_mode ) { - return true; + for( const std::pair &mode_map : weapon.gun_all_modes() ) { + const bool check_common = ranged::gunmode_checks_common( you, m, messages, mode_map.second ); + const bool check_weapon = ranged::gunmode_checks_weapon( you, m, messages, mode_map.second ); + const bool can_use_mode = check_common && check_weapon; + if( can_use_mode ) { + return true; + } } for( const std::string &message : messages ) {