From ac3d8f54b67ea84ad78631d928c2aec6b13bba22 Mon Sep 17 00:00:00 2001 From: Dean Santos Date: Mon, 28 Oct 2019 10:38:31 +1000 Subject: [PATCH 1/2] Fix for issue #35067 An assert was being thrown while attempting to render information for non-gun weapons in the UI. This was caused by attempting to render ammunition information incorrectly for items that did not contain the ammunition structure. Adding a check for is_gun() before rendering is necessary to prevent the crash. --- src/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index f3a0a840ba0ad..a08190203d92f 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1875,7 +1875,7 @@ std::string item::info( std::vector &info, const iteminfo_query *parts info.emplace_back( "GUNMOD", _( "Handling modifier: " ), "", iteminfo::show_plus, mod.handling ); } - if( !type->mod->ammo_modifier.empty() && parts->test( iteminfo_parts::GUNMOD_AMMO ) ) { + if(is_gun() && !type->mod->ammo_modifier.empty() && parts->test( iteminfo_parts::GUNMOD_AMMO ) ) { for( const ammotype &at : type->mod->ammo_modifier ) { info.push_back( iteminfo( "GUNMOD", string_format( _( "Ammo: %s" ), at->name() ) ) ); From 73487d0db58587e5ccd93471d691fa46b928c68a Mon Sep 17 00:00:00 2001 From: eso Date: Sun, 27 Oct 2019 18:10:39 -0700 Subject: [PATCH 2/2] astyle fix --- src/item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.cpp b/src/item.cpp index a08190203d92f..305e1699f3cc2 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1875,7 +1875,7 @@ std::string item::info( std::vector &info, const iteminfo_query *parts info.emplace_back( "GUNMOD", _( "Handling modifier: " ), "", iteminfo::show_plus, mod.handling ); } - if(is_gun() && !type->mod->ammo_modifier.empty() && parts->test( iteminfo_parts::GUNMOD_AMMO ) ) { + if( is_gun() && !type->mod->ammo_modifier.empty() && parts->test( iteminfo_parts::GUNMOD_AMMO ) ) { for( const ammotype &at : type->mod->ammo_modifier ) { info.push_back( iteminfo( "GUNMOD", string_format( _( "Ammo: %s" ), at->name() ) ) );