Add "show part uuid" and "show part name" console commands.

These commands will display part/prim details for a given uuid or name
The "show object uuid" and "show object name" commands will now only display details for objects (i.e. not child parts in a linkset).
This is for consistency with the "delete object" commands which only delete objects, not parts.
0.7.2-post-fixes
Justin Clark-Casey (justincc) 2012-01-31 23:35:13 +00:00
parent 34d4bde585
commit 0b5210dd6a
1 changed files with 97 additions and 7 deletions

View File

@ -107,6 +107,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"show object name", "show object name",
"show object name <name>", "show object name <name>",
"Show details of scene objects with the given name", HandleShowObjectByName); "Show details of scene objects with the given name", HandleShowObjectByName);
m_console.Commands.AddCommand(
"region",
false,
"show part uuid",
"show part uuid <UUID>",
"Show details of a scene object parts with the given UUID", HandleShowPartByUuid);
m_console.Commands.AddCommand(
"region",
false,
"show part name",
"show part name <name>",
"Show details of scene object parts with the given name", HandleShowPartByName);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -137,16 +151,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return; return;
} }
SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
if (sop == null) if (so == null)
{ {
// m_console.OutputFormat("No object found with uuid {0}", objectUuid); // m_console.OutputFormat("No part found with uuid {0}", objectUuid);
return; return;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
AddPartReport(sb, sop); AddSceneObjectReport(sb, so);
m_console.OutputFormat(sb.ToString()); m_console.OutputFormat(sb.ToString());
} }
@ -164,6 +178,72 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
string name = cmd[3]; string name = cmd[3];
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }});
if (sceneObjects.Count == 0)
{
m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
return;
}
StringBuilder sb = new StringBuilder();
foreach (SceneObjectGroup so in sceneObjects)
{
AddSceneObjectReport(sb, so);
sb.Append("\n");
}
m_console.OutputFormat(sb.ToString());
}
private void HandleShowPartByUuid(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 4)
{
m_console.OutputFormat("Usage: show part uuid <uuid>");
return;
}
UUID objectUuid;
if (!UUID.TryParse(cmd[3], out objectUuid))
{
m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
return;
}
SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid);
if (sop == null)
{
// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
return;
}
StringBuilder sb = new StringBuilder();
AddScenePartReport(sb, sop);
m_console.OutputFormat(sb.ToString());
}
private void HandleShowPartByName(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmd.Length < 4)
{
m_console.OutputFormat("Usage: show part name <name>");
return;
}
string name = cmd[3];
List<SceneObjectPart> parts = new List<SceneObjectPart>(); List<SceneObjectPart> parts = new List<SceneObjectPart>();
m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }));
@ -178,21 +258,31 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
foreach (SceneObjectPart part in parts) foreach (SceneObjectPart part in parts)
{ {
AddPartReport(sb, part); AddScenePartReport(sb, part);
sb.Append("\n"); sb.Append("\n");
} }
m_console.OutputFormat(sb.ToString()); m_console.OutputFormat(sb.ToString());
} }
private StringBuilder AddPartReport(StringBuilder sb, SceneObjectPart sop) private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so)
{
sb.AppendFormat("Name: {0}\n", so.Name);
sb.AppendFormat("Description: {0}\n", so.Description);
sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName);
sb.AppendFormat("Parts: {0}\n", so.PrimCount);
return sb;
}
private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop)
{ {
sb.AppendFormat("Name: {0}\n", sop.Name); sb.AppendFormat("Name: {0}\n", sop.Name);
sb.AppendFormat("Description: {0}\n", sop.Description); sb.AppendFormat("Description: {0}\n", sop.Description);
sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName);
sb.AppendFormat("Parent: {0}", sb.AppendFormat("Parent: {0}",
sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID));
sb.AppendFormat("Parts: {0}\n", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());;
return sb; return sb;
} }