File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -508,14 +508,9 @@ bool InventoryList::operator == (const InventoryList &other) const
508
508
return false ;
509
509
if (m_name != other.m_name )
510
510
return false ;
511
- for (u32 i=0 ; i<m_items.size (); i++)
512
- {
513
- ItemStack s1 = m_items[i];
514
- ItemStack s2 = other.m_items [i];
515
- if (s1.name != s2.name || s1.wear != s2.wear || s1.count != s2.count ||
516
- s1.metadata != s2.metadata )
511
+ for (u32 i = 0 ; i < m_items.size (); i++)
512
+ if (m_items[i] != other.m_items [i])
517
513
return false ;
518
- }
519
514
520
515
return true ;
521
516
}
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ struct ItemStack
41
41
42
42
// Serialization
43
43
void serialize (std::ostream &os) const ;
44
- // Deserialization. Pass itemdef unless you don't want aliases resolved.
44
+ // Deserialization. Pass itemdef unless you don't want aliases resolved.
45
45
void deSerialize (std::istream &is, IItemDefManager *itemdef = NULL );
46
46
void deSerialize (const std::string &s, IItemDefManager *itemdef = NULL );
47
47
@@ -161,6 +161,19 @@ struct ItemStack
161
161
// Similar to takeItem, but keeps this ItemStack intact.
162
162
ItemStack peekItem (u32 peekcount) const ;
163
163
164
+ bool operator ==(const ItemStack &s) const
165
+ {
166
+ return (this ->name == s.name &&
167
+ this ->count == s.count &&
168
+ this ->wear == s.wear &&
169
+ this ->metadata == s.metadata );
170
+ }
171
+
172
+ bool operator !=(const ItemStack &s) const
173
+ {
174
+ return !(*this == s);
175
+ }
176
+
164
177
/*
165
178
Properties
166
179
*/
You can’t perform that action at this time.
0 commit comments