diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Objects')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 173 |
1 files changed, 106 insertions, 67 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 87241e1..b2c9bce 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -27,10 +27,12 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
30 | using System.Linq; | 31 | using System.Linq; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Text.RegularExpressions; | 34 | using System.Text.RegularExpressions; |
35 | using System.Xml; | ||
34 | using log4net; | 36 | using log4net; |
35 | using Mono.Addins; | 37 | using Mono.Addins; |
36 | using NDesk.Options; | 38 | using NDesk.Options; |
@@ -41,6 +43,7 @@ using OpenSim.Framework.Console; | |||
41 | using OpenSim.Framework.Monitoring; | 43 | using OpenSim.Framework.Monitoring; |
42 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
46 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | 47 | ||
45 | namespace OpenSim.Region.CoreModules.World.Objects.Commands | 48 | namespace OpenSim.Region.CoreModules.World.Objects.Commands |
46 | { | 49 | { |
@@ -96,9 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
96 | HandleDeleteObject); | 99 | HandleDeleteObject); |
97 | 100 | ||
98 | m_console.Commands.AddCommand( | 101 | m_console.Commands.AddCommand( |
99 | "Objects", false, "delete object uuid", | 102 | "Objects", false, "delete object id", |
100 | "delete object uuid <UUID>", | 103 | "delete object id <UUID-or-localID>", |
101 | "Delete a scene object by uuid", | 104 | "Delete a scene object by uuid or localID", |
102 | HandleDeleteObject); | 105 | HandleDeleteObject); |
103 | 106 | ||
104 | m_console.Commands.AddCommand( | 107 | m_console.Commands.AddCommand( |
@@ -122,28 +125,18 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
122 | "delete object pos", | 125 | "delete object pos", |
123 | "delete object pos <start-coord> to <end-coord>", | 126 | "delete object pos <start-coord> to <end-coord>", |
124 | "Delete scene objects within the given area.", | 127 | "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" | 128 | ConsoleUtil.CoordHelp, |
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); | 129 | HandleDeleteObject); |
137 | 130 | ||
138 | m_console.Commands.AddCommand( | 131 | m_console.Commands.AddCommand( |
139 | "Objects", | 132 | "Objects", |
140 | false, | 133 | false, |
141 | "show object uuid", | 134 | "show object id", |
142 | "show object uuid [--full] <UUID>", | 135 | "show object id [--full] <UUID-or-localID>", |
143 | "Show details of a scene object with the given UUID", | 136 | "Show details of a scene object with the given UUID or localID", |
144 | "The --full option will print out information on all the parts of the object.\n" | 137 | "The --full option will print out information on all the parts of the object.\n" |
145 | + "For yet more detailed part information, use the \"show part\" commands.", | 138 | + "For yet more detailed part information, use the \"show part\" commands.", |
146 | HandleShowObjectByUuid); | 139 | HandleShowObjectById); |
147 | 140 | ||
148 | m_console.Commands.AddCommand( | 141 | m_console.Commands.AddCommand( |
149 | "Objects", | 142 | "Objects", |
@@ -164,25 +157,15 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
164 | "Show details of scene objects within the given area.", | 157 | "Show details of scene objects within the given area.", |
165 | "The --full option will print out information on all the parts of the object.\n" | 158 | "The --full option will print out information on all the parts of the object.\n" |
166 | + "For yet more detailed part information, use the \"show part\" commands.\n" | 159 | + "For yet more detailed part information, use the \"show part\" commands.\n" |
167 | + "Each component of the coord is comma separated. There must be no spaces between the commas.\n" | 160 | + ConsoleUtil.CoordHelp, |
168 | + "If you don't care about the z component you can simply omit it.\n" | ||
169 | + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" | ||
170 | + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n" | ||
171 | + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n" | ||
172 | + "e.g.\n" | ||
173 | + "show object pos 20,20,20 to 40,40,40\n" | ||
174 | + "show object pos 20,20 to 40,40\n" | ||
175 | + "show object pos ,20,20 to ,40,40\n" | ||
176 | + "show object pos ,,30 to ,,~\n" | ||
177 | + "show object pos ,,-~ to ,,30", | ||
178 | HandleShowObjectByPos); | 161 | HandleShowObjectByPos); |
179 | 162 | ||
180 | m_console.Commands.AddCommand( | 163 | m_console.Commands.AddCommand( |
181 | "Objects", | 164 | "Objects", |
182 | false, | 165 | false, |
183 | "show part uuid", | 166 | "show part id", |
184 | "show part uuid <UUID>", | 167 | "show part id <UUID-or-localID>", |
185 | "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); | 168 | "Show details of a scene object part with the given UUID or localID", HandleShowPartById); |
186 | 169 | ||
187 | m_console.Commands.AddCommand( | 170 | m_console.Commands.AddCommand( |
188 | "Objects", | 171 | "Objects", |
@@ -190,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
190 | "show part name", | 173 | "show part name", |
191 | "show part name [--regex] <name>", | 174 | "show part name [--regex] <name>", |
192 | "Show details of scene object parts with the given name.", | 175 | "Show details of scene object parts with the given name.", |
193 | "If --regex is specified then the name is treatead as a regular expression", | 176 | "If --regex is specified then the name is treated as a regular expression", |
194 | HandleShowPartByName); | 177 | HandleShowPartByName); |
195 | 178 | ||
196 | m_console.Commands.AddCommand( | 179 | m_console.Commands.AddCommand( |
@@ -199,18 +182,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
199 | "show part pos", | 182 | "show part pos", |
200 | "show part pos <start-coord> to <end-coord>", | 183 | "show part pos <start-coord> to <end-coord>", |
201 | "Show details of scene object parts within the given area.", | 184 | "Show details of scene object parts within the given area.", |
202 | "Each component of the coord is comma separated. There must be no spaces between the commas.\n" | 185 | ConsoleUtil.CoordHelp, |
203 | + "If you don't care about the z component you can simply omit it.\n" | ||
204 | + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" | ||
205 | + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n" | ||
206 | + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n" | ||
207 | + "e.g.\n" | ||
208 | + "show object pos 20,20,20 to 40,40,40\n" | ||
209 | + "show object pos 20,20 to 40,40\n" | ||
210 | + "show object pos ,20,20 to ,40,40\n" | ||
211 | + "show object pos ,,30 to ,,~\n" | ||
212 | + "show object pos ,,-~ to ,,30", | ||
213 | HandleShowPartByPos); | 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); | ||
214 | } | 198 | } |
215 | 199 | ||
216 | public void RemoveRegion(Scene scene) | 200 | public void RemoveRegion(Scene scene) |
@@ -265,7 +249,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
265 | m_console.OutputFormat(sb.ToString()); | 249 | m_console.OutputFormat(sb.ToString()); |
266 | } | 250 | } |
267 | 251 | ||
268 | private void HandleShowObjectByUuid(string module, string[] cmdparams) | 252 | private void HandleShowObjectById(string module, string[] cmdparams) |
269 | { | 253 | { |
270 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 254 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
271 | return; | 255 | return; |
@@ -281,14 +265,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
281 | return; | 265 | return; |
282 | } | 266 | } |
283 | 267 | ||
284 | UUID objectUuid; | 268 | UUID uuid; |
285 | if (!UUID.TryParse(mainParams[3], out objectUuid)) | 269 | uint localId; |
286 | { | 270 | if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out uuid, out localId)) |
287 | m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]); | ||
288 | return; | 271 | return; |
289 | } | ||
290 | 272 | ||
291 | SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid); | 273 | SceneObjectGroup so; |
274 | |||
275 | if (localId != ConsoleUtil.LocalIdNotFound) | ||
276 | so = m_scene.GetSceneObjectGroup(localId); | ||
277 | else | ||
278 | so = m_scene.GetSceneObjectGroup(uuid); | ||
292 | 279 | ||
293 | if (so == null) | 280 | if (so == null) |
294 | { | 281 | { |
@@ -365,7 +352,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
365 | OutputSogsToConsole(searchPredicate, showFull); | 352 | OutputSogsToConsole(searchPredicate, showFull); |
366 | } | 353 | } |
367 | 354 | ||
368 | private void HandleShowPartByUuid(string module, string[] cmdparams) | 355 | private void HandleShowPartById(string module, string[] cmdparams) |
369 | { | 356 | { |
370 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 357 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
371 | return; | 358 | return; |
@@ -378,18 +365,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
378 | 365 | ||
379 | if (mainParams.Count < 4) | 366 | if (mainParams.Count < 4) |
380 | { | 367 | { |
381 | m_console.OutputFormat("Usage: show part uuid [--full] <uuid>"); | 368 | m_console.OutputFormat("Usage: show part id [--full] <UUID-or-localID>"); |
382 | return; | 369 | return; |
383 | } | 370 | } |
384 | 371 | ||
385 | UUID objectUuid; | 372 | UUID objectUuid; |
386 | if (!UUID.TryParse(mainParams[3], out objectUuid)) | 373 | uint localId; |
387 | { | 374 | if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out objectUuid, out localId)) |
388 | m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]); | ||
389 | return; | 375 | return; |
390 | } | ||
391 | 376 | ||
392 | SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); | 377 | SceneObjectPart sop; |
378 | if (localId == ConsoleUtil.LocalIdNotFound) | ||
379 | sop = m_scene.GetSceneObjectPart(objectUuid); | ||
380 | else | ||
381 | sop = m_scene.GetSceneObjectPart(localId); | ||
393 | 382 | ||
394 | if (sop == null) | 383 | if (sop == null) |
395 | { | 384 | { |
@@ -477,6 +466,51 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
477 | OutputSopsToConsole(searchPredicate, true); | 466 | OutputSopsToConsole(searchPredicate, true); |
478 | } | 467 | } |
479 | 468 | ||
469 | private void HandleDumpObjectById(string module, string[] cmdparams) | ||
470 | { | ||
471 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | ||
472 | return; | ||
473 | |||
474 | if (cmdparams.Length < 4) | ||
475 | { | ||
476 | m_console.OutputFormat("Usage: dump object id <UUID-or-localID>"); | ||
477 | return; | ||
478 | } | ||
479 | |||
480 | UUID objectUuid; | ||
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 | |||
491 | if (so == null) | ||
492 | { | ||
493 | // m_console.OutputFormat("No part found with uuid {0}", objectUuid); | ||
494 | return; | ||
495 | } | ||
496 | |||
497 | // In case we found it via local ID. | ||
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 | } | ||
513 | |||
480 | /// <summary> | 514 | /// <summary> |
481 | /// Append a scene object report to an input StringBuilder | 515 | /// Append a scene object report to an input StringBuilder |
482 | /// </summary> | 516 | /// </summary> |
@@ -641,19 +675,24 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
641 | 675 | ||
642 | break; | 676 | break; |
643 | 677 | ||
644 | case "uuid": | 678 | case "id": |
645 | if (!UUID.TryParse(o, out match)) | 679 | UUID uuid; |
680 | uint localId; | ||
681 | if (!ConsoleUtil.TryParseConsoleId(m_console, o, out uuid, out localId)) | ||
646 | return; | 682 | return; |
647 | 683 | ||
648 | requireConfirmation = false; | 684 | requireConfirmation = false; |
649 | deletes = new List<SceneObjectGroup>(); | 685 | deletes = new List<SceneObjectGroup>(); |
650 | 686 | ||
651 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 687 | SceneObjectGroup so; |
652 | { | 688 | if (localId == ConsoleUtil.LocalIdNotFound) |
653 | if (g.UUID == match && !g.IsAttachment) | 689 | so = m_scene.GetSceneObjectGroup(uuid); |
654 | deletes.Add(g); | 690 | else |
655 | }); | 691 | so = m_scene.GetSceneObjectGroup(localId); |
656 | 692 | ||
693 | if (!so.IsAttachment) | ||
694 | deletes.Add(so); | ||
695 | |||
657 | // if (deletes.Count == 0) | 696 | // if (deletes.Count == 0) |
658 | // m_console.OutputFormat("No objects were found with uuid {0}", match); | 697 | // m_console.OutputFormat("No objects were found with uuid {0}", match); |
659 | 698 | ||