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 items with different mods getting stacked together #52252

Merged
merged 2 commits into from
Oct 13, 2021
Merged
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
21 changes: 21 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,27 @@ bool item::stacks_with( const item &rhs, bool check_components, bool combine_liq
}
}
}
const std::vector<const item *> this_mods = mods();
const std::vector<const item *> that_mods = rhs.mods();
if( this_mods.size() != that_mods.size() ) {
return false;
}
for( const item *it1 : this_mods ) {
bool match = false;
const bool i1_isnull = it1 == nullptr;
for( const item *it2 : that_mods ) {
const bool i2_isnull = it2 == nullptr;
if( i1_isnull != i2_isnull ) {
continue;
} else if( it1 == it2 || it1->typeId() == it2->typeId() ) {
match = true;
break;
}
}
if( !match ) {
return false;
}
}
return contents.stacks_with( rhs.contents );
}

Expand Down