From 0e265889dd909d23b45175ec0e6f2d52725c008c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 8 Dec 2011 19:25:24 +0000 Subject: [PATCH] Remove unnecessary AgentCircuitData null check from Scene.AddNewClient(). The only caller is the LLUDP stack and this has to validate the UDP circuit itself, so we know that it exists. This allows us to eliminate another null check elsewhere and simplifies the method contract --- OpenSim/Framework/IScene.cs | 4 +--- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 15 ++++----------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 6919c48d91..e0e023d76c 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -74,9 +74,7 @@ namespace OpenSim.Framework /// /// The type of agent to add. /// - /// The scene agent if the new client was added. - /// Null if the required scene agent already existed or no scene agent was added because the required client circuit doesn't exist. - /// + /// The scene agent if the new client was added or if an agent that already existed. ISceneAgent AddNewClient(IClientAPI client, PresenceType type); /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 7db5f6bc5b..4ab8fd02fd 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -897,12 +897,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP IClientAPI client = AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); // Send ack straight away to let the viewer know that the connection is active. + // The client will be null if it already exists (e.g. if on a region crossing the client sends a use + // circuit code to the existing child agent. This is not particularly obvious. SendAckImmediate(remoteEndPoint, packet.Header.Sequence); - // FIXME: Nasty - this is the only way we currently know if Scene.AddNewClient() failed to find a - // circuit and bombed out early. That check might be pointless since authorization is established - // up here. - if (client != null && client.SceneAgent != null) + // We only want to send initial data to new clients, not ones which are being converted from child to root. + if (client != null) client.SceneAgent.SendInitialDataToMe(); // m_log.DebugFormat( diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d47536a866..11505cc040 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2486,21 +2486,14 @@ namespace OpenSim.Region.Framework.Scenes #region Add/Remove Avatar Methods - /// - /// Add a new client and create a child scene presence for it. - /// - /// - /// The type of agent to add. public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) { + // Validation occurs in LLUDPServer AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); - bool vialogin = false; - if (aCircuit == null) // no good, didn't pass NewUserConnection successfully - return null; - - vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || - (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; + bool vialogin + = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 + || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; CheckHeartbeat(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6463ab10dd..882492178e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2548,7 +2548,7 @@ namespace OpenSim.Region.Framework.Scenes } // This agent just became root. We are going to tell everyone about it. The process of - // getting other avatars information was initiated in the constructor... don't do it + // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it // again here... this comes after the cached appearance check because the avatars // appearance goes into the avatar update packet SendAvatarDataToAllAgents();