summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-06-28 14:06:34 +0000
committerPilzAdam <pilzadam@minetest.net>2013-06-28 14:15:48 +0000
commit280946ba836cde9516f9344f47561f3356bdf869 (patch)
treefb238ce650df6cf6df0545b90f4ebe2859fcbe41 /src/inventory.cpp
parent9e100bc42b5275299020ea8619e64f2e4aa76192 (diff)
downloadminetest-280946ba836cde9516f9344f47561f3356bdf869.tar.gz
minetest-280946ba836cde9516f9344f47561f3356bdf869.tar.bz2
minetest-280946ba836cde9516f9344f47561f3356bdf869.zip
Dont write player files all the time
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index d6815d329..928021c2f 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -562,6 +562,26 @@ InventoryList & InventoryList::operator = (const InventoryList &other)
return *this;
}
+bool InventoryList::operator == (const InventoryList &other)
+{
+ if(m_size != other.m_size)
+ return false;
+ if(m_width != other.m_width)
+ return false;
+ 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)
+ return false;
+ }
+
+ return true;
+}
+
const std::string &InventoryList::getName() const
{
return m_name;
@@ -855,6 +875,19 @@ Inventory & Inventory::operator = (const Inventory &other)
return *this;
}
+bool Inventory::operator == (const Inventory &other)
+{
+ if(m_lists.size() != other.m_lists.size())
+ return false;
+
+ for(u32 i=0; i<m_lists.size(); i++)
+ {
+ if(m_lists[i] != other.m_lists[i])
+ return false;
+ }
+ return true;
+}
+
void Inventory::serialize(std::ostream &os) const
{
for(u32 i=0; i<m_lists.size(); i++)