aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-12-08 16:10:47 +0000
committerJustin Clark-Casey (justincc)2011-12-08 16:10:47 +0000
commit355cde464a7ada3c6ab8fce7eb4118ad5cec0351 (patch)
tree042dc6f5d25abb570e8b15fba1701f7e0c1bdbad /OpenSim/Region/Framework/Scenes/Scene.cs
parentRemove a left over log output (diff)
downloadopensim-SC_OLD-355cde464a7ada3c6ab8fce7eb4118ad5cec0351.zip
opensim-SC_OLD-355cde464a7ada3c6ab8fce7eb4118ad5cec0351.tar.gz
opensim-SC_OLD-355cde464a7ada3c6ab8fce7eb4118ad5cec0351.tar.bz2
opensim-SC_OLD-355cde464a7ada3c6ab8fce7eb4118ad5cec0351.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs45
1 files changed, 28 insertions, 17 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 87af206..21c4a87 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2487,7 +2487,7 @@ namespace OpenSim.Region.Framework.Scenes
2487 #region Add/Remove Avatar Methods 2487 #region Add/Remove Avatar Methods
2488 2488
2489 /// <summary> 2489 /// <summary>
2490 /// Add a new client and create a child agent for it. 2490 /// Add a new client and create a child scene presence for it.
2491 /// </summary> 2491 /// </summary>
2492 /// <param name="client"></param> 2492 /// <param name="client"></param>
2493 /// <param name="type">The type of agent to add.</param> 2493 /// <param name="type">The type of agent to add.</param>
@@ -2504,42 +2504,53 @@ namespace OpenSim.Region.Framework.Scenes
2504 2504
2505 CheckHeartbeat(); 2505 CheckHeartbeat();
2506 2506
2507 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2507 ScenePresence sp = GetScenePresence(client.AgentId);
2508
2509 // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this
2510 // could occur if a viewer crashes and relogs before the old client is kicked out. But this could cause
2511 // other problems, and possible the code calling AddNewClient() should ensure that no client is already
2512 // connected.
2513 if (sp == null)
2508 { 2514 {
2509 m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2515 m_log.Debug("[SCENE]: Adding new child scene presence " + client.Name + " to scene " + RegionInfo.RegionName);
2510 2516
2511 m_clientManager.Add(client); 2517 m_clientManager.Add(client);
2512 SubscribeToClientEvents(client); 2518 SubscribeToClientEvents(client);
2513 2519
2514 ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); 2520 sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type);
2515 m_eventManager.TriggerOnNewPresence(sp); 2521 m_eventManager.TriggerOnNewPresence(sp);
2516 2522
2517 sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; 2523 sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags;
2518 2524
2519 // HERE!!! Do the initial attachments right here 2525 // The first agent upon login is a root agent by design.
2520 // first agent upon login is a root agent by design. 2526 // For this agent we will have to rez the attachments.
2521 // All other AddNewClient calls find aCircuit.child to be true 2527 // All other AddNewClient calls find aCircuit.child to be true.
2522 if (aCircuit.child == false) 2528 if (aCircuit.child == false)
2523 { 2529 {
2530 // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to
2531 // start the scripts again (since this is done in RezAttachments()).
2532 // XXX: This is convoluted.
2524 sp.IsChildAgent = false; 2533 sp.IsChildAgent = false;
2525 2534
2526 if (AttachmentsModule != null) 2535 if (AttachmentsModule != null)
2527 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); 2536 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
2528 } 2537 }
2529 } 2538 }
2530 2539 else
2531 ScenePresence createdSp = GetScenePresence(client.AgentId);
2532 if (createdSp != null)
2533 { 2540 {
2534 m_LastLogin = Util.EnvironmentTickCount(); 2541 m_log.WarnFormat(
2542 "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence",
2543 sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName);
2544 }
2535 2545
2536 // Cache the user's name 2546 m_LastLogin = Util.EnvironmentTickCount();
2537 CacheUserName(createdSp, aCircuit);
2538 2547
2539 EventManager.TriggerOnNewClient(client); 2548 // Cache the user's name
2540 if (vialogin) 2549 CacheUserName(sp, aCircuit);
2541 EventManager.TriggerOnClientLogin(client); 2550
2542 } 2551 EventManager.TriggerOnNewClient(client);
2552 if (vialogin)
2553 EventManager.TriggerOnClientLogin(client);
2543 2554
2544 // Send all scene object to the new client 2555 // Send all scene object to the new client
2545 Util.FireAndForget(delegate 2556 Util.FireAndForget(delegate