From 760010d6fb6aac313d79ce0a4d0016d3809246a0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 22 Mar 2012 22:33:37 +0000
Subject: Fix llGiveInventory() so that it checks the destination part for
AllowInventoryDrop, not the source.
This allows llAllowInventoryDrop() to work.
Regression test added for this case.
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 10 ++--
.../Shared/Tests/LSL_ApiInventoryTests.cs | 59 +++++++++++++++++++++-
2 files changed, 63 insertions(+), 6 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 6ae4adc..d10136f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1210,9 +1210,9 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Copy a task (prim) inventory item to another task (prim)
///
- ///
- ///
- ///
+ /// ID of destination part
+ /// Source part
+ /// Source item id to transfer
public void MoveTaskInventoryItem(UUID destId, SceneObjectPart part, UUID itemId)
{
TaskInventoryItem srcTaskItem = part.Inventory.GetInventoryItem(itemId);
@@ -1240,10 +1240,10 @@ namespace OpenSim.Region.Framework.Scenes
// Can't transfer this
//
- if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0))
+ if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
return;
- if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
+ if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
{
// object cannot copy items to an object owned by a different owner
// unless llAllowInventoryDrop has been called
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index ca27b27..e2d0db2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
/// Test giving inventory from an object to an object where both are owned by the same user.
///
[Test]
- public void TestLlGiveInventorySameOwner()
+ public void TestLlGiveInventoryO2OSameOwner()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@@ -107,5 +107,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
Assert.That(copiedItems.Count, Is.EqualTo(1));
Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName));
}
+
+ ///
+ /// Test giving inventory from an object to an object where they have different owners
+ ///
+ [Test]
+ public void TestLlGiveInventoryO2ODifferentOwners()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ UUID user1Id = TestHelpers.ParseTail(0x1);
+ UUID user2Id = TestHelpers.ParseTail(0x2);
+ string inventoryItemName = "item1";
+
+ SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10);
+ m_scene.AddSceneObject(so1);
+ LSL_Api api = new LSL_Api();
+ api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID);
+
+ // Create an object embedded inside the first
+ UUID itemId = TestHelpers.ParseTail(0x20);
+ TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id);
+
+ // Create a second object
+ SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100);
+ m_scene.AddSceneObject(so2);
+ LSL_Api api2 = new LSL_Api();
+ api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, so2.RootPart.UUID);
+
+ // *** Firstly, we test where llAllowInventoryDrop() has not been called. ***
+ api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);
+
+ {
+ // Item has copy permissions so original should stay intact.
+ List originalItems = so1.RootPart.Inventory.GetInventoryItems();
+ Assert.That(originalItems.Count, Is.EqualTo(1));
+
+ // Should have not copied
+ List copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName);
+ Assert.That(copiedItems.Count, Is.EqualTo(0));
+ }
+
+ // *** Secondly, we turn on allow inventory drop in the target and retest. ***
+ api2.llAllowInventoryDrop(1);
+ api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);
+
+ {
+ // Item has copy permissions so original should stay intact.
+ List originalItems = so1.RootPart.Inventory.GetInventoryItems();
+ Assert.That(originalItems.Count, Is.EqualTo(1));
+
+ // Should now have copied.
+ List copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName);
+ Assert.That(copiedItems.Count, Is.EqualTo(1));
+ Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName));
+ }
+ }
}
}
\ No newline at end of file
--
cgit v1.1