aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs53
1 files changed, 27 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index d6e8223..11dad6c 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -53,19 +53,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
53 /// <summary> 53 /// <summary>
54 /// Deserialize a scene object from the original xml format 54 /// Deserialize a scene object from the original xml format
55 /// </summary> 55 /// </summary>
56 /// <param name="serialization"></param> 56 /// <param name="xmlData"></param>
57 /// <returns></returns> 57 /// <returns></returns>
58 public static SceneObjectGroup FromOriginalXmlFormat(string serialization) 58 public static SceneObjectGroup FromOriginalXmlFormat(string xmlData)
59 {
60 return FromOriginalXmlFormat(UUID.Zero, serialization);
61 }
62
63 /// <summary>
64 /// Deserialize a scene object from the original xml format
65 /// </summary>
66 /// <param name="serialization"></param>
67 /// <returns></returns>
68 public static SceneObjectGroup FromOriginalXmlFormat(UUID fromUserInventoryItemID, string xmlData)
69 { 59 {
70 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 60 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
71 //int time = System.Environment.TickCount; 61 //int time = System.Environment.TickCount;
@@ -87,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
87 77
88 sr = new StringReader(parts[0].InnerXml); 78 sr = new StringReader(parts[0].InnerXml);
89 reader = new XmlTextReader(sr); 79 reader = new XmlTextReader(sr);
90 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); 80 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
91 reader.Close(); 81 reader.Close();
92 sr.Close(); 82 sr.Close();
93 83
@@ -102,7 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
102 sceneObject.AddPart(part); 92 sceneObject.AddPart(part);
103 part.LinkNum = linkNum; 93 part.LinkNum = linkNum;
104 part.TrimPermissions(); 94 part.TrimPermissions();
105 part.StoreUndoState(UndoType.STATE_ALL);
106 reader.Close(); 95 reader.Close();
107 sr.Close(); 96 sr.Close();
108 } 97 }
@@ -128,26 +117,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
128 /// <returns></returns> 117 /// <returns></returns>
129 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) 118 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject)
130 { 119 {
120 return ToOriginalXmlFormat(sceneObject, true);
121 }
122
123 /// <summary>
124 /// Serialize a scene object to the original xml format
125 /// </summary>
126 /// <param name="sceneObject"></param>
127 /// <param name="doScriptStates">Control whether script states are also serialized.</para>
128 /// <returns></returns>
129 public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, bool doScriptStates)
130 {
131 using (StringWriter sw = new StringWriter()) 131 using (StringWriter sw = new StringWriter())
132 { 132 {
133 using (XmlTextWriter writer = new XmlTextWriter(sw)) 133 using (XmlTextWriter writer = new XmlTextWriter(sw))
134 { 134 {
135 ToOriginalXmlFormat(sceneObject, writer); 135 ToOriginalXmlFormat(sceneObject, writer, doScriptStates);
136 } 136 }
137 137
138 return sw.ToString(); 138 return sw.ToString();
139 } 139 }
140 } 140 }
141
142 141
143 /// <summary> 142 /// <summary>
144 /// Serialize a scene object to the original xml format 143 /// Serialize a scene object to the original xml format
145 /// </summary> 144 /// </summary>
146 /// <param name="sceneObject"></param> 145 /// <param name="sceneObject"></param>
147 /// <returns></returns> 146 /// <returns></returns>
148 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) 147 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates)
149 { 148 {
150 ToOriginalXmlFormat(sceneObject, writer, false); 149 ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false);
151 } 150 }
152 151
153 /// <summary> 152 /// <summary>
@@ -157,10 +156,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
157 /// <param name="writer"></param> 156 /// <param name="writer"></param>
158 /// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param> 157 /// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param>
159 /// <returns></returns> 158 /// <returns></returns>
160 public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool noRootElement) 159 public static void ToOriginalXmlFormat(
160 SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates, bool noRootElement)
161 { 161 {
162 //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); 162// m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", sceneObject.Name);
163 //int time = System.Environment.TickCount; 163// int time = System.Environment.TickCount;
164 164
165 if (!noRootElement) 165 if (!noRootElement)
166 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); 166 writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
@@ -183,12 +183,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
183 } 183 }
184 184
185 writer.WriteEndElement(); // OtherParts 185 writer.WriteEndElement(); // OtherParts
186 sceneObject.SaveScriptedState(writer); 186
187 if (doScriptStates)
188 sceneObject.SaveScriptedState(writer);
187 189
188 if (!noRootElement) 190 if (!noRootElement)
189 writer.WriteEndElement(); // SceneObjectGroup 191 writer.WriteEndElement(); // SceneObjectGroup
190 192
191 //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); 193// m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", sceneObject.Name, System.Environment.TickCount - time);
192 } 194 }
193 195
194 protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) 196 protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer)
@@ -236,15 +238,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
236 if (originalLinkNum != 0) 238 if (originalLinkNum != 0)
237 part.LinkNum = originalLinkNum; 239 part.LinkNum = originalLinkNum;
238 240
239 part.StoreUndoState(UndoType.STATE_ALL);
240 reader.Close(); 241 reader.Close();
241 sr.Close(); 242 sr.Close();
242 } 243 }
243 244
244 // Script state may, or may not, exist. Not having any, is NOT 245 // Script state may, or may not, exist. Not having any, is NOT
245 // ever a problem. 246 // ever a problem.
246
247 sceneObject.LoadScriptState(doc); 247 sceneObject.LoadScriptState(doc);
248
248 return sceneObject; 249 return sceneObject;
249 } 250 }
250 catch (Exception e) 251 catch (Exception e)
@@ -1592,4 +1593,4 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1592 1593
1593 #endregion 1594 #endregion
1594 } 1595 }
1595} 1596} \ No newline at end of file