From 395f343498bc429c0360201991147c6e089b0730 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Mar 2010 00:07:47 +0000 Subject: refactor: Move DetachSingleAttachmentToInv to region module need to rationalize method names later --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 20 +------------ OpenSim/Region/Framework/Scenes/Scene.cs | 18 ++++++----- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 35 +--------------------- 3 files changed, 12 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index bd3b433..dad0efd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1858,7 +1858,7 @@ namespace OpenSim.Region.Framework.Scenes if (att == null) { - DetachSingleAttachmentToInv(itemID, remoteClient); + AttachmentsModule.ShowDetachInUserInventory(itemID, remoteClient); return UUID.Zero; } @@ -1904,24 +1904,6 @@ namespace OpenSim.Region.Framework.Scenes SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); } - public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) - { - ScenePresence presence; - if (TryGetAvatar(remoteClient.AgentId, out presence)) - { - presence.Appearance.DetachAttachment(itemID); - - // Save avatar attachment information - if (m_AvatarFactory != null) - { - m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID); - m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); - } - } - - m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient); - } - public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) { EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c83132f..7c0375e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2646,10 +2646,12 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) { client.OnRezSingleAttachmentFromInv += RezSingleAttachment; - client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; - client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; + client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; client.OnObjectAttach += m_sceneGraph.AttachObject; client.OnObjectDetach += m_sceneGraph.DetachObject; + + if (AttachmentsModule != null) + client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; } public virtual void SubscribeToClientTeleportEvents(IClientAPI client) @@ -2696,8 +2698,7 @@ namespace OpenSim.Region.Framework.Scenes } protected virtual void UnsubscribeToClientEvents(IClientAPI client) - { - + { } /// @@ -2719,7 +2720,6 @@ namespace OpenSim.Region.Framework.Scenes UnSubscribeToClientNetworkEvents(client); - // EventManager.TriggerOnNewClient(client); } @@ -2799,12 +2799,14 @@ namespace OpenSim.Region.Framework.Scenes } public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) - { - client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; + { client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; - client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; + client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; client.OnObjectAttach -= m_sceneGraph.AttachObject; client.OnObjectDetach -= m_sceneGraph.DetachObject; + + if (AttachmentsModule != null) + client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; } public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 48744d7..380722d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -452,7 +452,7 @@ namespace OpenSim.Region.Framework.Scenes if (group != null) { //group.DetachToGround(); - m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); + m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); } } @@ -574,39 +574,6 @@ namespace OpenSim.Region.Framework.Scenes return null; } - // 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?? - public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) - { - 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 - // - List detachEntities = GetEntities(); - SceneObjectGroup group; - - foreach (EntityBase entity in detachEntities) - { - if (entity is SceneObjectGroup) - { - group = (SceneObjectGroup)entity; - if (group.GetFromItemID() == itemID) - { - m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero); - group.DetachToInventoryPrep(); - m_log.Debug("[DETACH]: Saving attachpoint: " + - ((uint)group.GetAttachmentPoint()).ToString()); - m_parentScene.UpdateKnownItem(remoteClient, group, - group.GetFromItemID(), group.OwnerID); - m_parentScene.DeleteSceneObject(group, false); - return; - } - } - } - } - protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) { ScenePresence newAvatar = null; -- cgit v1.1