aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs78
3 files changed, 74 insertions, 82 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index cceb444..fd2d746 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -407,78 +407,6 @@ namespace OpenSim.Region.Framework.Scenes
407 } 407 }
408 408
409 /// <summary> 409 /// <summary>
410 /// Create an object using serialized data in OpenSim's xml2 format.
411 /// </summary>
412 public SceneObjectGroup(string xmlData)
413 {
414 SetFromXml(xmlData);
415 }
416
417 protected void SetFromXml(string xmlData)
418 {
419
420 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
421 //int time = System.Environment.TickCount;
422
423 // libomv.types changes UUID to Guid
424 xmlData = xmlData.Replace("<UUID>", "<Guid>");
425 xmlData = xmlData.Replace("</UUID>", "</Guid>");
426
427 // Handle Nested <UUID><UUID> property
428 xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
429 xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
430
431 try
432 {
433
434 XmlDocument doc = new XmlDocument();
435 doc.LoadXml(xmlData);
436
437 XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart");
438
439 // Process the root part first
440 if (parts.Count > 0)
441 {
442 StringReader sr = new StringReader(parts[0].OuterXml);
443 XmlTextReader reader = new XmlTextReader(sr);
444 SetRootPart(CreatePartFromXml(reader));
445 reader.Close();
446 sr.Close();
447 }
448
449 // Then deal with the rest
450 for (int i=1; i<parts.Count; i++)
451 {
452 StringReader sr = new StringReader(parts[i].OuterXml);
453 XmlTextReader reader = new XmlTextReader(sr);
454 SceneObjectPart part = CreatePartFromXml(reader);
455 AddPart(part);
456 part.StoreUndoState();
457 reader.Close();
458 sr.Close();
459 }
460
461 // Script state may, or may not, exist. Not having any, is NOT
462 // ever a problem.
463
464 LoadScriptState(doc);
465
466 }
467 catch (Exception e)
468 {
469 m_log.ErrorFormat("[SCENE]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
470 }
471
472 //m_log.DebugFormat("[SOG]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
473 }
474
475 protected virtual SceneObjectPart CreatePartFromXml(XmlTextReader reader)
476 {
477 SceneObjectPart part = SceneObjectPart.FromXml(reader);
478 return part;
479 }
480
481 /// <summary>
482 /// Constructor. This object is added to the scene later via AttachToScene() 410 /// Constructor. This object is added to the scene later via AttachToScene()
483 /// </summary> 411 /// </summary>
484 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) 412 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
diff --git a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
index 212ca72..49fe8a4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
@@ -125,14 +125,14 @@ namespace OpenSim.Region.Framework.Scenes
125 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 125 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
126 { 126 {
127 // There is only ever one prim. This oddity should be removeable post 0.5.9 127 // There is only ever one prim. This oddity should be removeable post 0.5.9
128 return new SceneObjectGroup(aPrimNode.OuterXml); 128 return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
129 } 129 }
130 130
131 return null; 131 return null;
132 } 132 }
133 else 133 else
134 { 134 {
135 return new SceneObjectGroup(rootNode.OuterXml); 135 return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
136 } 136 }
137 } 137 }
138 138
@@ -193,7 +193,7 @@ namespace OpenSim.Region.Framework.Scenes
193 /// <returns>The scene object created. null if the scene object already existed</returns> 193 /// <returns>The scene object created. null if the scene object already existed</returns>
194 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData) 194 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
195 { 195 {
196 SceneObjectGroup obj = new SceneObjectGroup(xmlData); 196 SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
197 197
198 if (scene.AddRestoredSceneObject(obj, true, false)) 198 if (scene.AddRestoredSceneObject(obj, true, false))
199 return obj; 199 return obj;
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>