From 818379ba14e487568571113d24a9de7c3a29b458 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 29 Sep 2012 01:14:23 +0100 Subject: Fire EventManager.TriggerOnAttach (and hence LSL attach event) when an object is attached from the scene. Enables previously disabled regression test. Based on SingpostMarv's patch in http://opensimulator.org/mantis/view.php?id=6302 but I prefer a simpler approach that does not expose a resume scripts option right now. --- .../Avatar/Attachments/AttachmentsModule.cs | 28 +++++++++++++--------- .../Attachments/Tests/AttachmentsModuleTests.cs | 4 +--- 2 files changed, 18 insertions(+), 14 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 c74584c..130c869 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -238,9 +238,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments sp.ClearAttachments(); } - + public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) { + if (!Enabled) + return false; + + if (AttachObjectInternal(sp, group, attachmentPt, silent, temp)) + { + m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); + return true; + } + + return false; + } + + private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) + { lock (sp.AttachmentsSyncLock) { // m_log.DebugFormat( @@ -794,7 +808,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // This will throw if the attachment fails try { - AttachObject(sp, objatt, attachmentPt, false, false); + AttachObjectInternal(sp, objatt, attachmentPt, false, false); } catch (Exception e) { @@ -951,15 +965,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments AttachmentPt &= 0x7f; // Calls attach with a Zero position - if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false)) - { -// m_log.Debug( -// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId -// + ", AttachmentPoint: " + AttachmentPt); - - // Save avatar attachment information - m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); - } + AttachObject(sp, part.ParentGroup, AttachmentPt, false, false); } catch (Exception e) { diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8d4e2e0..0ee01c7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -225,9 +225,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events - - // FIXME: This is currently not occuring! -// Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); + Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); } /// -- cgit v1.1