mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Inventory: Make addList() consistent (#11382)
Fixes list clearing for inv:set_list() using same size, since 2db6b07
.
addList() now clears the list in all cases. Use setSize() to resize without clearing.
This commit is contained in:
parent
72927b73ca
commit
f2fd443262
3 changed files with 9 additions and 12 deletions
|
@ -938,19 +938,16 @@ void Inventory::deSerialize(std::istream &is)
|
|||
InventoryList * Inventory::addList(const std::string &name, u32 size)
|
||||
{
|
||||
setModified();
|
||||
|
||||
// Remove existing lists
|
||||
s32 i = getListIndex(name);
|
||||
if(i != -1)
|
||||
{
|
||||
if(m_lists[i]->getSize() != size)
|
||||
{
|
||||
delete m_lists[i];
|
||||
m_lists[i] = new InventoryList(name, size, m_itemdef);
|
||||
m_lists[i]->setModified();
|
||||
}
|
||||
if (i != -1) {
|
||||
delete m_lists[i];
|
||||
m_lists[i] = new InventoryList(name, size, m_itemdef);
|
||||
m_lists[i]->setModified();
|
||||
return m_lists[i];
|
||||
}
|
||||
|
||||
|
||||
//don't create list with invalid name
|
||||
if (name.find(' ') != std::string::npos)
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue