From 0cb0140a1d652c3ba47f1c9000d1ba81c8e786f8 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Sep 2011 00:29:37 +0100
Subject: Stop the pointless double setting of every attachment in
AvatarAppearance.
The second was already being filtered out so this has no user level effect
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++------
.../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 1 +
2 files changed, 3 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 4881499..e2e697e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -242,7 +242,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
-// group.Name, group.LocalId, sp.Name, AttachmentPt, silent);
+// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
if (sp.GetAttachments(attachmentPt).Contains(group))
{
@@ -356,8 +356,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
if (att == null)
DetachSingleAttachmentToInv(itemID, sp.ControllingClient);
- else
- ShowAttachInUserInventory(att, sp, itemID, AttachmentPt);
}
return att;
@@ -386,9 +384,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (objatt != null)
{
- // Loading the inventory from XML will have set this, but
- // there is no way the object could have changed yet,
- // since scripts aren't running yet. So, clear it here.
+ // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
objatt.HasGroupChanged = false;
bool tainted = false;
if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 363e258..3f8c01f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -150,6 +150,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attSo.IsTemporary, Is.False);
// Check appearance status
+ Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1));
Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest));
}
--
cgit v1.1
From 05a4bedc305a299efaf89c881b7dafbe25ed23a6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Sep 2011 00:32:52 +0100
Subject: get rid of the unused AttachmentsModule.ShowAttachInUserInventory()
---
.../Avatar/Attachments/AttachmentsModule.cs | 28 ----------------------
1 file changed, 28 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index e2e697e..dde6ca6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -430,34 +430,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return null;
}
-
- ///
- /// Update the user inventory to the attachment of an item
- ///
- ///
- ///
- ///
- ///
- ///
- private UUID ShowAttachInUserInventory(
- SceneObjectGroup att, IScenePresence sp, UUID itemID, uint attachmentPoint)
- {
-// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}",
-// sp.Name, att.Name, att.LocalId, itemID, AttachmentPt);
-
- if (!att.IsDeleted)
- attachmentPoint = att.AttachmentPoint;
-
- InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
- item = m_scene.InventoryService.GetItem(item);
-
- bool changed = sp.Appearance.SetAttachment((int)attachmentPoint, itemID, item.AssetID);
- if (changed && m_scene.AvatarFactory != null)
- m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
-
- return att.UUID;
- }
///
/// Update the user inventory to reflect an attachment
--
cgit v1.1
From c6ec573d105b52f65e02077e8603a9b586884ecd Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Sep 2011 00:36:38 +0100
Subject: Get rid of the confusing version of
IAttachmentsModule.RezSingleAttachmentFromInventory() with the
updateInventoryStatus switch, since this is never called with false
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index dde6ca6..67969b7 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -326,12 +326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public ISceneEntity RezSingleAttachmentFromInventory(
IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
- return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true);
- }
-
- public ISceneEntity RezSingleAttachmentFromInventory(
- IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
- {
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
// (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
@@ -352,11 +346,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
- if (updateInventoryStatus)
- {
- if (att == null)
- DetachSingleAttachmentToInv(itemID, sp.ControllingClient);
- }
+ if (att == null)
+ DetachSingleAttachmentToInv(itemID, sp.ControllingClient);
return att;
}
--
cgit v1.1
From b903d2ca963d5f68803a1cabbd033f89ab72634a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Sep 2011 01:59:21 +0100
Subject: In SetAttachment, if the existing attachment has no asset id then
carry on rather than abort.
When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However,
the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If
we simply perform an item check then the asset ids (which are now present) are never set, and NPC attachments
later fail unless the attachment is detached and reattached.
Hopefully resolves part of http://opensimulator.org/mantis/view.php?id=5653
---
.../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 3f8c01f..0fa2e00 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -247,6 +247,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
Assert.That(attSo.IsTemporary, Is.False);
+
+ // Check appearance status
+ List retreivedAttachments = presence.Appearance.GetAttachments();
+ Assert.That(retreivedAttachments.Count, Is.EqualTo(1));
+ Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
+ Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItemId));
+ Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attAssetId));
+ Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest));
}
// I'm commenting this test because scene setup NEEDS InventoryService to
--
cgit v1.1
From 5beee42809ad0fbdf559cb82038a5d3d41e98d9e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Sep 2011 02:29:22 +0100
Subject: rename AM.AddSceneObjectAsAttachment() to
AddSceneObjectAsNewAttachmentInInv
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 67969b7..af431f4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -302,7 +302,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
itemID = group.GetFromItemID();
if (itemID == UUID.Zero)
- itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
+ itemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID;
ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
}
@@ -733,12 +733,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
///
- /// Add a scene object that was previously free in the scene as an attachment to an avatar.
+ /// Add a scene object as a new attachment in the user inventory.
///
///
///
/// The user inventory item created that holds the attachment.
- private InventoryItemBase AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp)
+ private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IClientAPI remoteClient, SceneObjectGroup grp)
{
// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
--
cgit v1.1
From 1a8f5b97b968bcb46f31cb1b3458acee4ed7f1db Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Sep 2011 02:40:19 +0100
Subject: refactor: Make logic in AM.AttachObject() clearer by not reusing
existing variables in different contexts
---
.../Avatar/Attachments/AttachmentsModule.cs | 33 +++++++++++++---------
1 file changed, 19 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index af431f4..996e2ab 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -285,26 +285,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.AttachmentPoint = attachmentPt;
group.AbsolutePosition = attachPos;
- // Remove any previous attachments
- UUID itemID = UUID.Zero;
-
- List attachments = sp.GetAttachments(attachmentPt);
-
- // At the moment we can only deal with a single attachment
// We also don't want to do any of the inventory operations for an NPC.
if (sp.PresenceType != PresenceType.Npc)
{
+ // Remove any previous attachments
+ List attachments = sp.GetAttachments(attachmentPt);
+
+ // At the moment we can only deal with a single attachment
if (attachments.Count != 0)
- itemID = attachments[0].GetFromItemID();
-
- if (itemID != UUID.Zero)
- DetachSingleAttachmentToInv(itemID, sp);
+ {
+ UUID oldAttachmentItemID = attachments[0].GetFromItemID();
- itemID = group.GetFromItemID();
- if (itemID == UUID.Zero)
- itemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID;
+ if (oldAttachmentItemID != UUID.Zero)
+ DetachSingleAttachmentToInv(oldAttachmentItemID, sp);
+ else
+ m_log.WarnFormat(
+ "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
+ attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
+ }
+
+ // Add the new attachment to inventory if we don't already have it.
+ UUID newAttachmentItemID = group.GetFromItemID();
+ if (newAttachmentItemID == UUID.Zero)
+ newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID;
- ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
+ ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
}
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
--
cgit v1.1
From 96a3b68086c44dfe35018cc1eaf20be5cba1b0b1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 8 Sep 2011 20:59:52 +0100
Subject: Remember to set and unset the fire and forget method at the top of
the attachment and npc tests
---
.../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 0fa2e00..35183b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -58,12 +58,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
private AttachmentsModule m_attMod;
private ScenePresence m_presence;
- [SetUp]
- public void Init()
+ [TestFixtureSetUp]
+ public void FixtureInit()
{
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
Util.FireAndForgetMethod = FireAndForgetMethod.None;
+ }
+ [SetUp]
+ public void Init()
+ {
IConfigSource config = new IniConfigSource();
config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
@@ -73,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule());
}
- [TearDown]
+ [TestFixtureTearDown]
public void TearDown()
{
// We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
--
cgit v1.1
From ea0f78c97152d3aa54822487e5343ca2db0b47b9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 12 Sep 2011 21:57:22 +0100
Subject: Start locking entire add/remove operations on an
IScenePresence.AttachmentsSyncLock object
Attach and detach packets are processed asynchronously when received from a viewer.
Bugs like http://opensimulator.org/mantis/view.php?id=5644 indicate that in some situations (such as attaching/detaching entire folders of objects at once), there are race conditions between these threads.
Since multiple data structures need to be updated on attach/detach, it's not enough to lock the individual collections.
Therefore, this commit introduces a new IScenePresence.AttachmentsSyncLock which add/remove operations lock on.
---
.../Avatar/Attachments/AttachmentsModule.cs | 382 +++++++++++----------
1 file changed, 207 insertions(+), 175 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 996e2ab..2fa233b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -240,80 +240,83 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
private bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
{
-// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
-// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
-
- if (sp.GetAttachments(attachmentPt).Contains(group))
- {
-// m_log.WarnFormat(
-// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
-// group.Name, group.LocalId, sp.Name, AttachmentPt);
-
- return false;
- }
-
- Vector3 attachPos = group.AbsolutePosition;
-
- // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
- // be removed when that functionality is implemented in opensim
- attachmentPt &= 0x7f;
-
- // If the attachment point isn't the same as the one previously used
- // set it's offset position = 0 so that it appears on the attachment point
- // and not in a weird location somewhere unknown.
- if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
- {
- attachPos = Vector3.Zero;
- }
-
- // AttachmentPt 0 means the client chose to 'wear' the attachment.
- if (attachmentPt == 0)
- {
- // Check object for stored attachment point
- attachmentPt = group.AttachmentPoint;
- }
-
- // if we still didn't find a suitable attachment point.......
- if (attachmentPt == 0)
+ lock (sp.AttachmentsSyncLock)
{
- // Stick it on left hand with Zero Offset from the attachment point.
- attachmentPt = (uint)AttachmentPoint.LeftHand;
- attachPos = Vector3.Zero;
- }
-
- group.AttachmentPoint = attachmentPt;
- group.AbsolutePosition = attachPos;
-
- // We also don't want to do any of the inventory operations for an NPC.
- if (sp.PresenceType != PresenceType.Npc)
- {
- // Remove any previous attachments
- List attachments = sp.GetAttachments(attachmentPt);
-
- // At the moment we can only deal with a single attachment
- if (attachments.Count != 0)
+ // m_log.DebugFormat(
+ // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
+ // group.Name, group.LocalId, sp.Name, attachmentPt, silent);
+
+ if (sp.GetAttachments(attachmentPt).Contains(group))
{
- UUID oldAttachmentItemID = attachments[0].GetFromItemID();
+ // m_log.WarnFormat(
+ // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
+ // group.Name, group.LocalId, sp.Name, AttachmentPt);
- if (oldAttachmentItemID != UUID.Zero)
- DetachSingleAttachmentToInv(oldAttachmentItemID, sp);
- else
- m_log.WarnFormat(
- "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
- attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
+ return false;
}
-
- // Add the new attachment to inventory if we don't already have it.
- UUID newAttachmentItemID = group.GetFromItemID();
- if (newAttachmentItemID == UUID.Zero)
- newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID;
- ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
+ Vector3 attachPos = group.AbsolutePosition;
+
+ // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
+ // be removed when that functionality is implemented in opensim
+ attachmentPt &= 0x7f;
+
+ // If the attachment point isn't the same as the one previously used
+ // set it's offset position = 0 so that it appears on the attachment point
+ // and not in a weird location somewhere unknown.
+ if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
+ {
+ attachPos = Vector3.Zero;
+ }
+
+ // AttachmentPt 0 means the client chose to 'wear' the attachment.
+ if (attachmentPt == 0)
+ {
+ // Check object for stored attachment point
+ attachmentPt = group.AttachmentPoint;
+ }
+
+ // if we still didn't find a suitable attachment point.......
+ if (attachmentPt == 0)
+ {
+ // Stick it on left hand with Zero Offset from the attachment point.
+ attachmentPt = (uint)AttachmentPoint.LeftHand;
+ attachPos = Vector3.Zero;
+ }
+
+ group.AttachmentPoint = attachmentPt;
+ group.AbsolutePosition = attachPos;
+
+ // We also don't want to do any of the inventory operations for an NPC.
+ if (sp.PresenceType != PresenceType.Npc)
+ {
+ // Remove any previous attachments
+ List attachments = sp.GetAttachments(attachmentPt);
+
+ // At the moment we can only deal with a single attachment
+ if (attachments.Count != 0)
+ {
+ UUID oldAttachmentItemID = attachments[0].GetFromItemID();
+
+ if (oldAttachmentItemID != UUID.Zero)
+ DetachSingleAttachmentToInv(oldAttachmentItemID, sp);
+ else
+ m_log.WarnFormat(
+ "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
+ attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
+ }
+
+ // Add the new attachment to inventory if we don't already have it.
+ UUID newAttachmentItemID = group.GetFromItemID();
+ if (newAttachmentItemID == UUID.Zero)
+ newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID;
+
+ ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
+ }
+
+ AttachToAgent(sp, group, attachmentPt, attachPos, silent);
}
- AttachToAgent(sp, group, attachmentPt, attachPos, silent);
-
return true;
}
@@ -322,14 +325,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
{
- foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
+ ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
+
+ if (sp == null)
{
- RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
+ m_log.ErrorFormat(
+ "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezMultipleAttachmentsFromInventory()",
+ remoteClient.Name, remoteClient.AgentId);
+ return;
+ }
+
+ lock (sp.AttachmentsSyncLock)
+ {
+ foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
+ {
+ RezSingleAttachmentFromInventory(sp, obj.ItemID, obj.AttachmentPt);
+ }
}
}
- public ISceneEntity RezSingleAttachmentFromInventory(
- IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
+ public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
@@ -344,7 +359,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
remoteClient.Name, remoteClient.AgentId);
return null;
}
-
+
+ return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt);
+ }
+
+ public ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt)
+ {
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
@@ -363,65 +383,68 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface();
if (invAccess != null)
{
- SceneObjectGroup objatt;
-
- if (itemID != UUID.Zero)
- objatt = invAccess.RezObject(sp.ControllingClient,
- itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
- false, false, sp.UUID, true);
- else
- objatt = invAccess.RezObject(sp.ControllingClient,
- null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
- false, false, sp.UUID, true);
-
-// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
-// objatt.Name, remoteClient.Name, AttachmentPt);
-
- if (objatt != null)
+ lock (sp.AttachmentsSyncLock)
{
- // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
- objatt.HasGroupChanged = false;
- bool tainted = false;
- if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
- tainted = true;
-
- // This will throw if the attachment fails
- try
+ SceneObjectGroup objatt;
+
+ if (itemID != UUID.Zero)
+ objatt = invAccess.RezObject(sp.ControllingClient,
+ itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
+ false, false, sp.UUID, true);
+ else
+ objatt = invAccess.RezObject(sp.ControllingClient,
+ null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
+ false, false, sp.UUID, true);
+
+ // m_log.DebugFormat(
+ // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
+ // objatt.Name, remoteClient.Name, AttachmentPt);
+
+ if (objatt != null)
{
- AttachObject(sp, objatt, attachmentPt, false);
+ // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
+ objatt.HasGroupChanged = false;
+ bool tainted = false;
+ if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
+ tainted = true;
+
+ // This will throw if the attachment fails
+ try
+ {
+ AttachObject(sp, objatt, attachmentPt, false);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat(
+ "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
+ objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
+
+ // Make sure the object doesn't stick around and bail
+ sp.RemoveAttachment(objatt);
+ m_scene.DeleteSceneObject(objatt, false);
+ return null;
+ }
+
+ if (tainted)
+ objatt.HasGroupChanged = true;
+
+ // Fire after attach, so we don't get messy perms dialogs
+ // 4 == AttachedRez
+ objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
+ objatt.ResumeScripts();
+
+ // Do this last so that event listeners have access to all the effects of the attachment
+ m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
+
+ return objatt;
}
- catch (Exception e)
+ else
{
- m_log.ErrorFormat(
- "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
- objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
-
- // Make sure the object doesn't stick around and bail
- sp.RemoveAttachment(objatt);
- m_scene.DeleteSceneObject(objatt, false);
- return null;
+ m_log.WarnFormat(
+ "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
+ itemID, sp.Name, attachmentPt);
}
-
- if (tainted)
- objatt.HasGroupChanged = true;
-
- // Fire after attach, so we don't get messy perms dialogs
- // 4 == AttachedRez
- objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
- objatt.ResumeScripts();
-
- // Do this last so that event listeners have access to all the effects of the attachment
- m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
}
- else
- {
- m_log.WarnFormat(
- "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
- itemID, sp.Name, attachmentPt);
- }
-
- return objatt;
}
return null;
@@ -474,14 +497,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
- // Save avatar attachment information
- m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
-
- bool changed = presence.Appearance.DetachAttachment(itemID);
- if (changed && m_scene.AvatarFactory != null)
- m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
+ lock (presence.AttachmentsSyncLock)
+ {
+ // Save avatar attachment information
+ m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
- DetachSingleAttachmentToInv(itemID, presence);
+ bool changed = presence.Appearance.DetachAttachment(itemID);
+ if (changed && m_scene.AvatarFactory != null)
+ m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
+
+ DetachSingleAttachmentToInv(itemID, presence);
+ }
}
}
@@ -508,24 +534,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
- if (!m_scene.Permissions.CanRezObject(
- so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
- return;
+ lock (presence.AttachmentsSyncLock)
+ {
+ if (!m_scene.Permissions.CanRezObject(
+ so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
+ return;
- bool changed = presence.Appearance.DetachAttachment(inventoryID);
- if (changed && m_scene.AvatarFactory != null)
- m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
+ bool changed = presence.Appearance.DetachAttachment(inventoryID);
+ if (changed && m_scene.AvatarFactory != null)
+ m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- presence.RemoveAttachment(so);
- DetachSceneObjectToGround(so, presence);
+ presence.RemoveAttachment(so);
+ DetachSceneObjectToGround(so, presence);
- 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(so.LocalId, so.UUID, UUID.Zero);
+ m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
+ }
}
///
@@ -567,37 +596,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
EntityBase[] detachEntities = m_scene.GetEntities();
SceneObjectGroup group;
- foreach (EntityBase entity in detachEntities)
+ lock (sp.AttachmentsSyncLock)
{
- if (entity is SceneObjectGroup)
+ foreach (EntityBase entity in detachEntities)
{
- group = (SceneObjectGroup)entity;
- if (group.GetFromItemID() == itemID)
+ if (entity is SceneObjectGroup)
{
- m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
- sp.RemoveAttachment(group);
-
- // Prepare sog for storage
- group.AttachedAvatar = UUID.Zero;
-
- group.ForEachPart(
- delegate(SceneObjectPart part)
- {
- // If there are any scripts,
- // then always trigger a new object and state persistence in UpdateKnownItem()
- if (part.Inventory.ContainsScripts())
- group.HasGroupChanged = true;
- }
- );
-
- group.RootPart.SetParentLocalId(0);
- group.IsAttachment = false;
- group.AbsolutePosition = group.RootPart.AttachedPos;
-
- UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
- m_scene.DeleteSceneObject(group, false);
-
- return;
+ group = (SceneObjectGroup)entity;
+ if (group.GetFromItemID() == itemID)
+ {
+ m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
+ sp.RemoveAttachment(group);
+
+ // Prepare sog for storage
+ group.AttachedAvatar = UUID.Zero;
+
+ group.ForEachPart(
+ delegate(SceneObjectPart part)
+ {
+ // If there are any scripts,
+ // then always trigger a new object and state persistence in UpdateKnownItem()
+ if (part.Inventory.ContainsScripts())
+ group.HasGroupChanged = true;
+ }
+ );
+
+ group.RootPart.SetParentLocalId(0);
+ group.IsAttachment = false;
+ group.AbsolutePosition = group.RootPart.AttachedPos;
+
+ UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
+ m_scene.DeleteSceneObject(group, false);
+
+ return;
+ }
}
}
}
@@ -829,4 +861,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return item;
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1
From 618277e797c7d501f98e884e50abd313498cf00b Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 20:25:32 +0100
Subject: Comment out attachments code in Scene.IncomingCreateObject(UUID
userID, UUID itemID) for now
As far as I can see, this is only invoked by a PUT request to ObjectHandlers, which is not being used anyway.
Invoking attachments code at this point is probably inappropriate since it would still be invoked when the client entered the scene.
Being commented to simplify analysis of attachments issues. Can be uncommented when in use.
Also, small tweak to lock and log removal of a SOG from the SceneObjectGroupsByLocalPartID collection in SceneGraph.GetGroupByPrim() if an inconsistency is found.
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2fa233b..c817559 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -143,6 +143,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void SaveChangedAttachments(IScenePresence sp)
{
+// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
+
foreach (SceneObjectGroup grp in sp.GetAttachments())
{
if (grp.HasGroupChanged) // Resizer scripts?
@@ -242,9 +244,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
lock (sp.AttachmentsSyncLock)
{
- // m_log.DebugFormat(
- // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
- // group.Name, group.LocalId, sp.Name, attachmentPt, silent);
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
+// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
if (sp.GetAttachments(attachmentPt).Contains(group))
{
@@ -365,6 +367,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public ISceneEntity RezSingleAttachmentFromInventory(ScenePresence sp, UUID itemID, uint AttachmentPt)
{
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}",
+// (AttachmentPoint)AttachmentPt, itemID, sp.Name);
+
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
@@ -485,6 +491,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
{
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: DetachObject() for object {0} on {1}", objectLocalID, remoteClient.Name);
+
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
if (group != null)
{
@@ -588,6 +597,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// To LocalId or UUID, *THAT* is the question. How now Brown UUID??
private void DetachSingleAttachmentToInv(UUID itemID, IScenePresence sp)
{
+// m_log.DebugFormat("[ATTACHMENTS MODULE]: Detaching item {0} to inventory for {1}", itemID, sp.Name);
+
if (itemID == UUID.Zero) // If this happened, someone made a mistake....
return;
--
cgit v1.1
From 8880aea728af2ccb95ea2400c7d180aa4dc98112 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 22:13:58 +0100
Subject: Stop attempts to rewear already worn items from removing and
reattaching.
Viewer 2/3 will sometimes attempt to rewear attachments, even though they have already been attached during the main login process.
This change ignores those attempts.
This stops script failures during login, as the rewearing was racing with the script startup code.
It might also help with attachments being abnormally put into deleted state.
Hopefully resolves some more of http://opensimulator.org/mantis/view.php?id=5644
---
.../Avatar/Attachments/AttachmentsModule.cs | 119 +++++++++++++--------
1 file changed, 77 insertions(+), 42 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index c817559..1e9a001 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -147,18 +147,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
foreach (SceneObjectGroup grp in sp.GetAttachments())
{
- if (grp.HasGroupChanged) // Resizer scripts?
- {
+// if (grp.HasGroupChanged) // Resizer scripts?
+// {
grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos;
UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID);
grp.IsAttachment = true;
- }
+// }
}
}
public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
{
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
+// m_scene.RegionInfo.RegionName, sp.Name, silent);
+
foreach (SceneObjectGroup sop in sp.GetAttachments())
{
sop.Scene.DeleteSceneObject(sop, silent);
@@ -214,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
// Save avatar attachment information
- m_log.Info(
+ m_log.Debug(
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
+ ", AttachmentPoint: " + AttachmentPt);
@@ -339,6 +343,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
lock (sp.AttachmentsSyncLock)
{
+// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name);
+
foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
{
RezSingleAttachmentFromInventory(sp, obj.ItemID, obj.AttachmentPt);
@@ -349,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
+// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
// (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
@@ -375,6 +381,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
+ // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such).
+ // This often happens during login - not sure the exact reason.
+ // For now, we will ignore the request. Unfortunately, this means that we need to dig through all the
+ // ScenePresence attachments. We can't use the data in AvatarAppearance because that's present at login
+ // before anything has actually been attached.
+ bool alreadyOn = false;
+ List existingAttachments = sp.GetAttachments();
+ foreach (SceneObjectGroup so in existingAttachments)
+ {
+ if (so.GetFromItemID() == itemID)
+ {
+ alreadyOn = true;
+ break;
+ }
+ }
+
+// if (sp.Appearance.GetAttachmentForItem(itemID) != null)
+ if (alreadyOn)
+ {
+// m_log.WarnFormat(
+// "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn",
+// sp.Name, itemID, AttachmentPt);
+
+ return null;
+ }
+
SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
if (att == null)
@@ -467,8 +499,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
{
// m_log.DebugFormat(
-// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
-// att.Name, remoteClient.Name, AttachmentPt, itemID);
+// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
+// att.Name, sp.Name, AttachmentPt, itemID);
if (UUID.Zero == itemID)
{
@@ -524,7 +556,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
-// remoteClient.Name, sceneObjectID);
+// remoteClient.Name, soLocalId);
SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId);
@@ -677,45 +709,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
if (grp != null)
{
- if (!grp.HasGroupChanged)
+ if (grp.HasGroupChanged || grp.ContainsScripts())
{
m_log.DebugFormat(
- "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
+ "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.AttachmentPoint);
- return;
- }
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
- m_log.DebugFormat(
- "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
- grp.UUID, grp.AttachmentPoint);
+ InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
+ item = m_scene.InventoryService.GetItem(item);
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
-
- InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
- item = m_scene.InventoryService.GetItem(item);
-
- if (item != null)
+ if (item != null)
+ {
+ AssetBase asset = m_scene.CreateAsset(
+ grp.GetPartName(grp.LocalId),
+ grp.GetPartDescription(grp.LocalId),
+ (sbyte)AssetType.Object,
+ Utils.StringToBytes(sceneObjectXml),
+ remoteClient.AgentId);
+ m_scene.AssetService.Store(asset);
+
+ item.AssetID = asset.FullID;
+ item.Description = asset.Description;
+ item.Name = asset.Name;
+ item.AssetType = asset.Type;
+ item.InvType = (int)InventoryType.Object;
+
+ m_scene.InventoryService.UpdateItem(item);
+
+ // this gets called when the agent logs off!
+ if (remoteClient != null)
+ remoteClient.SendInventoryItemCreateUpdate(item, 0);
+ }
+ }
+ else
{
- AssetBase asset = m_scene.CreateAsset(
- grp.GetPartName(grp.LocalId),
- grp.GetPartDescription(grp.LocalId),
- (sbyte)AssetType.Object,
- Utils.StringToBytes(sceneObjectXml),
- remoteClient.AgentId);
- m_scene.AssetService.Store(asset);
-
- item.AssetID = asset.FullID;
- item.Description = asset.Description;
- item.Name = asset.Name;
- item.AssetType = asset.Type;
- item.InvType = (int)InventoryType.Object;
-
- m_scene.InventoryService.UpdateItem(item);
-
- // this gets called when the agent logs off!
- if (remoteClient != null)
- remoteClient.SendInventoryItemCreateUpdate(item, 0);
+ m_log.DebugFormat(
+ "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
+ grp.UUID, grp.AttachmentPoint);
}
}
}
@@ -735,7 +767,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
private void AttachToAgent(
IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
{
-// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
so.DetachFromBackup();
@@ -788,7 +821,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// The user inventory item created that holds the attachment.
private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IClientAPI remoteClient, SceneObjectGroup grp)
{
-// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}",
+// grp.Name, grp.LocalId, remoteClient.Name);
Vector3 inventoryStoredPosition = new Vector3
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
--
cgit v1.1
From 62b3e74bc5c3f08f33e15b30d04a799db4228c06 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 22:24:33 +0100
Subject: minor: remove redundant grp != null check from AM.UpdateKnownItem()
---
.../Avatar/Attachments/AttachmentsModule.cs | 69 +++++++++++-----------
1 file changed, 33 insertions(+), 36 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 1e9a001..ae19224 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -707,49 +707,46 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
{
- if (grp != null)
+ if (grp.HasGroupChanged || grp.ContainsScripts())
{
- if (grp.HasGroupChanged || grp.ContainsScripts())
- {
- m_log.DebugFormat(
- "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
- grp.UUID, grp.AttachmentPoint);
+ m_log.DebugFormat(
+ "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
+ grp.UUID, grp.AttachmentPoint);
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
- InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
- item = m_scene.InventoryService.GetItem(item);
+ InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
+ item = m_scene.InventoryService.GetItem(item);
- if (item != null)
- {
- AssetBase asset = m_scene.CreateAsset(
- grp.GetPartName(grp.LocalId),
- grp.GetPartDescription(grp.LocalId),
- (sbyte)AssetType.Object,
- Utils.StringToBytes(sceneObjectXml),
- remoteClient.AgentId);
- m_scene.AssetService.Store(asset);
-
- item.AssetID = asset.FullID;
- item.Description = asset.Description;
- item.Name = asset.Name;
- item.AssetType = asset.Type;
- item.InvType = (int)InventoryType.Object;
-
- m_scene.InventoryService.UpdateItem(item);
-
- // this gets called when the agent logs off!
- if (remoteClient != null)
- remoteClient.SendInventoryItemCreateUpdate(item, 0);
- }
- }
- else
+ if (item != null)
{
- m_log.DebugFormat(
- "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
- grp.UUID, grp.AttachmentPoint);
+ AssetBase asset = m_scene.CreateAsset(
+ grp.GetPartName(grp.LocalId),
+ grp.GetPartDescription(grp.LocalId),
+ (sbyte)AssetType.Object,
+ Utils.StringToBytes(sceneObjectXml),
+ remoteClient.AgentId);
+ m_scene.AssetService.Store(asset);
+
+ item.AssetID = asset.FullID;
+ item.Description = asset.Description;
+ item.Name = asset.Name;
+ item.AssetType = asset.Type;
+ item.InvType = (int)InventoryType.Object;
+
+ m_scene.InventoryService.UpdateItem(item);
+
+ // this gets called when the agent logs off!
+ if (remoteClient != null)
+ remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
}
+ else
+ {
+ m_log.DebugFormat(
+ "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
+ grp.UUID, grp.AttachmentPoint);
+ }
}
///
--
cgit v1.1
From 2d62484f11710cbeb066ab6bf02f78ad379ecca3 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 22:27:33 +0100
Subject: Remove UpdateKnownItem() from IAttachmentsModule.
It's not appropriate for code outside the attachments module to call this.
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index ae19224..03837b5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -705,7 +705,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
///
- public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
+ private void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
{
if (grp.HasGroupChanged || grp.ContainsScripts())
{
--
cgit v1.1
From 61affee814b6c2a09cb33b1823f009d386f54818 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 22:33:15 +0100
Subject: remove redunant itemID and agentID arguments from UpdateKnownItem().
itemID is always taken taken from the group's stored item id, and agentID is never used.
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 03837b5..b9cd880 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -151,7 +151,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// {
grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos;
- UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID);
+ UpdateKnownItem(sp.ControllingClient, grp);
grp.IsAttachment = true;
// }
}
@@ -668,7 +668,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
- UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
+ UpdateKnownItem(sp.ControllingClient, group);
m_scene.DeleteSceneObject(group, false);
return;
@@ -703,9 +703,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
///
- ///
- ///
- private void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
+ private void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp)
{
if (grp.HasGroupChanged || grp.ContainsScripts())
{
@@ -715,7 +713,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
- InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
+ InventoryItemBase item = new InventoryItemBase(grp.GetFromItemID(), remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
if (item != null)
--
cgit v1.1
From 1084d8f6a2bcf63c594e1a8bd180c42f51b05e2f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 22:39:06 +0100
Subject: Remove code from DetachSingleAttachmentToInv() that sets group
changed on all parts, now that we're performing this check in
UpdateKnownItem() for other purposes
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 11 -----------
1 file changed, 11 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index b9cd880..b965d75 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -653,17 +653,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Prepare sog for storage
group.AttachedAvatar = UUID.Zero;
-
- group.ForEachPart(
- delegate(SceneObjectPart part)
- {
- // If there are any scripts,
- // then always trigger a new object and state persistence in UpdateKnownItem()
- if (part.Inventory.ContainsScripts())
- group.HasGroupChanged = true;
- }
- );
-
group.RootPart.SetParentLocalId(0);
group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
--
cgit v1.1
From bd991fc95f8ec648f7dbb0086ae716e4204d1687 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 13 Sep 2011 22:54:50 +0100
Subject: Don't try and delete attachments for child agent close
---
.../Attachments/Tests/AttachmentsModuleTests.cs | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 35183b3..ff3358f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -220,6 +220,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0));
}
+ ///
+ /// Test that attachments don't hang about in the scene when the agent is closed
+ ///
+ [Test]
+ public void TestRemoveAttachmentsOnAvatarExit()
+ {
+ TestHelpers.InMethod();
+// log4net.Config.XmlConfigurator.Configure();
+
+ UUID userId = TestHelpers.ParseTail(0x1);
+ UUID attItemId = TestHelpers.ParseTail(0x2);
+ UUID attAssetId = TestHelpers.ParseTail(0x3);
+ string attName = "att";
+
+ UserAccountHelpers.CreateUserWithInventory(scene, userId);
+ InventoryItemBase attItem
+ = UserInventoryHelpers.CreateInventoryItem(
+ scene, attName, attItemId, attAssetId, userId, InventoryType.Object);
+
+ AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
+ acd.Appearance = new AvatarAppearance();
+ acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
+ ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
+
+ SceneObjectGroup rezzedAtt = presence.GetAttachments()[0];
+
+ scene.IncomingCloseAgent(presence.UUID);
+
+ // Check that we can't retrieve this attachment from the scene.
+ Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null);
+ }
+
[Test]
public void TestRezAttachmentsOnAvatarEntrance()
{
--
cgit v1.1