From e7a515bab0e46c228f8f543397f97b7ba2f0df3c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 30 Aug 2011 22:06:24 +0100
Subject: Fix bug where attachments were remaining on the avatar after being
dropped.
If the inventory service is configured not to allow deletion then these will not disappear from inventory
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++++++++--
.../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 14 ++++++++++----
2 files changed, 20 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2d5eb18..b7a7f77 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -451,6 +451,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient)
{
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
+// remoteClient.Name, sceneObjectID);
+
SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID);
if (so == null)
@@ -461,6 +465,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
UUID inventoryID = so.GetFromItemID();
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
+// so.Name, so.LocalId, inventoryID);
+
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
@@ -468,7 +476,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
return;
- bool changed = presence.Appearance.DetachAttachment(sceneObjectID);
+ bool changed = presence.Appearance.DetachAttachment(inventoryID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
@@ -485,7 +493,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
///
- /// Detach the given scene objet to the ground.
+ /// Detach the given scene object to the ground.
///
///
/// The caller has to take care of all the other work in updating avatar appearance, inventory, etc.
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index bb53601..b1f9197 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -138,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
- // Check status on scene presence
+ // Check scene presence status
Assert.That(m_presence.HasAttachments(), Is.True);
List attachments = m_presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(1));
@@ -149,12 +149,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attSo.UsesPhysics, Is.False);
Assert.That(attSo.IsTemporary, Is.False);
- // Check item status
+ // Check appearance status
Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest));
}
[Test]
- public void TestDetachAttachmentToScene()
+ public void TestDetachAttachmentToGround()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@@ -168,15 +168,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
UserInventoryHelpers.CreateInventoryItem(
scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
+// Check item status
+ Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Not.Null);
+
UUID attSoId = m_attMod.RezSingleAttachmentFromInventory(
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient);
- // Check status on scene presence
+ // Check scene presence status
Assert.That(m_presence.HasAttachments(), Is.False);
List attachments = m_presence.Attachments;
Assert.That(attachments.Count, Is.EqualTo(0));
+ // Check appearance status
+ Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0));
+
// Check item status
Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null);
--
cgit v1.1