refactor: eliminate some now duplicate code in ObjectCommandsModule
parent
45dc7ac7d1
commit
470ea6cf70
|
@ -139,7 +139,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
+ "show object pos 20,20 to 40,40\n"
|
+ "show object pos 20,20 to 40,40\n"
|
||||||
+ "show object pos ,20,20 to ,40,40\n"
|
+ "show object pos ,20,20 to ,40,40\n"
|
||||||
+ "show object pos ,,30 to ,,~\n"
|
+ "show object pos ,,30 to ,,~\n"
|
||||||
+ "show object pos ,,-~ to ,,30\n",
|
+ "show object pos ,,-~ to ,,30",
|
||||||
HandleShowObjectByPos);
|
HandleShowObjectByPos);
|
||||||
|
|
||||||
m_console.Commands.AddCommand(
|
m_console.Commands.AddCommand(
|
||||||
|
@ -169,6 +169,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
|
// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OutputSogsToConsole(Predicate<SceneObjectGroup> searchPredicate)
|
||||||
|
{
|
||||||
|
List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups().FindAll(searchPredicate);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (SceneObjectGroup so in sceneObjects)
|
||||||
|
{
|
||||||
|
AddSceneObjectReport(sb, so);
|
||||||
|
sb.Append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendFormat("{0} object(s) found in {1}\n", sceneObjects.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))
|
||||||
|
@ -219,32 +236,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
|
|
||||||
string name = mainParams[3];
|
string name = mainParams[3];
|
||||||
|
|
||||||
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
Predicate<SceneObjectGroup> searchPredicate;
|
||||||
Action<SceneObjectGroup> searchAction;
|
|
||||||
|
|
||||||
if (useRegex)
|
if (useRegex)
|
||||||
{
|
{
|
||||||
Regex nameRegex = new Regex(name);
|
Regex nameRegex = new Regex(name);
|
||||||
searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }};
|
searchPredicate = so => nameRegex.IsMatch(so.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }};
|
searchPredicate = so => so.Name == name;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.ForEachSOG(searchAction);
|
OutputSogsToConsole(searchPredicate);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (SceneObjectGroup so in sceneObjects)
|
|
||||||
{
|
|
||||||
AddSceneObjectReport(sb, so);
|
|
||||||
sb.Append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.AppendFormat("{0} objects found in {1}\n", sceneObjects.Count, m_scene.Name);
|
|
||||||
|
|
||||||
m_console.OutputFormat(sb.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleShowObjectByPos(string module, string[] cmdparams)
|
private void HandleShowObjectByPos(string module, string[] cmdparams)
|
||||||
|
@ -276,23 +280,10 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
Predicate<SceneObjectGroup> searchPredicate
|
||||||
Action<SceneObjectGroup> searchAction
|
= so => Util.IsInsideBox(so.AbsolutePosition, startVector, endVector);
|
||||||
= so => { if (Util.IsInsideBox(so.AbsolutePosition, startVector, endVector)) { sceneObjects.Add(so); }};
|
|
||||||
|
|
||||||
m_scene.ForEachSOG(searchAction);
|
OutputSogsToConsole(searchPredicate);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (SceneObjectGroup so in sceneObjects)
|
|
||||||
{
|
|
||||||
AddSceneObjectReport(sb, so);
|
|
||||||
sb.Append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.AppendFormat("{0} objects found in {1}\n", sceneObjects.Count, m_scene.Name);
|
|
||||||
|
|
||||||
m_console.OutputFormat(sb.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleShowPartByUuid(string module, string[] cmd)
|
private void HandleShowPartByUuid(string module, string[] cmd)
|
||||||
|
|
Loading…
Reference in New Issue