From b9380c033db89a82efe846c06ef83e3b89e3b494 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 10 Sep 2016 12:43:48 +0100 Subject: [PATCH] move region comands out of LocalGridServiceConnector where they do not belong --- .../Grid/LocalGridServiceConnector.cs | 73 ------------------- .../World/Region/RegionCommandsModule.cs | 67 ++++++++++++++++- 2 files changed, 66 insertions(+), 74 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 563773a687..70733fc0e0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -138,15 +138,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { - // FIXME: We will still add this command even if we aren't enabled since RemoteGridServiceConnector - // will have instantiated us directly. - MainConsole.Instance.Commands.AddCommand("Regions", false, "show neighbours", - "show neighbours", - "Shows the local region neighbours", HandleShowNeighboursCommand); - - MainConsole.Instance.Commands.AddCommand("Regions", false, "show regionsinview", - "show regionsinview", - "Shows regions that can be seen from a region", HandleShowRegionsInViewCommand); } public void Close() @@ -304,69 +295,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion - public void HandleShowNeighboursCommand(string module, string[] cmdparams) - { - if(!m_Enabled || m_scenes.Count == 0) - return; - - System.Text.StringBuilder caps = new System.Text.StringBuilder(); - - List scenes; - lock (m_scenes) - scenes = new List(m_scenes); - - foreach (Scene s in scenes) - { - RegionInfo sr = s.RegionInfo; - caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", sr.RegionName, sr.RegionID); - List regions = GetNeighbours(sr.ScopeID, sr.RegionID); - foreach (GridRegion r in regions) - caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY)); - } - - MainConsole.Instance.Output(caps.ToString()); - - } - - public void HandleShowRegionsInViewCommand(string module, string[] cmdparams) - { - if(!m_Enabled || m_scenes.Count == 0) - return; - - System.Text.StringBuilder caps = new System.Text.StringBuilder(); - - List scenes; - lock (m_scenes) - scenes = new List(m_scenes); - - foreach (Scene s in scenes) - { - int maxview = (int)s.MaxRegionViewDistance; - RegionInfo sr = s.RegionInfo; - caps.AppendFormat("*** Regions that can be seen from {0} ({1}) (MaxRegionViewDistance {2}m) ***\n", sr.RegionName, sr.RegionID, maxview); - int startX = (int)sr.WorldLocX; - int endX = startX + (int)sr.RegionSizeX; - int startY = (int)sr.WorldLocY; - int endY = startY + (int)sr.RegionSizeY; - startX -= maxview; - if(startX < 0 ) - startX = 0; - startY -= maxview; - if(startY < 0) - startY = 0; - endX += maxview; - endY += maxview; - - List regions = GetRegionRange(sr.ScopeID, startX, endX, startY, endY); - foreach (GridRegion r in regions) - { - if(r.RegionHandle == sr.RegionHandle) - continue; - caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY)); - } - } - - MainConsole.Instance.Output(caps.ToString()); - } } } diff --git a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs index b9bcb8b7c0..411c4d67a9 100644 --- a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs @@ -40,6 +40,7 @@ using OpenSim.Framework.Console; using OpenSim.Framework.Monitoring; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.World.Objects.Commands { @@ -107,6 +108,15 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands + "max-agent-limit - Maximum root agent limit. agent-limit cannot exceed this." + " This is not persisted over restart - to set it every time you must add a MaxAgents entry to your regions file.", HandleRegionSet); + + m_console.Commands.AddCommand("Regions", false, "show neighbours", + "show neighbours", + "Shows the local region neighbours", HandleShowNeighboursCommand); + + m_console.Commands.AddCommand("Regions", false, "show regionsinview", + "show regionsinview", + "Shows regions that can be seen from a region", HandleShowRegionsInViewCommand); + } public void RemoveRegion(Scene scene) @@ -309,5 +319,60 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands MainConsole.Instance.Output(sb.ToString()); } + + public void HandleShowNeighboursCommand(string module, string[] cmdparams) + { + if(m_scene == null) + return; + + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene)) + return; + + System.Text.StringBuilder caps = new System.Text.StringBuilder(); + + RegionInfo sr = m_scene.RegionInfo; + caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", sr.RegionName, sr.RegionID); + List regions = m_scene.GridService.GetNeighbours(sr.ScopeID, sr.RegionID); + foreach (GridRegion r in regions) + caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY)); + + MainConsole.Instance.Output(caps.ToString()); + } + + public void HandleShowRegionsInViewCommand(string module, string[] cmdparams) + { + if(m_scene == null) + return; + + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene)) + return; + + System.Text.StringBuilder caps = new System.Text.StringBuilder(); + int maxview = (int)m_scene.MaxRegionViewDistance; + RegionInfo sr = m_scene.RegionInfo; + caps.AppendFormat("*** Regions that can be seen from {0} ({1}) (MaxRegionViewDistance {2}m) ***\n", sr.RegionName, sr.RegionID, maxview); + int startX = (int)sr.WorldLocX; + int endX = startX + (int)sr.RegionSizeX; + int startY = (int)sr.WorldLocY; + int endY = startY + (int)sr.RegionSizeY; + startX -= maxview; + if(startX < 0 ) + startX = 0; + startY -= maxview; + if(startY < 0) + startY = 0; + endX += maxview; + endY += maxview; + + List regions = m_scene.GridService.GetRegionRange(sr.ScopeID, startX, endX, startY, endY); + foreach (GridRegion r in regions) + { + if(r.RegionHandle == sr.RegionHandle) + continue; + caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY)); + } + + MainConsole.Instance.Output(caps.ToString()); + } } -} \ No newline at end of file +}