diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 78 |
1 files changed, 71 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9eac3be..aa331d9 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
59 | /// </summary> | 59 | /// </summary> |
60 | /// <param name="serialization"></param> | 60 | /// <param name="serialization"></param> |
61 | /// <returns></returns> | 61 | /// <returns></returns> |
62 | public static SceneObjectGroup FromOriginalXmlFormat(UUID fromUserInventoryItemID, string serialization) | 62 | public static SceneObjectGroup FromOriginalXmlFormat(UUID fromUserInventoryItemID, string xmlData) |
63 | { | 63 | { |
64 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | 64 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); |
65 | //int time = System.Environment.TickCount; | 65 | //int time = System.Environment.TickCount; |
@@ -67,12 +67,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
67 | SceneObjectGroup sceneObject = new SceneObjectGroup(); | 67 | SceneObjectGroup sceneObject = new SceneObjectGroup(); |
68 | 68 | ||
69 | // libomv.types changes UUID to Guid | 69 | // libomv.types changes UUID to Guid |
70 | serialization = serialization.Replace("<UUID>", "<Guid>"); | 70 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); |
71 | serialization = serialization.Replace("</UUID>", "</Guid>"); | 71 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); |
72 | 72 | ||
73 | // Handle Nested <UUID><UUID> property | 73 | // Handle Nested <UUID><UUID> property |
74 | serialization = serialization.Replace("<Guid><Guid>", "<UUID><Guid>"); | 74 | xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>"); |
75 | serialization = serialization.Replace("</Guid></Guid>", "</Guid></UUID>"); | 75 | xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>"); |
76 | 76 | ||
77 | try | 77 | try |
78 | { | 78 | { |
@@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
83 | int linkNum; | 83 | int linkNum; |
84 | 84 | ||
85 | doc = new XmlDocument(); | 85 | doc = new XmlDocument(); |
86 | doc.LoadXml(serialization); | 86 | doc.LoadXml(xmlData); |
87 | parts = doc.GetElementsByTagName("RootPart"); | 87 | parts = doc.GetElementsByTagName("RootPart"); |
88 | 88 | ||
89 | if (parts.Count == 0) | 89 | if (parts.Count == 0) |
@@ -122,7 +122,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
122 | catch (Exception e) | 122 | catch (Exception e) |
123 | { | 123 | { |
124 | m_log.ErrorFormat( | 124 | m_log.ErrorFormat( |
125 | "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, serialization); | 125 | "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); |
126 | } | 126 | } |
127 | 127 | ||
128 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | 128 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); |
@@ -131,6 +131,70 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
131 | } | 131 | } |
132 | 132 | ||
133 | /// <summary> | 133 | /// <summary> |
134 | /// Deserialize a scene object from the 'xml2' format | ||
135 | /// </summary> | ||
136 | /// <param name="serialization"></param> | ||
137 | /// <returns></returns> | ||
138 | public static SceneObjectGroup FromXml2Format(string xmlData) | ||
139 | { | ||
140 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | ||
141 | //int time = System.Environment.TickCount; | ||
142 | |||
143 | SceneObjectGroup sceneObject = new SceneObjectGroup(); | ||
144 | |||
145 | // libomv.types changes UUID to Guid | ||
146 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); | ||
147 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); | ||
148 | |||
149 | // Handle Nested <UUID><UUID> property | ||
150 | xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>"); | ||
151 | xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>"); | ||
152 | |||
153 | try | ||
154 | { | ||
155 | XmlDocument doc = new XmlDocument(); | ||
156 | doc.LoadXml(xmlData); | ||
157 | |||
158 | XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart"); | ||
159 | |||
160 | // Process the root part first | ||
161 | if (parts.Count > 0) | ||
162 | { | ||
163 | StringReader sr = new StringReader(parts[0].OuterXml); | ||
164 | XmlTextReader reader = new XmlTextReader(sr); | ||
165 | sceneObject.SetRootPart(SceneObjectPart.FromXml(reader)); | ||
166 | reader.Close(); | ||
167 | sr.Close(); | ||
168 | } | ||
169 | |||
170 | // Then deal with the rest | ||
171 | for (int i = 1; i < parts.Count; i++) | ||
172 | { | ||
173 | StringReader sr = new StringReader(parts[i].OuterXml); | ||
174 | XmlTextReader reader = new XmlTextReader(sr); | ||
175 | SceneObjectPart part = SceneObjectPart.FromXml(reader); | ||
176 | sceneObject.AddPart(part); | ||
177 | part.StoreUndoState(); | ||
178 | reader.Close(); | ||
179 | sr.Close(); | ||
180 | } | ||
181 | |||
182 | // Script state may, or may not, exist. Not having any, is NOT | ||
183 | // ever a problem. | ||
184 | |||
185 | sceneObject.LoadScriptState(doc); | ||
186 | } | ||
187 | catch (Exception e) | ||
188 | { | ||
189 | m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); | ||
190 | } | ||
191 | |||
192 | //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | ||
193 | |||
194 | return sceneObject; | ||
195 | } | ||
196 | |||
197 | /// <summary> | ||
134 | /// Serialize a scene object to the original xml format | 198 | /// Serialize a scene object to the original xml format |
135 | /// </summary> | 199 | /// </summary> |
136 | /// <param name="sceneObject"></param> | 200 | /// <param name="sceneObject"></param> |