From f6ef48741303b6e19a5aa73de038b46e0ab409c5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Dec 2009 06:29:23 +0000 Subject: Script State Fix: Step 1 Add Engine=xxx attribute and check for it's presence. Ignore state data written bby another engine --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 6 ++++++ 1 file changed, 6 insertions(+) (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 9030a5c..20dbbd4 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1266,6 +1266,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); assetID.Value = instance.AssetID.ToString(); stateData.Attributes.Append(assetID); + XmlAttribute engineName = doc.CreateAttribute("", "Engine", ""); + engineName.Value = ScriptEngineName; + stateData.Attributes.Append(engineName); doc.AppendChild(stateData); // Add ... @@ -1388,6 +1391,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine XmlElement rootE = (XmlElement)rootL[0]; + if (rootE.GetAttribute("Engine") != ScriptEngineName) + return; + if (rootE.GetAttribute("UUID") != itemID.ToString()) return; -- cgit v1.1 From 83d8ba5775146da220b7e60d3779810db8a1eb5d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Dec 2009 06:41:10 +0000 Subject: Remove extra checking on the itemID of saved state, since it changes during rez from inventory. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 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 20dbbd4..082c99b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1394,10 +1394,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (rootE.GetAttribute("Engine") != ScriptEngineName) return; - if (rootE.GetAttribute("UUID") != itemID.ToString()) - return; - -// 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"); -- cgit v1.1 From 27453890d5a5d09e47c638ccef92f45b1ce360b2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Dec 2009 10:26:52 +0000 Subject: Script State Fix: Part 2 Change the reader to wrap old-style definitions in new style wrappers. Change importer to not check irrelevant data that can't be reconstructed This removes the last bit of knowledge of XEngine's .state files from core. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 36 ++++++++++++++------------ 1 file changed, 20 insertions(+), 16 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 082c99b..25a4cd6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1368,10 +1368,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine return false; } - public void SetXMLState(UUID itemID, string xml) + public bool SetXMLState(UUID itemID, string xml) { if (xml == String.Empty) - return; + return false; XmlDocument doc = new XmlDocument(); @@ -1382,17 +1382,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine catch (Exception) { m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); - return; + return false; } XmlNodeList rootL = doc.GetElementsByTagName("State"); if (rootL.Count < 1) - return; + return false; XmlElement rootE = (XmlElement)rootL[0]; if (rootE.GetAttribute("Engine") != ScriptEngineName) - return; + return false; // On rez from inventory, that ID will have changed. It was only // advisory anyway. So we don't check it anymore. @@ -1403,7 +1403,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); if (stateL.Count != 1) - return; + return false; XmlElement stateE = (XmlElement)stateL[0]; @@ -1412,7 +1412,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); if (assemL.Count != 1) - return; + return false; XmlElement assemE = (XmlElement)assemL[0]; @@ -1452,19 +1452,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine sfs.Close(); XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); - - XmlElement mapE = (XmlElement)mapL[0]; + if (mapL.Count > 0) + { + XmlElement mapE = (XmlElement)mapL[0]; - string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); - mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); + 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); + FileStream mfs = File.Create(mappath); + StreamWriter msw = new StreamWriter(mfs); - msw.Write(mapE.InnerText); + msw.Write(mapE.InnerText); - msw.Close(); - mfs.Close(); + msw.Close(); + mfs.Close(); + } + + return true; } } } -- cgit v1.1