aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Serialization
diff options
context:
space:
mode:
authorJohn Hurliman2009-09-16 15:06:08 -0700
committerJohn Hurliman2009-09-16 15:06:08 -0700
commitf42d085ab17098709bcba0c816c9742a213d3c01 (patch)
treecdf3af0cf5e65ad949f07afc80d28a29954bfa42 /OpenSim/Region/Framework/Scenes/Serialization
parentAdd the Null storage implementation for the RegionData service. Standalones (diff)
downloadopensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.zip
opensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.tar.gz
opensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.tar.bz2
opensim-SC_OLD-f42d085ab17098709bcba0c816c9742a213d3c01.tar.xz
SceneObjectGroup cleanup. Removes the default constructor and unnecessary null checks on m_rootPart
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization')
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs53
1 files changed, 22 insertions, 31 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 5ae81cd..fe74158 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -65,8 +65,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
65 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 65 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
66 //int time = System.Environment.TickCount; 66 //int time = System.Environment.TickCount;
67 67
68 SceneObjectGroup sceneObject = new SceneObjectGroup();
69
70 // libomv.types changes UUID to Guid 68 // libomv.types changes UUID to Guid
71 xmlData = xmlData.Replace("<UUID>", "<Guid>"); 69 xmlData = xmlData.Replace("<UUID>", "<Guid>");
72 xmlData = xmlData.Replace("</UUID>", "</Guid>"); 70 xmlData = xmlData.Replace("</UUID>", "</Guid>");
@@ -88,17 +86,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
88 parts = doc.GetElementsByTagName("RootPart"); 86 parts = doc.GetElementsByTagName("RootPart");
89 87
90 if (parts.Count == 0) 88 if (parts.Count == 0)
91 {
92 throw new Exception("Invalid Xml format - no root part"); 89 throw new Exception("Invalid Xml format - no root part");
93 } 90
94 else 91 sr = new StringReader(parts[0].InnerXml);
95 { 92 reader = new XmlTextReader(sr);
96 sr = new StringReader(parts[0].InnerXml); 93 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(fromUserInventoryItemID, reader));
97 reader = new XmlTextReader(sr); 94 reader.Close();
98 sceneObject.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); 95 sr.Close();
99 reader.Close();
100 sr.Close();
101 }
102 96
103 parts = doc.GetElementsByTagName("Part"); 97 parts = doc.GetElementsByTagName("Part");
104 98
@@ -119,16 +113,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
119 // Script state may, or may not, exist. Not having any, is NOT 113 // Script state may, or may not, exist. Not having any, is NOT
120 // ever a problem. 114 // ever a problem.
121 sceneObject.LoadScriptState(doc); 115 sceneObject.LoadScriptState(doc);
116
117 return sceneObject;
122 } 118 }
123 catch (Exception e) 119 catch (Exception e)
124 { 120 {
125 m_log.ErrorFormat( 121 m_log.ErrorFormat(
126 "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); 122 "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
123 return null;
127 } 124 }
128
129 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
130
131 return sceneObject;
132 } 125 }
133 126
134 /// <summary> 127 /// <summary>
@@ -194,8 +187,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
194 { 187 {
195 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 188 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
196 //int time = System.Environment.TickCount; 189 //int time = System.Environment.TickCount;
197
198 SceneObjectGroup sceneObject = new SceneObjectGroup();
199 190
200 // libomv.types changes UUID to Guid 191 // libomv.types changes UUID to Guid
201 xmlData = xmlData.Replace("<UUID>", "<Guid>"); 192 xmlData = xmlData.Replace("<UUID>", "<Guid>");
@@ -212,21 +203,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
212 203
213 XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart"); 204 XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart");
214 205
215 // Process the root part first 206 if (parts.Count == 0)
216 if (parts.Count > 0)
217 { 207 {
218 StringReader sr = new StringReader(parts[0].OuterXml); 208 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes. xml was " + xmlData);
219 XmlTextReader reader = new XmlTextReader(sr); 209 return null;
220 sceneObject.SetRootPart(SceneObjectPart.FromXml(reader));
221 reader.Close();
222 sr.Close();
223 } 210 }
224 211
212 StringReader sr = new StringReader(parts[0].OuterXml);
213 XmlTextReader reader = new XmlTextReader(sr);
214 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
215 reader.Close();
216 sr.Close();
217
225 // Then deal with the rest 218 // Then deal with the rest
226 for (int i = 1; i < parts.Count; i++) 219 for (int i = 1; i < parts.Count; i++)
227 { 220 {
228 StringReader sr = new StringReader(parts[i].OuterXml); 221 sr = new StringReader(parts[i].OuterXml);
229 XmlTextReader reader = new XmlTextReader(sr); 222 reader = new XmlTextReader(sr);
230 SceneObjectPart part = SceneObjectPart.FromXml(reader); 223 SceneObjectPart part = SceneObjectPart.FromXml(reader);
231 sceneObject.AddPart(part); 224 sceneObject.AddPart(part);
232 part.StoreUndoState(); 225 part.StoreUndoState();
@@ -238,15 +231,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
238 // ever a problem. 231 // ever a problem.
239 232
240 sceneObject.LoadScriptState(doc); 233 sceneObject.LoadScriptState(doc);
234 return sceneObject;
241 } 235 }
242 catch (Exception e) 236 catch (Exception e)
243 { 237 {
244 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); 238 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
239 return null;
245 } 240 }
246
247 //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
248
249 return sceneObject;
250 } 241 }
251 242
252 /// <summary> 243 /// <summary>