From cfb20f09a967ede0a64e7151c3430f74362aec99 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 00:57:43 +0000 Subject: [PATCH 01/10] refactor: combine the checks for megaregion view range into a single place. --- .../EntityTransfer/EntityTransferModule.cs | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8af236e2f8..f5ffef2e1c 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -117,6 +117,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer new ExpiringCache>(); private IEventQueue m_eqModule; + private IRegionCombinerModule m_regionCombinerModule; #region ISharedRegionModule @@ -267,6 +268,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; m_eqModule = Scene.RequestModuleInterface(); + m_regionCombinerModule = Scene.RequestModuleInterface(); } #endregion @@ -1005,41 +1007,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) { - Border[] northBorders = Scene.NorthBorders.ToArray(); - Border[] southBorders = Scene.SouthBorders.ToArray(); - Border[] eastBorders = Scene.EastBorders.ToArray(); - Border[] westBorders = Scene.WestBorders.ToArray(); - - // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't - // clear what should be done with a "far view" given that megaregions already extended the - // view to include everything in the megaregion - if (northBorders.Length > 1 || southBorders.Length > 1 || eastBorders.Length > 1 || westBorders.Length > 1) + if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) { - Vector2 extent = Vector2.Zero; - for (int i = 0; i < eastBorders.Length; i++) - { - extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; - } - for (int i = 0; i < northBorders.Length; i++) - { - extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; - } - - // Loss of fraction on purpose - extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; - extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; - - uint startX = oldRegionX - 1; - uint startY = oldRegionY - 1; - - uint endX = oldRegionX + (uint)extent.X; - uint endY = oldRegionY + (uint)extent.Y; + Vector2 swCorner, neCorner; + GetMegaregionViewRange(out swCorner, out neCorner); m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Megaregion view of {0} is from {1},{2} to {3},{4} with new agent check for {5},{6}", - Scene.Name, startX, startY, endX, endY, newRegionX, newRegionY); + "[ENTITY TRANSFER MODULE]: Megaregion view of {0} is from {1} to {2} with new agent check for {3},{4}", + Scene.Name, swCorner, neCorner, newRegionX, newRegionY); - return !(newRegionX >= startX && newRegionX <= endX && newRegionY >= startY && newRegionY <= endY); + return !(newRegionX >= swCorner.X && newRegionX <= neCorner.X && newRegionY >= swCorner.Y && newRegionY <= neCorner.Y); } else { @@ -1902,6 +1879,37 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer reg.RegionName, sp.Name, sp.UUID, reason); } + /// + /// Gets the range considered in view of this megaregion (assuming this is a megaregion). + /// + /// Expressed in 256m units + /// + /// + private void GetMegaregionViewRange(out Vector2 swCorner, out Vector2 neCorner) + { + Border[] northBorders = Scene.NorthBorders.ToArray(); + Border[] eastBorders = Scene.EastBorders.ToArray(); + + Vector2 extent = Vector2.Zero; + for (int i = 0; i < eastBorders.Length; i++) + { + extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; + } + for (int i = 0; i < northBorders.Length; i++) + { + extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; + } + + // Loss of fraction on purpose + extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; + extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; + + swCorner.X = Scene.RegionInfo.RegionLocX - 1; + swCorner.Y = Scene.RegionInfo.RegionLocY - 1; + neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; + neCorner.Y = Scene.RegionInfo.RegionLocY + extent.Y; + } + /// /// Return the list of regions that are considered to be neighbours to the given scene. /// @@ -1922,8 +1930,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't // clear what should be done with a "far view" given that megaregions already extended the // view to include everything in the megaregion - if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) + if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) { + Console.WriteLine("NOT MEGA"); int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance; int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); @@ -1940,27 +1949,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else { - Vector2 extent = Vector2.Zero; - for (int i = 0; i < eastBorders.Length; i++) - { - extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; - } - for (int i = 0; i < northBorders.Length; i++) - { - extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; - } + Console.WriteLine("MEGA"); + Vector2 swCorner, neCorner; + GetMegaregionViewRange(out swCorner, out neCorner); - // Loss of fraction on purpose - extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; - extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; + List neighbours + = pScene.GridService.GetRegionRange( + m_regionInfo.ScopeID, + (int)swCorner.X * (int)Constants.RegionSize, + (int)neCorner.X * (int)Constants.RegionSize, + (int)swCorner.Y * (int)Constants.RegionSize, + (int)neCorner.Y * (int)Constants.RegionSize); - int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize; - int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize; - - int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; - int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; - - List neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); return neighbours; From f32027f3b53e8ad4f0b9fed0fee65a7e46ec91b0 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 01:08:47 +0000 Subject: [PATCH 02/10] Remove some Console.WriteLines accidentally left in last commit cfb20f09 --- .../Framework/EntityTransfer/EntityTransferModule.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index f5ffef2e1c..dc6a2a0725 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1932,7 +1932,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // view to include everything in the megaregion if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) { - Console.WriteLine("NOT MEGA"); int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance; int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); @@ -1949,7 +1948,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else { - Console.WriteLine("MEGA"); Vector2 swCorner, neCorner; GetMegaregionViewRange(out swCorner, out neCorner); From 876d0d310f3c7248a4a6fc29d8babe55a7b1e570 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 01:36:34 +0000 Subject: [PATCH 03/10] Add "show eq" console command to show numbers of messages in agent event queues. For debugging purposes. --- .../Caps/EventQueue/EventQueueGetModule.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 3cc395016f..624378ea98 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -97,6 +97,14 @@ namespace OpenSim.Region.ClientStack.Linden + " >= 1 - turns on outgoing event logging\n" + " >= 2 - turns on poll notification", HandleDebugEq); + + MainConsole.Instance.Commands.AddCommand( + "Debug", + false, + "show eq", + "show eq", + "Show contents of event queues for logged in avatars. Used for debugging.", + HandleShowEq); } public void RemoveRegion(Scene scene) @@ -148,6 +156,21 @@ namespace OpenSim.Region.ClientStack.Linden } } + protected void HandleShowEq(string module, string[] args) + { + MainConsole.Instance.OutputFormat("For scene {0}", m_scene.Name); + + lock (queues) + { + foreach (KeyValuePair> kvp in queues) + { + MainConsole.Instance.OutputFormat( + "For agent {0} there are {1} messages queued for send.", + kvp.Key, kvp.Value.Count); + } + } + } + /// /// Always returns a valid queue /// From b5b01e5bb59656078012c12146ea6f9e71589d43 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 01:37:52 +0000 Subject: [PATCH 04/10] Make HGLureModule track god like lures as well as normal lures, to see if this fixes issues where second megaregion auto-teleport hangs on black teleport screen when HG is active. --- OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index 6c9fd86689..a34f2d21fb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs @@ -154,7 +154,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure void OnIncomingInstantMessage(GridInstantMessage im) { - if (im.dialog == (byte)InstantMessageDialog.RequestTeleport) + if (im.dialog == (byte)InstantMessageDialog.RequestTeleport + || im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) { UUID sessionID = new UUID(im.imSessionID); From 617637c788045f5776d21fc4ce246f3a8d6ecfb8 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 01:41:23 +0000 Subject: [PATCH 05/10] minor: Fix usage error message for "debug eq" console command --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 624378ea98..c7d4283b1a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.ClientStack.Linden if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel))) { - MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]"); + MainConsole.Instance.OutputFormat("Usage: debug eq [0|1|2]"); } else { From 506d5e41bf3fff8acb78002e565eab96beede370 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 01:54:11 +0000 Subject: [PATCH 06/10] On the North and East sides of a megaregion, only consider regions within 256m to be neighbours rather than regions up to 512 distant. This looks like an off-by-one bug since the view distance was already only 256 on the west and south sides. This reduces the number of child agents being logged into regions neighbouring a megaregion. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index dc6a2a0725..8da76dfc49 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1901,8 +1901,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } // Loss of fraction on purpose - extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; - extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; + extent.X = ((int)extent.X / (int)Constants.RegionSize); + extent.Y = ((int)extent.Y / (int)Constants.RegionSize); swCorner.X = Scene.RegionInfo.RegionLocX - 1; swCorner.Y = Scene.RegionInfo.RegionLocY - 1; From b05ed4ffa693f3481f97a197de7e582492dc7271 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 02:17:32 +0000 Subject: [PATCH 07/10] Instead of going via GodLikeRequestTeleport, auto-teleport the agent directly in a megaregion, in the same manner at the "teleport user" console command. This is to bypass an issue with the HGLureModule which stops the auto-teleport from happening. --- .../Region/CoreModules/Avatar/Lure/LureModule.cs | 2 +- .../EntityTransfer/EntityTransferModule.cs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index e4b0cfa734..7f4606b366 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs @@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure (uint)presence.AbsolutePosition.Y, (uint)Math.Ceiling(presence.AbsolutePosition.Z)); - m_log.DebugFormat("TP invite with message {0}", message); + m_log.DebugFormat("TP invite with message {0}, type {1}", message, lureType); GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, client.FirstName+" "+client.LastName, targetid, diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8da76dfc49..8a1694396d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -379,8 +379,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 emergencyPos = new Vector3(128, 128, 128); m_log.WarnFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", - position, sp.Name, sp.UUID, emergencyPos); + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2} in {3}. Substituting {4}", + position, sp.Name, sp.UUID, Scene.Name, emergencyPos); position = emergencyPos; } @@ -1346,7 +1346,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Scene initiatingScene) { Thread.Sleep(10000); - + + agent.Scene.RequestTeleportLocation( + agent.ControllingClient, + Utils.UIntsToLong(regionX * (uint)Constants.RegionSize, regionY * (uint)Constants.RegionSize), + position, + agent.Lookat, + (uint)Constants.TeleportFlags.ViaLocation); + + /* IMessageTransferModule im = initiatingScene.RequestModuleInterface(); if (im != null) { @@ -1381,6 +1389,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer }); } + */ } private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) From d9c049fd9f1a78d73931f6aaa4cf9e6c512ba576 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 02:20:43 +0000 Subject: [PATCH 08/10] Fix a bug in HGEntityTransferModule to call base.RemoveRegion() when a region is removed rather than base.AddRegion() --- .../Framework/EntityTransfer/HGEntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index b1887418ee..33ea063600 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public override void RemoveRegion(Scene scene) { - base.AddRegion(scene); + base.RemoveRegion(scene); if (m_Enabled) scene.UnregisterModuleInterface(this); From afd0d6af0710375bf566ef5a6fcf00e7d1c5ca0f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 02:23:09 +0000 Subject: [PATCH 09/10] minor: Only try to deregister stats in EntityTransferModule.RemoveRegion() if module was enabled. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8a1694396d..f351da6d78 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -256,10 +256,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public virtual void RemoveRegion(Scene scene) { - StatsManager.DeregisterStat(m_interRegionTeleportAttempts); - StatsManager.DeregisterStat(m_interRegionTeleportAborts); - StatsManager.DeregisterStat(m_interRegionTeleportCancels); - StatsManager.DeregisterStat(m_interRegionTeleportFailures); + if (m_Enabled) + { + StatsManager.DeregisterStat(m_interRegionTeleportAttempts); + StatsManager.DeregisterStat(m_interRegionTeleportAborts); + StatsManager.DeregisterStat(m_interRegionTeleportCancels); + StatsManager.DeregisterStat(m_interRegionTeleportFailures); + } } public virtual void RegionLoaded(Scene scene) From 9ca54d00d8b1ca6181392d027077e82e64c53c3d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 28 Mar 2013 02:29:34 +0000 Subject: [PATCH 10/10] Add back a log message when we attempt a megaregion auto-reteleport --- .../Framework/EntityTransfer/EntityTransferModule.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index f351da6d78..035632b39b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1350,6 +1350,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { Thread.Sleep(10000); + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: Auto-reteleporting {0} to correct megaregion location {1},{2},{3} from {4}", + agent.Name, regionX, regionY, position, initiatingScene.Name); + agent.Scene.RequestTeleportLocation( agent.ControllingClient, Utils.UIntsToLong(regionX * (uint)Constants.RegionSize, regionY * (uint)Constants.RegionSize),