From 23ae24b4061f7c1e1bc1c0d5428374ccf4e25891 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 16 May 2012 00:10:42 +0100 Subject: [PATCH] Route OAR SOG loading through the common SceneObjectSerializer.FromXml2Format() rather than the functionally identical but buggy Xml2ToSOG(). Remove buggy Xml2ToSOG(). --- .../World/Archiver/ArchiveReadRequest.cs | 3 +- .../Serialization/SceneObjectSerializer.cs | 45 ------------ .../Scenes/Serialization/SceneXmlLoader.cs | 72 ++----------------- 3 files changed, 5 insertions(+), 115 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 11eca12527..2b61800c94 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -267,8 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver } */ - SceneObjectGroup sceneObject = SceneObjectSerializer.FromXml2Format(serialisedSceneObject); -// SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); + SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); bool isTelehub = (sceneObject.UUID == oldTelehubUUID); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index a11dc4965d..0b34156495 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1424,51 +1424,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } - //////// Read ///////// - public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog) - { - reader.Read(); - reader.ReadStartElement("SceneObjectGroup"); - SceneObjectPart root = Xml2ToSOP(reader); - if (root != null) - sog.SetRootPart(root); - else - { - return false; - } - - if (sog.UUID == UUID.Zero) - sog.UUID = sog.RootPart.UUID; - - reader.Read(); // OtherParts - - while (!reader.EOF) - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - if (reader.Name == "SceneObjectPart") - { - SceneObjectPart child = Xml2ToSOP(reader); - if (child != null) - sog.AddPart(child); - } - else - { - //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug); - reader.Read(); - } - break; - case XmlNodeType.EndElement: - default: - reader.Read(); - break; - } - - } - return true; - } - public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) { SceneObjectPart obj = new SceneObjectPart(); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index d214eba1fc..a3485d29e6 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs @@ -223,50 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) { - XmlDocument doc = new XmlDocument(); - XmlNode rootNode; - - XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); - reader.WhitespaceHandling = WhitespaceHandling.None; - doc.Load(reader); - reader.Close(); - rootNode = doc.FirstChild; - - // This is to deal with neighbouring regions that are still surrounding the group xml with the - // tag. It should be possible to remove the first part of this if statement once we go past 0.5.9 (or - // when some other changes forces all regions to upgrade). - // This might seem rather pointless since prim crossing from this revision to an earlier revision remains - // broken. But it isn't much work to accomodate the old format here. - if (rootNode.LocalName.Equals("scene")) - { - foreach (XmlNode aPrimNode in rootNode.ChildNodes) - { - // There is only ever one prim. This oddity should be removeable post 0.5.9 - //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml); - using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml))) - { - SceneObjectGroup obj = new SceneObjectGroup(); - if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) - return obj; - - return null; - } - } - - return null; - } - else - { - //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml); - using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml))) - { - SceneObjectGroup obj = new SceneObjectGroup(); - if (SceneObjectSerializer.Xml2ToSOG(reader, obj)) - return obj; - - return null; - } - } + return SceneObjectSerializer.FromXml2Format(xmlString); } /// @@ -307,8 +264,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization ICollection sceneObjects = new List(); foreach (XmlNode aPrimNode in rootNode.ChildNodes) { - SceneObjectGroup obj = CreatePrimFromXml2(scene, aPrimNode.OuterXml); - if (obj != null && startScripts) + SceneObjectGroup obj = DeserializeGroupFromXml2(aPrimNode.OuterXml); + if (startScripts) sceneObjects.Add(obj); } @@ -319,27 +276,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } - /// - /// Create a prim from the xml2 representation. - /// - /// - /// - /// The scene object created. null if the scene object already existed - protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) - { - //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData); - using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData))) - { - SceneObjectGroup obj = new SceneObjectGroup(); - SceneObjectSerializer.Xml2ToSOG(reader, obj); - - if (scene.AddRestoredSceneObject(obj, true, false)) - return obj; - else - return null; - } - } - #endregion } -} +} \ No newline at end of file