From: Perttu Ahola Date: Fri, 1 Jun 2012 21:42:56 +0000 (+0300) Subject: Properly handle dropping of items from nodes, and disallow moving items directly... X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=5f3c70061deea330a23be33164a34f675721d452;p=zefram%2Fminetest%2Fminetest_engine.git Properly handle dropping of items from nodes, and disallow moving items directly between nodes --- diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index 46f744f8..b6740f1b 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -202,6 +202,14 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame // Handle node metadata move if(from_inv.type == InventoryLocation::NODEMETA && + to_inv.type == InventoryLocation::NODEMETA && + from_inv.p != to_inv.p) + { + errorstream<<"Directly moving items between two nodes is " + <<"disallowed."<changeItem(from_i, ItemStack()); + + // Handle node metadata take + if(from_inv.type == InventoryLocation::NODEMETA) + { + lua_State *L = player->getEnv()->getLua(); + int count0 = count; + if(count0 == 0) + count0 = list_from->getItem(from_i).count; + infostream<getDescription()<<" dropping "<takeItem(from_i, count); + { + // Take item from source list + if(count == 0) + item1 = list_from->changeItem(from_i, ItemStack()); + else + item1 = list_from->takeItem(from_i, count); + } // Drop the item and apply the returned ItemStack ItemStack item2 = item1;