Fix bug where CHANGED_REGION and/or CHANGED_TELEPORT weren't firing for scripts in attachments.

This was because the script resumption in AttachmentsModule was firing the attach event instead.
Had to reinstate the code in 285bd3a do we can resume the scripts there instead, though the bug existed before its removal.
This is to resolve http://opensimulator.org/mantis/view.php?id=6578
user_profiles
Justin Clark-Casey (justincc) 2013-03-29 02:21:38 +00:00
parent e89bcf4f77
commit 23ae4c0a4d
4 changed files with 31 additions and 2 deletions

View File

@ -328,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (!Enabled)
return false;
return AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, true, append);
return AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, false, append);
}
/// <summary>

View File

@ -2739,7 +2739,10 @@ namespace OpenSim.Region.Framework.Scenes
// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
// We must currently not resume scripts at this stage since AttachmentsModule does not have the
// information that this is due to a teleport/border cross rather than an ordinary attachment.
// We currently do this in Scene.MakeRootAgent() instead.
if (AttachmentsModule != null)
AttachmentsModule.AttachObject(sp, grp, 0, false, false, true);
}

View File

@ -3203,6 +3203,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="events"></param>
public void SetScriptEvents(UUID scriptid, int events)
{
// m_log.DebugFormat(
// "[SCENE OBJECT PART]: Set script events for script with id {0} on {1}/{2} to {3} in {4}",
// scriptid, Name, ParentGroup.Name, events, ParentGroup.Scene.Name);
// scriptEvents oldparts;
lock (m_scriptEvents)
{

View File

@ -968,6 +968,28 @@ namespace OpenSim.Region.Framework.Scenes
Scene.AttachmentsModule.RezAttachments(this);
});
}
else
{
// We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
// and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
// be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
// not transporting the required data.
lock (m_attachments)
{
if (HasAttachments())
{
m_log.DebugFormat(
"[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
// Resume scripts
foreach (SceneObjectGroup sog in m_attachments)
{
sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
sog.ResumeScripts();
}
}
}
}
// send the animations of the other presences to me
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)