diff options
author | Diva Canto | 2010-10-17 10:35:38 -0700 |
---|---|---|
committer | Diva Canto | 2010-10-17 10:35:38 -0700 |
commit | 22eff055d4c03d2bb0bd44f4259a280761d90715 (patch) | |
tree | 393cf829e3c3ec3c5a8b2ff4f88b60e6595955b7 /OpenSim/Region/Framework/Scenes/Serialization | |
parent | Drop max oar loading version back to 0 from 1 (diff) | |
download | opensim-SC_OLD-22eff055d4c03d2bb0bd44f4259a280761d90715.zip opensim-SC_OLD-22eff055d4c03d2bb0bd44f4259a280761d90715.tar.gz opensim-SC_OLD-22eff055d4c03d2bb0bd44f4259a280761d90715.tar.bz2 opensim-SC_OLD-22eff055d4c03d2bb0bd44f4259a280761d90715.tar.xz |
.NET automagical serialization of SOPs replaced by manual serialization across the board.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 65 |
1 files changed, 15 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9a00bea..4897cd6 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -67,14 +67,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
67 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | 67 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); |
68 | //int time = System.Environment.TickCount; | 68 | //int time = System.Environment.TickCount; |
69 | 69 | ||
70 | // libomv.types changes UUID to Guid | ||
71 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); | ||
72 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); | ||
73 | |||
74 | // Handle Nested <UUID><UUID> property | ||
75 | xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>"); | ||
76 | xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>"); | ||
77 | |||
78 | try | 70 | try |
79 | { | 71 | { |
80 | StringReader sr; | 72 | StringReader sr; |
@@ -126,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
126 | } | 118 | } |
127 | } | 119 | } |
128 | 120 | ||
121 | |||
129 | /// <summary> | 122 | /// <summary> |
130 | /// Serialize a scene object to the original xml format | 123 | /// Serialize a scene object to the original xml format |
131 | /// </summary> | 124 | /// </summary> |
@@ -181,7 +174,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
181 | 174 | ||
182 | protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) | 175 | protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) |
183 | { | 176 | { |
184 | part.ToXml(writer); | 177 | SOPToXml2(writer, part, new Dictionary<string, object>()); |
185 | } | 178 | } |
186 | 179 | ||
187 | public static SceneObjectGroup FromXml2Format(string xmlData) | 180 | public static SceneObjectGroup FromXml2Format(string xmlData) |
@@ -189,14 +182,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
189 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); | 182 | //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); |
190 | //int time = System.Environment.TickCount; | 183 | //int time = System.Environment.TickCount; |
191 | 184 | ||
192 | // libomv.types changes UUID to Guid | ||
193 | xmlData = xmlData.Replace("<UUID>", "<Guid>"); | ||
194 | xmlData = xmlData.Replace("</UUID>", "</Guid>"); | ||
195 | |||
196 | // Handle Nested <UUID><UUID> property | ||
197 | xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>"); | ||
198 | xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>"); | ||
199 | |||
200 | try | 185 | try |
201 | { | 186 | { |
202 | XmlDocument doc = new XmlDocument(); | 187 | XmlDocument doc = new XmlDocument(); |
@@ -261,41 +246,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
261 | { | 246 | { |
262 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | 247 | using (XmlTextWriter writer = new XmlTextWriter(sw)) |
263 | { | 248 | { |
264 | ToXml2Format(sceneObject, writer); | 249 | SOGToXml2(writer, sceneObject, new Dictionary<string,object>()); |
265 | } | 250 | } |
266 | 251 | ||
267 | return sw.ToString(); | 252 | return sw.ToString(); |
268 | } | 253 | } |
269 | } | 254 | } |
270 | 255 | ||
271 | /// <summary> | ||
272 | /// Serialize a scene object to the 'xml2' format. | ||
273 | /// </summary> | ||
274 | /// <param name="sceneObject"></param> | ||
275 | /// <returns></returns> | ||
276 | public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) | ||
277 | { | ||
278 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); | ||
279 | //int time = System.Environment.TickCount; | ||
280 | |||
281 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
282 | sceneObject.RootPart.ToXml(writer); | ||
283 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | ||
284 | |||
285 | SceneObjectPart[] parts = sceneObject.Parts; | ||
286 | for (int i = 0; i < parts.Length; i++) | ||
287 | { | ||
288 | SceneObjectPart part = parts[i]; | ||
289 | if (part.UUID != sceneObject.RootPart.UUID) | ||
290 | part.ToXml(writer); | ||
291 | } | ||
292 | |||
293 | writer.WriteEndElement(); // End of OtherParts | ||
294 | sceneObject.SaveScriptedState(writer); | ||
295 | writer.WriteEndElement(); // End of SceneObjectGroup | ||
296 | |||
297 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); | ||
298 | } | ||
299 | 256 | ||
300 | #region manual serialization | 257 | #region manual serialization |
301 | 258 | ||
@@ -386,6 +343,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
386 | m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter); | 343 | m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter); |
387 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 344 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
388 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 345 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
346 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | ||
347 | |||
389 | #endregion | 348 | #endregion |
390 | 349 | ||
391 | #region ShapeXmlProcessors initialization | 350 | #region ShapeXmlProcessors initialization |
@@ -817,6 +776,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
817 | item.Type = reader.ReadElementContentAsInt("Type", String.Empty); | 776 | item.Type = reader.ReadElementContentAsInt("Type", String.Empty); |
818 | } | 777 | } |
819 | 778 | ||
779 | private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader) | ||
780 | { | ||
781 | item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty); | ||
782 | } | ||
783 | |||
820 | #endregion | 784 | #endregion |
821 | 785 | ||
822 | #region ShapeXmlProcessors | 786 | #region ShapeXmlProcessors |
@@ -1078,20 +1042,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1078 | public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options) | 1042 | public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options) |
1079 | { | 1043 | { |
1080 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 1044 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); |
1081 | SOPToXml2(writer, sog.RootPart, null, options); | 1045 | SOPToXml2(writer, sog.RootPart, options); |
1082 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | 1046 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); |
1083 | 1047 | ||
1084 | sog.ForEachPart(delegate(SceneObjectPart sop) | 1048 | sog.ForEachPart(delegate(SceneObjectPart sop) |
1085 | { | 1049 | { |
1086 | if (sop.UUID != sog.RootPart.UUID) | 1050 | if (sop.UUID != sog.RootPart.UUID) |
1087 | SOPToXml2(writer, sop, sog.RootPart, options); | 1051 | SOPToXml2(writer, sop, options); |
1088 | }); | 1052 | }); |
1089 | 1053 | ||
1090 | writer.WriteEndElement(); | 1054 | writer.WriteEndElement(); |
1091 | writer.WriteEndElement(); | 1055 | writer.WriteEndElement(); |
1092 | } | 1056 | } |
1093 | 1057 | ||
1094 | static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent, Dictionary<string, object> options) | 1058 | public static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary<string, object> options) |
1095 | { | 1059 | { |
1096 | writer.WriteStartElement("SceneObjectPart"); | 1060 | writer.WriteStartElement("SceneObjectPart"); |
1097 | writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); | 1061 | writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
@@ -1229,6 +1193,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1229 | WriteUUID(writer, "PermsGranter", item.PermsGranter, options); | 1193 | WriteUUID(writer, "PermsGranter", item.PermsGranter, options); |
1230 | writer.WriteElementString("PermsMask", item.PermsMask.ToString()); | 1194 | writer.WriteElementString("PermsMask", item.PermsMask.ToString()); |
1231 | writer.WriteElementString("Type", item.Type.ToString()); | 1195 | writer.WriteElementString("Type", item.Type.ToString()); |
1196 | writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower()); | ||
1232 | 1197 | ||
1233 | writer.WriteEndElement(); // TaskInventoryItem | 1198 | writer.WriteEndElement(); // TaskInventoryItem |
1234 | } | 1199 | } |
@@ -1398,7 +1363,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1398 | } | 1363 | } |
1399 | else | 1364 | else |
1400 | { | 1365 | { |
1401 | //m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); | 1366 | m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); |
1402 | reader.ReadOuterXml(); // ignore | 1367 | reader.ReadOuterXml(); // ignore |
1403 | } | 1368 | } |
1404 | 1369 | ||