diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index ab4ed66ae6..7c6295d6a9 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -383,9 +383,11 @@ namespace OpenSim.Framework // DEBUG OFF /// - /// Get a list of the attachments, note that there may be - /// duplicate attachpoints + /// Get a list of the attachments. /// + /// + /// There may be duplicate attachpoints + /// public List GetAttachments() { List alist = new List(); @@ -487,6 +489,7 @@ namespace OpenSim.Framework // And remove the list if there are no more attachments here if (m_attachments[kvp.Key].Count == 0) m_attachments.Remove(kvp.Key); + return true; } } diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2d5eb18f50..b7a7f770a3 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 bb536013fa..b1f9197833 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);