From 5f3ffc195f60ac54492ccb389843f292b0be7511 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:49:11 +0100 Subject: refactor: move SOG.DetachToGround() to AttachmentsModule.DetachSceneObjectToGround() and remove redundant code --- .../Avatar/Attachments/AttachmentsModule.cs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 42a18c5..93920b0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -472,7 +472,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - so.DetachToGround(); + presence.RemoveAttachment(so); + DetachSceneObjectToGround(so, presence); List uuids = new List(); uuids.Add(inventoryID); @@ -482,6 +483,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } + + /// + /// Detach the given scene objet to the ground. + /// + /// + /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. + /// + /// The scene object to detach. + /// The scene presence from which the scene object is being detached. + private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) + { + SceneObjectPart rootPart = so.RootPart; + + rootPart.FromItemID = UUID.Zero; + so.AbsolutePosition = sp.AbsolutePosition; + so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); + rootPart.SetParentLocalId(0); + so.ClearPartAttachmentData(); + rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); + so.HasGroupChanged = true; + rootPart.Rezzed = DateTime.Now; + rootPart.RemFlag(PrimFlags.TemporaryOnRez); + so.AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); + rootPart.ScheduleFullUpdate(); + rootPart.ClearUndoState(); + } // 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?? -- cgit v1.1