mirror of
https://github.com/opensim/opensim.git
synced 2026-07-31 22:05:36 +08:00
Merge branch 'master' into careminster
This commit is contained in:
@@ -1328,6 +1328,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
}
|
||||
}
|
||||
|
||||
string map = String.Empty;
|
||||
|
||||
if (File.Exists(fn + ".map"))
|
||||
{
|
||||
FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read);
|
||||
StreamReader msr = new StreamReader(mfs);
|
||||
|
||||
map = msr.ReadToEnd();
|
||||
|
||||
msr.Close();
|
||||
mfs.Close();
|
||||
}
|
||||
|
||||
XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
|
||||
XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
|
||||
|
||||
@@ -1338,21 +1351,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
|
||||
stateData.AppendChild(assemblyData);
|
||||
|
||||
XmlElement mapData = doc.CreateElement("", "LineMap", "");
|
||||
XmlAttribute mapName = doc.CreateAttribute("", "Filename", "");
|
||||
|
||||
mapName.Value = fn + ".map";
|
||||
mapData.Attributes.Append(mapName);
|
||||
|
||||
mapData.InnerText = map;
|
||||
|
||||
stateData.AppendChild(mapData);
|
||||
return doc.InnerXml;
|
||||
}
|
||||
|
||||
public bool CanBeDeleted(UUID itemID)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance == null)
|
||||
return true;
|
||||
|
||||
return instance.CanBeDeleted();
|
||||
}
|
||||
|
||||
private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetXMLState(UUID itemID, string xml)
|
||||
{
|
||||
if (xml == String.Empty)
|
||||
return;
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
doc.LoadXml(xml);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
m_log.Error("[XEngine]: Exception decoding XML data from region transfer");
|
||||
return;
|
||||
}
|
||||
|
||||
XmlNodeList rootL = doc.GetElementsByTagName("State");
|
||||
if (rootL.Count < 1)
|
||||
return;
|
||||
|
||||
XmlElement rootE = (XmlElement)rootL[0];
|
||||
|
||||
if (rootE.GetAttribute("UUID") != itemID.ToString())
|
||||
return;
|
||||
|
||||
string assetID = rootE.GetAttribute("Asset");
|
||||
|
||||
XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
|
||||
|
||||
if (stateL.Count != 1)
|
||||
return;
|
||||
|
||||
XmlElement stateE = (XmlElement)stateL[0];
|
||||
|
||||
if (World.m_trustBinaries)
|
||||
{
|
||||
XmlNodeList assemL = rootE.GetElementsByTagName("Assembly");
|
||||
|
||||
if (assemL.Count != 1)
|
||||
return;
|
||||
|
||||
XmlElement assemE = (XmlElement)assemL[0];
|
||||
|
||||
string fn = assemE.GetAttribute("Filename");
|
||||
string base64 = assemE.InnerText;
|
||||
|
||||
string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
|
||||
path = Path.Combine(path, fn);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Byte[] filedata = Convert.FromBase64String(base64);
|
||||
|
||||
FileStream fs = File.Create(path);
|
||||
fs.Write(filedata, 0, filedata.Length);
|
||||
fs.Close();
|
||||
|
||||
fs = File.Create(path + ".text");
|
||||
StreamWriter sw = new StreamWriter(fs);
|
||||
|
||||
sw.Write(base64);
|
||||
|
||||
sw.Close();
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
|
||||
string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
|
||||
statepath = Path.Combine(statepath, itemID.ToString() + ".state");
|
||||
|
||||
FileStream sfs = File.Create(statepath);
|
||||
StreamWriter ssw = new StreamWriter(sfs);
|
||||
|
||||
ssw.Write(stateE.OuterXml);
|
||||
|
||||
ssw.Close();
|
||||
sfs.Close();
|
||||
|
||||
XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
|
||||
|
||||
XmlElement mapE = (XmlElement)mapL[0];
|
||||
|
||||
string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
|
||||
mappath = Path.Combine(mappath, mapE.GetAttribute("Filename"));
|
||||
|
||||
FileStream mfs = File.Create(mappath);
|
||||
StreamWriter msw = new StreamWriter(mfs);
|
||||
|
||||
msw.Write(mapE.InnerText);
|
||||
|
||||
msw.Close();
|
||||
mfs.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user