From 0d49611f6db017da16b6099c440b6c1e2b2218b9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Apr 2011 15:52:06 -0700 Subject: [PATCH] Remove the scripts of the attachments in the departing region and recreate them if fail. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 12 ++++++++++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 10547857f7..b985fbb371 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -479,7 +479,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Fail. Reset it back sp.IsChildAgent = false; - + ReInstantiateScripts(sp); ResetFromTransit(sp.UUID); EnableChildAgents(sp); @@ -930,6 +930,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!WaitForCallback(agent.UUID)) { m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent"); + ReInstantiateScripts(agent); ResetFromTransit(agent.UUID); // Yikes! We should just have a ref to scene here. @@ -1756,7 +1757,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return false; } - + protected void ReInstantiateScripts(ScenePresence sp) + { + sp.Attachments.ForEach(delegate(SceneObjectGroup sog) + { + sog.CreateScriptInstances(0, false, sp.Scene.DefaultScriptEngine, 0); + sog.ResumeScripts(); + }); + } #endregion } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fe4a7d1fa7..9b9d9dabc8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3113,6 +3113,8 @@ namespace OpenSim.Region.Framework.Scenes ((SceneObjectGroup)clone).RootPart.IsAttachment = false; cAgent.AttachmentObjects.Add(clone); cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot()); + // Let's remove the scripts of the original object here + sog.RemoveScriptInstances(true); } } }