aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs109
1 files changed, 85 insertions, 24 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index 6e39e9a..85779ec 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Reflection; 31using System.Reflection;
31using System.Text; 32using System.Text;
32using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
@@ -83,29 +84,56 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
83 m_console.Commands.AddCommand( 84 m_console.Commands.AddCommand(
84 "Objects", false, "delete object owner", 85 "Objects", false, "delete object owner",
85 "delete object owner <UUID>", 86 "delete object owner <UUID>",
86 "Delete a scene object by owner", HandleDeleteObject); 87 "Delete scene objects by owner",
88 "Command will ask for confirmation before proceeding.",
89 HandleDeleteObject);
87 90
88 m_console.Commands.AddCommand( 91 m_console.Commands.AddCommand(
89 "Objects", false, "delete object creator", 92 "Objects", false, "delete object creator",
90 "delete object creator <UUID>", 93 "delete object creator <UUID>",
91 "Delete a scene object by creator", HandleDeleteObject); 94 "Delete scene objects by creator",
95 "Command will ask for confirmation before proceeding.",
96 HandleDeleteObject);
92 97
93 m_console.Commands.AddCommand( 98 m_console.Commands.AddCommand(
94 "Objects", false, "delete object uuid", 99 "Objects", false, "delete object uuid",
95 "delete object uuid <UUID>", 100 "delete object uuid <UUID>",
96 "Delete a scene object by uuid", HandleDeleteObject); 101 "Delete a scene object by uuid",
102 HandleDeleteObject);
97 103
98 m_console.Commands.AddCommand( 104 m_console.Commands.AddCommand(
99 "Objects", false, "delete object name", 105 "Objects", false, "delete object name",
100 "delete object name [--regex] <name>", 106 "delete object name [--regex] <name>",
101 "Delete a scene object by name.", 107 "Delete a scene object by name.",
102 "If --regex is specified then the name is treatead as a regular expression", 108 "Command will ask for confirmation before proceeding.\n"
109 + "If --regex is specified then the name is treatead as a regular expression",
103 HandleDeleteObject); 110 HandleDeleteObject);
104 111
105 m_console.Commands.AddCommand( 112 m_console.Commands.AddCommand(
106 "Objects", false, "delete object outside", 113 "Objects", false, "delete object outside",
107 "delete object outside", 114 "delete object outside",
108 "Delete all scene objects outside region boundaries", HandleDeleteObject); 115 "Delete all scene objects outside region boundaries",
116 "Command will ask for confirmation before proceeding.",
117 HandleDeleteObject);
118
119 m_console.Commands.AddCommand(
120 "Objects",
121 false,
122 "delete object pos",
123 "delete object pos <start-coord> to <end-coord>",
124 "Delete scene objects within the given area.",
125 "Each component of the coord is comma separated. There must be no spaces between the commas.\n"
126 + "If you don't care about the z component you can simply omit it.\n"
127 + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n"
128 + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n"
129 + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n"
130 + "e.g.\n"
131 + "delete object pos 20,20,20 to 40,40,40\n"
132 + "delete object pos 20,20 to 40,40\n"
133 + "delete object pos ,20,20 to ,40,40\n"
134 + "delete object pos ,,30 to ,,~\n"
135 + "delete object pos ,,-~ to ,,30",
136 HandleDeleteObject);
109 137
110 m_console.Commands.AddCommand( 138 m_console.Commands.AddCommand(
111 "Objects", 139 "Objects",
@@ -301,23 +329,10 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
301 return; 329 return;
302 } 330 }
303 331
304 string rawConsoleStartVector = cmdparams[3]; 332 Vector3 startVector, endVector;
305 Vector3 startVector;
306 333
307 if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector)) 334 if (!TryParseVectorRange(cmdparams.Skip(3).Take(3), out startVector, out endVector))
308 {
309 m_console.OutputFormat("Error: Start vector {0} does not have a valid format", rawConsoleStartVector);
310 return; 335 return;
311 }
312
313 string rawConsoleEndVector = cmdparams[5];
314 Vector3 endVector;
315
316 if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
317 {
318 m_console.OutputFormat("Error: End vector {0} does not have a valid format", rawConsoleEndVector);
319 return;
320 }
321 336
322 Predicate<SceneObjectGroup> searchPredicate 337 Predicate<SceneObjectGroup> searchPredicate
323 = so => Util.IsInsideBox(so.AbsolutePosition, startVector, endVector); 338 = so => Util.IsInsideBox(so.AbsolutePosition, startVector, endVector);
@@ -557,6 +572,10 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
557 572
558 break; 573 break;
559 574
575 case "pos":
576 deletes = GetDeleteCandidatesByPos(module, cmd);
577 break;
578
560 default: 579 default:
561 m_console.OutputFormat("Unrecognized mode {0}", mode); 580 m_console.OutputFormat("Unrecognized mode {0}", mode);
562 return; 581 return;
@@ -571,7 +590,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
571 string.Format( 590 string.Format(
572 "Are you sure that you want to delete {0} objects from {1}", 591 "Are you sure that you want to delete {0} objects from {1}",
573 deletes.Count, m_scene.RegionInfo.RegionName), 592 deletes.Count, m_scene.RegionInfo.RegionName),
574 "n"); 593 "y/N");
575 594
576 if (response.ToLower() != "y") 595 if (response.ToLower() != "y")
577 { 596 {
@@ -593,9 +612,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
593 612
594 private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams) 613 private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams)
595 { 614 {
596 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
597 return null;
598
599 bool useRegex = false; 615 bool useRegex = false;
600 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); 616 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
601 617
@@ -629,5 +645,50 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
629 645
630 return sceneObjects; 646 return sceneObjects;
631 } 647 }
648
649 /// <summary>
650 /// Get scene object delete candidates by position
651 /// </summary>
652 /// <param name='module'></param>
653 /// <param name='cmdparams'></param>
654 /// <returns>null if parsing failed on one of the arguments, otherwise a list of objects to delete. If there
655 /// are no objects to delete then the list will be empty./returns>
656 private List<SceneObjectGroup> GetDeleteCandidatesByPos(string module, string[] cmdparams)
657 {
658 if (cmdparams.Length < 5)
659 {
660 m_console.OutputFormat("Usage: delete object pos <start-coord> to <end-coord>");
661 return null;
662 }
663
664 Vector3 startVector, endVector;
665
666 if (!TryParseVectorRange(cmdparams.Skip(3).Take(3), out startVector, out endVector))
667 return null;
668
669 return m_scene.GetSceneObjectGroups().FindAll(
670 so => !so.IsAttachment && Util.IsInsideBox(so.AbsolutePosition, startVector, endVector));
671 }
672
673 private bool TryParseVectorRange(IEnumerable<string> rawComponents, out Vector3 startVector, out Vector3 endVector)
674 {
675 string rawConsoleStartVector = rawComponents.Take(1).Single();
676
677 if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector))
678 {
679 m_console.OutputFormat("Error: Start vector {0} does not have a valid format", rawConsoleStartVector);
680 return false;
681 }
682
683 string rawConsoleEndVector = rawComponents.Skip(1).Take(1).Single();
684
685 if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
686 {
687 m_console.OutputFormat("Error: End vector {0} does not have a valid format", rawConsoleEndVector);
688 return false;
689 }
690
691 return true;
692 }
632 } 693 }
633} \ No newline at end of file 694} \ No newline at end of file