From 36097a8198772d937c82e7bfc6e01a643d7785af Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 3 Oct 2008 13:45:54 +0000 Subject: [PATCH] Prevent attachments to be persisted in the destination region when the avatar is not present there. --- .../Modules/ContentManagementSystem/CMModel.cs | 2 +- OpenSim/Region/Environment/Scenes/InnerScene.cs | 4 ++++ OpenSim/Region/Environment/Scenes/Scene.cs | 8 ++++++++ OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 8 ++++---- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs index 1a41c7b375..ff9423f86d 100644 --- a/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs +++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs @@ -258,7 +258,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement try { // I thought that the DeleteGroup() function would handle all of this, but it doesn't. I'm not sure WHAT it handles. - ((SceneObjectGroup)scene.Entities[uuid]).DetachFromBackup((SceneObjectGroup)scene.Entities[uuid]); + ((SceneObjectGroup)scene.Entities[uuid]).DetachFromBackup(); scene.PhysicsScene.RemovePrim(((SceneObjectGroup)scene.Entities[uuid]).RootPart.PhysActor); scene.SendKiPrimitive(scene.Entities[uuid].LocalId); scene.m_innerScene.DeleteSceneObject(uuid, false); diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index d63544a152..f58f33417f 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -517,6 +517,10 @@ namespace OpenSim.Region.Environment.Scenes group.SetFromAssetID(newAssetID); } group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); + // In case it is later dropped again, don't let + // it get cleaned up + // + group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); } else { diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8f8c89eb51..09ebbee18b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2052,6 +2052,10 @@ namespace OpenSim.Region.Environment.Scenes { if (RootPrim.Shape.State != 0) { + // Never persist + + grp.DetachFromBackup(); + // Attachment ScenePresence sp = GetScenePresence(grp.OwnerID); if (sp != null) @@ -2063,6 +2067,10 @@ namespace OpenSim.Region.Environment.Scenes grp.SetFromAssetID(grp.RootPart.LastOwnerID); AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); } + else + { + RootPrim.AddFlag(PrimFlags.TemporaryOnRez); + } } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 482d936ba6..ebd79e24d5 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -713,7 +713,7 @@ namespace OpenSim.Region.Environment.Scenes // don't attach attachments to child agents if (avatar.IsChildAgent) return; - DetachFromBackup(this); + DetachFromBackup(); m_rootPart.AttachedAvatar = agentID; @@ -955,7 +955,7 @@ namespace OpenSim.Region.Environment.Scenes // code needs a redesign. m_isDeleted = true; - DetachFromBackup(this); + DetachFromBackup(); lock (m_parts) { @@ -1925,9 +1925,9 @@ namespace OpenSim.Region.Environment.Scenes /// Stop this object from being persisted over server restarts. /// /// - public void DetachFromBackup(SceneObjectGroup objectGroup) + public void DetachFromBackup() { - m_scene.EventManager.OnBackup -= objectGroup.ProcessBackup; + m_scene.EventManager.OnBackup -= ProcessBackup; } private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation)