diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index e89368a4b6..9c1154b585 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -178,12 +178,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments UUID itemID = UUID.Zero; if (sp != null) { - foreach (SceneObjectGroup grp in sp.GetAttachments(AttachmentPt)) + foreach(SceneObjectGroup grp in sp.Attachments) { - itemID = grp.GetFromItemID(); - if (itemID != UUID.Zero) - DetachSingleAttachmentToInv(itemID, remoteClient); + if (grp.GetAttachmentPoint() == (byte)AttachmentPt) + { + itemID = grp.GetFromItemID(); + break; + } } + if (itemID != UUID.Zero) + DetachSingleAttachmentToInv(itemID, remoteClient); } if (group.GetFromItemID() == UUID.Zero) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 485e05ab1c..b5cab84e67 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -459,6 +459,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Now let's make it officially a child agent sp.MakeChildAgent(); + sp.Scene.CleanDroppedAttachments(); + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3343d081ab..3576a88b7c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3162,6 +3162,9 @@ namespace OpenSim.Region.Framework.Scenes } m_eventManager.TriggerOnRemovePresence(agentID); + + CleanDroppedAttachments(); + ForEachClient( delegate(IClientAPI client) { @@ -3408,6 +3411,8 @@ namespace OpenSim.Region.Framework.Scenes if (vialogin) { + CleanDroppedAttachments(); + if (TestBorderCross(agent.startpos, Cardinals.E)) { Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); @@ -4984,5 +4989,36 @@ namespace OpenSim.Region.Framework.Scenes throw new Exception(error); } } + + public void CleanDroppedAttachments() + { + List objectsToDelete = + new List(); + + ForEachSOG(delegate (SceneObjectGroup grp) + { + if (grp.RootPart.Shape.State != 0) + { + if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) + { + objectsToDelete.Add(grp); + return; + } + + ScenePresence sp = GetScenePresence(agentID); + if (sp == null) + { + objectsToDelete.Add(grp); + return; + } + } + }); + + foreach (SceneObjectGroup grp in objectsToDelete) + { + m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); + DeleteSceneObject(grp, true); + } + } } }