Skip to content

Commit 690cc17

Browse files
authored
Fix segfault when toggling RAS with an inappropriate item (#82388)
1 parent 17869a9 commit 690cc17

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ranged.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,7 +3001,9 @@ void target_ui::init_window_and_input()
30013001
ctxt.register_action( "NEXT_TARGET" );
30023002
ctxt.register_action( "PREV_TARGET" );
30033003
ctxt.register_action( "CENTER" );
3004-
ctxt.register_action( "TOGGLE_UNLOAD_RAS_WEAPON" );
3004+
if( mode == TargetMode::Fire && relevant->has_flag( flag_RELOAD_AND_SHOOT ) ) {
3005+
ctxt.register_action( "TOGGLE_UNLOAD_RAS_WEAPON" );
3006+
}
30053007
ctxt.register_action( "TOGGLE_SNAP_TO_TARGET" );
30063008
ctxt.register_action( "HELP_KEYBINDINGS" );
30073009
ctxt.register_action( "QUIT" );
@@ -4087,12 +4089,12 @@ void target_ui::draw_controls_list( int text_y )
40874089
} );
40884090
} else {
40894091
if( !unload_RAS_weapon ) {
4090-
std::string unload = string_format( _( "[%s] Unload the %s after quitting." ),
4092+
std::string unload = string_format( _( "[%s] to unload the %s after quitting." ),
40914093
bound_key( "TOGGLE_UNLOAD_RAS_WEAPON" ).short_description(),
40924094
relevant->tname() );
4093-
lines.push_back( {3, colored( col_disabled, unload )} );
4095+
lines.push_back( {3, colored( col_enabled, unload )} );
40944096
} else {
4095-
std::string unload = string_format( _( "[%s] Keep the %s loaded after quitting." ),
4097+
std::string unload = string_format( _( "[%s] to keep the %s loaded after quitting." ),
40964098
bound_key( "TOGGLE_UNLOAD_RAS_WEAPON" ).short_description(),
40974099
relevant->tname() );
40984100
lines.push_back( {3, colored( col_enabled, unload )} );

0 commit comments

Comments
 (0)