aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs83
1 files changed, 80 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 5fa6609..c3485ab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -309,6 +309,8 @@ namespace OpenSim.Region.Framework.Scenes
309 309
310 public string GetStateSnapshot() 310 public string GetStateSnapshot()
311 { 311 {
312 Console.WriteLine(" >>> GetStateSnapshot <<<");
313
312 List<string> assemblies = new List<string>(); 314 List<string> assemblies = new List<string>();
313 Dictionary<UUID, string> states = new Dictionary<UUID, string>(); 315 Dictionary<UUID, string> states = new Dictionary<UUID, string>();
314 316
@@ -358,9 +360,16 @@ namespace OpenSim.Region.Framework.Scenes
358 360
359 Byte[] data = new Byte[fi.Length]; 361 Byte[] data = new Byte[fi.Length];
360 362
361 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); 363 try
362 fs.Read(data, 0, data.Length); 364 {
363 fs.Close(); 365 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
366 fs.Read(data, 0, data.Length);
367 fs.Close();
368 }
369 catch (Exception e)
370 {
371 m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
372 }
364 373
365 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); 374 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
366 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); 375 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
@@ -397,5 +406,73 @@ namespace OpenSim.Region.Framework.Scenes
397 406
398 return xmldoc.InnerXml; 407 return xmldoc.InnerXml;
399 } 408 }
409
410 public void SetState(string objXMLData, UUID RegionID)
411 {
412
413 XmlDocument doc = new XmlDocument();
414 doc.LoadXml(objXMLData);
415
416 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
417 if (rootL.Count == 1)
418 {
419 XmlNode rootNode = rootL[0];
420 if (rootNode != null)
421 {
422 XmlNodeList partL = rootNode.ChildNodes;
423
424 foreach (XmlNode part in partL)
425 {
426 XmlNodeList nodeL = part.ChildNodes;
427
428 switch (part.Name)
429 {
430 case "Assemblies":
431 foreach (XmlNode asm in nodeL)
432 {
433 string fn = asm.Attributes.GetNamedItem("Filename").Value;
434
435 Byte[] filedata = Convert.FromBase64String(asm.InnerText);
436 string path = Path.Combine("ScriptEngines", RegionID.ToString());
437 path = Path.Combine(path, fn);
438
439 if (!File.Exists(path))
440 {
441 FileStream fs = File.Create(path);
442 fs.Write(filedata, 0, filedata.Length);
443 fs.Close();
444 }
445 }
446 break;
447 case "ScriptStates":
448 foreach (XmlNode st in nodeL)
449 {
450 string id = st.Attributes.GetNamedItem("UUID").Value;
451 UUID uuid = new UUID(id);
452 XmlNode state = st.ChildNodes[0];
453
454 XmlDocument sdoc = new XmlDocument();
455 XmlNode sxmlnode = sdoc.CreateNode(
456 XmlNodeType.XmlDeclaration,
457 "", "");
458 sdoc.AppendChild(sxmlnode);
459
460 XmlNode newnode = sdoc.ImportNode(state, true);
461 sdoc.AppendChild(newnode);
462
463 string spath = Path.Combine("ScriptEngines", RegionID.ToString());
464 spath = Path.Combine(spath, uuid.ToString());
465 FileStream sfs = File.Create(spath + ".state");
466 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
467 Byte[] buf = enc.GetBytes(sdoc.InnerXml);
468 sfs.Write(buf, 0, buf.Length);
469 sfs.Close();
470 }
471 break;
472 }
473 }
474 }
475 }
476 }
400 } 477 }
401} 478}