move region comands out of LocalGridServiceConnector where they do not belong

LSLKeyTest
UbitUmarov 2016-09-10 12:43:48 +01:00
parent b8d97ff37d
commit b9380c033d
2 changed files with 66 additions and 74 deletions

View File

@ -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<Scene> scenes;
lock (m_scenes)
scenes = new List<Scene>(m_scenes);
foreach (Scene s in scenes)
{
RegionInfo sr = s.RegionInfo;
caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", sr.RegionName, sr.RegionID);
List<GridRegion> 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<Scene> scenes;
lock (m_scenes)
scenes = new List<Scene>(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<GridRegion> 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());
}
}
}

View File

@ -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 <int> - 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<GridRegion> 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<GridRegion> 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());
}
}
}
}