From a3755d831d016d7c4fb75c900663b63a2e6d28c4 Mon Sep 17 00:00:00 2001 From: OpenSim Master Date: Wed, 25 Nov 2009 10:55:33 -0800 Subject: [PATCH 1/8] Patch: Fix a bug in LAND animation when the TickCount wraps into negative numbers by Mic Bowman Signed-off-by: Teravus Ovares (Dan Olivares) --- .../Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 2e4c260093..b37249dff9 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -247,8 +247,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (m_movementAnimation == "LAND") { float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - - if (landElapsed <= FALL_DELAY) + if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) return "LAND"; } From a5f2803c79b8d3a25124bef5f68afd57b5feba96 Mon Sep 17 00:00:00 2001 From: "Teravus Ovares (Dan Olivares)" Date: Thu, 26 Nov 2009 01:34:46 -0500 Subject: [PATCH 2/8] * Re-enable the AbsolutePosition = AbsolutePosition in the LSL_Api in the SetRot method if the object is not active physical. This is important for scripted rotating doors. without AbsolutePosition = AbsolutePosition, the door won't rotate. It's also important that we do not use AbsolutePosition = AbsolutePosition if the object is active physical because that would cause a complete rebuild of the object which would break vehicles. This is the best of both worlds right now. Doors as child prim should work again so long as you don't check the Physical box. * Thanks talentraspel * Thanks NixNerd * Thanks KittoFlora * Thanks lockd --- .../Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9c627758b0..fbbbfdc727 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1987,6 +1987,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; + + // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line + // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt + // It's perfectly okay when the object is not an active physical body though. + // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against + // but only if the object is not physial and active. This is important for rotating doors. + // without the absoluteposition = absoluteposition happening, the doors do not move in the physics + // scene + if (part.PhysActor != null && !part.PhysActor.IsPhysical) + { + part.ParentGroup.ResetChildPrimPhysicsPositions(); + } } /// From 88842edc95bafeb9f3b2f2ea0ab09394028a0916 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:08:20 +0000 Subject: [PATCH 3/8] Remove GetAssemblyName and friends from the SE interface. It's now handled internally --- .../Framework/Interfaces/IEntityInventory.cs | 6 -- .../Framework/Interfaces/IScriptModule.cs | 1 - .../Scenes/SceneObjectGroup.Inventory.cs | 93 +----------------- .../Scenes/SceneObjectPartInventory.cs | 30 ------ .../Region/ScriptEngine/XEngine/XEngine.cs | 95 +++++++++++++++++-- 5 files changed, 91 insertions(+), 134 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2c906a28f8..2998f4553d 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -184,12 +184,6 @@ namespace OpenSim.Region.Framework.Interfaces /// List GetInventoryList(); - /// - /// Get the names of the assemblies associated with scripts in this inventory. - /// - /// - string[] GetScriptAssemblies(); - /// /// Get the xml representing the saved states of scripts in this inventory. /// diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 10835b9db4..72bb0f0eec 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces { string ScriptEngineName { get; } - string GetAssemblyName(UUID itemID); string GetXMLState(UUID itemID); bool CanBeDeleted(UUID itemID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 3cec77f41c..9a6f2b83c4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes public string GetStateSnapshot() { - //m_log.Debug(" >>> GetStateSnapshot <<<"); - - List assemblies = new List(); Dictionary states = new Dictionary(); foreach (SceneObjectPart part in m_parts.Values) { - foreach (string a in part.Inventory.GetScriptAssemblies()) - { - if (a != "" && !assemblies.Contains(a)) - assemblies.Add(a); - } - foreach (KeyValuePair s in part.Inventory.GetScriptStates()) - { states[s.Key] = s.Value; - } } - if (states.Count < 1 || assemblies.Count < 1) + if (states.Count < 1) return ""; XmlDocument xmldoc = new XmlDocument(); @@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes xmldoc.AppendChild(rootElement); - XmlElement wrapper = xmldoc.CreateElement("", "Assemblies", - ""); - rootElement.AppendChild(wrapper); - - foreach (string assembly in assemblies) - { - string fn = Path.GetFileName(assembly); - if (fn == String.Empty) - continue; - - String filedata = String.Empty; - - if (File.Exists(assembly+".text")) - { - FileInfo tfi = new FileInfo(assembly+".text"); - - if (tfi == null) - continue; - - Byte[] tdata = new Byte[tfi.Length]; - - try - { - FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); - } - - filedata = new System.Text.ASCIIEncoding().GetString(tdata); - } - else - { - FileInfo fi = new FileInfo(assembly); - - if (fi == null) - continue; - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); - } - - filedata = System.Convert.ToBase64String(data); - } - XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); - XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); - assemblyName.Value = fn; - assemblyData.Attributes.Append(assemblyName); - - assemblyData.InnerText = filedata; - - wrapper.AppendChild(assemblyData); - } - - wrapper = xmldoc.CreateElement("", "ScriptStates", + XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", ""); rootElement.AppendChild(wrapper); foreach (KeyValuePair state in states) { - XmlElement stateData = xmldoc.CreateElement("", "State", ""); - - XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", ""); - stateID.Value = state.Key.ToString(); - stateData.Attributes.Append(stateID); - XmlDocument sdoc = new XmlDocument(); sdoc.LoadXml(state.Value); - XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNodeList rootL = sdoc.GetElementsByTagName("State"); XmlNode rootNode = rootL[0]; XmlNode newNode = xmldoc.ImportNode(rootNode, true); - stateData.AppendChild(newNode); - wrapper.AppendChild(stateData); + wrapper.AppendChild(newNode); } return xmldoc.InnerXml; @@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(string objXMLData, UUID RegionID) { +m_log.Debug("SetState called with " + objXMLData); if (objXMLData == String.Empty) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f4ca877941..7f49ced7a5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes return ret; } - public string[] GetScriptAssemblies() - { - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - List ret = new List(); - if (engines == null) // No engine at all - return new string[0]; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (e != null) - { - string n = e.GetAssemblyName(item.ItemID); - if (n != String.Empty) - { - if (!ret.Contains(n)) - ret.Add(n); - break; - } - } - } - } - } - return ret.ToArray(); - } - public Dictionary GetScriptStates() { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a60c0bac73..0a9af2c1ec 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1245,20 +1245,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - public string GetAssemblyName(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return ""; - return instance.GetAssemblyName(); - } - public string GetXMLState(UUID itemID) { IScriptInstance instance = GetInstance(itemID); if (instance == null) return ""; - return instance.GetXMLState(); + string xml = instance.GetXMLState(); + + XmlDocument sdoc = new XmlDocument(); + sdoc.LoadXml(xml); + XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNode rootNode = rootL[0]; + + // Create + XmlDocument doc = new XmlDocument(); + XmlElement stateData = doc.CreateElement("", "State", ""); + XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); + stateID.Value = itemID.ToString(); + stateData.Attributes.Append(stateID); + XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); + assetID.Value = instance.AssetID.ToString(); + stateData.Attributes.Append(assetID); + doc.AppendChild(stateData); + + // Add ... + XmlNode xmlstate = doc.ImportNode(rootNode, true); + stateData.AppendChild(xmlstate); + + string assemName = instance.GetAssemblyName(); + + string fn = Path.GetFileName(assemName); + + string assem = String.Empty; + + if (File.Exists(assemName + ".text")) + { + FileInfo tfi = new FileInfo(assemName + ".text"); + + if (tfi != null) + { + Byte[] tdata = new Byte[tfi.Length]; + + try + { + FileStream tfs = File.Open(assemName + ".text", + FileMode.Open, FileAccess.Read); + tfs.Read(tdata, 0, tdata.Length); + tfs.Close(); + + assem = new System.Text.ASCIIEncoding().GetString(tdata); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); + } + } + } + else + { + FileInfo fi = new FileInfo(assemName); + + if (fi != null) + { + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + + assem = System.Convert.ToBase64String(data); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); + } + + } + } + + XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); + XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); + + assemblyName.Value = fn; + assemblyData.Attributes.Append(assemblyName); + + assemblyData.InnerText = assem; + + stateData.AppendChild(assemblyData); + + return doc.InnerXml; } public bool CanBeDeleted(UUID itemID) From 05fc504ff3698ec472c582f26a9ddfdd0ce2c8f6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:16:42 +0000 Subject: [PATCH 4/8] Remove the old remoting-type interregion code for prim/script crossing --- OpenSim/Framework/IRegionCommsListener.cs | 2 - OpenSim/Framework/RegionCommsListener.cs | 25 ----- OpenSim/Region/Framework/Scenes/Scene.cs | 99 ------------------- .../Scenes/SceneCommunicationService.cs | 72 -------------- 4 files changed, 198 deletions(-) diff --git a/OpenSim/Framework/IRegionCommsListener.cs b/OpenSim/Framework/IRegionCommsListener.cs index 307c6bc8b9..cd59c63db6 100644 --- a/OpenSim/Framework/IRegionCommsListener.cs +++ b/OpenSim/Framework/IRegionCommsListener.cs @@ -32,7 +32,6 @@ namespace OpenSim.Framework { public delegate void ExpectUserDelegate(AgentCircuitData agent); - public delegate bool ExpectPrimDelegate(UUID primID, string objData, int XMLMethod); public delegate void UpdateNeighbours(List neighbours); @@ -55,7 +54,6 @@ namespace OpenSim.Framework public interface IRegionCommsListener { event ExpectUserDelegate OnExpectUser; - event ExpectPrimDelegate OnExpectPrim; event GenericCall2 OnExpectChildAgent; event AgentCrossing OnAvatarCrossingIntoRegion; event PrimCrossing OnPrimCrossingIntoRegion; diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs index 90200d6e91..718a5563e9 100644 --- a/OpenSim/Framework/RegionCommsListener.cs +++ b/OpenSim/Framework/RegionCommsListener.cs @@ -43,7 +43,6 @@ namespace OpenSim.Framework private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent; - private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; @@ -53,7 +52,6 @@ namespace OpenSim.Framework #region IRegionCommsListener Members public event ExpectUserDelegate OnExpectUser; - public event ExpectPrimDelegate OnExpectPrim; public event GenericCall2 OnExpectChildAgent; public event AgentCrossing OnAvatarCrossingIntoRegion; public event PrimCrossing OnPrimCrossingIntoRegion; @@ -95,17 +93,6 @@ namespace OpenSim.Framework } - public virtual bool TriggerExpectPrim(UUID primID, string objData, int XMLMethod) - { - handlerExpectPrim = OnExpectPrim; - if (handlerExpectPrim != null) - { - handlerExpectPrim(primID, objData, XMLMethod); - return true; - } - return false; - } - public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData) { handlerChildAgentUpdate = OnChildAgentUpdate; @@ -128,18 +115,6 @@ namespace OpenSim.Framework return false; } - public virtual bool TriggerExpectPrimCrossing(UUID primID, Vector3 position, - bool isPhysical) - { - handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; - if (handlerPrimCrossingIntoRegion != null) - { - handlerPrimCrossingIntoRegion(primID, position, isPhysical); - return true; - } - return false; - } - public virtual bool TriggerAcknowledgeAgentCrossed(UUID agentID) { handlerAcknowledgeAgentCrossed = OnAcknowledgeAgentCrossed; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f444e51348..0ee818d10b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2381,103 +2381,6 @@ namespace OpenSim.Region.Framework.Scenes return successYN; } - /// - /// Handle a scene object that is crossing into this region from another. - /// NOTE: Unused as of 2009-02-09. Soon to be deleted. - /// - /// - /// - /// - /// - /// - public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod) - { - if (XMLMethod == 0) - { - m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); - SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); - if (sceneObject.IsAttachment) - sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; - - return AddSceneObject(sceneObject); - } - else if ((XMLMethod == 100) && m_allowScriptCrossings) - { - m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor"); - - XmlDocument doc = new XmlDocument(); - doc.LoadXml(objXMLData); - - XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); - if (rootL.Count == 1) - { - XmlNode rootNode = rootL[0]; - if (rootNode != null) - { - XmlNodeList partL = rootNode.ChildNodes; - - foreach (XmlNode part in partL) - { - XmlNodeList nodeL = part.ChildNodes; - - switch (part.Name) - { - case "Assemblies": - foreach (XmlNode asm in nodeL) - { - string fn = asm.Attributes.GetNamedItem("Filename").Value; - - Byte[] filedata = Convert.FromBase64String(asm.InnerText); - string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - } - } - break; - case "ScriptStates": - foreach (XmlNode st in nodeL) - { - string id = st.Attributes.GetNamedItem("UUID").Value; - UUID uuid = new UUID(id); - XmlNode state = st.ChildNodes[0]; - - XmlDocument sdoc = new XmlDocument(); - XmlNode sxmlnode = sdoc.CreateNode( - XmlNodeType.XmlDeclaration, - "", ""); - sdoc.AppendChild(sxmlnode); - - XmlNode newnode = sdoc.ImportNode(state, true); - sdoc.AppendChild(newnode); - - string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - spath = Path.Combine(spath, uuid.ToString()); - FileStream sfs = File.Create(spath + ".state"); - ASCIIEncoding enc = new ASCIIEncoding(); - Byte[] buf = enc.GetBytes(sdoc.InnerXml); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - } - break; - } - } - } - } - - SceneObjectPart RootPrim = GetSceneObjectPart(primID); - RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); - - return true; - } - - return true; - } - public bool IncomingCreateObject(ISceneObject sog) { //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); @@ -3350,7 +3253,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; //m_eventManager.OnRegionUp += OtherRegionUp; //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; m_sceneGridService.KiPrimitive += SendKillObject; @@ -3374,7 +3276,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.KiPrimitive -= SendKillObject; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; - m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; //m_eventManager.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= HandleNewUserConnection; diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 76c6caba33..389276988a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// A Prim will arrive shortly /// - public event ExpectPrimDelegate OnExpectPrim; public event CloseAgentConnection OnCloseAgentConnection; /// @@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; - private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; //private RegionUp handlerRegionUp = null; // OnRegionUp; @@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes /// Thrown if region registration fails. public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) { - //m_interregionCommsOut = comms_out; - - //m_regionInfo = regionInfos; - //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; - //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); - - //if (regionCommsHost != null) - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); - - // regionCommsHost.debugRegionName = regionInfos.RegionName; - // regionCommsHost.OnExpectPrim += IncomingPrimCrossing; - // regionCommsHost.OnExpectUser += NewUserConnection; - // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; - // regionCommsHost.OnCloseAgentConnection += CloseConnection; - // regionCommsHost.OnRegionUp += newRegionUp; - // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - // regionCommsHost.OnLogOffUser += GridLogOffUser; - // regionCommsHost.OnGetLandData += FetchLandData; - //} - //else - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); - //} } /// @@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void Close() { - - //if (regionCommsHost != null) - //{ - // regionCommsHost.OnLogOffUser -= GridLogOffUser; - // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; - // regionCommsHost.OnRegionUp -= newRegionUp; - // regionCommsHost.OnExpectUser -= NewUserConnection; - // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; - // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; - // regionCommsHost.OnCloseAgentConnection -= CloseConnection; - // regionCommsHost.OnGetLandData -= FetchLandData; - - // try - // { - // m_commsProvider.GridService.DeregisterRegion(m_regionInfo); - // } - // catch (Exception e) - // { - // m_log.ErrorFormat( - // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", - // m_regionInfo.RegionName, e); - // } - - // regionCommsHost = null; - //} } #region CommsManager Event handlers @@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// We have a new prim from a neighbor - /// - /// unique ID for the primative - /// XML2 encoded data of the primative - /// An Int that represents the version of the XMLMethod - /// True if the prim was accepted, false if it was not - protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod) - { - handlerExpectPrim = OnExpectPrim; - if (handlerExpectPrim != null) - { - return handlerExpectPrim(primID, objXMLData, XMLMethod); - } - else - { - return false; - } - - } - protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) { handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; From 2bc19a1e23594e00e2bc812d27d4b4804b438bdf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 26 Nov 2009 16:39:30 +0000 Subject: [PATCH 5/8] Resolve issue where an iar load fails to preserve original item creators See http://opensimulator.org/mantis/view.php?id=4394 This change preserves the uuid when a profile is found rather than the ospa --- .../Inventory/Archiver/InventoryArchiveReadRequest.cs | 8 ++++++++ .../Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 2 +- .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 8532d03122..b7783899cd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -348,9 +348,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); if (UUID.Zero != ospResolvedId) + { item.CreatorIdAsUuid = ospResolvedId; + + // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the + // database). Instead, replace with the UUID that we found. + item.CreatorId = ospResolvedId.ToString(); + } else + { item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; + } item.Owner = m_userInfo.UserProfile.ID; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2c0d11357a..ecd60bdaad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); m_log.InfoFormat( - "[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}", + "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); Guid id = Guid.NewGuid(); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 792735231a..e4dad18c21 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -259,9 +259,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); + +// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the +// UUID, not the OSPA itself. +// Assert.That( +// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), +// "Loaded item non-uuid creator doesn't match original"); Assert.That( - foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), + foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), "Loaded item non-uuid creator doesn't match original"); + Assert.That( foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), "Loaded item uuid creator doesn't match original"); From ee0b5abc6236e0204af74c582d67695021b73790 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 26 Nov 2009 16:51:10 +0000 Subject: [PATCH 6/8] minor: reduce region ready logging verbosity --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 91c25a656a..c653e98401 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -62,7 +62,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady public void Initialise(IConfigSource config) { - m_log.Info("[RegionReady] Initialising"); + //m_log.Info("[RegionReady] Initialising"); m_config = config.Configs["RegionReady"]; if (m_config != null) @@ -74,8 +74,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } - if (!m_enabled) - m_log.Info("[RegionReady] disabled."); +// if (!m_enabled) +// m_log.Info("[RegionReady] disabled."); } public void AddRegion(Scene scene) @@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; - m_log.InfoFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); + m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); } public void RemoveRegion(Scene scene) @@ -120,7 +120,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } #endregion - void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) { From 9d63f90467dbc60622a49f564a56fdd20de90f51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 17:03:09 +0000 Subject: [PATCH 7/8] 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/Framework/ISceneObject.cs | 2 +- .../Interregion/LocalInterregionComms.cs | 9 +- .../Interregion/RESTInterregionComms.cs | 6 +- .../Framework/Interfaces/IEntityInventory.cs | 2 - .../Framework/Interfaces/IScriptModule.cs | 2 +- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 5 - OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../Scenes/SceneObjectGroup.Inventory.cs | 97 +++++--------- .../Framework/Scenes/SceneObjectGroup.cs | 11 -- .../Framework/Scenes/SceneObjectPart.cs | 5 - .../Scenes/SceneObjectPartInventory.cs | 25 ---- .../Interfaces/IScriptInstance.cs | 1 - .../Shared/Instance/ScriptInstance.cs | 5 - .../Region/ScriptEngine/XEngine/XEngine.cs | 126 ++++++++++++++++-- 14 files changed, 160 insertions(+), 138 deletions(-) diff --git a/OpenSim/Framework/ISceneObject.cs b/OpenSim/Framework/ISceneObject.cs index 4fc3e01fcb..51479014cd 100644 --- a/OpenSim/Framework/ISceneObject.cs +++ b/OpenSim/Framework/ISceneObject.cs @@ -38,6 +38,6 @@ namespace OpenSim.Framework string ExtraToXmlString(); void ExtraFromXmlString(string xmlstr); string GetStateSnapshot(); - void SetState(string xmlstr, UUID regionID); + void SetState(string xmlstr, IScene s); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs index ee809bd248..d9f6e3300a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs @@ -263,8 +263,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); - sogClone.SetState(sog.GetStateSnapshot(), - s.RegionInfo.RegionID); + sogClone.SetState(sog.GetStateSnapshot(), s); return s.IncomingCreateObject(sogClone); } else @@ -294,15 +293,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion #region Misc - public UUID GetRegionID(ulong regionhandle) + public Scene GetScene(ulong regionhandle) { foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionHandle == regionhandle) - return s.RegionInfo.RegionID; + return s; } // ? weird. should not happen - return m_sceneList[0].RegionInfo.RegionID; + return m_sceneList[0]; } public bool IsLocalRegion(ulong regionhandle) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 696225cddc..710e3ca5d9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -641,7 +641,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion if (args["extra"] != null) extraStr = args["extra"].AsString(); - UUID regionID = m_localBackend.GetRegionID(regionhandle); + IScene s = m_localBackend.GetScene(regionhandle); SceneObjectGroup sog = null; try { @@ -663,7 +663,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { try { - sog.SetState(stateXmlStr, regionID); + sog.SetState(stateXmlStr, s); } catch (Exception ex) { @@ -695,8 +695,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion if (args["itemid"] != null) itemID = args["itemid"].AsUUID(); - //UUID regionID = m_localBackend.GetRegionID(regionhandle); - // This is the meaning of PUT object bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2998f4553d..89a45da1c9 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -191,7 +191,5 @@ namespace OpenSim.Region.Framework.Interfaces /// A /// Dictionary GetScriptStates(); - - bool CanBeDeleted(); } } diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 72bb0f0eec..f11e5713d0 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces string ScriptEngineName { get; } string GetXMLState(UUID itemID); - bool CanBeDeleted(UUID itemID); + void SetXMLState(UUID itemID, string xml); bool PostScriptEvent(UUID itemID, string name, Object[] args); bool PostObjectEvent(UUID itemID, string name, Object[] args); diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 5b571c7227..9a7863b595 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -131,11 +131,6 @@ namespace OpenSim.Region.Framework.Scenes if (left > 0) { x = m_inventoryDeletes.Dequeue(); - if (!x.objectGroup.CanBeDeleted()) - { - m_inventoryDeletes.Enqueue(x); - return true; - } m_log.DebugFormat( "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0ee818d10b..eb8567fc7c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -618,7 +618,7 @@ namespace OpenSim.Region.Framework.Scenes startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; - m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine"); + m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9a6f2b83c4..5a06bdb7b9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -351,12 +351,29 @@ namespace OpenSim.Region.Framework.Scenes return xmldoc.InnerXml; } - public void SetState(string objXMLData, UUID RegionID) + public void SetState(string objXMLData, IScene ins) { -m_log.Debug("SetState called with " + objXMLData); + if (!(ins is Scene)) + return; + + Scene s = (Scene)ins; + if (objXMLData == String.Empty) return; + IScriptModule scriptModule = null; + + foreach (IScriptModule sm in s.RequestModuleInterfaces()) + { + if (sm.ScriptEngineName == s.DefaultScriptEngine) + scriptModule = sm; + else if (scriptModule == null) + scriptModule = sm; + } + + if (scriptModule == null) + return; + XmlDocument doc = new XmlDocument(); try { @@ -374,69 +391,23 @@ m_log.Debug("SetState called with " + objXMLData); } XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); - if (rootL.Count == 1) + if (rootL.Count != 1) + return; + + XmlElement rootE = (XmlElement)rootL[0]; + + XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates"); + if (dataL.Count != 1) + return; + + XmlElement dataE = (XmlElement)dataL[0]; + + foreach (XmlNode n in dataE.ChildNodes) { - XmlNode rootNode = rootL[0]; - if (rootNode != null) - { - XmlNodeList partL = rootNode.ChildNodes; + XmlElement stateE = (XmlElement)n; + UUID itemID = new UUID(stateE.GetAttribute("UUID")); - foreach (XmlNode part in partL) - { - XmlNodeList nodeL = part.ChildNodes; - - switch (part.Name) - { - case "Assemblies": - foreach (XmlNode asm in nodeL) - { - string fn = asm.Attributes.GetNamedItem("Filename").Value; - - Byte[] filedata = Convert.FromBase64String(asm.InnerText); - string path = Path.Combine("ScriptEngines", RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - - Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText); - fs = File.Create(path+".text"); - fs.Write(textbytes, 0, textbytes.Length); - fs.Close(); - } - } - break; - case "ScriptStates": - foreach (XmlNode st in nodeL) - { - string id = st.Attributes.GetNamedItem("UUID").Value; - UUID uuid = new UUID(id); - XmlNode state = st.ChildNodes[0]; - - XmlDocument sdoc = new XmlDocument(); - XmlNode sxmlnode = sdoc.CreateNode( - XmlNodeType.XmlDeclaration, - "", ""); - sdoc.AppendChild(sxmlnode); - - XmlNode newnode = sdoc.ImportNode(state, true); - sdoc.AppendChild(newnode); - - string spath = Path.Combine("ScriptEngines", RegionID.ToString()); - spath = Path.Combine(spath, uuid.ToString()); - FileStream sfs = File.Create(spath + ".state"); - System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); - Byte[] buf = enc.GetBytes(sdoc.InnerXml); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - } - break; - } - } - } + scriptModule.SetXMLState(itemID, n.OuterXml); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bcc9b37aee..6ec2a01be5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3341,17 +3341,6 @@ namespace OpenSim.Region.Framework.Scenes } #endregion - public bool CanBeDeleted() - { - foreach (SceneObjectPart part in Children.Values) - { - if (!part.CanBeDeleted()) - return false; - } - - return true; - } - public double GetUpdatePriority(IClientAPI client) { switch (Scene.UpdatePrioritizationScheme) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6f1b4581be..b6916f227d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3797,10 +3797,5 @@ namespace OpenSim.Region.Framework.Scenes Inventory.ApplyNextOwnerPermissions(); } - - public bool CanBeDeleted() - { - return Inventory.CanBeDeleted(); - } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7f49ced7a5..7a0d7b7ff9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -886,30 +886,5 @@ namespace OpenSim.Region.Framework.Scenes } return ret; } - - public bool CanBeDeleted() - { - if (!ContainsScripts()) - return true; - - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - if (engines == null) // No engine at all - return true; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (!e.CanBeDeleted(item.ItemID)) - return false; - } - } - } - - return true; - } } } diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index f49aea8104..ae148a9c5a 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -96,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces UUID GetDetectID(int idx); void SaveState(string assembly); void DestroyScriptInstance(); - bool CanBeDeleted(); IScriptApi GetApi(string name); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d497da..5c5d57e817 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -1011,10 +1011,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { get { return m_RegionID; } } - - public bool CanBeDeleted() - { - return true; - } } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0a9af2c1ec..b0991774c5 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); + 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(sfs); + + msw.Write(mapE.InnerText); + + msw.Close(); + mfs.Close(); + } } } From c6bfecccaa3b1128c6d670bdedc13275732e738b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 17:16:02 +0000 Subject: [PATCH 8/8] Fix a small bug. Trusted script crossings now work again --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b0991774c5..5584f87dc4 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1452,7 +1452,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); FileStream mfs = File.Create(mappath); - StreamWriter msw = new StreamWriter(sfs); + StreamWriter msw = new StreamWriter(mfs); msw.Write(mapE.InnerText);