aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs55
1 files changed, 48 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index b57d912..0321c41 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Xml;
29using System.IO; 30using System.IO;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.Reflection; 32using System.Reflection;
@@ -295,15 +296,55 @@ namespace OpenSim.Region.Framework.Scenes
295 296
296 private void RestoreSavedScriptState(UUID oldID, UUID newID) 297 private void RestoreSavedScriptState(UUID oldID, UUID newID)
297 { 298 {
299 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
300 if (engines == null) // No engine at all
301 return;
302
298 if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) 303 if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
299 { 304 {
300 string fpath = Path.Combine("ScriptEngines/"+m_part.ParentGroup.Scene.RegionInfo.RegionID.ToString(), 305 XmlDocument doc = new XmlDocument();
301 newID.ToString()+".state"); 306
302 FileStream fs = File.Create(fpath); 307 doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]);
303 Byte[] buffer = enc.GetBytes(m_part.ParentGroup.m_savedScriptState[oldID]); 308
304 fs.Write(buffer,0,buffer.Length); 309 ////////// CRUFT WARNING ///////////////////////////////////
305 fs.Close(); 310 //
306 m_part.ParentGroup.m_savedScriptState.Remove(oldID); 311 // Old objects will have <ScriptState><State> ...
312 // This format is XEngine ONLY
313 //
314 // New objects have <State Engine="...." ...><ScriptState>...
315 // This can be passed to any engine
316 //
317 XmlNode n = doc.SelectSingleNode("ScriptState");
318 if (n != null) // Old format data
319 {
320 XmlDocument newDoc = new XmlDocument();
321
322 XmlElement rootN = newDoc.CreateElement("", "State", "");
323 XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", "");
324 uuidA.Value = oldID.ToString();
325 rootN.Attributes.Append(uuidA);
326 XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", "");
327 engineA.Value = "XEngine";
328 rootN.Attributes.Append(engineA);
329
330 newDoc.AppendChild(rootN);
331
332 XmlNode stateN = newDoc.ImportNode(n, true);
333 rootN.AppendChild(stateN);
334
335 // This created document has only the minimun data
336 // necessary for XEngine to parse it successfully
337
338 m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml;
339 }
340 foreach (IScriptModule e in engines)
341 {
342 if (e != null)
343 {
344 if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID]))
345 break;
346 }
347 }
307 } 348 }
308 } 349 }
309 350