diff options
Diffstat (limited to 'src/inventorymanager.cpp')
-rw-r--r-- | src/inventorymanager.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index 35e986b56..02b887ac2 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -238,8 +238,10 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if(from_inv.type == InventoryLocation::DETACHED) { lua_State *L = player->getEnv()->getLua(); + ItemStack src_item = list_from->getItem(from_i); + src_item.count = try_take_count; src_can_take_count = scriptapi_detached_inventory_allow_take( - L, from_inv.name, from_list, from_i, try_take_count, player); + L, from_inv.name, from_list, from_i, src_item, player); } } @@ -272,8 +274,10 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if(from_inv.type == InventoryLocation::NODEMETA) { lua_State *L = player->getEnv()->getLua(); + ItemStack src_item = list_from->getItem(from_i); + src_item.count = try_take_count; src_can_take_count = scriptapi_nodemeta_inventory_allow_take( - L, from_inv.p, from_list, from_i, try_take_count, player); + L, from_inv.p, from_list, from_i, src_item, player); } } @@ -300,6 +304,9 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame } count = new_count; + + ItemStack src_item = list_from->getItem(from_i); + src_item.count = count; /* Perform actual move @@ -341,8 +348,6 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if(to_inv.type == InventoryLocation::DETACHED) { lua_State *L = player->getEnv()->getLua(); - ItemStack src_item = list_from->getItem(from_i); - src_item.count = count; scriptapi_detached_inventory_on_put( L, to_inv.name, to_list, to_i, src_item, player); } @@ -350,10 +355,8 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if(from_inv.type == InventoryLocation::DETACHED) { lua_State *L = player->getEnv()->getLua(); - ItemStack src_item = list_from->getItem(from_i); - src_item.count = count; scriptapi_detached_inventory_on_take( - L, from_inv.name, from_list, from_i, src_item.count, player); + L, from_inv.name, from_list, from_i, src_item, player); } } @@ -374,8 +377,6 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if(to_inv.type == InventoryLocation::NODEMETA) { lua_State *L = player->getEnv()->getLua(); - ItemStack src_item = list_from->getItem(from_i); - src_item.count = count; scriptapi_nodemeta_inventory_on_put( L, to_inv.p, to_list, to_i, src_item, player); } @@ -383,10 +384,8 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame else if(from_inv.type == InventoryLocation::NODEMETA) { lua_State *L = player->getEnv()->getLua(); - ItemStack src_item = list_from->getItem(from_i); - src_item.count = count; scriptapi_nodemeta_inventory_on_take( - L, from_inv.p, from_list, from_i, src_item.count, player); + L, from_inv.p, from_list, from_i, src_item, player); } } @@ -485,16 +484,20 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame if(from_inv.type == InventoryLocation::DETACHED) { lua_State *L = player->getEnv()->getLua(); + ItemStack src_item = list_from->getItem(from_i); + src_item.count = take_count; src_can_take_count = scriptapi_detached_inventory_allow_take( - L, from_inv.name, from_list, from_i, take_count, player); + L, from_inv.name, from_list, from_i, src_item, player); } // Source is nodemeta if(from_inv.type == InventoryLocation::NODEMETA) { lua_State *L = player->getEnv()->getLua(); + ItemStack src_item = list_from->getItem(from_i); + src_item.count = take_count; src_can_take_count = scriptapi_nodemeta_inventory_allow_take( - L, from_inv.p, from_list, from_i, take_count, player); + L, from_inv.p, from_list, from_i, src_item, player); } if(src_can_take_count < take_count) @@ -502,6 +505,8 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame int actually_dropped_count = 0; + ItemStack src_item = list_from->getItem(from_i); + // Drop the item ItemStack item1 = list_from->getItem(from_i); if(scriptapi_item_on_drop(player->getEnv()->getLua(), item1, player, @@ -528,6 +533,8 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame <<" list=\""<<from_list<<"\"" <<" i="<<from_i <<std::endl; + + src_item.count = actually_dropped_count; /* Report drop to endpoints @@ -538,7 +545,7 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame { lua_State *L = player->getEnv()->getLua(); scriptapi_detached_inventory_on_take( - L, from_inv.name, from_list, from_i, actually_dropped_count, player); + L, from_inv.name, from_list, from_i, src_item, player); } // Source is nodemeta @@ -546,7 +553,7 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame { lua_State *L = player->getEnv()->getLua(); scriptapi_nodemeta_inventory_on_take( - L, from_inv.p, from_list, from_i, actually_dropped_count, player); + L, from_inv.p, from_list, from_i, src_item, player); } } |