forked from Mirrorlandia_minetest/minetest
Inventory: Allow InvRef:set_list with new_size >= old_size (#13497)
Fixes a regression introduced by enforced checks to work with valid pointers within inventory actions.
This commit is contained in:
parent
f393214fef
commit
95a9f4ab7c
@ -964,15 +964,16 @@ InventoryList * Inventory::addList(const std::string &name, u32 size)
|
|||||||
{
|
{
|
||||||
setModified();
|
setModified();
|
||||||
|
|
||||||
// Remove existing lists
|
// Reset existing lists instead of re-creating if possible.
|
||||||
|
// InventoryAction::apply() largely caches InventoryList pointers which must not be
|
||||||
|
// invalidated by Lua API calls (e.g. InvRef:set_list), hence do resize & clear which
|
||||||
|
// also include the neccessary resize lock checks.
|
||||||
s32 i = getListIndex(name);
|
s32 i = getListIndex(name);
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
m_lists[i]->checkResizeLock();
|
InventoryList *list = m_lists[i];
|
||||||
delete m_lists[i];
|
list->setSize(size);
|
||||||
|
list->clearItems();
|
||||||
m_lists[i] = new InventoryList(name, size, m_itemdef);
|
return list;
|
||||||
m_lists[i]->setModified();
|
|
||||||
return m_lists[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//don't create list with invalid name
|
//don't create list with invalid name
|
||||||
|
Loading…
Reference in New Issue
Block a user