From 9d63f90467dbc60622a49f564a56fdd20de90f51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 17:03:09 +0000 Subject: Remove the old (Remoting) region crossing code. Fix the new code to pass script state and assembly again properly. Reintroduce respecting tht TrustBinaries flag. Changes the interregion protocol! No version bump because it was broken anyway, so with a version mismatch it will simply stay broken, but not crash. Region corssing still doesn't work because there is still monkey business with both rezzed prims being pushed across a border and attached prims when walking across a border. Teleport is untested by may work. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 124 +++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0a9af2c..b099177 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1325,6 +1325,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", ""); @@ -1335,21 +1348,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine stateData.AppendChild(assemblyData); - return doc.InnerXml; - } + XmlElement mapData = doc.CreateElement("", "LineMap", ""); + XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); - public bool CanBeDeleted(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return true; + mapName.Value = fn + ".map"; + mapData.Attributes.Append(mapName); - return instance.CanBeDeleted(); + mapData.InnerText = map; + + stateData.AppendChild(mapData); + return doc.InnerXml; } 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(sfs); + + msw.Write(mapE.InnerText); + + msw.Close(); + mfs.Close(); + } } } -- cgit v1.1