aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-04-16 23:15:13 +0100
committerJustin Clark-Casey (justincc)2010-04-16 23:15:13 +0100
commit57c293d604874c8033a602d1cea6f5250769ff14 (patch)
treee5da635f17ceba90715e8910612b83ea4a0f2dc6 /OpenSim
parentminor: correctly print out missing item id when it can't be found rather than... (diff)
downloadopensim-SC_OLD-57c293d604874c8033a602d1cea6f5250769ff14.zip
opensim-SC_OLD-57c293d604874c8033a602d1cea6f5250769ff14.tar.gz
opensim-SC_OLD-57c293d604874c8033a602d1cea6f5250769ff14.tar.bz2
opensim-SC_OLD-57c293d604874c8033a602d1cea6f5250769ff14.tar.xz
refactor: crudely move DetachSingleAttachmentToGround() over to the AttachmentsModule
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs32
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs4
4 files changed, 40 insertions, 33 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 37f790d..f8fb7ca 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -341,6 +341,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
341 DetachSingleAttachmentToInv(itemID, remoteClient); 341 DetachSingleAttachmentToInv(itemID, remoteClient);
342 } 342 }
343 343
344 public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
345 {
346 SceneObjectPart part = m_scene.GetSceneObjectPart(itemID);
347 if (part == null || part.ParentGroup == null)
348 return;
349
350 UUID inventoryID = part.ParentGroup.GetFromItemID();
351
352 ScenePresence presence;
353 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
354 {
355 if (!m_scene.Permissions.CanRezObject(
356 part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
357 return;
358
359 presence.Appearance.DetachAttachment(itemID);
360
361 if (m_scene.AvatarFactory != null)
362 {
363 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
364 }
365 part.ParentGroup.DetachToGround();
366
367 List<UUID> uuids = new List<UUID>();
368 uuids.Add(inventoryID);
369 m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids);
370 remoteClient.SendRemoveInventoryItem(inventoryID);
371 }
372
373 m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero);
374 }
375
344 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 376 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
345 // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? 377 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
346 protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) 378 protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 77e9a7e..d43ce1f 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -92,6 +92,13 @@ namespace OpenSim.Region.Framework.Interfaces
92 IClientAPI remoteClient, 92 IClientAPI remoteClient,
93 RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, 93 RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
94 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); 94 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects);
95
96 /// <summary>
97 /// Detach the given item to the ground.
98 /// </summary>
99 /// <param name="itemID"></param>
100 /// <param name="remoteClient"></param>
101 void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient);
95 102
96 /// <summary> 103 /// <summary>
97 /// Update the user inventory to the attachment of an item 104 /// Update the user inventory to the attachment of an item
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index a90c4b3..e3f1636 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1873,36 +1873,6 @@ namespace OpenSim.Region.Framework.Scenes
1873 EventManager.TriggerOnAttach(localID, itemID, avatarID); 1873 EventManager.TriggerOnAttach(localID, itemID, avatarID);
1874 } 1874 }
1875 1875
1876 public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
1877 {
1878 SceneObjectPart part = GetSceneObjectPart(itemID);
1879 if (part == null || part.ParentGroup == null)
1880 return;
1881
1882 UUID inventoryID = part.ParentGroup.GetFromItemID();
1883
1884 ScenePresence presence;
1885 if (TryGetScenePresence(remoteClient.AgentId, out presence))
1886 {
1887 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
1888 return;
1889
1890 presence.Appearance.DetachAttachment(itemID);
1891 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
1892 if (ava != null)
1893 {
1894 ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
1895 }
1896 part.ParentGroup.DetachToGround();
1897
1898 List<UUID> uuids = new List<UUID>();
1899 uuids.Add(inventoryID);
1900 InventoryService.DeleteItems(remoteClient.AgentId, uuids);
1901 remoteClient.SendRemoveInventoryItem(inventoryID);
1902 }
1903 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
1904 }
1905
1906 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 1876 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
1907 { 1877 {
1908 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); 1878 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 23a4ee9..89eb54d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -443,9 +443,7 @@ namespace OpenSim.Region.Framework.Scenes
443 { 443 {
444 SceneObjectGroup group = GetGroupByPrim(objectLocalID); 444 SceneObjectGroup group = GetGroupByPrim(objectLocalID);
445 if (group != null) 445 if (group != null)
446 { 446 m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient);
447 m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient);
448 }
449 } 447 }
450 448
451 protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) 449 protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient)