Skip to content

Commit

Permalink
Merge pull request #24420 from Qrox/fix-invlet-cleared-after-trading
Browse files Browse the repository at this point in the history
Fix inventory letter assignment getting cleared after trade
  • Loading branch information
ZhilkinSerg authored Jul 22, 2018
2 parents eb1924e + bd3f6a3 commit c762328
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions src/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class inventory : public visitable<inventory>

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<std::string, std::vector<char> > invlet_cache;
Expand Down
1 change: 1 addition & 0 deletions src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down

0 comments on commit c762328

Please sign in to comment.