From 733a8c9f898de941fe828cb6f2356452b3ab0ad9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Jun 2012 23:01:12 +0100 Subject: [PATCH] Rather than iterating through all SOGs in the scene looking for the one that matches out fromItemID on detach, go through the agent's attachment sog list instead. --- .../Avatar/Attachments/AttachmentsModule.cs | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 41ec727e67..5b1235d087 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -666,34 +666,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (itemID == UUID.Zero) // If this happened, someone made a mistake.... return; - // We can NOT use the dictionries here, as we are looking - // for an entity by the fromAssetID, which is NOT the prim UUID - EntityBase[] detachEntities = m_scene.GetEntities(); - SceneObjectGroup group; - lock (sp.AttachmentsSyncLock) { - foreach (EntityBase entity in detachEntities) + List attachments = sp.GetAttachments(); + + foreach (SceneObjectGroup group in attachments) { - if (entity is SceneObjectGroup) + if (group.FromItemID == itemID) { - group = (SceneObjectGroup)entity; - if (group.FromItemID == itemID) - { - m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); - sp.RemoveAttachment(group); - m_scene.DeleteSceneObject(group, false); + m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); + sp.RemoveAttachment(group); + m_scene.DeleteSceneObject(group, false); - // Prepare sog for storage - group.AttachedAvatar = UUID.Zero; - group.RootPart.SetParentLocalId(0); - group.IsAttachment = false; - group.AbsolutePosition = group.RootPart.AttachedPos; + // Prepare sog for storage + group.AttachedAvatar = UUID.Zero; + group.RootPart.SetParentLocalId(0); + group.IsAttachment = false; + group.AbsolutePosition = group.RootPart.AttachedPos; - UpdateKnownItem(sp, group, true); + UpdateKnownItem(sp, group, true); - return; - } + return; } } }