1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Inventory: Release resizes-locked lists on all on_-callbacks

This commit is contained in:
Desour 2023-10-23 00:31:10 +02:00 committed by DS
parent 1a562ca144
commit a464b41d99

View file

@ -592,16 +592,21 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
Report move to endpoints Report move to endpoints
*/ */
list_to.reset(); list_to.reset();
list_from.reset();
// Source = destination => move // Source = destination => move
if (from_inv == to_inv) { if (from_inv == to_inv) {
onMove(count, player); onMove(count, player);
if (did_swap) { if (did_swap) {
// Item is now placed in source list // Item is now placed in source list
src_item = list_from->getItem(from_i); list_from = get_borrow_checked_invlist(inv_from, from_list);
swapDirections(); if (list_from) {
onMove(src_item.count, player); src_item = list_from->getItem(from_i);
swapDirections(); list_from.reset();
swapDirections();
onMove(src_item.count, player);
swapDirections();
}
} }
mgr->setInventoryModified(from_inv); mgr->setInventoryModified(from_inv);
} else { } else {
@ -616,10 +621,14 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
src_item.count = src_item_count; src_item.count = src_item_count;
if (did_swap) { if (did_swap) {
// Item is now placed in source list // Item is now placed in source list
src_item = list_from->getItem(from_i); list_from = get_borrow_checked_invlist(inv_from, from_list);
swapDirections(); if (list_from) {
onPutAndOnTake(src_item, player); src_item = list_from->getItem(from_i);
swapDirections(); list_from.reset();
swapDirections();
onPutAndOnTake(src_item, player);
swapDirections();
}
} }
mgr->setInventoryModified(to_inv); mgr->setInventoryModified(to_inv);
mgr->setInventoryModified(from_inv); mgr->setInventoryModified(from_inv);