1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-13 16:45:20 +02:00

Make players check inventory modification properly

This commit is contained in:
ShadowNinja
2014-09-02 12:53:20 -04:00
parent 8b3135a643
commit e9c9b66ae9
6 changed files with 39 additions and 9 deletions

View File

@@ -831,6 +831,7 @@ Inventory::~Inventory()
void Inventory::clear()
{
m_dirty = true;
for(u32 i=0; i<m_lists.size(); i++)
{
delete m_lists[i];
@@ -840,6 +841,7 @@ void Inventory::clear()
void Inventory::clearContents()
{
m_dirty = true;
for(u32 i=0; i<m_lists.size(); i++)
{
InventoryList *list = m_lists[i];
@@ -852,12 +854,14 @@ void Inventory::clearContents()
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)
@@ -865,6 +869,7 @@ 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++)
@@ -945,6 +950,7 @@ void Inventory::deSerialize(std::istream &is)
InventoryList * Inventory::addList(const std::string &name, u32 size)
{
m_dirty = true;
s32 i = getListIndex(name);
if(i != -1)
{
@@ -990,6 +996,7 @@ bool Inventory::deleteList(const std::string &name)
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;