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 | |
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 '')
3 files changed, 28 insertions, 62 deletions
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index bac7827..f10e848 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -303,15 +303,19 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
303 | { | 303 | { |
304 | case "UUID": | 304 | case "UUID": |
305 | xtr.ReadStartElement("UUID"); | 305 | xtr.ReadStartElement("UUID"); |
306 | uuid = UUID.Parse(xtr.ReadElementString("Guid")); | 306 | try |
307 | xtr.ReadEndElement(); | 307 | { |
308 | uuid = UUID.Parse(xtr.ReadElementString("UUID")); | ||
309 | xtr.ReadEndElement(); | ||
310 | } | ||
311 | catch { } // ignore everything but <UUID><UUID>...</UUID></UUID> | ||
308 | break; | 312 | break; |
309 | case "Name": | 313 | case "Name": |
310 | name = xtr.ReadElementContentAsString(); | 314 | name = xtr.ReadElementContentAsString(); |
311 | break; | 315 | break; |
312 | case "CreatorID": | 316 | case "CreatorID": |
313 | xtr.ReadStartElement("CreatorID"); | 317 | xtr.ReadStartElement("CreatorID"); |
314 | creatorId = UUID.Parse(xtr.ReadElementString("Guid")); | 318 | creatorId = UUID.Parse(xtr.ReadElementString("UUID")); |
315 | xtr.ReadEndElement(); | 319 | xtr.ReadEndElement(); |
316 | break; | 320 | break; |
317 | } | 321 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 39b109b..bf4c55c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -39,6 +39,7 @@ using OpenMetaverse.Packets; | |||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes.Scripting; | 41 | using OpenSim.Region.Framework.Scenes.Scripting; |
42 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
42 | using OpenSim.Region.Physics.Manager; | 43 | using OpenSim.Region.Physics.Manager; |
43 | 44 | ||
44 | namespace OpenSim.Region.Framework.Scenes | 45 | namespace OpenSim.Region.Framework.Scenes |
@@ -124,10 +125,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | get { return ParentGroup.RootPart == this; } | 125 | get { return ParentGroup.RootPart == this; } |
125 | } | 126 | } |
126 | 127 | ||
127 | // use only one serializer to give the runtime a chance to optimize it (it won't do that if you | ||
128 | // use a new instance every time) | ||
129 | private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); | ||
130 | |||
131 | #region Fields | 128 | #region Fields |
132 | 129 | ||
133 | public bool AllowedDrop; | 130 | public bool AllowedDrop; |
@@ -1850,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1850 | /// </summary> | 1847 | /// </summary> |
1851 | /// <param name="xmlReader"></param> | 1848 | /// <param name="xmlReader"></param> |
1852 | /// <returns></returns> | 1849 | /// <returns></returns> |
1853 | public static SceneObjectPart FromXml(XmlReader xmlReader) | 1850 | public static SceneObjectPart FromXml(XmlTextReader xmlReader) |
1854 | { | 1851 | { |
1855 | return FromXml(UUID.Zero, xmlReader); | 1852 | return FromXml(UUID.Zero, xmlReader); |
1856 | } | 1853 | } |
@@ -1861,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1861 | /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param> | 1858 | /// <param name="fromUserInventoryItemId">The inventory id from which this part came, if applicable</param> |
1862 | /// <param name="xmlReader"></param> | 1859 | /// <param name="xmlReader"></param> |
1863 | /// <returns></returns> | 1860 | /// <returns></returns> |
1864 | public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) | 1861 | public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlTextReader xmlReader) |
1865 | { | 1862 | { |
1866 | SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); | 1863 | SceneObjectPart part = SceneObjectSerializer.Xml2ToSOP(xmlReader); |
1867 | part.m_fromUserInventoryItemID = fromUserInventoryItemId; | 1864 | part.m_fromUserInventoryItemID = fromUserInventoryItemId; |
1868 | 1865 | ||
1869 | // for tempOnRez objects, we have to fix the Expire date. | 1866 | // for tempOnRez objects, we have to fix the Expire date. |
@@ -4058,9 +4055,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4058 | /// Serialize this part to xml. | 4055 | /// Serialize this part to xml. |
4059 | /// </summary> | 4056 | /// </summary> |
4060 | /// <param name="xmlWriter"></param> | 4057 | /// <param name="xmlWriter"></param> |
4061 | public void ToXml(XmlWriter xmlWriter) | 4058 | public void ToXml(XmlTextWriter xmlWriter) |
4062 | { | 4059 | { |
4063 | serializer.Serialize(xmlWriter, this); | 4060 | SceneObjectSerializer.SOPToXml2(xmlWriter, this, new Dictionary<string, object>()); |
4064 | } | 4061 | } |
4065 | 4062 | ||
4066 | public void TriggerScriptChangedEvent(Changed val) | 4063 | public void TriggerScriptChangedEvent(Changed val) |
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 | ||