aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
diff options
context:
space:
mode:
authorteravus2012-11-15 10:05:16 -0500
committerteravus2012-11-15 10:05:16 -0500
commite9153e1d1aae50024d8cd05fe14a9bce34343a0e (patch)
treebc111d34f95a26b99c7e34d9e495dc14d1802cc3 /OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
parentMerge master into teravuswork (diff)
downloadopensim-SC_OLD-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.zip
opensim-SC_OLD-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.tar.gz
opensim-SC_OLD-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.tar.bz2
opensim-SC_OLD-e9153e1d1aae50024d8cd05fe14a9bce34343a0e.tar.xz
Revert "Merge master into teravuswork", it should have been avination, not master.
This reverts commit dfac269032300872c4d0dc507f4f9062d102b0f4, reversing changes made to 619c39e5144f15aca129d6d999bcc5c34133ee64.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs522
1 files changed, 93 insertions, 429 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index ab8f143..09f6758 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -27,12 +27,9 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
31using System.Linq;
32using System.Reflection; 30using System.Reflection;
33using System.Text; 31using System.Text;
34using System.Text.RegularExpressions; 32using System.Text.RegularExpressions;
35using System.Xml;
36using log4net; 33using log4net;
37using Mono.Addins; 34using Mono.Addins;
38using NDesk.Options; 35using NDesk.Options;
@@ -43,7 +40,6 @@ using OpenSim.Framework.Console;
43using OpenSim.Framework.Monitoring; 40using OpenSim.Framework.Monitoring;
44using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
46using OpenSim.Region.Framework.Scenes.Serialization;
47 43
48namespace OpenSim.Region.CoreModules.World.Objects.Commands 44namespace OpenSim.Region.CoreModules.World.Objects.Commands
49{ 45{
@@ -87,85 +83,52 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
87 m_console.Commands.AddCommand( 83 m_console.Commands.AddCommand(
88 "Objects", false, "delete object owner", 84 "Objects", false, "delete object owner",
89 "delete object owner <UUID>", 85 "delete object owner <UUID>",
90 "Delete scene objects by owner", 86 "Delete a scene object by owner", HandleDeleteObject);
91 "Command will ask for confirmation before proceeding.",
92 HandleDeleteObject);
93 87
94 m_console.Commands.AddCommand( 88 m_console.Commands.AddCommand(
95 "Objects", false, "delete object creator", 89 "Objects", false, "delete object creator",
96 "delete object creator <UUID>", 90 "delete object creator <UUID>",
97 "Delete scene objects by creator", 91 "Delete a scene object by creator", HandleDeleteObject);
98 "Command will ask for confirmation before proceeding.",
99 HandleDeleteObject);
100 92
101 m_console.Commands.AddCommand( 93 m_console.Commands.AddCommand(
102 "Objects", false, "delete object id", 94 "Objects", false, "delete object uuid",
103 "delete object id <UUID-or-localID>", 95 "delete object uuid <UUID>",
104 "Delete a scene object by uuid or localID", 96 "Delete a scene object by uuid", HandleDeleteObject);
105 HandleDeleteObject);
106 97
107 m_console.Commands.AddCommand( 98 m_console.Commands.AddCommand(
108 "Objects", false, "delete object name", 99 "Objects", false, "delete object name",
109 "delete object name [--regex] <name>", 100 "delete object name [--regex] <name>",
110 "Delete a scene object by name.", 101 "Delete a scene object by name.",
111 "Command will ask for confirmation before proceeding.\n" 102 "If --regex is specified then the name is treatead as a regular expression",
112 + "If --regex is specified then the name is treatead as a regular expression",
113 HandleDeleteObject); 103 HandleDeleteObject);
114 104
115 m_console.Commands.AddCommand( 105 m_console.Commands.AddCommand(
116 "Objects", false, "delete object outside", 106 "Objects", false, "delete object outside",
117 "delete object outside", 107 "delete object outside",
118 "Delete all scene objects outside region boundaries", 108 "Delete all scene objects outside region boundaries", HandleDeleteObject);
119 "Command will ask for confirmation before proceeding.",
120 HandleDeleteObject);
121 109
122 m_console.Commands.AddCommand( 110 m_console.Commands.AddCommand(
123 "Objects", 111 "Objects",
124 false, 112 false,
125 "delete object pos", 113 "show object uuid",
126 "delete object pos <start-coord> to <end-coord>", 114 "show object uuid <UUID>",
127 "Delete scene objects within the given area.", 115 "Show details of a scene object with the given UUID", HandleShowObjectByUuid);
128 ConsoleUtil.CoordHelp,
129 HandleDeleteObject);
130
131 m_console.Commands.AddCommand(
132 "Objects",
133 false,
134 "show object id",
135 "show object id [--full] <UUID-or-localID>",
136 "Show details of a scene object with the given UUID or localID",
137 "The --full option will print out information on all the parts of the object.\n"
138 + "For yet more detailed part information, use the \"show part\" commands.",
139 HandleShowObjectById);
140 116
141 m_console.Commands.AddCommand( 117 m_console.Commands.AddCommand(
142 "Objects", 118 "Objects",
143 false, 119 false,
144 "show object name", 120 "show object name",
145 "show object name [--full] [--regex] <name>", 121 "show object name [--regex] <name>",
146 "Show details of scene objects with the given name.", 122 "Show details of scene objects with the given name.",
147 "The --full option will print out information on all the parts of the object.\n" 123 "If --regex is specified then the name is treatead as a regular expression",
148 + "For yet more detailed part information, use the \"show part\" commands.\n"
149 + "If --regex is specified then the name is treatead as a regular expression.",
150 HandleShowObjectByName); 124 HandleShowObjectByName);
151 125
152 m_console.Commands.AddCommand( 126 m_console.Commands.AddCommand(
153 "Objects", 127 "Objects",
154 false, 128 false,
155 "show object pos", 129 "show part uuid",
156 "show object pos [--full] <start-coord> to <end-coord>", 130 "show part uuid <UUID>",
157 "Show details of scene objects within the given area.", 131 "Show details of a scene object parts with the given UUID", HandleShowPartByUuid);
158 "The --full option will print out information on all the parts of the object.\n"
159 + "For yet more detailed part information, use the \"show part\" commands.\n"
160 + ConsoleUtil.CoordHelp,
161 HandleShowObjectByPos);
162
163 m_console.Commands.AddCommand(
164 "Objects",
165 false,
166 "show part id",
167 "show part id <UUID-or-localID>",
168 "Show details of a scene object part with the given UUID or localID", HandleShowPartById);
169 132
170 m_console.Commands.AddCommand( 133 m_console.Commands.AddCommand(
171 "Objects", 134 "Objects",
@@ -173,28 +136,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
173 "show part name", 136 "show part name",
174 "show part name [--regex] <name>", 137 "show part name [--regex] <name>",
175 "Show details of scene object parts with the given name.", 138 "Show details of scene object parts with the given name.",
176 "If --regex is specified then the name is treated as a regular expression", 139 "If --regex is specified then the name is treatead as a regular expression",
177 HandleShowPartByName); 140 HandleShowPartByName);
178
179 m_console.Commands.AddCommand(
180 "Objects",
181 false,
182 "show part pos",
183 "show part pos <start-coord> to <end-coord>",
184 "Show details of scene object parts within the given area.",
185 ConsoleUtil.CoordHelp,
186 HandleShowPartByPos);
187
188 m_console.Commands.AddCommand(
189 "Objects",
190 false,
191 "dump object id",
192 "dump object id <UUID-or-localID>",
193 "Dump the formatted serialization of the given object to the file <UUID>.xml",
194 "e.g. dump object uuid c1ed6809-cc24-4061-a4c2-93082a2d1f1d will dump serialization to c1ed6809-cc24-4061-a4c2-93082a2d1f1d.xml\n"
195 + "To locate the UUID or localID in the first place, you need to use the other show object commands.\n"
196 + "If a local ID is given then the filename used is still that for the UUID",
197 HandleDumpObjectById);
198 } 141 }
199 142
200 public void RemoveRegion(Scene scene) 143 public void RemoveRegion(Scene scene)
@@ -207,75 +150,25 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
207// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 150// m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
208 } 151 }
209 152
210 /// <summary> 153 private void HandleShowObjectByUuid(string module, string[] cmd)
211 /// Outputs the sogs to console.
212 /// </summary>
213 /// <param name='searchPredicate'></param>
214 /// <param name='showFull'>If true then output all part details. If false then output summary.</param>
215 private void OutputSogsToConsole(Predicate<SceneObjectGroup> searchPredicate, bool showFull)
216 {
217 List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups().FindAll(searchPredicate);
218
219 StringBuilder sb = new StringBuilder();
220
221 foreach (SceneObjectGroup so in sceneObjects)
222 {
223 AddSceneObjectReport(sb, so, showFull);
224 sb.Append("\n");
225 }
226
227 sb.AppendFormat("{0} object(s) found in {1}\n", sceneObjects.Count, m_scene.Name);
228
229 m_console.OutputFormat(sb.ToString());
230 }
231
232 private void OutputSopsToConsole(Predicate<SceneObjectPart> searchPredicate, bool showFull)
233 {
234 List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups();
235 List<SceneObjectPart> parts = new List<SceneObjectPart>();
236
237 sceneObjects.ForEach(so => parts.AddRange(Array.FindAll<SceneObjectPart>(so.Parts, searchPredicate)));
238
239 StringBuilder sb = new StringBuilder();
240
241 foreach (SceneObjectPart part in parts)
242 {
243 AddScenePartReport(sb, part, showFull);
244 sb.Append("\n");
245 }
246
247 sb.AppendFormat("{0} parts found in {1}\n", parts.Count, m_scene.Name);
248
249 m_console.OutputFormat(sb.ToString());
250 }
251
252 private void HandleShowObjectById(string module, string[] cmdparams)
253 { 154 {
254 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) 155 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
255 return; 156 return;
256 157
257 bool showFull = false; 158 if (cmd.Length < 4)
258 OptionSet options = new OptionSet().Add("full", v => showFull = v != null );
259
260 List<string> mainParams = options.Parse(cmdparams);
261
262 if (mainParams.Count < 4)
263 { 159 {
264 m_console.OutputFormat("Usage: show object uuid <uuid>"); 160 m_console.OutputFormat("Usage: show object uuid <uuid>");
265 return; 161 return;
266 } 162 }
267 163
268 UUID uuid; 164 UUID objectUuid;
269 uint localId; 165 if (!UUID.TryParse(cmd[3], out objectUuid))
270 if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out uuid, out localId)) 166 {
167 m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
271 return; 168 return;
169 }
272 170
273 SceneObjectGroup so; 171 SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
274
275 if (localId != ConsoleUtil.LocalIdNotFound)
276 so = m_scene.GetSceneObjectGroup(localId);
277 else
278 so = m_scene.GetSceneObjectGroup(uuid);
279 172
280 if (so == null) 173 if (so == null)
281 { 174 {
@@ -284,7 +177,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
284 } 177 }
285 178
286 StringBuilder sb = new StringBuilder(); 179 StringBuilder sb = new StringBuilder();
287 AddSceneObjectReport(sb, so, showFull); 180 AddSceneObjectReport(sb, so);
288 181
289 m_console.OutputFormat(sb.ToString()); 182 m_console.OutputFormat(sb.ToString());
290 } 183 }
@@ -294,91 +187,70 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
294 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) 187 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
295 return; 188 return;
296 189
297 bool showFull = false;
298 bool useRegex = false; 190 bool useRegex = false;
299 OptionSet options = new OptionSet(); 191 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
300 options.Add("full", v => showFull = v != null );
301 options.Add("regex", v => useRegex = v != null );
302 192
303 List<string> mainParams = options.Parse(cmdparams); 193 List<string> mainParams = options.Parse(cmdparams);
304 194
305 if (mainParams.Count < 4) 195 if (mainParams.Count < 4)
306 { 196 {
307 m_console.OutputFormat("Usage: show object name [--full] [--regex] <name>"); 197 m_console.OutputFormat("Usage: show object name [--regex] <name>");
308 return; 198 return;
309 } 199 }
310 200
311 string name = mainParams[3]; 201 string name = mainParams[3];
312 202
313 Predicate<SceneObjectGroup> searchPredicate; 203 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
204 Action<SceneObjectGroup> searchAction;
314 205
315 if (useRegex) 206 if (useRegex)
316 { 207 {
317 Regex nameRegex = new Regex(name); 208 Regex nameRegex = new Regex(name);
318 searchPredicate = so => nameRegex.IsMatch(so.Name); 209 searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }};
319 } 210 }
320 else 211 else
321 { 212 {
322 searchPredicate = so => so.Name == name; 213 searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }};
323 } 214 }
324 215
325 OutputSogsToConsole(searchPredicate, showFull); 216 m_scene.ForEachSOG(searchAction);
326 }
327
328 private void HandleShowObjectByPos(string module, string[] cmdparams)
329 {
330 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
331 return;
332
333 bool showFull = false;
334 OptionSet options = new OptionSet().Add("full", v => showFull = v != null );
335
336 List<string> mainParams = options.Parse(cmdparams);
337 217
338 if (mainParams.Count < 5) 218 if (sceneObjects.Count == 0)
339 { 219 {
340 m_console.OutputFormat("Usage: show object pos [--full] <start-coord> to <end-coord>"); 220 m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
341 return; 221 return;
342 } 222 }
343 223
344 Vector3 startVector, endVector; 224 StringBuilder sb = new StringBuilder();
345
346 if (!TryParseVectorRange(cmdparams.Skip(3).Take(3), out startVector, out endVector))
347 return;
348 225
349 Predicate<SceneObjectGroup> searchPredicate 226 foreach (SceneObjectGroup so in sceneObjects)
350 = so => Util.IsInsideBox(so.AbsolutePosition, startVector, endVector); 227 {
228 AddSceneObjectReport(sb, so);
229 sb.Append("\n");
230 }
351 231
352 OutputSogsToConsole(searchPredicate, showFull); 232 m_console.OutputFormat(sb.ToString());
353 } 233 }
354 234
355 private void HandleShowPartById(string module, string[] cmdparams) 235 private void HandleShowPartByUuid(string module, string[] cmd)
356 { 236 {
357 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) 237 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
358 return; 238 return;
359 239
360// bool showFull = false; 240 if (cmd.Length < 4)
361 OptionSet options = new OptionSet();
362// options.Add("full", v => showFull = v != null );
363
364 List<string> mainParams = options.Parse(cmdparams);
365
366 if (mainParams.Count < 4)
367 { 241 {
368 m_console.OutputFormat("Usage: show part id [--full] <UUID-or-localID>"); 242 m_console.OutputFormat("Usage: show part uuid <uuid>");
369 return; 243 return;
370 } 244 }
371 245
372 UUID objectUuid; 246 UUID objectUuid;
373 uint localId; 247 if (!UUID.TryParse(cmd[3], out objectUuid))
374 if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out objectUuid, out localId)) 248 {
249 m_console.OutputFormat("{0} is not a valid uuid", cmd[3]);
375 return; 250 return;
251 }
376 252
377 SceneObjectPart sop; 253 SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid);
378 if (localId == ConsoleUtil.LocalIdNotFound)
379 sop = m_scene.GetSceneObjectPart(objectUuid);
380 else
381 sop = m_scene.GetSceneObjectPart(localId);
382 254
383 if (sop == null) 255 if (sop == null)
384 { 256 {
@@ -387,239 +259,84 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
387 } 259 }
388 260
389 StringBuilder sb = new StringBuilder(); 261 StringBuilder sb = new StringBuilder();
390 AddScenePartReport(sb, sop, true); 262 AddScenePartReport(sb, sop);
391 263
392 m_console.OutputFormat(sb.ToString()); 264 m_console.OutputFormat(sb.ToString());
393 } 265 }
394 266
395 private void HandleShowPartByPos(string module, string[] cmdparams)
396 {
397 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
398 return;
399
400// bool showFull = false;
401 OptionSet options = new OptionSet();
402// options.Add("full", v => showFull = v != null );
403
404 List<string> mainParams = options.Parse(cmdparams);
405
406 if (mainParams.Count < 5)
407 {
408 m_console.OutputFormat("Usage: show part pos [--full] <start-coord> to <end-coord>");
409 return;
410 }
411
412 string rawConsoleStartVector = mainParams[3];
413 Vector3 startVector;
414
415 if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector))
416 {
417 m_console.OutputFormat("Error: Start vector {0} does not have a valid format", rawConsoleStartVector);
418 return;
419 }
420
421 string rawConsoleEndVector = mainParams[5];
422 Vector3 endVector;
423
424 if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
425 {
426 m_console.OutputFormat("Error: End vector {0} does not have a valid format", rawConsoleEndVector);
427 return;
428 }
429
430 OutputSopsToConsole(sop => Util.IsInsideBox(sop.AbsolutePosition, startVector, endVector), true);
431 }
432
433 private void HandleShowPartByName(string module, string[] cmdparams) 267 private void HandleShowPartByName(string module, string[] cmdparams)
434 { 268 {
435 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) 269 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
436 return; 270 return;
437 271
438// bool showFull = false;
439 bool useRegex = false; 272 bool useRegex = false;
440 OptionSet options = new OptionSet(); 273 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
441// options.Add("full", v => showFull = v != null );
442 options.Add("regex", v => useRegex = v != null );
443 274
444 List<string> mainParams = options.Parse(cmdparams); 275 List<string> mainParams = options.Parse(cmdparams);
445 276
446 if (mainParams.Count < 4) 277 if (mainParams.Count < 4)
447 { 278 {
448 m_console.OutputFormat("Usage: show part name [--full] [--regex] <name>"); 279 m_console.OutputFormat("Usage: show part name [--regex] <name>");
449 return; 280 return;
450 } 281 }
451 282
452 string name = mainParams[3]; 283 string name = mainParams[3];
453 284
454 Predicate<SceneObjectPart> searchPredicate; 285 List<SceneObjectPart> parts = new List<SceneObjectPart>();
286
287 Action<SceneObjectGroup> searchAction;
455 288
456 if (useRegex) 289 if (useRegex)
457 { 290 {
458 Regex nameRegex = new Regex(name); 291 Regex nameRegex = new Regex(name);
459 searchPredicate = sop => nameRegex.IsMatch(sop.Name); 292 searchAction = so => so.ForEachPart(sop => { if (nameRegex.IsMatch(sop.Name)) { parts.Add(sop); } });
460 } 293 }
461 else 294 else
462 { 295 {
463 searchPredicate = sop => sop.Name == name; 296 searchAction = so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } });
464 } 297 }
465 298
466 OutputSopsToConsole(searchPredicate, true); 299 m_scene.ForEachSOG(searchAction);
467 }
468
469 private void HandleDumpObjectById(string module, string[] cmdparams)
470 {
471 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
472 return;
473 300
474 if (cmdparams.Length < 4) 301 if (parts.Count == 0)
475 { 302 {
476 m_console.OutputFormat("Usage: dump object id <UUID-or-localID>"); 303 m_console.OutputFormat("No parts with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
477 return; 304 return;
478 } 305 }
479 306
480 UUID objectUuid; 307 StringBuilder sb = new StringBuilder();
481 uint localId;
482 if (!ConsoleUtil.TryParseConsoleId(m_console, cmdparams[3], out objectUuid, out localId))
483 return;
484
485 SceneObjectGroup so;
486 if (localId == ConsoleUtil.LocalIdNotFound)
487 so = m_scene.GetSceneObjectGroup(objectUuid);
488 else
489 so = m_scene.GetSceneObjectGroup(localId);
490 308
491 if (so == null) 309 foreach (SceneObjectPart part in parts)
492 { 310 {
493// m_console.OutputFormat("No part found with uuid {0}", objectUuid); 311 AddScenePartReport(sb, part);
494 return; 312 sb.Append("\n");
495 } 313 }
496 314
497 // In case we found it via local ID. 315 m_console.OutputFormat(sb.ToString());
498 objectUuid = so.UUID;
499
500 string fileName = string.Format("{0}.xml", objectUuid);
501
502 if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName))
503 return;
504
505 using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
506 {
507 xtw.Formatting = Formatting.Indented;
508 SceneObjectSerializer.ToOriginalXmlFormat(so, xtw, true);
509 }
510
511 m_console.OutputFormat("Object dumped to file {0}", fileName);
512 } 316 }
513 317
514 /// <summary> 318 private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so)
515 /// Append a scene object report to an input StringBuilder
516 /// </summary>
517 /// <returns></returns>
518 /// <param name='sb'></param>
519 /// <param name='so'</param>
520 /// <param name='showFull'>
521 /// If true then information on all parts of an object is appended.
522 /// If false then only summary information about an object is appended.
523 /// </param>
524 private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so, bool showFull)
525 { 319 {
526 if (showFull) 320 sb.AppendFormat("Name: {0}\n", so.Name);
527 { 321 sb.AppendFormat("Description: {0}\n", so.Description);
528 foreach (SceneObjectPart sop in so.Parts) 322 sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName);
529 { 323 sb.AppendFormat("Parts: {0}\n", so.PrimCount);
530 AddScenePartReport(sb, sop, false); 324 sb.AppendFormat("Flags: {0}\n", so.RootPart.Flags);
531 sb.Append("\n");
532 }
533 }
534 else
535 {
536 AddSummarySceneObjectReport(sb, so);
537 }
538 325
539 return sb; 326 return sb;
540 } 327 }
541 328
542 private StringBuilder AddSummarySceneObjectReport(StringBuilder sb, SceneObjectGroup so) 329 private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop)
543 {
544 ConsoleDisplayList cdl = new ConsoleDisplayList();
545 cdl.AddRow("Name", so.Name);
546 cdl.AddRow("Descrition", so.Description);
547 cdl.AddRow("Local ID", so.LocalId);
548 cdl.AddRow("UUID", so.UUID);
549 cdl.AddRow("Location", string.Format("{0} @ {1}", so.AbsolutePosition, so.Scene.Name));
550 cdl.AddRow("Parts", so.PrimCount);
551 cdl.AddRow("Flags", so.RootPart.Flags);
552
553 return sb.Append(cdl.ToString());
554 }
555
556 /// <summary>
557 /// Append a scene object part report to an input StringBuilder
558 /// </summary>
559 /// <returns></returns>
560 /// <param name='sb'></param>
561 /// <param name='sop'</param>
562 /// <param name='showFull'>
563 /// If true then information on each inventory item will be shown.
564 /// If false then only summary inventory information is shown.
565 /// </param>
566 private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop, bool showFull)
567 {
568 ConsoleDisplayList cdl = new ConsoleDisplayList();
569 cdl.AddRow("Name", sop.Name);
570 cdl.AddRow("Description", sop.Description);
571 cdl.AddRow("Local ID", sop.LocalId);
572 cdl.AddRow("UUID", sop.UUID);
573 cdl.AddRow("Location", string.Format("{0} @ {1}", sop.AbsolutePosition, sop.ParentGroup.Scene.Name));
574 cdl.AddRow(
575 "Parent",
576 sop.IsRoot ? "Is Root" : string.Format("{0} {1}", sop.ParentGroup.Name, sop.ParentGroup.UUID));
577 cdl.AddRow("Link number", sop.LinkNum);
578 cdl.AddRow("Flags", sop.Flags);
579
580 object itemsOutput;
581 if (showFull)
582 {
583 StringBuilder itemsSb = new StringBuilder("\n");
584 itemsOutput = AddScenePartItemsReport(itemsSb, sop.Inventory).ToString();
585 }
586 else
587 {
588 itemsOutput = sop.Inventory.Count;
589 }
590
591
592 cdl.AddRow("Items", itemsOutput);
593
594 return sb.Append(cdl.ToString());
595 }
596
597 private StringBuilder AddScenePartItemsReport(StringBuilder sb, IEntityInventory inv)
598 { 330 {
599 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 331 sb.AppendFormat("Name: {0}\n", sop.Name);
600 cdt.Indent = 2; 332 sb.AppendFormat("Description: {0}\n", sop.Description);
601 333 sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName);
602 cdt.AddColumn("Name", 50); 334 sb.AppendFormat("Parent: {0}",
603 cdt.AddColumn("Type", 12); 335 sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID));
604 cdt.AddColumn("Running", 7); 336 sb.AppendFormat("Link number: {0}\n", sop.LinkNum);
605 cdt.AddColumn("Item UUID", 36); 337 sb.AppendFormat("Flags: {0}\n", sop.Flags);
606 cdt.AddColumn("Asset UUID", 36);
607
608 foreach (TaskInventoryItem item in inv.GetInventoryItems())
609 {
610 bool foundScriptInstance, scriptRunning;
611 foundScriptInstance
612 = SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, item, out scriptRunning);
613
614 cdt.AddRow(
615 item.Name,
616 ((InventoryType)item.InvType).ToString(),
617 foundScriptInstance ? scriptRunning.ToString() : "n/a",
618 item.ItemID.ToString(),
619 item.AssetID.ToString());
620 }
621 338
622 return sb.Append(cdt.ToString()); 339 return sb;
623 } 340 }
624 341
625 private void HandleDeleteObject(string module, string[] cmd) 342 private void HandleDeleteObject(string module, string[] cmd)
@@ -681,24 +398,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
681 398
682 break; 399 break;
683 400
684 case "id": 401 case "uuid":
685 UUID uuid; 402 if (!UUID.TryParse(o, out match))
686 uint localId;
687 if (!ConsoleUtil.TryParseConsoleId(m_console, o, out uuid, out localId))
688 return; 403 return;
689 404
690 requireConfirmation = false; 405 requireConfirmation = false;
691 deletes = new List<SceneObjectGroup>(); 406 deletes = new List<SceneObjectGroup>();
692 407
693 SceneObjectGroup so; 408 m_scene.ForEachSOG(delegate (SceneObjectGroup g)
694 if (localId == ConsoleUtil.LocalIdNotFound) 409 {
695 so = m_scene.GetSceneObjectGroup(uuid); 410 if (g.UUID == match && !g.IsAttachment)
696 else 411 deletes.Add(g);
697 so = m_scene.GetSceneObjectGroup(localId); 412 });
698 413
699 if (!so.IsAttachment)
700 deletes.Add(so);
701
702 // if (deletes.Count == 0) 414 // if (deletes.Count == 0)
703 // m_console.OutputFormat("No objects were found with uuid {0}", match); 415 // m_console.OutputFormat("No objects were found with uuid {0}", match);
704 416
@@ -738,10 +450,6 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
738 450
739 break; 451 break;
740 452
741 case "pos":
742 deletes = GetDeleteCandidatesByPos(module, cmd);
743 break;
744
745 default: 453 default:
746 m_console.OutputFormat("Unrecognized mode {0}", mode); 454 m_console.OutputFormat("Unrecognized mode {0}", mode);
747 return; 455 return;
@@ -756,7 +464,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
756 string.Format( 464 string.Format(
757 "Are you sure that you want to delete {0} objects from {1}", 465 "Are you sure that you want to delete {0} objects from {1}",
758 deletes.Count, m_scene.RegionInfo.RegionName), 466 deletes.Count, m_scene.RegionInfo.RegionName),
759 "y/N"); 467 "n");
760 468
761 if (response.ToLower() != "y") 469 if (response.ToLower() != "y")
762 { 470 {
@@ -778,6 +486,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
778 486
779 private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams) 487 private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams)
780 { 488 {
489 if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
490 return null;
491
781 bool useRegex = false; 492 bool useRegex = false;
782 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null ); 493 OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
783 494
@@ -811,52 +522,5 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
811 522
812 return sceneObjects; 523 return sceneObjects;
813 } 524 }
814
815 /// <summary>
816 /// Get scene object delete candidates by position
817 /// </summary>
818 /// <param name='module'></param>
819 /// <param name='cmdparams'></param>
820 /// <returns>null if parsing failed on one of the arguments, otherwise a list of objects to delete. If there
821 /// are no objects to delete then the list will be empty./returns>
822 private List<SceneObjectGroup> GetDeleteCandidatesByPos(string module, string[] cmdparams)
823 {
824 if (cmdparams.Length < 5)
825 {
826 m_console.OutputFormat("Usage: delete object pos <start-coord> to <end-coord>");
827 return null;
828 }
829
830 Vector3 startVector, endVector;
831
832 if (!TryParseVectorRange(cmdparams.Skip(3).Take(3), out startVector, out endVector))
833 return null;
834
835 return m_scene.GetSceneObjectGroups().FindAll(
836 so => !so.IsAttachment && Util.IsInsideBox(so.AbsolutePosition, startVector, endVector));
837 }
838
839 private bool TryParseVectorRange(IEnumerable<string> rawComponents, out Vector3 startVector, out Vector3 endVector)
840 {
841 string rawConsoleStartVector = rawComponents.Take(1).Single();
842
843 if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector))
844 {
845 m_console.OutputFormat("Error: Start vector {0} does not have a valid format", rawConsoleStartVector);
846 endVector = Vector3.Zero;
847
848 return false;
849 }
850
851 string rawConsoleEndVector = rawComponents.Skip(1).Take(1).Single();
852
853 if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
854 {
855 m_console.OutputFormat("Error: End vector {0} does not have a valid format", rawConsoleEndVector);
856 return false;
857 }
858
859 return true;
860 }
861 } 525 }
862} \ No newline at end of file 526} \ No newline at end of file