aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2009-12-21 10:28:50 +0000
committerMelanie2009-12-21 10:28:50 +0000
commitdf30b1c832998ffbf3ed69f4a0977019fa13110d (patch)
tree7b78760e1df906b1a4d5a84d8299d6710a0ca3fa /OpenSim/Region
parentMerge branch 'master' into careminster (diff)
parentScript State Fix: Part 2 (diff)
downloadopensim-SC_OLD-df30b1c832998ffbf3ed69f4a0977019fa13110d.zip
opensim-SC_OLD-df30b1c832998ffbf3ed69f4a0977019fa13110d.tar.gz
opensim-SC_OLD-df30b1c832998ffbf3ed69f4a0977019fa13110d.tar.bz2
opensim-SC_OLD-df30b1c832998ffbf3ed69f4a0977019fa13110d.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs55
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs47
3 files changed, 78 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index f11e571..98efcbe 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
35 string ScriptEngineName { get; } 35 string ScriptEngineName { get; }
36 36
37 string GetXMLState(UUID itemID); 37 string GetXMLState(UUID itemID);
38 void SetXMLState(UUID itemID, string xml); 38 bool SetXMLState(UUID itemID, string xml);
39 39
40 bool PostScriptEvent(UUID itemID, string name, Object[] args); 40 bool PostScriptEvent(UUID itemID, string name, Object[] args);
41 bool PostObjectEvent(UUID itemID, string name, Object[] args); 41 bool PostObjectEvent(UUID itemID, string name, Object[] args);
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
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 184af19..2a9a2db 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1348,6 +1348,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1348 XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); 1348 XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
1349 assetID.Value = instance.AssetID.ToString(); 1349 assetID.Value = instance.AssetID.ToString();
1350 stateData.Attributes.Append(assetID); 1350 stateData.Attributes.Append(assetID);
1351 XmlAttribute engineName = doc.CreateAttribute("", "Engine", "");
1352 engineName.Value = ScriptEngineName;
1353 stateData.Attributes.Append(engineName);
1351 doc.AppendChild(stateData); 1354 doc.AppendChild(stateData);
1352 1355
1353 // Add <ScriptState>...</ScriptState> 1356 // Add <ScriptState>...</ScriptState>
@@ -1447,10 +1450,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1447 return false; 1450 return false;
1448 } 1451 }
1449 1452
1450 public void SetXMLState(UUID itemID, string xml) 1453 public bool SetXMLState(UUID itemID, string xml)
1451 { 1454 {
1452 if (xml == String.Empty) 1455 if (xml == String.Empty)
1453 return; 1456 return false;
1454 1457
1455 XmlDocument doc = new XmlDocument(); 1458 XmlDocument doc = new XmlDocument();
1456 1459
@@ -1461,24 +1464,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1461 catch (Exception) 1464 catch (Exception)
1462 { 1465 {
1463 m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); 1466 m_log.Error("[XEngine]: Exception decoding XML data from region transfer");
1464 return; 1467 return false;
1465 } 1468 }
1466 1469
1467 XmlNodeList rootL = doc.GetElementsByTagName("State"); 1470 XmlNodeList rootL = doc.GetElementsByTagName("State");
1468 if (rootL.Count < 1) 1471 if (rootL.Count < 1)
1469 return; 1472 return false;
1470 1473
1471 XmlElement rootE = (XmlElement)rootL[0]; 1474 XmlElement rootE = (XmlElement)rootL[0];
1472 1475
1473 if (rootE.GetAttribute("UUID") != itemID.ToString()) 1476 if (rootE.GetAttribute("Engine") != ScriptEngineName)
1474 return; 1477 return false;
1475 1478
1476// string assetID = rootE.GetAttribute("Asset"); 1479// On rez from inventory, that ID will have changed. It was only
1480// advisory anyway. So we don't check it anymore.
1481//
1482// if (rootE.GetAttribute("UUID") != itemID.ToString())
1483// return;
1477 1484
1478 XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); 1485 XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
1479 1486
1480 if (stateL.Count != 1) 1487 if (stateL.Count != 1)
1481 return; 1488 return false;
1482 1489
1483 XmlElement stateE = (XmlElement)stateL[0]; 1490 XmlElement stateE = (XmlElement)stateL[0];
1484 1491
@@ -1487,7 +1494,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1487 XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); 1494 XmlNodeList assemL = rootE.GetElementsByTagName("Assembly");
1488 1495
1489 if (assemL.Count != 1) 1496 if (assemL.Count != 1)
1490 return; 1497 return false;
1491 1498
1492 XmlElement assemE = (XmlElement)assemL[0]; 1499 XmlElement assemE = (XmlElement)assemL[0];
1493 1500
@@ -1527,19 +1534,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1527 sfs.Close(); 1534 sfs.Close();
1528 1535
1529 XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); 1536 XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
1530 1537 if (mapL.Count > 0)
1531 XmlElement mapE = (XmlElement)mapL[0]; 1538 {
1539 XmlElement mapE = (XmlElement)mapL[0];
1532 1540
1533 string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); 1541 string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
1534 mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); 1542 mappath = Path.Combine(mappath, mapE.GetAttribute("Filename"));
1535 1543
1536 FileStream mfs = File.Create(mappath); 1544 FileStream mfs = File.Create(mappath);
1537 StreamWriter msw = new StreamWriter(mfs); 1545 StreamWriter msw = new StreamWriter(mfs);
1538 1546
1539 msw.Write(mapE.InnerText); 1547 msw.Write(mapE.InnerText);
1540 1548
1541 msw.Close(); 1549 msw.Close();
1542 mfs.Close(); 1550 mfs.Close();
1551 }
1552
1553 return true;
1543 } 1554 }
1544 } 1555 }
1545} 1556}