Fix bug in implementation of "show part pos" that would not filter probably.

Also refactors more of ObjectCommandsModule to remove duplicate code
0.7.4-extended
Justin Clark-Casey (justincc) 2012-10-05 04:31:43 +01:00
parent e5ac4a72b7
commit 3ec9eec257
1 changed files with 25 additions and 40 deletions

View File

@ -205,6 +205,26 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.OutputFormat(sb.ToString()); m_console.OutputFormat(sb.ToString());
} }
private void OutputSopsToConsole(Predicate<SceneObjectPart> searchPredicate)
{
List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups();
List<SceneObjectPart> parts = new List<SceneObjectPart>();
sceneObjects.ForEach(so => parts.AddRange(Array.FindAll<SceneObjectPart>(so.Parts, searchPredicate)));
StringBuilder sb = new StringBuilder();
foreach (SceneObjectPart part in parts)
{
AddScenePartReport(sb, part);
sb.Append("\n");
}
sb.AppendFormat("{0} parts found in {1}\n", parts.Count, m_scene.Name);
m_console.OutputFormat(sb.ToString());
}
private void HandleShowObjectByUuid(string module, string[] cmd) private void HandleShowObjectByUuid(string module, string[] cmd)
{ {
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
@ -366,28 +386,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return; return;
} }
Predicate<SceneObjectGroup> searchPredicate OutputSopsToConsole(sop => Util.IsInsideBox(sop.AbsolutePosition, startVector, endVector));
= so => Util.IsInsideBox(so.AbsolutePosition, startVector, endVector);
List<SceneObjectPart> parts = new List<SceneObjectPart>();
Action<SceneObjectGroup> searchAction
= so
=> so.ForEachPart(sop => { if (Util.IsInsideBox(so.AbsolutePosition, startVector, endVector)) { parts.Add(sop); }});
m_scene.ForEachSOG(searchAction);
StringBuilder sb = new StringBuilder();
foreach (SceneObjectPart part in parts)
{
AddScenePartReport(sb, part);
sb.Append("\n");
}
sb.AppendFormat("{0} parts found in {1}\n", parts.Count, m_scene.Name);
m_console.OutputFormat(sb.ToString());
} }
private void HandleShowPartByName(string module, string[] cmdparams) private void HandleShowPartByName(string module, string[] cmdparams)
@ -408,33 +407,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
string name = mainParams[3]; string name = mainParams[3];
List<SceneObjectPart> parts = new List<SceneObjectPart>(); Predicate<SceneObjectPart> searchPredicate;
Action<SceneObjectGroup> searchAction;
if (useRegex) if (useRegex)
{ {
Regex nameRegex = new Regex(name); Regex nameRegex = new Regex(name);
searchAction = so => so.ForEachPart(sop => { if (nameRegex.IsMatch(sop.Name)) { parts.Add(sop); } }); searchPredicate = sop => nameRegex.IsMatch(sop.Name);
} }
else else
{ {
searchAction = so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }); searchPredicate = sop => sop.Name == name;
} }
m_scene.ForEachSOG(searchAction); OutputSopsToConsole(searchPredicate);
StringBuilder sb = new StringBuilder();
foreach (SceneObjectPart part in parts)
{
AddScenePartReport(sb, part);
sb.Append("\n");
}
sb.AppendFormat("{0} parts found in {1}\n", parts.Count, m_scene.Name);
m_console.OutputFormat(sb.ToString());
} }
private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so) private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so)