Skip to content

Commit

Permalink
Inventory: Release resizes-locked lists on all on_-callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Desour committed Oct 27, 2023
1 parent 1a562ca commit a464b41
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/inventorymanager.cpp
Expand Up @@ -592,16 +592,21 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
Report move to endpoints
*/
list_to.reset();
list_from.reset();

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

0 comments on commit a464b41

Please sign in to comment.