From 57c293d604874c8033a602d1cea6f5250769ff14 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 16 Apr 2010 23:15:13 +0100 Subject: [PATCH] refactor: crudely move DetachSingleAttachmentToGround() over to the AttachmentsModule --- .../Avatar/Attachments/AttachmentsModule.cs | 32 +++++++++++++++++++ .../Interfaces/IAttachmentsModule.cs | 7 ++++ .../Framework/Scenes/Scene.Inventory.cs | 30 ----------------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 +-- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 37f790d67a..f8fb7ca5fd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -341,6 +341,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments DetachSingleAttachmentToInv(itemID, remoteClient); } + public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); + if (part == null || part.ParentGroup == null) + return; + + UUID inventoryID = part.ParentGroup.GetFromItemID(); + + ScenePresence presence; + if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) + { + if (!m_scene.Permissions.CanRezObject( + part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) + return; + + presence.Appearance.DetachAttachment(itemID); + + if (m_scene.AvatarFactory != null) + { + m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } + part.ParentGroup.DetachToGround(); + + List uuids = new List(); + uuids.Add(inventoryID); + m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); + remoteClient.SendRemoveInventoryItem(inventoryID); + } + + m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); + } + // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 77e9a7ec32..d43ce1fa0b 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -92,6 +92,13 @@ namespace OpenSim.Region.Framework.Interfaces IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); + + /// + /// Detach the given item to the ground. + /// + /// + /// + void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); /// /// Update the user inventory to the attachment of an item diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a90c4b3402..e3f1636e54 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1873,36 +1873,6 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnAttach(localID, itemID, avatarID); } - public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) - { - SceneObjectPart part = GetSceneObjectPart(itemID); - if (part == null || part.ParentGroup == null) - return; - - UUID inventoryID = part.ParentGroup.GetFromItemID(); - - ScenePresence presence; - if (TryGetScenePresence(remoteClient.AgentId, out presence)) - { - if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) - return; - - presence.Appearance.DetachAttachment(itemID); - IAvatarFactory ava = RequestModuleInterface(); - if (ava != null) - { - ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); - } - part.ParentGroup.DetachToGround(); - - List uuids = new List(); - uuids.Add(inventoryID); - InventoryService.DeleteItems(remoteClient.AgentId, uuids); - remoteClient.SendRemoveInventoryItem(inventoryID); - } - SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); - } - public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) { EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 23a4ee9274..89eb54d1dc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -443,9 +443,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup group = GetGroupByPrim(objectLocalID); if (group != null) - { - m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient); - } + m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient); } protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient)