@@ -1246,6 +1246,9 @@ void monster::shift( point sm_shift )
12461246
12471247detached_ptr<item> monster::set_tack_item ( detached_ptr<item> &&to )
12481248{
1249+ if ( to && to->typeId () != itype_id::NULL_ID () ) {
1250+ has_processable_items = true ;
1251+ }
12491252 return tack_item.swap ( std::move ( to ) );
12501253}
12511254
@@ -1264,6 +1267,9 @@ item *monster::get_tack_item() const
12641267
12651268detached_ptr<item> monster::set_tied_item ( detached_ptr<item> &&to )
12661269{
1270+ if ( to && to->typeId () != itype_id::NULL_ID () ) {
1271+ has_processable_items = true ;
1272+ }
12671273 return tied_item.swap ( std::move ( to ) );
12681274}
12691275
@@ -1282,6 +1288,9 @@ item *monster::get_tied_item() const
12821288
12831289detached_ptr<item> monster::set_armor_item ( detached_ptr<item> &&to )
12841290{
1291+ if ( to && to->typeId () != itype_id::NULL_ID () ) {
1292+ has_processable_items = true ;
1293+ }
12851294 return armor_item.swap ( std::move ( to ) );
12861295}
12871296
@@ -1300,6 +1309,9 @@ item *monster::get_armor_item() const
13001309
13011310detached_ptr<item> monster::set_storage_item ( detached_ptr<item> &&to )
13021311{
1312+ if ( to && to->typeId () != itype_id::NULL_ID () ) {
1313+ has_processable_items = true ;
1314+ }
13031315 return storage_item.swap ( std::move ( to ) );
13041316}
13051317
@@ -1318,6 +1330,9 @@ item *monster::get_storage_item() const
13181330
13191331detached_ptr<item> monster::set_battery_item ( detached_ptr<item> &&to )
13201332{
1333+ if ( to && to->typeId () != itype_id::NULL_ID () ) {
1334+ has_processable_items = true ;
1335+ }
13211336 return battery_item.swap ( std::move ( to ) );
13221337}
13231338
@@ -3018,19 +3033,22 @@ static void process_item_valptr( item *ptr, monster &mon )
30183033void monster::process_items ()
30193034{
30203035 ZoneScoped;
3036+ if ( !inv.empty () ) {
3037+ inv.remove_with ( [this ]( detached_ptr<item> &&it ) {
3038+ if ( it->needs_processing () ) {
3039+ return item::process ( std::move ( it ), nullptr , pos (), false );
3040+ }
3041+ return std::move ( it );
3042+ } );
3043+ }
30213044
3022- inv.remove_with ( [this ]( detached_ptr<item> &&it ) {
3023- if ( it->needs_processing () ) {
3024- return item::process ( std::move ( it ), nullptr , pos (), false );
3025- }
3026- return std::move ( it );
3027- } );
3028-
3029- process_item_valptr ( &*storage_item, *this );
3030- process_item_valptr ( &*armor_item, *this );
3031- process_item_valptr ( &*tack_item, *this );
3032- process_item_valptr ( &*tied_item, *this );
3033- process_item_valptr ( &*battery_item, *this );
3045+ if ( has_processable_items ) {
3046+ process_item_valptr ( &*storage_item, *this );
3047+ process_item_valptr ( &*armor_item, *this );
3048+ process_item_valptr ( &*tack_item, *this );
3049+ process_item_valptr ( &*tied_item, *this );
3050+ process_item_valptr ( &*battery_item, *this );
3051+ }
30343052}
30353053
30363054namespace
0 commit comments