diff options
author | Justin Clark-Casey (justincc) | 2012-10-24 02:05:28 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-24 02:05:28 +0100 |
commit | 73db057fa1dbda7d6dff7de770cef8670b234f84 (patch) | |
tree | 6f20e418aafe23b6a21044195dd100afa9aa65de /OpenSim/Region/CoreModules | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-73db057fa1dbda7d6dff7de770cef8670b234f84.zip opensim-SC-73db057fa1dbda7d6dff7de770cef8670b234f84.tar.gz opensim-SC-73db057fa1dbda7d6dff7de770cef8670b234f84.tar.bz2 opensim-SC-73db057fa1dbda7d6dff7de770cef8670b234f84.tar.xz |
Add "dump object uuid" console command. This allows any object in the scene to be serialized and dumped to XML for debug purposes.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 6435ae6..41a1afd 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 | { |
@@ -181,6 +184,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
181 | "Show details of scene object parts within the given area.", | 184 | "Show details of scene object parts within the given area.", |
182 | ConsoleUtil.CoordHelp, | 185 | ConsoleUtil.CoordHelp, |
183 | HandleShowPartByPos); | 186 | HandleShowPartByPos); |
187 | |||
188 | m_console.Commands.AddCommand( | ||
189 | "Objects", | ||
190 | false, | ||
191 | "dump object uuid", | ||
192 | "dump object uuid <UUID>", | ||
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 in the first place, you need to use the other show object commands", | ||
196 | HandleDumpObjectByUuid); | ||
184 | } | 197 | } |
185 | 198 | ||
186 | public void RemoveRegion(Scene scene) | 199 | public void RemoveRegion(Scene scene) |
@@ -447,6 +460,46 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
447 | OutputSopsToConsole(searchPredicate, true); | 460 | OutputSopsToConsole(searchPredicate, true); |
448 | } | 461 | } |
449 | 462 | ||
463 | private void HandleDumpObjectByUuid(string module, string[] cmdparams) | ||
464 | { | ||
465 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | ||
466 | return; | ||
467 | |||
468 | if (cmdparams.Length < 4) | ||
469 | { | ||
470 | m_console.OutputFormat("Usage: dump object uuid <uuid>"); | ||
471 | return; | ||
472 | } | ||
473 | |||
474 | UUID objectUuid; | ||
475 | if (!ConsoleUtil.TryParseConsoleUuid(m_console, cmdparams[3], out objectUuid)) | ||
476 | return; | ||
477 | |||
478 | SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid); | ||
479 | |||
480 | if (so == null) | ||
481 | { | ||
482 | // m_console.OutputFormat("No part found with uuid {0}", objectUuid); | ||
483 | return; | ||
484 | } | ||
485 | |||
486 | string fileName = string.Format("{0}.xml", objectUuid); | ||
487 | |||
488 | if (File.Exists(fileName)) | ||
489 | { | ||
490 | m_console.OutputFormat("File {0} already exists. Please move or remove it.", fileName); | ||
491 | return; | ||
492 | } | ||
493 | |||
494 | using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8)) | ||
495 | { | ||
496 | xtw.Formatting = Formatting.Indented; | ||
497 | SceneObjectSerializer.ToOriginalXmlFormat(so, xtw, true); | ||
498 | } | ||
499 | |||
500 | m_console.OutputFormat("Object dumped to file {0}", fileName); | ||
501 | } | ||
502 | |||
450 | /// <summary> | 503 | /// <summary> |
451 | /// Append a scene object report to an input StringBuilder | 504 | /// Append a scene object report to an input StringBuilder |
452 | /// </summary> | 505 | /// </summary> |