return *this;
}
-bool InventoryList::operator == (const InventoryList &other)
+bool InventoryList::operator == (const InventoryList &other) const
{
if(m_size != other.m_size)
return false;
void Inventory::clear()
{
+ m_dirty = true;
for(u32 i=0; i<m_lists.size(); i++)
{
delete m_lists[i];
void Inventory::clearContents()
{
+ m_dirty = true;
for(u32 i=0; i<m_lists.size(); i++)
{
InventoryList *list = m_lists[i];
Inventory::Inventory(IItemDefManager *itemdef)
{
+ m_dirty = false;
m_itemdef = itemdef;
}
Inventory::Inventory(const Inventory &other)
{
*this = other;
+ m_dirty = false;
}
Inventory & Inventory::operator = (const Inventory &other)
// Gracefully handle self assignment
if(this != &other)
{
+ m_dirty = true;
clear();
m_itemdef = other.m_itemdef;
for(u32 i=0; i<other.m_lists.size(); i++)
return *this;
}
-bool Inventory::operator == (const Inventory &other)
+bool Inventory::operator == (const Inventory &other) const
{
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])
+ if(*m_lists[i] != *other.m_lists[i])
return false;
}
return true;
}
else
{
- throw SerializationError("invalid inventory specifier");
+ throw SerializationError("invalid inventory specifier: " + name);
}
}
}
InventoryList * Inventory::addList(const std::string &name, u32 size)
{
+ m_dirty = true;
s32 i = getListIndex(name);
if(i != -1)
{
s32 i = getListIndex(name);
if(i == -1)
return false;
+ m_dirty = true;
delete m_lists[i];
m_lists.erase(m_lists.begin() + i);
return true;