Merge branch 'master' into careminster
commit
df30b1c832
|
@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
string ScriptEngineName { get; }
|
string ScriptEngineName { get; }
|
||||||
|
|
||||||
string GetXMLState(UUID itemID);
|
string GetXMLState(UUID itemID);
|
||||||
void SetXMLState(UUID itemID, string xml);
|
bool SetXMLState(UUID itemID, string xml);
|
||||||
|
|
||||||
bool PostScriptEvent(UUID itemID, string name, Object[] args);
|
bool PostScriptEvent(UUID itemID, string name, Object[] args);
|
||||||
bool PostObjectEvent(UUID itemID, string name, Object[] args);
|
bool PostObjectEvent(UUID itemID, string name, Object[] args);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Xml;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -295,15 +296,55 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private void RestoreSavedScriptState(UUID oldID, UUID newID)
|
private void RestoreSavedScriptState(UUID oldID, UUID newID)
|
||||||
{
|
{
|
||||||
|
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||||
|
if (engines == null) // No engine at all
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
|
if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
|
||||||
{
|
{
|
||||||
string fpath = Path.Combine("ScriptEngines/"+m_part.ParentGroup.Scene.RegionInfo.RegionID.ToString(),
|
XmlDocument doc = new XmlDocument();
|
||||||
newID.ToString()+".state");
|
|
||||||
FileStream fs = File.Create(fpath);
|
doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]);
|
||||||
Byte[] buffer = enc.GetBytes(m_part.ParentGroup.m_savedScriptState[oldID]);
|
|
||||||
fs.Write(buffer,0,buffer.Length);
|
////////// CRUFT WARNING ///////////////////////////////////
|
||||||
fs.Close();
|
//
|
||||||
m_part.ParentGroup.m_savedScriptState.Remove(oldID);
|
// Old objects will have <ScriptState><State> ...
|
||||||
|
// This format is XEngine ONLY
|
||||||
|
//
|
||||||
|
// New objects have <State Engine="...." ...><ScriptState>...
|
||||||
|
// This can be passed to any engine
|
||||||
|
//
|
||||||
|
XmlNode n = doc.SelectSingleNode("ScriptState");
|
||||||
|
if (n != null) // Old format data
|
||||||
|
{
|
||||||
|
XmlDocument newDoc = new XmlDocument();
|
||||||
|
|
||||||
|
XmlElement rootN = newDoc.CreateElement("", "State", "");
|
||||||
|
XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", "");
|
||||||
|
uuidA.Value = oldID.ToString();
|
||||||
|
rootN.Attributes.Append(uuidA);
|
||||||
|
XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", "");
|
||||||
|
engineA.Value = "XEngine";
|
||||||
|
rootN.Attributes.Append(engineA);
|
||||||
|
|
||||||
|
newDoc.AppendChild(rootN);
|
||||||
|
|
||||||
|
XmlNode stateN = newDoc.ImportNode(n, true);
|
||||||
|
rootN.AppendChild(stateN);
|
||||||
|
|
||||||
|
// This created document has only the minimun data
|
||||||
|
// necessary for XEngine to parse it successfully
|
||||||
|
|
||||||
|
m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml;
|
||||||
|
}
|
||||||
|
foreach (IScriptModule e in engines)
|
||||||
|
{
|
||||||
|
if (e != null)
|
||||||
|
{
|
||||||
|
if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1348,6 +1348,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
|
XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
|
||||||
assetID.Value = instance.AssetID.ToString();
|
assetID.Value = instance.AssetID.ToString();
|
||||||
stateData.Attributes.Append(assetID);
|
stateData.Attributes.Append(assetID);
|
||||||
|
XmlAttribute engineName = doc.CreateAttribute("", "Engine", "");
|
||||||
|
engineName.Value = ScriptEngineName;
|
||||||
|
stateData.Attributes.Append(engineName);
|
||||||
doc.AppendChild(stateData);
|
doc.AppendChild(stateData);
|
||||||
|
|
||||||
// Add <ScriptState>...</ScriptState>
|
// Add <ScriptState>...</ScriptState>
|
||||||
|
@ -1447,10 +1450,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetXMLState(UUID itemID, string xml)
|
public bool SetXMLState(UUID itemID, string xml)
|
||||||
{
|
{
|
||||||
if (xml == String.Empty)
|
if (xml == String.Empty)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
|
|
||||||
|
@ -1461,24 +1464,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
m_log.Error("[XEngine]: Exception decoding XML data from region transfer");
|
m_log.Error("[XEngine]: Exception decoding XML data from region transfer");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNodeList rootL = doc.GetElementsByTagName("State");
|
XmlNodeList rootL = doc.GetElementsByTagName("State");
|
||||||
if (rootL.Count < 1)
|
if (rootL.Count < 1)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
XmlElement rootE = (XmlElement)rootL[0];
|
XmlElement rootE = (XmlElement)rootL[0];
|
||||||
|
|
||||||
if (rootE.GetAttribute("UUID") != itemID.ToString())
|
if (rootE.GetAttribute("Engine") != ScriptEngineName)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// string assetID = rootE.GetAttribute("Asset");
|
// On rez from inventory, that ID will have changed. It was only
|
||||||
|
// advisory anyway. So we don't check it anymore.
|
||||||
|
//
|
||||||
|
// if (rootE.GetAttribute("UUID") != itemID.ToString())
|
||||||
|
// return;
|
||||||
|
|
||||||
XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
|
XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
|
||||||
|
|
||||||
if (stateL.Count != 1)
|
if (stateL.Count != 1)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
XmlElement stateE = (XmlElement)stateL[0];
|
XmlElement stateE = (XmlElement)stateL[0];
|
||||||
|
|
||||||
|
@ -1487,7 +1494,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
XmlNodeList assemL = rootE.GetElementsByTagName("Assembly");
|
XmlNodeList assemL = rootE.GetElementsByTagName("Assembly");
|
||||||
|
|
||||||
if (assemL.Count != 1)
|
if (assemL.Count != 1)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
XmlElement assemE = (XmlElement)assemL[0];
|
XmlElement assemE = (XmlElement)assemL[0];
|
||||||
|
|
||||||
|
@ -1527,7 +1534,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
sfs.Close();
|
sfs.Close();
|
||||||
|
|
||||||
XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
|
XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
|
||||||
|
if (mapL.Count > 0)
|
||||||
|
{
|
||||||
XmlElement mapE = (XmlElement)mapL[0];
|
XmlElement mapE = (XmlElement)mapL[0];
|
||||||
|
|
||||||
string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
|
string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
|
||||||
|
@ -1541,5 +1549,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
msw.Close();
|
msw.Close();
|
||||||
mfs.Close();
|
mfs.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue