Delaying starting the scripts on TPs and crossings until the agent is root.

bulletsim
Diva Canto 2011-04-29 17:09:48 -07:00
parent 412503b216
commit 4d5d6222f7
2 changed files with 40 additions and 23 deletions

View File

@ -1229,7 +1229,6 @@ namespace OpenSim.Region.Framework.Scenes
// Increment the frame counter // Increment the frame counter
++Frame; ++Frame;
try try
{ {
// Check if any objects have reached their targets // Check if any objects have reached their targets
@ -2336,9 +2335,13 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
// For attachments, we need to wait until the agent is root
// before we restart the scripts, or else some functions won't work.
if (!newObject.IsAttachment)
{
newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
newObject.ResumeScripts(); newObject.ResumeScripts();
}
// Do this as late as possible so that listeners have full access to the incoming object // Do this as late as possible so that listeners have full access to the incoming object
EventManager.TriggerOnIncomingSceneObject(newObject); EventManager.TriggerOnIncomingSceneObject(newObject);
@ -2455,17 +2458,8 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence sp = GetScenePresence(sog.OwnerID); ScenePresence sp = GetScenePresence(sog.OwnerID);
if (sp != null) if (sp != null)
{ return sp.GetStateSource();
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(sp.UUID);
if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
{
// This will get your attention
//m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
return 5; // StateSource.Teleporting
}
}
return 2; // StateSource.PrimCrossing return 2; // StateSource.PrimCrossing
} }

View File

@ -840,6 +840,9 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
bool wasChild = m_isChildAgent;
m_isChildAgent = false;
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
if (gm != null) if (gm != null)
m_grouptitle = gm.GetGroupTitle(m_uuid); m_grouptitle = gm.GetGroupTitle(m_uuid);
@ -930,13 +933,20 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.SwapRootAgentCount(false); m_scene.SwapRootAgentCount(false);
//CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); // The initial login scene presence is already root when it gets here
//if (userInfo != null) // and it has already rezzed the attachments and started their scripts.
// userInfo.FetchInventory(); // We do the following only for non-login agents, because their scripts
//else // haven't started yet.
// m_log.ErrorFormat("[SCENE]: Could not find user info for {0} when making it a root agent", m_uuid); if (wasChild)
{
m_isChildAgent = false; m_log.DebugFormat("[SCENE PRESENCE]: Restarting scripts in attachments...");
// Resume scripts
Attachments.ForEach(delegate(SceneObjectGroup sog)
{
sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
sog.ResumeScripts();
});
}
// send the animations of the other presences to me // send the animations of the other presences to me
m_scene.ForEachScenePresence(delegate(ScenePresence presence) m_scene.ForEachScenePresence(delegate(ScenePresence presence)
@ -948,6 +958,20 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.EventManager.TriggerOnMakeRootAgent(this); m_scene.EventManager.TriggerOnMakeRootAgent(this);
} }
public int GetStateSource()
{
AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(UUID);
if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
{
// This will get your attention
//m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
return 5; // StateSource.Teleporting
}
return 2; // StateSource.PrimCrossing
}
/// <summary> /// <summary>
/// This turns a root agent into a child agent /// This turns a root agent into a child agent
/// when an agent departs this region for a neighbor, this gets called. /// when an agent departs this region for a neighbor, this gets called.
@ -1139,7 +1163,6 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = pos; AbsolutePosition = pos;
} }
m_isChildAgent = false;
bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
MakeRootAgent(AbsolutePosition, m_flying); MakeRootAgent(AbsolutePosition, m_flying);