diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index e68f954..8f99dc6 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -59,57 +59,58 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
59 | /// <returns>The scene object deserialized. Null on failure.</returns> | 59 | /// <returns>The scene object deserialized. Null on failure.</returns> |
60 | public static SceneObjectGroup FromOriginalXmlFormat(string xmlData) | 60 | public static SceneObjectGroup FromOriginalXmlFormat(string xmlData) |
61 | { | 61 | { |
62 | using (XmlTextReader reader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) | ||
63 | return FromOriginalXmlFormat(reader); | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// Deserialize a scene object from the original xml format | ||
68 | /// </summary> | ||
69 | /// <param name="xmlData"></param> | ||
70 | /// <returns>The scene object deserialized. Null on failure.</returns> | ||
71 | public static SceneObjectGroup FromOriginalXmlFormat(XmlTextReader reader) | ||
72 | { | ||
62 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | 73 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); |
63 | //int time = System.Environment.TickCount; | 74 | //int time = System.Environment.TickCount; |
64 | 75 | ||
76 | SceneObjectGroup sceneObject = null; | ||
77 | |||
65 | try | 78 | try |
66 | { | 79 | { |
67 | StringReader sr; | ||
68 | XmlTextReader reader; | ||
69 | XmlNodeList parts; | ||
70 | XmlDocument doc; | ||
71 | int linkNum; | 80 | int linkNum; |
72 | 81 | ||
73 | doc = new XmlDocument(); | 82 | reader.ReadToFollowing("RootPart"); |
74 | doc.LoadXml(xmlData); | 83 | reader.ReadToFollowing("SceneObjectPart"); |
75 | parts = doc.GetElementsByTagName("RootPart"); | 84 | sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader)); |
85 | reader.ReadToFollowing("OtherParts"); | ||
76 | 86 | ||
77 | if (parts.Count == 0) | 87 | if (reader.ReadToDescendant("Part")) |
78 | throw new Exception("Invalid Xml format - no root part"); | ||
79 | |||
80 | sr = new StringReader(parts[0].InnerXml); | ||
81 | reader = new XmlTextReader(sr); | ||
82 | SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader)); | ||
83 | reader.Close(); | ||
84 | sr.Close(); | ||
85 | |||
86 | parts = doc.GetElementsByTagName("Part"); | ||
87 | |||
88 | for (int i = 0; i < parts.Count; i++) | ||
89 | { | 88 | { |
90 | sr = new StringReader(parts[i].InnerXml); | 89 | do |
91 | reader = new XmlTextReader(sr); | 90 | { |
92 | SceneObjectPart part = SceneObjectPart.FromXml(reader); | 91 | if (reader.ReadToDescendant("SceneObjectPart")) |
93 | linkNum = part.LinkNum; | 92 | { |
94 | sceneObject.AddPart(part); | 93 | SceneObjectPart part = SceneObjectPart.FromXml(reader); |
95 | part.LinkNum = linkNum; | 94 | linkNum = part.LinkNum; |
96 | part.TrimPermissions(); | 95 | sceneObject.AddPart(part); |
97 | reader.Close(); | 96 | part.LinkNum = linkNum; |
98 | sr.Close(); | 97 | part.TrimPermissions(); |
98 | } | ||
99 | } | ||
100 | while (reader.ReadToNextSibling("Part")); | ||
99 | } | 101 | } |
100 | 102 | ||
101 | // Script state may, or may not, exist. Not having any, is NOT | 103 | // Script state may, or may not, exist. Not having any, is NOT |
102 | // ever a problem. | 104 | // ever a problem. |
103 | sceneObject.LoadScriptState(doc); | 105 | sceneObject.LoadScriptState(reader); |
104 | |||
105 | return sceneObject; | ||
106 | } | 106 | } |
107 | catch (Exception e) | 107 | catch (Exception e) |
108 | { | 108 | { |
109 | m_log.ErrorFormat( | 109 | m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed. Exception {0}", e); |
110 | "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); | ||
111 | return null; | 110 | return null; |
112 | } | 111 | } |
112 | |||
113 | return sceneObject; | ||
113 | } | 114 | } |
114 | 115 | ||
115 | /// <summary> | 116 | /// <summary> |