Add "show region at" command to grid service to get the details of a region at a specific location. "show region" command becomes "show region name" to disambiguate

This is the same format as used by "show object name", etc.
"deregister region" also becomes "deregister region id"
0.7.4.1
Justin Clark-Casey (justincc) 2012-06-25 23:55:14 +01:00
parent f5316984ab
commit 854f2a913c
1 changed files with 71 additions and 24 deletions

View File

@ -85,19 +85,26 @@ namespace OpenSim.Services.GridService
if (MainConsole.Instance != null) if (MainConsole.Instance != null)
{ {
MainConsole.Instance.Commands.AddCommand("Regions", true, MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region", "deregister region id",
"deregister region <Region UUID>", "deregister region id <Region UUID>",
"Deregister a region manually.", "Deregister a region manually.",
String.Empty, String.Empty,
HandleDeregisterRegion); HandleDeregisterRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true, MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region", "show region name",
"show region <Region name>", "show region name <Region name>",
"Show details on a region", "Show details on a region",
String.Empty, String.Empty,
HandleShowRegion); HandleShowRegion);
MainConsole.Instance.Commands.AddCommand("Regions", true,
"show region at",
"show region at <x-coord> <y-coord>",
"Show details on a region at the given co-ordinate.",
"For example, show region at 1000 1000",
HandleShowRegionAt);
MainConsole.Instance.Commands.AddCommand("Regions", true, MainConsole.Instance.Commands.AddCommand("Regions", true,
"set region flags", "set region flags",
"set region flags <Region name> <flags>", "set region flags <Region name> <flags>",
@ -504,13 +511,13 @@ namespace OpenSim.Services.GridService
private void HandleDeregisterRegion(string module, string[] cmd) private void HandleDeregisterRegion(string module, string[] cmd)
{ {
if (cmd.Length != 3) if (cmd.Length != 4)
{ {
MainConsole.Instance.Output("Syntax: degregister region <Region UUID>"); MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>");
return; return;
} }
string rawRegionUuid = cmd[2]; string rawRegionUuid = cmd[3];
UUID regionUuid; UUID regionUuid;
if (!UUID.TryParse(rawRegionUuid, out regionUuid)) if (!UUID.TryParse(rawRegionUuid, out regionUuid))
@ -542,19 +549,56 @@ namespace OpenSim.Services.GridService
private void HandleShowRegion(string module, string[] cmd) private void HandleShowRegion(string module, string[] cmd)
{ {
if (cmd.Length != 3) if (cmd.Length != 4)
{ {
MainConsole.Instance.Output("Syntax: show region <region name>"); MainConsole.Instance.Output("Syntax: show region name <region name>");
return;
}
List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero);
if (regions == null || regions.Count < 1)
{
MainConsole.Instance.Output("Region not found");
return; return;
} }
foreach (RegionData r in regions) string regionName = cmd[3];
List<RegionData> regions = m_Database.Get(regionName, UUID.Zero);
if (regions == null || regions.Count < 1)
{
MainConsole.Instance.Output("No region with name {0} found", regionName);
return;
}
OutputRegionsToConsole(regions);
}
private void HandleShowRegionAt(string module, string[] cmd)
{
if (cmd.Length != 5)
{
MainConsole.Instance.Output("Syntax: show region at <x-coord> <y-coord>");
return;
}
int x, y;
if (!int.TryParse(cmd[3], out x))
{
MainConsole.Instance.Output("x-coord must be an integer");
return;
}
if (!int.TryParse(cmd[4], out y))
{
MainConsole.Instance.Output("y-coord must be an integer");
return;
}
RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero);
if (region == null)
{
MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
return;
}
OutputRegionToConsole(region);
}
private void OutputRegionToConsole(RegionData r)
{ {
OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
@ -569,7 +613,10 @@ namespace OpenSim.Services.GridService
MainConsole.Instance.Output(dispList.ToString()); MainConsole.Instance.Output(dispList.ToString());
} }
return; private void OutputRegionsToConsole(List<RegionData> regions)
{
foreach (RegionData r in regions)
OutputRegionToConsole(r);
} }
private int ParseFlags(int prev, string flags) private int ParseFlags(int prev, string flags)