mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Define operators == and != for ItemStack
This commit is contained in:
parent
72feab081c
commit
8e3b63bd28
@ -508,14 +508,9 @@ bool InventoryList::operator == (const InventoryList &other) const
|
|||||||
return false;
|
return false;
|
||||||
if(m_name != other.m_name)
|
if(m_name != other.m_name)
|
||||||
return false;
|
return false;
|
||||||
for(u32 i=0; i<m_items.size(); i++)
|
for (u32 i = 0; i < m_items.size(); i++)
|
||||||
{
|
if (m_items[i] != other.m_items[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)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ struct ItemStack
|
|||||||
|
|
||||||
// Serialization
|
// Serialization
|
||||||
void serialize(std::ostream &os) const;
|
void serialize(std::ostream &os) const;
|
||||||
// Deserialization. Pass itemdef unless you don't want aliases resolved.
|
// Deserialization. Pass itemdef unless you don't want aliases resolved.
|
||||||
void deSerialize(std::istream &is, IItemDefManager *itemdef = NULL);
|
void deSerialize(std::istream &is, IItemDefManager *itemdef = NULL);
|
||||||
void deSerialize(const std::string &s, IItemDefManager *itemdef = NULL);
|
void deSerialize(const std::string &s, IItemDefManager *itemdef = NULL);
|
||||||
|
|
||||||
@ -161,6 +161,19 @@ struct ItemStack
|
|||||||
// Similar to takeItem, but keeps this ItemStack intact.
|
// Similar to takeItem, but keeps this ItemStack intact.
|
||||||
ItemStack peekItem(u32 peekcount) const;
|
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
|
Properties
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user