diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f9ae39c..a51fca2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2610,17 +2610,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2610 | #region Add/Remove Avatar Methods | 2610 | #region Add/Remove Avatar Methods |
2611 | 2611 | ||
2612 | /// <summary> | 2612 | /// <summary> |
2613 | /// Add a new client and create a child agent for it. | 2613 | /// Add a new client and create a child scene presence for it. |
2614 | /// </summary> | 2614 | /// </summary> |
2615 | /// <param name="client"></param> | 2615 | /// <param name="client"></param> |
2616 | /// <param name="type">The type of agent to add.</param> | 2616 | /// <param name="type">The type of agent to add.</param> |
2617 | public override void AddNewClient(IClientAPI client, PresenceType type) | 2617 | public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) |
2618 | { | 2618 | { |
2619 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2619 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); |
2620 | bool vialogin = false; | 2620 | bool vialogin = false; |
2621 | 2621 | ||
2622 | if (aCircuit == null) // no good, didn't pass NewUserConnection successfully | 2622 | if (aCircuit == null) // no good, didn't pass NewUserConnection successfully |
2623 | return; | 2623 | return null; |
2624 | 2624 | ||
2625 | vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || | 2625 | vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || |
2626 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2626 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
@@ -2628,60 +2628,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
2628 | CheckHeartbeat(); | 2628 | CheckHeartbeat(); |
2629 | ScenePresence presence; | 2629 | ScenePresence presence; |
2630 | 2630 | ||
2631 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2631 | ScenePresence sp = GetScenePresence(client.AgentId); |
2632 | |||
2633 | // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this | ||
2634 | // could occur if a viewer crashes and relogs before the old client is kicked out. But this could cause | ||
2635 | // other problems, and possible the code calling AddNewClient() should ensure that no client is already | ||
2636 | // connected. | ||
2637 | if (sp == null) | ||
2632 | { | 2638 | { |
2633 | m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2639 | m_log.Debug("[SCENE]: Adding new child scene presence " + client.Name + " to scene " + RegionInfo.RegionName); |
2634 | 2640 | ||
2635 | m_clientManager.Add(client); | 2641 | m_clientManager.Add(client); |
2636 | SubscribeToClientEvents(client); | 2642 | SubscribeToClientEvents(client); |
2637 | 2643 | ||
2638 | ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 2644 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
2639 | m_eventManager.TriggerOnNewPresence(sp); | 2645 | m_eventManager.TriggerOnNewPresence(sp); |
2640 | 2646 | ||
2641 | sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; | 2647 | sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; |
2642 | 2648 | ||
2643 | // HERE!!! Do the initial attachments right here | 2649 | // The first agent upon login is a root agent by design. |
2644 | // first agent upon login is a root agent by design. | 2650 | // For this agent we will have to rez the attachments. |
2645 | // All other AddNewClient calls find aCircuit.child to be true | 2651 | // All other AddNewClient calls find aCircuit.child to be true. |
2646 | if (aCircuit.child == false) | 2652 | if (aCircuit.child == false) |
2647 | { | 2653 | { |
2654 | // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to | ||
2655 | // start the scripts again (since this is done in RezAttachments()). | ||
2656 | // XXX: This is convoluted. | ||
2648 | sp.IsChildAgent = false; | 2657 | sp.IsChildAgent = false; |
2649 | 2658 | ||
2650 | if (AttachmentsModule != null) | 2659 | if (AttachmentsModule != null) |
2651 | Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); | 2660 | Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); |
2652 | } | 2661 | } |
2653 | } | 2662 | } |
2654 | 2663 | else | |
2655 | ScenePresence createdSp = GetScenePresence(client.AgentId); | ||
2656 | if (createdSp != null) | ||
2657 | { | 2664 | { |
2658 | m_LastLogin = Util.EnvironmentTickCount(); | 2665 | m_log.WarnFormat( |
2666 | "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence", | ||
2667 | sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); | ||
2668 | } | ||
2659 | 2669 | ||
2660 | // Cache the user's name | 2670 | m_LastLogin = Util.EnvironmentTickCount(); |
2661 | CacheUserName(createdSp, aCircuit); | ||
2662 | 2671 | ||
2663 | EventManager.TriggerOnNewClient(client); | 2672 | // Cache the user's name |
2664 | if (vialogin) | 2673 | CacheUserName(sp, aCircuit); |
2665 | { | ||
2666 | EventManager.TriggerOnClientLogin(client); | ||
2667 | 2674 | ||
2668 | // Send initial parcel data | 2675 | EventManager.TriggerOnNewClient(client); |
2669 | Vector3 pos = createdSp.AbsolutePosition; | 2676 | if (vialogin) |
2670 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | 2677 | { |
2671 | land.SendLandUpdateToClient(client); | 2678 | EventManager.TriggerOnClientLogin(client); |
2672 | } | 2679 | // Send initial parcel data |
2680 | Vector3 pos = sp.AbsolutePosition; | ||
2681 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2682 | land.SendLandUpdateToClient(client); | ||
2673 | } | 2683 | } |
2674 | 2684 | ||
2675 | // Send all scene object to the new client | 2685 | return sp; |
2676 | Util.FireAndForget(delegate | ||
2677 | { | ||
2678 | EntityBase[] entities = Entities.GetEntities(); | ||
2679 | foreach(EntityBase e in entities) | ||
2680 | { | ||
2681 | if (e != null && e is SceneObjectGroup) | ||
2682 | ((SceneObjectGroup)e).SendFullUpdateToClient(client); | ||
2683 | } | ||
2684 | }); | ||
2685 | } | 2686 | } |
2686 | 2687 | ||
2687 | /// <summary> | 2688 | /// <summary> |