From 0ee7a5ee81437f7fb81814b1694c00cb5a206bda Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 15 Jul 2011 23:36:32 +0100
Subject: If object is an attachment, make llGetVel() return the avatar's speed
rather than the object's own zero speed.
As per http://opensimulator.org/mantis/view.php?id=5575
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 1 -
1 file changed, 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 520d794..1e09610 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -566,7 +566,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
protected void AttachToAgent(ScenePresence 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}", Name, avatar.Name,
attachmentpoint, attachOffset, so.RootPart.AttachedPos);
--
cgit v1.1
From 195c1dc9b8b8511980d9a607a242b24a5a91da17 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 10 Aug 2011 00:26:38 +0100
Subject: implement osNpcStopMoveTo() to cancel any current move target
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 1e09610..ebb5bd2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
protected void AttachToAgent(ScenePresence 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}", Name, avatar.Name,
- attachmentpoint, attachOffset, so.RootPart.AttachedPos);
+ 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();
--
cgit v1.1
From 696bd448334c89607c95385f05a53e2ab72cb984 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 17 Aug 2011 00:37:33 +0100
Subject: Add new regression TestRezAttachmentsOnAvatarEntrance() to do simple
attachments check
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index ebb5bd2..4dbc5e6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
false, false, remoteClient.AgentId, true);
// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
+// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
// objatt.Name, remoteClient.Name, AttachmentPt);
if (objatt != null)
--
cgit v1.1
From acfdca34fd9bf6d66d144ae5c0a325dd5e864517 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 17 Aug 2011 01:35:33 +0100
Subject: Fix issue where loading a new appearance onto an NPC would not remove
the previous attachments from the scene.
Addresses http://opensimulator.org/mantis/view.php?id=5636
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 4dbc5e6..0316d29 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
{
- m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
+// m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
try
{
@@ -466,7 +466,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
group.DetachToInventoryPrep();
- m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
+// m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
// If an item contains scripts, it's always changed.
// This ensures script state is saved on detach
--
cgit v1.1
From d8f886ccdb6f1bf185e7edaed7cd80b3027d58f2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 17 Aug 2011 23:41:20 +0100
Subject: comment out noisy attachments logging
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 0316d29..a3639e8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -226,9 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public UUID 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);
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
+// (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
// be removed when that functionality is implemented in opensim
@@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
protected void AttachToAgent(ScenePresence 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}",
- so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
+// 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();
--
cgit v1.1
From c1a34cd8da293e63d3cba70b5271c9a297789db2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 18 Aug 2011 00:53:05 +0100
Subject: Don't try to save changed attachment states when an NPC with
attachments is removed from the scene.
This is done by introducing a PresenceType enum into ScenePresence which currently has two values, User and Npc.
This seems better than a SaveAttachments flag in terms of code comprehension, though I'm still slightly uneasy about introducing these semantics to core objects
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index a3639e8..97a1be6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -501,10 +501,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
/// Update the attachment asset for the new sog details if they have changed.
///
- ///
+ ///
/// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
/// these details are not stored on the region.
- ///
+ ///
///
///
///
--
cgit v1.1
From d328046efbcd7449e0421f72138f48272f514481 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 22 Aug 2011 23:59:48 +0100
Subject: If an attachment fails, then start logging the exception for now, in
order to help with the inconsistent state bug.
This also refactors AttachmentsModules to stop pointlessly refetching the ScenePresence in various methods. However, more of this is required.
---
.../Avatar/Attachments/AttachmentsModule.cs | 135 ++++++++++++---------
1 file changed, 80 insertions(+), 55 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 97a1be6..c96de3a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -105,6 +105,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
try
{
+ ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
+
+ if (sp == null)
+ {
+ m_log.ErrorFormat(
+ "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId);
+ return;
+ }
+
// If we can't take it, we can't attach it!
SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID);
if (part == null)
@@ -123,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
AttachmentPt &= 0x7f;
// Calls attach with a Zero position
- if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false))
+ if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
{
m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
@@ -136,12 +145,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
catch (Exception e)
{
- m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e);
+ m_log.ErrorFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}{1}", e.Message, e.StackTrace);
}
}
-
+
public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent)
{
+ ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
+
+ if (sp == null)
+ {
+ m_log.ErrorFormat(
+ "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId);
+ return false;
+ }
+
+ return AttachObject(sp, group, AttachmentPt, silent);
+ }
+
+ public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent)
+ {
Vector3 attachPos = group.AbsolutePosition;
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
@@ -175,32 +198,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.AbsolutePosition = attachPos;
// Remove any previous attachments
- ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
UUID itemID = UUID.Zero;
- if (sp != null)
+ foreach (SceneObjectGroup grp in sp.Attachments)
{
- foreach (SceneObjectGroup grp in sp.Attachments)
+ if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
{
- if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
- {
- itemID = grp.GetFromItemID();
- break;
- }
+ itemID = grp.GetFromItemID();
+ break;
}
- if (itemID != UUID.Zero)
- DetachSingleAttachmentToInv(itemID, remoteClient);
}
+ if (itemID != UUID.Zero)
+ DetachSingleAttachmentToInv(itemID, sp);
+
if (group.GetFromItemID() == UUID.Zero)
{
- m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID);
+ m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID);
}
else
{
itemID = group.GetFromItemID();
}
- ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group);
+ ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
@@ -229,19 +249,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
// (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
+
+ ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
+
+ if (sp == null)
+ {
+ m_log.ErrorFormat(
+ "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()",
+ remoteClient.Name, remoteClient.AgentId);
+ return UUID.Zero;
+ }
// 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;
- SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt);
+ SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt);
if (updateInventoryStatus)
{
if (att == null)
- ShowDetachInUserInventory(itemID, remoteClient);
+ ShowDetachInUserInventory(itemID, sp.ControllingClient);
else
- ShowAttachInUserInventory(att, remoteClient, itemID, AttachmentPt);
+ ShowAttachInUserInventory(att, sp, itemID, AttachmentPt);
}
if (null == att)
@@ -250,15 +280,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return att.UUID;
}
- protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
- IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
+ private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
+ ScenePresence sp, UUID itemID, uint AttachmentPt)
{
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface();
if (invAccess != null)
{
- SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
+ SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient,
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
- false, false, remoteClient.AgentId, true);
+ false, false, sp.UUID, true);
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
@@ -277,10 +307,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// This will throw if the attachment fails
try
{
- AttachObject(remoteClient, objatt, AttachmentPt, false);
+ AttachObject(sp, objatt, AttachmentPt, false);
}
- catch
+ 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
m_scene.DeleteSceneObject(objatt, false);
return null;
@@ -295,13 +329,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
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, remoteClient.AgentId);
+ 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, remoteClient.Name, AttachmentPt);
+ itemID, sp.Name, AttachmentPt);
}
return objatt;
@@ -314,12 +348,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// Update the user inventory to the attachment of an item
///
///
- ///
+ ///
///
///
///
- protected UUID ShowAttachInUserInventory(
- SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
+ private UUID ShowAttachInUserInventory(
+ SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt)
{
// m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
@@ -328,16 +362,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (!att.IsDeleted)
AttachmentPt = att.RootPart.AttachmentPoint;
- ScenePresence presence;
- if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
- {
- InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
- item = m_scene.InventoryService.GetItem(item);
+ InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
+ item = m_scene.InventoryService.GetItem(item);
- bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
- if (changed && m_scene.AvatarFactory != null)
- m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- }
+ bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
+ if (changed && m_scene.AvatarFactory != null)
+ m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
return att.UUID;
}
@@ -345,12 +375,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
/// Update the user inventory to reflect an attachment
///
- ///
+ ///
///
///
///
- protected void ShowAttachInUserInventory(
- IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
+ private void ShowAttachInUserInventory(
+ ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
{
// m_log.DebugFormat(
// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
@@ -374,16 +404,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return;
}
- ScenePresence presence;
- if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
- {
- // XXYY!!
- InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
- item = m_scene.InventoryService.GetItem(item);
- bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
- if (changed && m_scene.AvatarFactory != null)
- m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- }
+ InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
+ item = m_scene.InventoryService.GetItem(item);
+ bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
+ if (changed && m_scene.AvatarFactory != null)
+ m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
}
public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
@@ -407,9 +432,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
bool changed = presence.Appearance.DetachAttachment(itemID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- }
- DetachSingleAttachmentToInv(itemID, remoteClient);
+ DetachSingleAttachmentToInv(itemID, presence);
+ }
}
public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
@@ -447,7 +472,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// 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)
+ private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp)
{
if (itemID == UUID.Zero) // If this happened, someone made a mistake....
return;
@@ -474,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (p.Inventory.ContainsScripts())
group.HasGroupChanged = true;
- UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
+ UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
m_scene.DeleteSceneObject(group, false);
return;
}
--
cgit v1.1
From 1f3ce48be110ad048784aef22ee8458466d3fe06 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 23 Aug 2011 00:04:38 +0100
Subject: If an object failed to attach due to an exception, then try and
detach it from the avatar's list of attachments as well as delete it from the
scene.
This may help with the "Inconsistent attachment state" errors seen on teleport.
See http://opensimulator.org/mantis/view.php?id=5644 and linked reports
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index c96de3a..90092ce 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -316,6 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
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;
}
@@ -433,7 +434,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- DetachSingleAttachmentToInv(itemID, presence);
+ DetachSingleAttachmentToInv(itemID, presence);
}
}
--
cgit v1.1
From 97b207240ee79abfec08d2dfaa9385211eb305c8 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 23 Aug 2011 22:05:22 +0100
Subject: rename AttachmentsModule.ShowDetachInUserInventory() to
DetachSingleAttachmentToInv() for consistency and to reflect it's actual
behaviour
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 90092ce..a854c11 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory;
client.OnObjectAttach += AttachObject;
client.OnObjectDetach += DetachObject;
- client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory;
+ client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
}
public void UnsubscribeFromClientEvents(IClientAPI client)
@@ -89,7 +89,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory;
client.OnObjectAttach -= AttachObject;
client.OnObjectDetach -= DetachObject;
- client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory;
+ client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv;
}
///
@@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (updateInventoryStatus)
{
if (att == null)
- ShowDetachInUserInventory(itemID, sp.ControllingClient);
+ DetachSingleAttachmentToInv(itemID, sp.ControllingClient);
else
ShowAttachInUserInventory(att, sp, itemID, AttachmentPt);
}
@@ -417,12 +417,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
if (group != null)
{
- //group.DetachToGround();
- ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
+ DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient);
}
}
- public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
+ public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
{
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
--
cgit v1.1
From cf3ffe5bb4c6a8bea9599b6143c2f7793500c984 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 20:49:23 +0100
Subject: Fix llAttachToAvatar()
Apart from one obvious bug, this was failing because attempting to serialize the script from inside the script (as part of saving the attachment as an inventory asset) was triggering an extremely long delay.
So we now don't do this. The state will be serialized anyway when the avatar normally logs out.
The worst that can happen is that if the client/server crashes, the attachment scripts start without previous state.
---
.../Avatar/Attachments/AttachmentsModule.cs | 35 +++++++++++++++-------
1 file changed, 25 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index a854c11..c274a5b 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -101,7 +101,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
{
-// m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})",
+// objectLocalID, remoteClient.Name, AttachmentPt, silent);
try
{
@@ -163,8 +165,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return AttachObject(sp, group, AttachmentPt, silent);
}
- public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent)
+ private bool AttachObject(ScenePresence 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
@@ -211,14 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (itemID != UUID.Zero)
DetachSingleAttachmentToInv(itemID, sp);
- if (group.GetFromItemID() == UUID.Zero)
- {
+ itemID = group.GetFromItemID();
+ if (itemID == UUID.Zero)
m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID);
- }
- else
- {
- itemID = group.GetFromItemID();
- }
ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
@@ -548,7 +558,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.GetAttachmentPoint());
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
+ // If we're being called from a script, then trying to serialize that same script's state will not complete
+ // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
+ // the client/server crashes rather than logging out normally, the attachment's scripts will resume
+ // without state on relog. Arguably, this is what we want anyway.
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
+
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
--
cgit v1.1
From b9ec625dbf99955c983b75651430785217559483 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:07:46 +0100
Subject: add TestAddAttachmentFromGround() regression test
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index c274a5b..f254974 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -563,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// the client/server crashes rather than logging out normally, the attachment's scripts will resume
// without state on relog. Arguably, this is what we want anyway.
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
-
+
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
--
cgit v1.1
From ccf07f6ae337acc9c2b8fa30a784ee01ee3de24e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:14:57 +0100
Subject: refactor: remove pointless AgentId argument from
attachObjectAssetStore()
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f254974..88fc9e4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -228,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
itemID = group.GetFromItemID();
if (itemID == UUID.Zero)
- m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID);
+ m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID);
ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
--
cgit v1.1
From 5eeee480d47b855774829c94aadcb69af8c0e8da Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:35:44 +0100
Subject: refactor: move Scene.Inventory.attachObjectAssetStore() into
AttachmentsModule.AddSceneObjectAsAttachment()
---
.../Avatar/Attachments/AttachmentsModule.cs | 102 ++++++++++++++++++++-
1 file changed, 100 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 88fc9e4..5661254 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- protected Scene m_scene = null;
+ private Scene m_scene = null;
+ private IDialogModule m_dialogModule;
public string Name { get { return "Attachments Module"; } }
public Type ReplaceableInterface { get { return null; } }
@@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void AddRegion(Scene scene)
{
m_scene = scene;
+ m_dialogModule = m_scene.RequestModuleInterface();
m_scene.RegisterModuleInterface(this);
m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
// TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI
@@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
itemID = group.GetFromItemID();
if (itemID == UUID.Zero)
- m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID);
+ AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID);
ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
@@ -656,5 +658,101 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// it get cleaned up
so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
}
+
+ ///
+ /// Add a scene object that was previously free in the scene as an attachment to an avatar.
+ ///
+ ///
+ ///
+ ///
+ ///
+ private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID)
+ {
+// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
+
+ itemID = UUID.Zero;
+
+ Vector3 inventoryStoredPosition = new Vector3
+ (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
+ ? Constants.RegionSize - 6
+ : grp.AbsolutePosition.X)
+ ,
+ (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
+ ? Constants.RegionSize - 6
+ : grp.AbsolutePosition.Y,
+ grp.AbsolutePosition.Z);
+
+ Vector3 originalPosition = grp.AbsolutePosition;
+
+ grp.AbsolutePosition = inventoryStoredPosition;
+
+ // If we're being called from a script, then trying to serialize that same script's state will not complete
+ // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
+ // the client/server crashes rather than logging out normally, the attachment's scripts will resume
+ // without state on relog. Arguably, this is what we want anyway.
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
+
+ grp.AbsolutePosition = originalPosition;
+
+ 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);
+
+ InventoryItemBase item = new InventoryItemBase();
+ item.CreatorId = grp.RootPart.CreatorID.ToString();
+ item.CreatorData = grp.RootPart.CreatorData;
+ item.Owner = remoteClient.AgentId;
+ item.ID = UUID.Random();
+ item.AssetID = asset.FullID;
+ item.Description = asset.Description;
+ item.Name = asset.Name;
+ item.AssetType = asset.Type;
+ item.InvType = (int)InventoryType.Object;
+
+ InventoryFolderBase folder = m_scene.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) && m_scene.Permissions.PropagatePermissions())
+ {
+ item.BasePermissions = grp.RootPart.NextOwnerMask;
+ item.CurrentPermissions = grp.RootPart.NextOwnerMask;
+ item.NextPermissions = grp.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
+ item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
+ }
+ else
+ {
+ item.BasePermissions = grp.RootPart.BaseMask;
+ item.CurrentPermissions = grp.RootPart.OwnerMask;
+ item.NextPermissions = grp.RootPart.NextOwnerMask;
+ item.EveryOnePermissions = grp.RootPart.EveryoneMask;
+ item.GroupPermissions = grp.RootPart.GroupMask;
+ }
+ item.CreationDate = Util.UnixTimeSinceEpoch();
+
+ // sets itemID so client can show item as 'attached' in inventory
+ grp.SetFromItemID(item.ID);
+
+ if (m_scene.AddInventoryItem(item))
+ {
+ remoteClient.SendInventoryItemCreateUpdate(item, 0);
+ }
+ else
+ {
+ if (m_dialogModule != null)
+ m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
+ }
+
+ itemID = item.ID;
+ return item.AssetID;
+ }
}
}
--
cgit v1.1
From 801b7f18a7170b3df7f678e927122125f1c16eba Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:40:36 +0100
Subject: return InventoryItemBase from AddSceneObjectAsAttachment()
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 5661254..928d43f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
itemID = group.GetFromItemID();
if (itemID == UUID.Zero)
- AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID);
+ itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
@@ -664,14 +664,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
///
- ///
- ///
- private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID)
+ /// The user inventory item created that holds the attachment.
+ private InventoryItemBase AddSceneObjectAsAttachment(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);
- itemID = UUID.Zero;
-
Vector3 inventoryStoredPosition = new Vector3
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
? Constants.RegionSize - 6
@@ -751,8 +748,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
}
- itemID = item.ID;
- return item.AssetID;
+ return item;
}
}
}
--
cgit v1.1
From 73d913dad25dc1680f66ed2acc32cc6eb672da6b Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 22:12:51 +0100
Subject: Make objects attached from the ground phantom
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 ++
1 file changed, 2 insertions(+)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 928d43f..767908e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -669,6 +669,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
+ grp.UpdatePrimFlags(grp.LocalId, grp.UsesPhysics, grp.IsTemporary, true, grp.IsVolumeDetect);
+
Vector3 inventoryStoredPosition = new Vector3
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
? Constants.RegionSize - 6
--
cgit v1.1
From 4b4c5e69e59eb7461ccaa67fd4467e0606ffbe8e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 22:45:51 +0100
Subject: Remove forcing of phantom on ground attached objects - attachments
can be both non-phantom and flagged as physical.
As per Melanie
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 --
1 file changed, 2 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 767908e..928d43f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -669,8 +669,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
- grp.UpdatePrimFlags(grp.LocalId, grp.UsesPhysics, grp.IsTemporary, true, grp.IsVolumeDetect);
-
Vector3 inventoryStoredPosition = new Vector3
(((grp.AbsolutePosition.X > (int)Constants.RegionSize)
? Constants.RegionSize - 6
--
cgit v1.1
From 6c692d2e2108eac31624b34e462b8b57b5141970 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 21:26:29 +0100
Subject: Fix a very recent regression from llAttachToAvatar() fix where I
accidentally stopped normal script state persistence on login/logout and
attach/detach
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 928d43f..afaf5c1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -560,11 +560,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.GetAttachmentPoint());
- // If we're being called from a script, then trying to serialize that same script's state will not complete
- // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
- // the client/server crashes rather than logging out normally, the attachment's scripts will resume
- // without state on relog. Arguably, this is what we want anyway.
- string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
+ string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
item = m_scene.InventoryService.GetItem(item);
--
cgit v1.1
From fcbed6479af5d64383c4ad5578ea28d7db5c3ae2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 21:46:12 +0100
Subject: Downgrade warning about not saving unchanged attachment to debug
instead, and change text to better indicate what it's saying
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index afaf5c1..2c49ba8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -552,7 +552,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
if (!grp.HasGroupChanged)
{
- m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
+ m_log.DebugFormat(
+ "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
+ grp.UUID, grp.GetAttachmentPoint());
+
return;
}
--
cgit v1.1
From 002313bf132e7eca3d33fdd0c695152146d469b4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:02:23 +0100
Subject: refactor: move sog.DetachToInventoryPrep() into
AttachmentsModule.DetachSingleAttachmentToInv()
---
.../Avatar/Attachments/AttachmentsModule.cs | 25 ++++++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2c49ba8..732e3e3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -502,17 +502,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
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());
+ sp.RemoveAttachment(group);
- // If an item contains scripts, it's always changed.
- // This ensures script state is saved on detach
- foreach (SceneObjectPart p in group.Parts)
- if (p.Inventory.ContainsScripts())
- group.HasGroupChanged = true;
+ // Prepare sog for storage
+ group.ForEachPart(
+ delegate(SceneObjectPart part)
+ {
+ part.AttachedAvatar = UUID.Zero;
+
+ // 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.RootPart.IsAttachment = false;
+ group.AbsolutePosition = group.RootPart.AttachedPos;
UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
m_scene.DeleteSceneObject(group, false);
+
return;
}
}
--
cgit v1.1
From ae614c1264a2c4d06f019f2a91ad481cc2f96770 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:37:53 +0100
Subject: refactor: simplify DetachSingleAttachmentToGround() by retrieving the
scene object group direct
---
.../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 732e3e3..42a18c5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -449,29 +449,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
}
- public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
+ public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient)
{
- SceneObjectPart part = m_scene.GetSceneObjectPart(itemID);
- if (part == null || part.ParentGroup == null)
+ SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID);
+
+ if (so == null)
return;
- if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId)
+ if (so.RootPart.AttachedAvatar != remoteClient.AgentId)
return;
- UUID inventoryID = part.ParentGroup.GetFromItemID();
+ UUID inventoryID = so.GetFromItemID();
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
if (!m_scene.Permissions.CanRezObject(
- part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
+ so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
return;
- bool changed = presence.Appearance.DetachAttachment(itemID);
+ bool changed = presence.Appearance.DetachAttachment(sceneObjectID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- part.ParentGroup.DetachToGround();
+ so.DetachToGround();
List uuids = new List();
uuids.Add(inventoryID);
@@ -479,7 +480,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
remoteClient.SendRemoveInventoryItem(inventoryID);
}
- m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero);
+ m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero);
}
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
--
cgit v1.1
From 5f3ffc195f60ac54492ccb389843f292b0be7511 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:49:11 +0100
Subject: refactor: move SOG.DetachToGround() to
AttachmentsModule.DetachSceneObjectToGround() and remove redundant code
---
.../Avatar/Attachments/AttachmentsModule.cs | 30 +++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 42a18c5..93920b0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -472,7 +472,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
- so.DetachToGround();
+ presence.RemoveAttachment(so);
+ DetachSceneObjectToGround(so, presence);
List uuids = new List();
uuids.Add(inventoryID);
@@ -482,6 +483,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero);
}
+
+ ///
+ /// Detach the given scene objet to the ground.
+ ///
+ ///
+ /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc.
+ ///
+ /// The scene object to detach.
+ /// The scene presence from which the scene object is being detached.
+ private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp)
+ {
+ SceneObjectPart rootPart = so.RootPart;
+
+ rootPart.FromItemID = UUID.Zero;
+ so.AbsolutePosition = sp.AbsolutePosition;
+ so.ForEachPart(part => part.AttachedAvatar = UUID.Zero);
+ rootPart.SetParentLocalId(0);
+ so.ClearPartAttachmentData();
+ rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
+ so.HasGroupChanged = true;
+ rootPart.Rezzed = DateTime.Now;
+ rootPart.RemFlag(PrimFlags.TemporaryOnRez);
+ so.AttachToBackup();
+ m_scene.EventManager.TriggerParcelPrimCountTainted();
+ rootPart.ScheduleFullUpdate();
+ rootPart.ClearUndoState();
+ }
// 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??
--
cgit v1.1
From 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 23:06:41 +0100
Subject: refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar
This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 93920b0..3e1cb02 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -456,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (so == null)
return;
- if (so.RootPart.AttachedAvatar != remoteClient.AgentId)
+ if (so.AttachedAvatar != remoteClient.AgentId)
return;
UUID inventoryID = so.GetFromItemID();
@@ -498,7 +498,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
rootPart.FromItemID = UUID.Zero;
so.AbsolutePosition = sp.AbsolutePosition;
- so.ForEachPart(part => part.AttachedAvatar = UUID.Zero);
+ so.AttachedAvatar = UUID.Zero;
rootPart.SetParentLocalId(0);
so.ClearPartAttachmentData();
rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
@@ -534,11 +534,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
sp.RemoveAttachment(group);
// Prepare sog for storage
+ group.AttachedAvatar = UUID.Zero;
+
group.ForEachPart(
delegate(SceneObjectPart part)
{
- part.AttachedAvatar = UUID.Zero;
-
// If there are any scripts,
// then always trigger a new object and state persistence in UpdateKnownItem()
if (part.Inventory.ContainsScripts())
@@ -656,12 +656,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
m_scene.DeleteFromStorage(so.UUID);
m_scene.EventManager.TriggerParcelPrimCountTainted();
- so.RootPart.AttachedAvatar = avatar.UUID;
-
- //Anakin Lohner bug #3839
- SceneObjectPart[] parts = so.Parts;
- for (int i = 0; i < parts.Length; i++)
- parts[i].AttachedAvatar = avatar.UUID;
+ so.AttachedAvatar = avatar.UUID;
if (so.RootPart.PhysActor != null)
{
--
cgit v1.1
From 33a894f3d2cc95a7a512b86f39f3c6a6afabb015 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 27 Aug 2011 00:15:21 +0100
Subject: refactor: move SOP.IsAttachment and AttachmentPoint up into SOG to
avoid pointless duplication of identical values
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 3e1cb02..b976020 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -369,11 +369,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt)
{
// m_log.DebugFormat(
-// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
-// remoteClient.Name, att.Name, itemID);
+// "[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)
- AttachmentPt = att.RootPart.AttachmentPoint;
+ AttachmentPt = att.AttachmentPoint;
InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
item = m_scene.InventoryService.GetItem(item);
@@ -547,7 +547,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
);
group.RootPart.SetParentLocalId(0);
- group.RootPart.IsAttachment = false;
+ group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
@@ -569,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Finally, we restore the object's attachment status.
byte attachmentPoint = sog.GetAttachmentPoint();
sog.UpdateGroupPosition(pos);
- sog.RootPart.IsAttachment = false;
+ sog.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
sog.SetAttachmentPoint(attachmentPoint);
sog.HasGroupChanged = true;
@@ -666,8 +666,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.AbsolutePosition = attachOffset;
so.RootPart.AttachedPos = attachOffset;
- so.RootPart.IsAttachment = true;
-
+ so.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
--
cgit v1.1
From b7700428ec298f29ae4cbb0e1090728fe3b93602 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 27 Aug 2011 00:20:15 +0100
Subject: refactor: camel case AttachmentPoint method arg as per code standards
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index b976020..d9259b3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -363,22 +363,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
///
- ///
+ ///
///
private UUID ShowAttachInUserInventory(
- SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt)
+ SceneObjectGroup att, ScenePresence 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)
- AttachmentPt = att.AttachmentPoint;
+ attachmentPoint = att.AttachmentPoint;
InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
item = m_scene.InventoryService.GetItem(item);
- bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
+ bool changed = sp.Appearance.SetAttachment((int)attachmentPoint, itemID, item.AssetID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
--
cgit v1.1
From 1615e7d29fb6961a3ffe791fde4318f819c1a4b7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 27 Aug 2011 00:33:24 +0100
Subject: Eliminate duplicate AttachmentPoint properties by always using the
one stored in the root part's state field.
---
.../Avatar/Attachments/AttachmentsModule.cs | 42 +++++++++++-----------
1 file changed, 21 insertions(+), 21 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index d9259b3..2d5eb18 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -167,13 +167,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return AttachObject(sp, group, AttachmentPt, silent);
}
- private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent)
+ private bool AttachObject(ScenePresence 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))
+ 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",
@@ -186,39 +186,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// 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;
+ 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 != (uint)group.GetAttachmentPoint())
+ if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
{
attachPos = Vector3.Zero;
}
// AttachmentPt 0 means the client chose to 'wear' the attachment.
- if (AttachmentPt == 0)
+ if (attachmentPt == 0)
{
// Check object for stored attachment point
- AttachmentPt = (uint)group.GetAttachmentPoint();
+ attachmentPt = group.AttachmentPoint;
}
// if we still didn't find a suitable attachment point.......
- if (AttachmentPt == 0)
+ if (attachmentPt == 0)
{
// Stick it on left hand with Zero Offset from the attachment point.
- AttachmentPt = (uint)AttachmentPoint.LeftHand;
+ attachmentPt = (uint)AttachmentPoint.LeftHand;
attachPos = Vector3.Zero;
}
- group.SetAttachmentPoint((byte)AttachmentPt);
+ group.AttachmentPoint = attachmentPt;
group.AbsolutePosition = attachPos;
// Remove any previous attachments
UUID itemID = UUID.Zero;
foreach (SceneObjectGroup grp in sp.Attachments)
{
- if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
+ if (grp.AttachmentPoint == attachmentPt)
{
itemID = grp.GetFromItemID();
break;
@@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (itemID == UUID.Zero)
itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
- ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
+ ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
- AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
+ AttachToAgent(sp, group, attachmentPt, attachPos, silent);
return true;
}
@@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
- ScenePresence sp, UUID itemID, uint AttachmentPt)
+ ScenePresence sp, UUID itemID, uint attachmentPt)
{
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface();
if (invAccess != null)
@@ -313,13 +313,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// since scripts aren't running yet. So, clear it here.
objatt.HasGroupChanged = false;
bool tainted = false;
- if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
+ if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
tainted = true;
// This will throw if the attachment fails
try
{
- AttachObject(sp, objatt, AttachmentPt, false);
+ AttachObject(sp, objatt, attachmentPt, false);
}
catch (Exception e)
{
@@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
- itemID, sp.Name, AttachmentPt);
+ itemID, sp.Name, attachmentPt);
}
return objatt;
@@ -567,11 +567,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// attachment. This is necessary in order to correctly save
// and retrieve GroupPosition information for the attachment.
// Finally, we restore the object's attachment status.
- byte attachmentPoint = sog.GetAttachmentPoint();
+ uint attachmentPoint = sog.AttachmentPoint;
sog.UpdateGroupPosition(pos);
sog.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
- sog.SetAttachmentPoint(attachmentPoint);
+ sog.AttachmentPoint = attachmentPoint;
sog.HasGroupChanged = true;
}
@@ -594,14 +594,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
- grp.UUID, grp.GetAttachmentPoint());
+ grp.UUID, grp.AttachmentPoint);
return;
}
m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
- grp.UUID, grp.GetAttachmentPoint());
+ grp.UUID, grp.AttachmentPoint);
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
@@ -668,7 +668,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.RootPart.AttachedPos = attachOffset;
so.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
- so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
+ so.AttachmentPoint = attachmentpoint;
avatar.AddAttachment(so);
--
cgit v1.1
From e7a515bab0e46c228f8f543397f97b7ba2f0df3c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 30 Aug 2011 22:06:24 +0100
Subject: Fix bug where attachments were remaining on the avatar after being
dropped.
If the inventory service is configured not to allow deletion then these will not disappear from inventory
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2d5eb18..b7a7f77 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -451,6 +451,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient)
{
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
+// remoteClient.Name, sceneObjectID);
+
SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID);
if (so == null)
@@ -461,6 +465,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
UUID inventoryID = so.GetFromItemID();
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
+// so.Name, so.LocalId, inventoryID);
+
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
@@ -468,7 +476,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
return;
- bool changed = presence.Appearance.DetachAttachment(sceneObjectID);
+ bool changed = presence.Appearance.DetachAttachment(inventoryID);
if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
@@ -485,7 +493,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
///
- /// Detach the given scene objet to the ground.
+ /// Detach the given scene object to the ground.
///
///
/// The caller has to take care of all the other work in updating avatar appearance, inventory, etc.
--
cgit v1.1
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
---
.../Avatar/Attachments/AttachmentsModule.cs | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
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);
}
///
--
cgit v1.1
From 04bafd21221a789b83b039efd1c52e141944cde0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 30 Aug 2011 23:05:43 +0100
Subject: refactor: Move ScenePresence.RezAttachments() into AttachmentsModule
This adds an incomplete IScenePresence to match ISceneEntity
---
.../Avatar/Attachments/AttachmentsModule.cs | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 02fd387..f6aea89 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -95,6 +95,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv;
client.OnObjectDrop -= DetachSingleAttachmentToGround;
}
+
+ ///
+ /// RezAttachments. This should only be called upon login on the first region.
+ /// Attachment rezzings on crossings and TPs are done in a different way.
+ ///
+ public void RezAttachments(IScenePresence sp)
+ {
+ if (null == sp.Appearance)
+ {
+ m_log.WarnFormat("[ATTACHMENTS MODULE]: Appearance has not been initialized for agent {0}", sp.UUID);
+ return;
+ }
+
+ List attachments = sp.Appearance.GetAttachments();
+ foreach (AvatarAttachment attach in attachments)
+ {
+ int p = attach.AttachPoint;
+ UUID itemID = attach.ItemID;
+
+ //UUID assetID = attach.AssetID;
+ // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
+ // But they're not used anyway, the item is being looked up for now, so let's proceed.
+ //if (UUID.Zero == assetID)
+ //{
+ // m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
+ // continue;
+ //}
+
+ try
+ {
+ RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, (uint)p);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace);
+ }
+ }
+ }
///
/// Called by client
--
cgit v1.1
From ddc733cd3d940a4357eb0d235562050eb6f206bf Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 30 Aug 2011 23:32:30 +0100
Subject: refactor: move SP.SaveChangedAttachments() fully into
AttachmentsModule
---
.../Avatar/Attachments/AttachmentsModule.cs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f6aea89..201ce7f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -133,6 +133,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
}
}
+
+ public void SaveChangedAttachments(IScenePresence sp)
+ {
+ // Need to copy this list because DetachToInventoryPrep mods it
+ List attachments = new List(sp.Attachments.ToArray());
+
+ foreach (SceneObjectGroup grp in attachments)
+ {
+ if (grp.HasGroupChanged) // Resizer scripts?
+ {
+ grp.IsAttachment = false;
+ grp.AbsolutePosition = grp.RootPart.AttachedPos;
+// grp.DetachToInventoryPrep();
+ UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID);
+ grp.IsAttachment = true;
+ }
+ }
+ }
///
/// Called by client
--
cgit v1.1
From 1809aaf74c3594ec40df8688a2dcc42074ddeec4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 30 Aug 2011 23:36:45 +0100
Subject: minor: remove already processed avatar null check in
Scene.RemoveClient()
remove some now duplicated method doc
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 1 -
1 file changed, 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 201ce7f..e2f6a9e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -145,7 +145,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{
grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos;
-// grp.DetachToInventoryPrep();
UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID);
grp.IsAttachment = true;
}
--
cgit v1.1
From 2acfff9f6d340984bbc51c4d18c2babe2e3cb6ca Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 30 Aug 2011 23:39:26 +0100
Subject: remove pointless ToArray() call in
AttachmentsModule.SaveChangedAttachments()
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index e2f6a9e..f4bc495 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -137,7 +137,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void SaveChangedAttachments(IScenePresence sp)
{
// Need to copy this list because DetachToInventoryPrep mods it
- List attachments = new List(sp.Attachments.ToArray());
+ List attachments = new List(sp.Attachments);
foreach (SceneObjectGroup grp in attachments)
{
--
cgit v1.1
From 32444d98cb13423fdf8c874e4fbb7ea17670d7c5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 31 Aug 2011 16:29:51 +0100
Subject: Make SP.Attachments available as sp.GetAttachments() instead.
The approach here, as in other parts of OpenSim, is to return a copy of the list rather than the attachments list itself
This prevents callers from forgetting to lock the list when they read it, as was happening in various parts of the codebase.
It also improves liveness.
This might improve attachment anomolies when performing region crossings.
---
.../Avatar/Attachments/AttachmentsModule.cs | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f4bc495..9e5ce8f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -136,10 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void SaveChangedAttachments(IScenePresence sp)
{
- // Need to copy this list because DetachToInventoryPrep mods it
- List attachments = new List(sp.Attachments);
-
- foreach (SceneObjectGroup grp in attachments)
+ foreach (SceneObjectGroup grp in sp.GetAttachments())
{
if (grp.HasGroupChanged) // Resizer scripts?
{
@@ -273,14 +270,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Remove any previous attachments
UUID itemID = UUID.Zero;
- foreach (SceneObjectGroup grp in sp.Attachments)
- {
- if (grp.AttachmentPoint == attachmentPt)
- {
- itemID = grp.GetFromItemID();
- break;
- }
- }
+
+ 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);
--
cgit v1.1
From 7d58b5fa157b4c3e842573d9fb02a9822034f4b0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 31 Aug 2011 17:53:58 +0100
Subject: move common code into AttachmentsModule.DeleteAttachmentsFromScene()
---
.../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 10 ++++++++++
1 file changed, 10 insertions(+)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 9e5ce8f..587f35e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -147,6 +147,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
}
}
+
+ public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
+ {
+ foreach (SceneObjectGroup sop in sp.GetAttachments())
+ {
+ sop.Scene.DeleteSceneObject(sop, silent);
+ }
+
+ sp.ClearAttachments();
+ }
///
/// Called by client
--
cgit v1.1
From 7eca929686bd2db1cb42f5c9740fd1d186cdc8b1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 1 Sep 2011 02:09:41 +0100
Subject: Eliminate pointless checks of SOG.RootPart != null
It's never possible for SOG to have no RootPart, except in the first few picosends of the big bang when it's pulled from region persistence or deserialized
---
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 ------
1 file changed, 6 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 587f35e..ffe76a8 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -470,12 +470,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return;
}
- if (null == att.RootPart)
- {
- m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!");
- return;
- }
-
InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
item = m_scene.InventoryService.GetItem(item);
bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
--
cgit v1.1
From 5c1fa968ab954bec9860023dffc8f68baf3c0620 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 3 Sep 2011 01:11:16 +0100
Subject: Stop NPCs losing attachments when the source avatar takes them off.
This was happening because we were using the source avatar's item IDs in the clone appearance.
Switch to using the asset IDs of attachments instead for NPCs.
The InventoryAccessModule and AttachmentModule had to be changed to allow rezzing of an object without an associated inventory item.
Hopefully goes some way towards resolving http://opensimulator.org/mantis/view.php?id=5653
---
.../Avatar/Attachments/AttachmentsModule.cs | 76 ++++++++++++++--------
1 file changed, 48 insertions(+), 28 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index ffe76a8..4881499 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -111,10 +111,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
List attachments = sp.Appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
- int p = attach.AttachPoint;
- UUID itemID = attach.ItemID;
+ uint p = (uint)attach.AttachPoint;
+
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Doing initial rez of attachment with itemID {0}, assetID {1}, point {2} for {3} in {4}",
+// attach.ItemID, attach.AssetID, p, sp.Name, m_scene.RegionInfo.RegionName);
- //UUID assetID = attach.AssetID;
// For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
// But they're not used anyway, the item is being looked up for now, so let's proceed.
//if (UUID.Zero == assetID)
@@ -125,7 +127,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
try
{
- RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, (uint)p);
+ // If we're an NPC then skip all the item checks and manipulations since we don't have an
+ // inventory right now.
+ if (sp.PresenceType == PresenceType.Npc)
+ RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p);
+ else
+ RezSingleAttachmentFromInventory(sp.ControllingClient, attach.ItemID, p);
}
catch (Exception e)
{
@@ -231,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return AttachObject(sp, group, AttachmentPt, silent);
}
- private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
+ 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})",
@@ -284,17 +291,21 @@ namespace OpenSim.Region.CoreModules.Avatar.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);
-
- itemID = group.GetFromItemID();
- if (itemID == UUID.Zero)
- itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
-
- ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
+ // We also don't want to do any of the inventory operations for an NPC.
+ if (sp.PresenceType != PresenceType.Npc)
+ {
+ if (attachments.Count != 0)
+ itemID = attachments[0].GetFromItemID();
+
+ if (itemID != UUID.Zero)
+ DetachSingleAttachmentToInv(itemID, sp);
+
+ itemID = group.GetFromItemID();
+ if (itemID == UUID.Zero)
+ itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
+
+ ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
+ }
AttachToAgent(sp, group, attachmentPt, attachPos, silent);
@@ -312,7 +323,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
}
- public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
+ public ISceneEntity RezSingleAttachmentFromInventory(
+ IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true);
}
@@ -338,7 +350,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// be removed when that functionality is implemented in opensim
AttachmentPt &= 0x7f;
- SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt);
+ SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
if (updateInventoryStatus)
{
@@ -352,14 +364,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
- ScenePresence sp, UUID itemID, uint attachmentPt)
+ IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt)
{
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface();
if (invAccess != null)
{
- SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient,
- itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
- false, false, sp.UUID, true);
+ 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}",
@@ -425,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
private UUID ShowAttachInUserInventory(
- SceneObjectGroup att, ScenePresence sp, UUID itemID, uint attachmentPoint)
+ 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}",
@@ -452,7 +471,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
private void ShowAttachInUserInventory(
- ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
+ IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
{
// m_log.DebugFormat(
// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
@@ -574,7 +593,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// 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??
- private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp)
+ private void DetachSingleAttachmentToInv(UUID itemID, IScenePresence sp)
{
if (itemID == UUID.Zero) // If this happened, someone made a mistake....
return;
@@ -697,16 +716,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
/// Attach this scene object to the given avatar.
///
- ///
+ ///
/// This isn't publicly available since attachments should always perform the corresponding inventory
/// operation (to show the attach in user inventory and update the asset with positional information).
- ///
+ ///
///
///
///
///
///
- protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
+ 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}",
// so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
--
cgit v1.1