From e0a85fae01287fb06c0d29fc309067d18286b100 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Tue, 17 Sep 2019 19:02:01 +0200 Subject: [PATCH] Inventory: Undo prediction on drop --- src/inventorymanager.cpp | 12 ++++++------ src/server.cpp | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index 02cb9e3a4..fccfdea16 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -646,8 +646,6 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if (src_can_take_count != -1 && src_can_take_count < take_count) take_count = src_can_take_count; - int actually_dropped_count = 0; - // Update item due executed callbacks src_item = list_from->getItem(from_i); @@ -656,10 +654,12 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame item1.count = take_count; if(PLAYER_TO_SA(player)->item_OnDrop(item1, player, player->getBasePosition())) { - actually_dropped_count = take_count - item1.count; + int actually_dropped_count = take_count - item1.count; if (actually_dropped_count == 0) { infostream<<"Actually dropped no items"<setInventoryModified(from_inv); return; } @@ -670,9 +670,10 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if (item2.count != actually_dropped_count) errorstream<<"Could not take dropped count of items"<setInventoryModified(from_inv); } + + src_item.count = actually_dropped_count; + mgr->setInventoryModified(from_inv); } infostream<<"IDropAction::apply(): dropped " @@ -681,7 +682,6 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame <<" i="<setModified(true); + player->inventory.setModified(true); // Updates are sent in ServerEnvironment::step() } break;