mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
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();
|
||||
|
||||
// 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);
|
||||
if (i != -1) {
|
||||
m_lists[i]->checkResizeLock();
|
||||
delete m_lists[i];
|
||||
|
||||
m_lists[i] = new InventoryList(name, size, m_itemdef);
|
||||
m_lists[i]->setModified();
|
||||
return m_lists[i];
|
||||
InventoryList *list = m_lists[i];
|
||||
list->setSize(size);
|
||||
list->clearItems();
|
||||
return list;
|
||||
}
|
||||
|
||||
//don't create list with invalid name
|
||||
|
Loading…
Reference in New Issue
Block a user