From 1be53b58a7a4c5b7a916c777cdee891b5a6dee26 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jun 2010 17:00:24 +0100 Subject: [PATCH 1/5] Give attachments the same priority as other avatars in BestAvatarResponsiveness policy --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 4780cdd569..7b7677bd6b 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -210,7 +210,10 @@ namespace OpenSim.Region.Framework.Scenes { PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; if (physActor == null || !physActor.IsPhysical) - priority+=100; + priority += 100; + + if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + priority = 1.0; } return priority; } From 8fc5eda2c913ea24125623ae4e529544417ee42a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 9 Jun 2010 10:55:37 -0700 Subject: [PATCH 2/5] Bug fix in attachments: when attaching from inworld the item's parentFolderID was wrong. --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cc7b6485f7..4180d5e066 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1736,7 +1736,11 @@ namespace OpenSim.Region.Framework.Scenes item.AssetType = asset.Type; item.InvType = (int)InventoryType.Object; - item.Folder = UUID.Zero; // Objects folder! + InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); + if (folder != null) + item.Folder = folder.ID; + else // oopsies + item.Folder = UUID.Zero; if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) { From 18bfe58de8208c369c0eb7b22680c51c37c2fe6c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 9 Jun 2010 11:24:37 -0700 Subject: [PATCH 3/5] Bug fix on attachments: don't delete the item from inventory when it's dropped on the ground. --- .../Avatar/Attachments/AttachmentsModule.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f050dcfba3..46d040f7ec 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -375,10 +375,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } part.ParentGroup.DetachToGround(); - List uuids = new List(); - uuids.Add(inventoryID); - m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); - remoteClient.SendRemoveInventoryItem(inventoryID); + // If the item is no-copy we need to delete it from inventory + InventoryItemBase item = m_scene.InventoryService.GetItem(new InventoryItemBase(itemID)); + if (item != null && (item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + List uuids = new List(); + uuids.Add(inventoryID); + m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); + remoteClient.SendRemoveInventoryItem(inventoryID); + } } m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); From 2a71df1285076260f9fa0d04fc66f7ce4018b5f3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 9 Jun 2010 12:22:25 -0700 Subject: [PATCH 4/5] Reverting that last permissions check upon drop. Looks like all dropped attachments are deleted from inventory. --- .../Avatar/Attachments/AttachmentsModule.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 46d040f7ec..d1792d7945 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -375,16 +375,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } part.ParentGroup.DetachToGround(); - // If the item is no-copy we need to delete it from inventory - InventoryItemBase item = m_scene.InventoryService.GetItem(new InventoryItemBase(itemID)); - if (item != null && (item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) - { - List uuids = new List(); - uuids.Add(inventoryID); - m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); - remoteClient.SendRemoveInventoryItem(inventoryID); - } - } + List uuids = new List(); + uuids.Add(inventoryID); + m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); + remoteClient.SendRemoveInventoryItem(inventoryID); + } m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); } From e80cb815df1a7e1f9e6effdcab438e0ce14f99eb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 9 Jun 2010 12:51:24 -0700 Subject: [PATCH 5/5] Bug fix on attachments: attach->drop->attach works now. --- .../Avatar/Attachments/AttachmentsModule.cs | 50 +++++++++++-------- .../Framework/Scenes/SceneObjectGroup.cs | 1 + 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index d1792d7945..6d16c52862 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; using System.Collections.Generic; using System.Reflection; using log4net; @@ -71,31 +72,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) { m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); - - // If we can't take it, we can't attach it! - SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); - if (part == null) - return; - if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) - return; - - // Calls attach with a Zero position - if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) + try { - m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); - - // Save avatar attachment information - ScenePresence presence; - if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) + // If we can't take it, we can't attach it! + SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); + if (part == null) + return; + + if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) + return; + + // Calls attach with a Zero position + if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) { - m_log.Info( - "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId - + ", AttachmentPoint: " + AttachmentPt); - - m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); + + // Save avatar attachment information + ScenePresence presence; + if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) + { + m_log.Info( + "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + + ", AttachmentPoint: " + AttachmentPt); + + m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } } } + catch (Exception e) + { + m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e); + } } public bool AttachObject( @@ -379,7 +387,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments uuids.Add(inventoryID); m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids); remoteClient.SendRemoveInventoryItem(inventoryID); - } + } m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 78c2566af6..e23f39ffbc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1052,6 +1052,7 @@ namespace OpenSim.Region.Framework.Scenes return; detachedpos = avatar.AbsolutePosition; + RootPart.FromItemID = UUID.Zero; AbsolutePosition = detachedpos; m_rootPart.AttachedAvatar = UUID.Zero;