Skip to content

Commit

Permalink
Fix items with different mods getting stacked together (#52252)
Browse files Browse the repository at this point in the history
* Compare item mods when stacking
  • Loading branch information
dseguin authored Oct 13, 2021
1 parent ed863fe commit 95019f2
Showing 1 changed file with 21 additions and 0 deletions.
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

0 comments on commit 95019f2

Please sign in to comment.