diff --git a/src/npc.cpp b/src/npc.cpp index 8d267cea57006..8587421cdcc35 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -2372,6 +2372,17 @@ void npc::die( Creature *nkiller ) elem->remove_owner(); elem->remove_old_owner(); } + // broadcast a signal to any items this NPC may have dropped nearby to clear their ownership too + // this will also validate when the items are interacted with + // but may as well solve what we can now. + for( const tripoint tri_elem : g->m.points_in_radius( pos(), 60 ) ) { + for( item &elem : g->m.i_at( tri_elem ) ) { + if( !elem.get_owner().is_null() && !g->faction_manager_ptr->get( elem.get_owner(), false ) ) { + elem.remove_owner(); + elem.remove_old_owner(); + } + } + } } my_fac->remove_member( getID() ); } diff --git a/src/pickup.cpp b/src/pickup.cpp index c0abaf506cbf9..38958714a43a3 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -517,6 +517,11 @@ void Pickup::pick_up( const tripoint &p, int min, from_where get_items_from ) std::vector> stacked_here; for( item_stack::iterator it : here ) { bool found_stack = false; + // an NPC may have dropped an item, then later died, the faction is now invalid. + if( !it->get_owner().is_null() && !g->faction_manager_ptr->get( it->get_owner(), false ) ) { + it->remove_owner(); + it->remove_old_owner(); + } for( std::list &stack : stacked_here ) { if( stack.front()->display_stacked_with( *it ) ) { stack.push_back( it );