From 01276ef43304c3bd9a090e809b7d4f44ecfffcf5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 31 Aug 2010 22:22:45 +0100
Subject: refactor: change AttachmentsModule.AttachObject to use
sp.GetAttachments rather than filter sp.Attachments list directly
---
.../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index d56145a..de65460 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -173,16 +173,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
UUID itemID = UUID.Zero;
if (sp != null)
{
- foreach(SceneObjectGroup grp in sp.Attachments)
+ foreach(SceneObjectGroup grp in sp.GetAttachments(AttachmentPt))
{
- if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
- {
- itemID = grp.GetFromItemID();
- break;
- }
- }
- if (itemID != UUID.Zero)
- DetachSingleAttachmentToInv(itemID, remoteClient);
+ itemID = grp.GetFromItemID();
+ if (itemID != UUID.Zero)
+ DetachSingleAttachmentToInv(itemID, remoteClient);
+ }
}
if (group.GetFromItemID() == UUID.Zero)
--
cgit v1.1
From 6cbf66827ba3cb878ab70b75fc4e3221b71d820e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 1 Sep 2010 01:11:52 +0100
Subject: refactor: move SOG.AttachToAgent() into AttachmentsModule
---
.../Avatar/Attachments/AttachmentsModule.cs | 81 ++++++++++++++++++++--
1 file changed, 74 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar/Attachments')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index de65460..6555b54 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -192,12 +192,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group);
- group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
-
- // In case it is later dropped again, don't let
- // it get cleaned up
- group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
- group.HasGroupChanged = false;
+ AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
}
else
{
@@ -525,6 +520,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
}
- }
+ }
+
+ ///
+ /// 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)
+ {
+ // don't attach attachments to child agents
+ if (avatar.IsChildAgent) return;
+
+// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
+
+ so.DetachFromBackup();
+
+ // Remove from database and parcel prim count
+ m_scene.DeleteFromStorage(so.UUID);
+ m_scene.EventManager.TriggerParcelPrimCountTainted();
+
+ so.RootPart.AttachedAvatar = avatar.UUID;
+
+ //Anakin Lohner bug #3839
+ lock (so.Children)
+ {
+ foreach (SceneObjectPart p in so.Children.Values)
+ {
+ p.AttachedAvatar = avatar.UUID;
+ }
+ }
+
+ if (so.RootPart.PhysActor != null)
+ {
+ m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
+ so.RootPart.PhysActor = null;
+ }
+
+ so.AbsolutePosition = AttachOffset;
+ so.RootPart.AttachedPos = AttachOffset;
+ so.RootPart.IsAttachment = true;
+
+ so.RootPart.SetParentLocalId(avatar.LocalId);
+ so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
+
+ avatar.AddAttachment(so);
+
+ if (!silent)
+ {
+ // Killing it here will cause the client to deselect it
+ // It then reappears on the avatar, deselected
+ // through the full update below
+ //
+ if (so.IsSelected)
+ {
+ m_scene.SendKillObject(so.RootPart.LocalId);
+ }
+
+ so.IsSelected = false; // fudge....
+ so.ScheduleGroupForFullUpdate();
+ }
+
+ // In case it is later dropped again, don't let
+ // it get cleaned up
+ so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
+ so.HasGroupChanged = false;
+ }
}
}
\ No newline at end of file
--
cgit v1.1