Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inventory letter assignment getting cleared after trade #24420

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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