diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 530a21ce70..d458364052 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
@@ -131,26 +132,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
else
{
- m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID);
+ m_log.DebugFormat("[ATTACHMENTS MODULE]: AttachObject found no such scene object {0}", objectLocalID);
return false;
}
return true;
- }
-
- ///
- /// Update the user inventory to reflect an attachment
- ///
- ///
- ///
- ///
- ///
- ///
+ }
+
public UUID SetAttachmentInventoryStatus(
SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
m_log.DebugFormat(
- "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
+ "[ATTACHMENTS MODULEY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
remoteClient.Name, att.Name, itemID);
if (!att.IsDeleted)
@@ -184,19 +177,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (UUID.Zero == itemID)
{
- m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
+ m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment. Error inventory item ID.");
return;
}
if (0 == AttachmentPt)
{
- m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point.");
+ m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment. Error attachment point.");
return;
}
if (null == att.RootPart)
{
- m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!");
+ m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!");
return;
}
@@ -212,5 +205,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
}
}
+
+ public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
+ {
+ ScenePresence presence;
+ if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence))
+ {
+ presence.Appearance.DetachAttachment(itemID);
+
+ // Save avatar attachment information
+ if (m_scene.AvatarFactory != null)
+ {
+ m_log.Debug("[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID);
+ m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
+ }
+ }
+
+ DetachSingleAttachmentToInv(itemID, remoteClient);
+ }
+
+ // 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??
+ protected 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 = m_scene.GetEntities();
+ SceneObjectGroup group;
+
+ foreach (EntityBase entity in detachEntities)
+ {
+ if (entity is SceneObjectGroup)
+ {
+ group = (SceneObjectGroup)entity;
+ if (group.GetFromItemID() == itemID)
+ {
+ m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
+ group.DetachToInventoryPrep();
+ m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
+ m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID);
+ m_scene.DeleteSceneObject(group, false);
+ return;
+ }
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 5e5df4bcf5..367ff3da5f 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -57,5 +57,16 @@ namespace OpenSim.Region.Framework.Interfaces
///
UUID SetAttachmentInventoryStatus(
SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
+
+ ///
+ /// Update the user inventory to show a detach.
+ ///
+ ///
+ /// A
+ ///
+ ///
+ /// A
+ ///
+ void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient);
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index bd3b433b5b..dad0efd6fa 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 c83132f97d..7c0375ec22 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 48744d71a9..380722d53b 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;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0eee1471c1..8217248671 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2931,8 +2931,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
- m_ScriptEngine.World.DetachSingleAttachmentToInv(itemID,
- presence.ControllingClient);
+ IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
+ if (attachmentsModule != null)
+ attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient);
}
}