diff options
Made some changes to the load/save xml format, So that the old format can still be used, I have added new console commands of "load-xml2" and "save-xml2", if the old versions worked for you then please continue using them (at least for now). The new versions haven't been tested that much, so their format could be subject to change.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 58 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneManager.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 33 |
4 files changed, 120 insertions, 4 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index c367537..d2f5648 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -146,7 +146,6 @@ namespace OpenSim | |||
146 | m_networkServersInfo.loadFromConfiguration(m_config); | 146 | m_networkServersInfo.loadFromConfiguration(m_config); |
147 | } | 147 | } |
148 | 148 | ||
149 | |||
150 | /// <summary> | 149 | /// <summary> |
151 | /// Performs initialisation of the scene, such as loading configuration from disk. | 150 | /// Performs initialisation of the scene, such as loading configuration from disk. |
152 | /// </summary> | 151 | /// </summary> |
@@ -485,6 +484,28 @@ namespace OpenSim | |||
485 | } | 484 | } |
486 | break; | 485 | break; |
487 | 486 | ||
487 | case "save-xml2": | ||
488 | if (cmdparams.Length > 0) | ||
489 | { | ||
490 | m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]); | ||
491 | } | ||
492 | else | ||
493 | { | ||
494 | m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME); | ||
495 | } | ||
496 | break; | ||
497 | |||
498 | case "load-xml2": | ||
499 | if (cmdparams.Length > 0) | ||
500 | { | ||
501 | m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]); | ||
502 | } | ||
503 | else | ||
504 | { | ||
505 | m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); | ||
506 | } | ||
507 | break; | ||
508 | |||
488 | case "terrain": | 509 | case "terrain": |
489 | if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result)) | 510 | if (!m_sceneManager.RunTerrainCmdOnCurrentScene(cmdparams, ref result)) |
490 | { | 511 | { |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index f7e3543..553e55f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -709,6 +709,64 @@ namespace OpenSim.Region.Environment.Scenes | |||
709 | file.Close(); | 709 | file.Close(); |
710 | } | 710 | } |
711 | 711 | ||
712 | public void LoadPrimsFromXml2(string fileName) | ||
713 | { | ||
714 | XmlDocument doc = new XmlDocument(); | ||
715 | XmlNode rootNode; | ||
716 | if ((fileName.StartsWith("http:")) | (File.Exists(fileName))) | ||
717 | { | ||
718 | XmlTextReader reader = new XmlTextReader(fileName); | ||
719 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
720 | doc.Load(reader); | ||
721 | reader.Close(); | ||
722 | rootNode = doc.FirstChild; | ||
723 | foreach (XmlNode aPrimNode in rootNode.ChildNodes) | ||
724 | { | ||
725 | CreatePrimFromXml(aPrimNode.OuterXml); | ||
726 | } | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | throw new Exception("Could not open file " + fileName + " for reading"); | ||
731 | } | ||
732 | } | ||
733 | |||
734 | public void CreatePrimFromXml(string xmlData) | ||
735 | { | ||
736 | SceneObjectGroup obj = new SceneObjectGroup(xmlData); | ||
737 | AddEntityFromStorage(obj); | ||
738 | |||
739 | SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); | ||
740 | if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) | ||
741 | rootPart.PhysActor = phyScene.AddPrimShape( | ||
742 | rootPart.Name, | ||
743 | rootPart.Shape, | ||
744 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | ||
745 | rootPart.AbsolutePosition.Z), | ||
746 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | ||
747 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | ||
748 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); | ||
749 | } | ||
750 | |||
751 | public void SavePrimsToXml2(string fileName) | ||
752 | { | ||
753 | FileStream file = new FileStream(fileName, FileMode.Create); | ||
754 | StreamWriter stream = new StreamWriter(file); | ||
755 | int primCount = 0; | ||
756 | stream.WriteLine("<scene>\n"); | ||
757 | foreach (EntityBase ent in Entities.Values) | ||
758 | { | ||
759 | if (ent is SceneObjectGroup) | ||
760 | { | ||
761 | stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); | ||
762 | primCount++; | ||
763 | } | ||
764 | } | ||
765 | stream.WriteLine("</scene>\n"); | ||
766 | stream.Close(); | ||
767 | file.Close(); | ||
768 | } | ||
769 | |||
712 | #endregion | 770 | #endregion |
713 | 771 | ||
714 | #region Add/Remove Avatar Methods | 772 | #region Add/Remove Avatar Methods |
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index e3da550..d2718df 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs | |||
@@ -85,6 +85,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
85 | public void LoadCurrentSceneFromXml(string filename) | 85 | public void LoadCurrentSceneFromXml(string filename) |
86 | { | 86 | { |
87 | CurrentOrFirstScene.LoadPrimsFromXml(filename); | 87 | CurrentOrFirstScene.LoadPrimsFromXml(filename); |
88 | } | ||
89 | |||
90 | public void SaveCurrentSceneToXml2(string filename) | ||
91 | { | ||
92 | CurrentOrFirstScene.SavePrimsToXml2(filename); | ||
93 | } | ||
94 | |||
95 | public void LoadCurrentSceneFromXml2(string filename) | ||
96 | { | ||
97 | CurrentOrFirstScene.LoadPrimsFromXml2(filename); | ||
88 | } | 98 | } |
89 | 99 | ||
90 | public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) | 100 | public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 1839051..bb2eadb 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -272,7 +272,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
272 | reader.Read(); | 272 | reader.Read(); |
273 | 273 | ||
274 | reader.ReadStartElement("SceneObjectGroup"); | 274 | reader.ReadStartElement("SceneObjectGroup"); |
275 | // reader.ReadStartElement("RootPart"); | ||
276 | m_rootPart = SceneObjectPart.FromXml(reader); | 275 | m_rootPart = SceneObjectPart.FromXml(reader); |
277 | 276 | ||
278 | reader.Read(); | 277 | reader.Read(); |
@@ -286,8 +285,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
286 | if (reader.Name == "SceneObjectPart") | 285 | if (reader.Name == "SceneObjectPart") |
287 | { | 286 | { |
288 | SceneObjectPart Part = SceneObjectPart.FromXml(reader); | 287 | SceneObjectPart Part = SceneObjectPart.FromXml(reader); |
289 | AddPart(Part); | 288 | AddPart(Part); |
290 | |||
291 | } | 289 | } |
292 | break; | 290 | break; |
293 | case XmlNodeType.EndElement: | 291 | case XmlNodeType.EndElement: |
@@ -375,6 +373,35 @@ namespace OpenSim.Region.Environment.Scenes | |||
375 | writer.WriteEndElement(); | 373 | writer.WriteEndElement(); |
376 | } | 374 | } |
377 | 375 | ||
376 | public string ToXmlString2() | ||
377 | { | ||
378 | using (StringWriter sw = new StringWriter()) | ||
379 | { | ||
380 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | ||
381 | { | ||
382 | ToXml2(writer); | ||
383 | } | ||
384 | |||
385 | return sw.ToString(); | ||
386 | } | ||
387 | } | ||
388 | |||
389 | public void ToXml2(XmlTextWriter writer) | ||
390 | { | ||
391 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
392 | m_rootPart.ToXml(writer); | ||
393 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
394 | foreach (SceneObjectPart part in m_parts.Values) | ||
395 | { | ||
396 | if (part.UUID != m_rootPart.UUID) | ||
397 | { | ||
398 | part.ToXml(writer); | ||
399 | } | ||
400 | } | ||
401 | writer.WriteEndElement(); | ||
402 | writer.WriteEndElement(); | ||
403 | } | ||
404 | |||
378 | #region Copying | 405 | #region Copying |
379 | 406 | ||
380 | /// <summary> | 407 | /// <summary> |