From 1de68b34d959570c6dc5de42e8dac5e36f960273 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 22:25:38 +0100 Subject: refactor: migrate DropObject handling fully into AttachmentsModule from Scene --- OpenSim/Framework/IClientAPI.cs | 2 +- .../Avatar/Attachments/AttachmentsModule.cs | 21 ++++++++++----------- .../Attachments/Tests/AttachmentsModuleTests.cs | 7 ++----- .../Framework/Interfaces/IAttachmentsModule.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 2 -- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 7 ------- 6 files changed, 17 insertions(+), 30 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a0d10ed..150ff1b 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID); - public delegate UUID RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); + public delegate ISceneEntity RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); public delegate void RezMultipleAttachmentsFromInv(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects); diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index b7a7f77..02fd387 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Scene m_scene = null; + private Scene m_scene; private IDialogModule m_dialogModule; public string Name { get { return "Attachments Module"; } } @@ -83,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnObjectAttach += AttachObject; client.OnObjectDetach += DetachObject; client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; + client.OnObjectDrop += DetachSingleAttachmentToGround; } public void UnsubscribeFromClientEvents(IClientAPI client) @@ -92,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnObjectAttach -= AttachObject; client.OnObjectDetach -= DetachObject; client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; + client.OnObjectDrop -= DetachSingleAttachmentToGround; } /// @@ -250,12 +252,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true); } - public UUID RezSingleAttachmentFromInventory( + public ISceneEntity RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) { // m_log.DebugFormat( @@ -269,7 +271,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_log.ErrorFormat( "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", remoteClient.Name, remoteClient.AgentId); - return UUID.Zero; + return null; } // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should @@ -286,10 +288,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); } - if (null == att) - return UUID.Zero; - else - return att.UUID; + return att; } private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( @@ -449,13 +448,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) + public void DetachSingleAttachmentToGround(uint soLocalId, IClientAPI remoteClient) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", // remoteClient.Name, sceneObjectID); - SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); + SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); if (so == null) return; @@ -489,7 +488,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments remoteClient.SendRemoveInventoryItem(inventoryID); } - m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); + m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero); } /// diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b1f9197..b0146a1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -168,12 +168,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); -// Check item status - Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Not.Null); - - UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( + ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient); + m_attMod.DetachSingleAttachmentToGround(so.LocalId, m_presence.ControllingClient); // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.False); diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 86f5a0f..c910289 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// The scene object that was attached. Null if the scene object could not be found - UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); + ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); /// /// Rez an attachment from user inventory @@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Interfaces /// False is required so that we don't attempt to update information when a user enters a scene with the /// attachment already correctly set up in inventory. /// The uuid of the scene object that was attached. Null if the scene object could not be found - UUID RezSingleAttachmentFromInventory( + ISceneEntity RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); /// @@ -105,9 +105,9 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Detach the given item to the ground. /// - /// + /// /// - void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient); + void DetachSingleAttachmentToGround(uint objectLocalID, IClientAPI remoteClient); /// /// Detach the given item so that it remains in the user's inventory. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 45d1a0e..e0250de 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2772,7 +2772,6 @@ namespace OpenSim.Region.Framework.Scenes client.OnUndo += m_sceneGraph.HandleUndo; client.OnRedo += m_sceneGraph.HandleRedo; client.OnObjectDescription += m_sceneGraph.PrimDescription; - client.OnObjectDrop += m_sceneGraph.DropObject; client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable; client.OnObjectOwner += ObjectOwner; } @@ -2899,7 +2898,6 @@ namespace OpenSim.Region.Framework.Scenes client.OnUndo -= m_sceneGraph.HandleUndo; client.OnRedo -= m_sceneGraph.HandleRedo; client.OnObjectDescription -= m_sceneGraph.PrimDescription; - client.OnObjectDrop -= m_sceneGraph.DropObject; client.OnObjectIncludeInSearch -= m_sceneGraph.MakeObjectSearchable; client.OnObjectOwner -= ObjectOwner; } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0582586..76ed55c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -548,13 +548,6 @@ namespace OpenSim.Region.Framework.Scenes m_activeScripts += number; } - public void DropObject(uint objectLocalID, IClientAPI remoteClient) - { - SceneObjectGroup group = GetGroupByPrim(objectLocalID); - if (group != null) - m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient); - } - protected internal void HandleUndo(IClientAPI remoteClient, UUID primId) { if (primId != UUID.Zero) -- cgit v1.1