From 53a01dc42273b9252eb290187e87a47a898af86a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 1 Feb 2010 20:06:43 +0000 Subject: Don't try to start attachment scripts or send updates if the attachment itself has been unsuccessful --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 77 ++++++++++++++++++--------- 1 file changed, 52 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f74fd5d..fc2798d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -478,46 +478,59 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; - if (!m_parentScene.Permissions.CanTakeObject( - part.UUID, remoteClient.AgentId)) + if (!m_parentScene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) return; // Calls attach with a Zero position - AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false); - m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); - - // Save avatar attachment information - ScenePresence presence; - if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) + if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) { - m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", AttachmentPoint: " + AttachmentPt); - m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); + + // Save avatar attachment information + ScenePresence presence; + if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) + { + m_log.Info( + "[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + + ", AttachmentPoint: " + AttachmentPt); + + m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } } } - public SceneObjectGroup RezSingleAttachment( - IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + /// + /// Rez an attachment + /// + /// + /// + /// + /// The scene object that was attached. Null if the scene object could not be found + public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) { SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, false, false, remoteClient.AgentId, true); - if (objatt != null) { bool tainted = false; if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) tainted = true; - AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); - objatt.ScheduleGroupForFullUpdate(); - if (tainted) - objatt.HasGroupChanged = true; - - // Fire after attach, so we don't get messy perms dialogs - // 3 == AttachedRez - objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + if (AttachObject( + remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false)) + { + objatt.ScheduleGroupForFullUpdate(); + if (tainted) + objatt.HasGroupChanged = true; + + // Fire after attach, so we don't get messy perms dialogs + // 3 == AttachedRez + objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + } } + return objatt; } @@ -554,7 +567,17 @@ namespace OpenSim.Region.Framework.Scenes } } - protected internal void AttachObject( + /// + /// Attach a scene object to an avatar. + /// + /// + /// + /// + /// + /// + /// + /// true if the attachment was successful, false otherwise + protected internal bool AttachObject( IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) { SceneObjectGroup group = GetGroupByPrim(objectLocalID); @@ -583,10 +606,8 @@ namespace OpenSim.Region.Framework.Scenes // Stick it on left hand with Zero Offset from the attachment point. AttachmentPt = (uint)AttachmentPoint.LeftHand; attachPos = Vector3.Zero; - } - group.SetAttachmentPoint((byte)AttachmentPt); group.AbsolutePosition = attachPos; @@ -609,15 +630,21 @@ namespace OpenSim.Region.Framework.Scenes // it get cleaned up // group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); - group.HasGroupChanged = false; + group.HasGroupChanged = false; } else { remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); + return false; } } else + { m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); + return false; + } + + return true; } protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) -- cgit v1.1 From 4c1740f7d8e4e577167a84438cce83a7cc32f56d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 1 Feb 2010 20:15:36 +0000 Subject: Actually make EventManager.OnAttach() fire when an object is attached. Previously, only detach was firing! --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index fc2798d..1ac061a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -528,6 +528,9 @@ namespace OpenSim.Region.Framework.Scenes // Fire after attach, so we don't get messy perms dialogs // 3 == AttachedRez objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); + + // Do this last so that event listeners have access to all the effects of the attachment + m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); } } -- cgit v1.1 From b6bee4999c9d238a052022f105069ea4eb85f8f4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Feb 2010 15:35:41 +0000 Subject: change position of OnAttach event firing so that this also happens when a user teleports into a region --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1ac061a..b508af5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -627,11 +627,10 @@ namespace OpenSim.Region.Framework.Scenes } m_parentScene.AttachObject(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; } -- cgit v1.1 From 2953bee1f4443e041dbce38d042f6ed421d30533 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Feb 2010 17:11:06 +0000 Subject: Revert "change position of OnAttach event firing so that this also happens when a user teleports into a region" The behavior introduced here is not compatible with SL This reverts commit b6bee4999c9d238a052022f105069ea4eb85f8f4. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b508af5..1ac061a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -627,10 +627,11 @@ namespace OpenSim.Region.Framework.Scenes } m_parentScene.AttachObject(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; } -- cgit v1.1