Simplify Scene.AddNewClient()
If sp becomes null right after we've checked or created it, then behaviour down the line is going to be wrong anyway. So instead retain the check/create ScenePresence reference and use this.0.7.2-post-fixes
parent
ac445463e9
commit
6ba4cbc259
|
@ -2468,7 +2468,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
#region Add/Remove Avatar Methods
|
#region Add/Remove Avatar Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new client and create a child agent for it.
|
/// Add a new client and create a child scene presence for it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="client"></param>
|
/// <param name="client"></param>
|
||||||
/// <param name="type">The type of agent to add.</param>
|
/// <param name="type">The type of agent to add.</param>
|
||||||
|
@ -2485,43 +2485,54 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
CheckHeartbeat();
|
CheckHeartbeat();
|
||||||
|
|
||||||
if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
|
ScenePresence sp = GetScenePresence(client.AgentId);
|
||||||
|
|
||||||
|
// XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this
|
||||||
|
// could occur if a viewer crashes and relogs before the old client is kicked out. But this could cause
|
||||||
|
// other problems, and possible the code calling AddNewClient() should ensure that no client is already
|
||||||
|
// connected.
|
||||||
|
if (sp == null)
|
||||||
{
|
{
|
||||||
m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
|
m_log.Debug("[SCENE]: Adding new child scene presence " + client.Name + " to scene " + RegionInfo.RegionName);
|
||||||
|
|
||||||
m_clientManager.Add(client);
|
m_clientManager.Add(client);
|
||||||
SubscribeToClientEvents(client);
|
SubscribeToClientEvents(client);
|
||||||
|
|
||||||
ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
|
sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
|
||||||
m_eventManager.TriggerOnNewPresence(sp);
|
m_eventManager.TriggerOnNewPresence(sp);
|
||||||
|
|
||||||
sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
|
sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
|
||||||
|
|
||||||
// HERE!!! Do the initial attachments right here
|
// The first agent upon login is a root agent by design.
|
||||||
// first agent upon login is a root agent by design.
|
// For this agent we will have to rez the attachments.
|
||||||
// All other AddNewClient calls find aCircuit.child to be true
|
// All other AddNewClient calls find aCircuit.child to be true.
|
||||||
if (aCircuit.child == false)
|
if (aCircuit.child == false)
|
||||||
{
|
{
|
||||||
|
// We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to
|
||||||
|
// start the scripts again (since this is done in RezAttachments()).
|
||||||
|
// XXX: This is convoluted.
|
||||||
sp.IsChildAgent = false;
|
sp.IsChildAgent = false;
|
||||||
|
|
||||||
if (AttachmentsModule != null)
|
if (AttachmentsModule != null)
|
||||||
Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
|
Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
ScenePresence createdSp = GetScenePresence(client.AgentId);
|
|
||||||
if (createdSp != null)
|
|
||||||
{
|
{
|
||||||
|
m_log.WarnFormat(
|
||||||
|
"[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence",
|
||||||
|
sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
|
||||||
|
}
|
||||||
|
|
||||||
m_LastLogin = Util.EnvironmentTickCount();
|
m_LastLogin = Util.EnvironmentTickCount();
|
||||||
|
|
||||||
// Cache the user's name
|
// Cache the user's name
|
||||||
CacheUserName(createdSp, aCircuit);
|
CacheUserName(sp, aCircuit);
|
||||||
|
|
||||||
EventManager.TriggerOnNewClient(client);
|
EventManager.TriggerOnNewClient(client);
|
||||||
if (vialogin)
|
if (vialogin)
|
||||||
EventManager.TriggerOnClientLogin(client);
|
EventManager.TriggerOnClientLogin(client);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cache the user name for later use.
|
/// Cache the user name for later use.
|
||||||
|
|
Loading…
Reference in New Issue