Define operators == and != for ItemStack

This commit is contained in:
ANAND ︻气デ═一 2019-05-11 22:18:27 +05:30 committed by sfan5
parent 72feab081c
commit 8e3b63bd28
2 changed files with 16 additions and 8 deletions

View File

@ -509,13 +509,8 @@ bool InventoryList::operator == (const InventoryList &other) const
if(m_name != other.m_name)
return false;
for (u32 i = 0; i < m_items.size(); i++)
{
ItemStack s1 = m_items[i];
ItemStack s2 = other.m_items[i];
if(s1.name != s2.name || s1.wear!= s2.wear || s1.count != s2.count ||
s1.metadata != s2.metadata)
if (m_items[i] != other.m_items[i])
return false;
}
return true;
}

View File

@ -161,6 +161,19 @@ struct ItemStack
// Similar to takeItem, but keeps this ItemStack intact.
ItemStack peekItem(u32 peekcount) const;
bool operator ==(const ItemStack &s) const
{
return (this->name == s.name &&
this->count == s.count &&
this->wear == s.wear &&
this->metadata == s.metadata);
}
bool operator !=(const ItemStack &s) const
{
return !(*this == s);
}
/*
Properties
*/