From d1841ca94d382215a40a7433efcf24173967d80b Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 30 Nov 2008 23:36:56 +0000 Subject: Mantis #2584 (again) Next step of diva's TP fixes and HG support --- .../Hypergrid/HGSceneCommunicationService.cs | 23 +++++++----- OpenSim/Region/Environment/Scenes/Scene.cs | 15 +++++++- .../Scenes/SceneCommunicationService.cs | 27 +++++++++----- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 43 +++++++++++++++++++++- 4 files changed, 86 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs index 5d34773..b6fd798 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -222,25 +222,28 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid KiPrimitive(avatar.LocalId); } - avatar.Close(); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); + + // Let's close some children agents + if (isHyperLink) // close them all + SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList()); + else // close just a few + avatar.CloseChildAgents(newRegionX, newRegionY); + + avatar.Close(); + + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone /// /// Hypergrid mod: extra check for isHyperLink /// - if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) || isHyperLink) + //if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 1) || isHyperLink) + //if (((int)Math.Abs((int)(newRegionX - oldRegionX)) > 1) || ((int)Math.Abs((int)(newRegionY - oldRegionY)) > 1) || isHyperLink) + if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) { - //SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList()); - SendCloseChildAgentConnections(avatar.UUID, childRegions); - if (eq != null) - { - OSD Item = EventQueueHelper.DisableSimulator(m_regionInfo.RegionHandle); - eq.Enqueue(Item, avatar.UUID); - } - Thread.Sleep(2000); CloseConnection(avatar.UUID); } // if (teleport success) // seems to be always success here diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f4bb2d3..7e13671 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -52,6 +52,7 @@ using Caps = OpenSim.Framework.Communications.Capabilities.Caps; using Image = System.Drawing.Image; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; using Timer = System.Timers.Timer; +using OSD = OpenMetaverse.StructuredData.OSD; namespace OpenSim.Region.Environment.Scenes { @@ -2807,9 +2808,10 @@ namespace OpenSim.Region.Environment.Scenes capsPaths[agent.AgentID] = agent.CapsPath; + AddCapsHandler(agent.AgentID); + if (!agent.child) { - AddCapsHandler(agent.AgentID); // Honor parcel landing type and position. ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); @@ -3027,7 +3029,18 @@ namespace OpenSim.Region.Environment.Scenes // } // Tell a single agent to disconnect from the region. + // This sends DisableSimulator over UDP, but that doesn't seem to be working + // well with the latest LL viewer, so we're sending it also via the EQ presence.ControllingClient.SendShutdownConnectionNotice(); + IEventQueue eq = RequestModuleInterface(); + if (eq != null) + { + OSD Item = EventQueueHelper.DisableSimulator(m_regInfo.RegionHandle); + eq.Enqueue(Item, agentID); + m_log.Debug("[Scene]: Enqueuing DisableSimulator for " + agentID + " in region " + m_regInfo.RegionName); + Thread.Sleep(2000); + } + RemoveCapsHandler(agentID); presence.ControllingClient.Close(true); } diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 54d4298..2268b28 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.Environment.Scenes protected bool CloseConnection(UUID agentID) { m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID); - + handlerCloseAgentConnection = OnCloseAgentConnection; if (handlerCloseAgentConnection != null) { @@ -727,24 +727,31 @@ namespace OpenSim.Region.Environment.Scenes KiPrimitive(avatar.LocalId); } - avatar.Close(); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); - if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) + + // Let's close some children agents + avatar.CloseChildAgents(newRegionX, newRegionY); + + avatar.Close(); + + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone + + // This is a little too fast of a distance computation... it's not consistent with the rule + // of having child agents in exactly the adjacent regions. Some topologies result in orphan + // children + //if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) + //if (((int)Math.Abs((int)(newRegionX - oldRegionX)) > 1) || ((int)Math.Abs((int)(newRegionY - oldRegionY)) > 1)) + if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) { //SendCloseChildAgentConnections(avatar.UUID,avatar.GetKnownRegionList()); - SendCloseChildAgentConnections(avatar.UUID, childRegions); - if (eq != null) - { - OSD Item = EventQueueHelper.DisableSimulator(m_regionInfo.RegionHandle); - eq.Enqueue(Item, avatar.UUID); - } - Thread.Sleep(2000); + //SendCloseChildAgentConnections(avatar.UUID, childRegions); CloseConnection(avatar.UUID); } + // if (teleport success) // seems to be always success here // the user may change their profile information in other region, // so the userinfo in UserProfileCache is not reliable any more, delete it diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index b85fd93..c26f862 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -2373,7 +2373,10 @@ namespace OpenSim.Region.Environment.Scenes CrossAttachmentsIntoNewRegion(neighbourHandle, true); -// m_scene.SendKillObject(m_localId); + // Next, let's close the child agent connections that are too far away. + CloseChildAgents(neighbourx, neighboury); + + // m_scene.SendKillObject(m_localId); m_scene.NotifyMyCoarseLocationChange(); // the user may change their profile information in other region, @@ -2391,6 +2394,44 @@ namespace OpenSim.Region.Environment.Scenes } } + /// + /// Computes which child agents to close when the scene presence moves to another region. + /// Removes those regions from m_knownRegions. + /// + /// The new region's x on the map + /// The new region's y on the map + /// + public void CloseChildAgents(uint newRegionX, uint newRegionY) + { + List byebyeRegions = new List(); + + foreach (ulong handle in m_knownChildRegions) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + + if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) + { + Console.WriteLine("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs(x-newRegionX)); + Console.WriteLine("---> y: " + y + "; newy:" + newRegionY); + byebyeRegions.Add(handle); + } + } + foreach (ulong handle in byebyeRegions) + { + RemoveNeighbourRegion(handle); + } + + if (byebyeRegions.Count > 0) + { + m_log.Info("[AVATAR]: Closing " + byebyeRegions.Count + " child agents"); + m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions); + } + + } + #endregion /// -- cgit v1.1