diff --git a/src/inventory.cpp b/src/inventory.cpp index e952426dec376..f33ac6e1d30b0 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -978,3 +978,9 @@ const itype_bin &inventory::get_binned_items() const binned = true; return binned_items; } + +void inventory::copy_invlet_of( const inventory &other ) +{ + assigned_invlet = other.assigned_invlet; + invlet_cache = other.invlet_cache; +} diff --git a/src/inventory.h b/src/inventory.h index cee11c954833a..f39022c929fbe 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -178,6 +178,8 @@ class inventory : public visitable void update_cache_with_item( item &newit ); + void copy_invlet_of( const inventory &other ); + private: // For each item ID, store a set of "favorite" inventory letters. std::map > invlet_cache; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 6c0c9cebe88dc..7c022aaea6ac9 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -3735,6 +3735,7 @@ inventory inventory_exchange( inventory &inv, inv.dump( item_dump ); item_dump.insert( item_dump.end(), added.begin(), added.end() ); inventory new_inv; + new_inv.copy_invlet_of( inv ); for( item *it : item_dump ) { if( without.count( it ) == 0 ) {