From ae614c1264a2c4d06f019f2a91ad481cc2f96770 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:37:53 +0100 Subject: refactor: simplify DetachSingleAttachmentToGround() by retrieving the scene object group direct --- .../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++++--------- .../Region/Framework/Interfaces/IAttachmentsModule.cs | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 732e3e3..42a18c5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -449,29 +449,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) { - SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); - if (part == null || part.ParentGroup == null) + SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); + + if (so == null) return; - if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId) + if (so.RootPart.AttachedAvatar != remoteClient.AgentId) return; - UUID inventoryID = part.ParentGroup.GetFromItemID(); + UUID inventoryID = so.GetFromItemID(); ScenePresence presence; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { if (!m_scene.Permissions.CanRezObject( - part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) + so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) return; - bool changed = presence.Appearance.DetachAttachment(itemID); + bool changed = presence.Appearance.DetachAttachment(sceneObjectID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - part.ParentGroup.DetachToGround(); + so.DetachToGround(); List uuids = new List(); uuids.Add(inventoryID); @@ -479,7 +480,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments remoteClient.SendRemoveInventoryItem(inventoryID); } - m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); + m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 0c82411..86f5a0f 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -105,9 +105,9 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Detach the given item to the ground. /// - /// + /// /// - void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); + void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient); /// /// Detach the given item so that it remains in the user's inventory. -- cgit v1.1