From d2fea2bb29d3678b79c895b2a0fc79123cf4efeb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 8 Jul 2010 16:05:59 -0700 Subject: These 2 files want to be committed. --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5941abd..c5226ba 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -450,7 +450,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llVecNorm(LSL_Vector v) { - m_host.AddScriptLPS(1); + m_host.AddScriptLPS(1); return LSL_Vector.Norm(v); } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index bb5267c..91e03ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -259,15 +259,15 @@ namespace OpenSim.Region.ScriptEngine.Shared return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); } - public static Vector3 Norm(Vector3 vector) - { - double mag = Mag(vector); - if (mag > 0.0) - { - double invMag = 1.0 / mag; - return vector * invMag; - } - return new Vector3(0, 0, 0); + public static Vector3 Norm(Vector3 vector) + { + double mag = Mag(vector); + if (mag > 0.0) + { + double invMag = 1.0 / mag; + return vector * invMag; + } + return new Vector3(0, 0, 0); } #endregion -- cgit v1.1 From 6352fc5f57b8602235319c4f927c6a41c5048cbc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Jul 2010 12:58:16 -0400 Subject: Bug in 0.6.9 sometimes restoring script state causes region console to crash due to unhandled file lock exception. Attempt to resolve by wrapping several instances of file create / read logic in using statements and added some error handling for locked file exceptions. If it is IDisposable, it must be disposed! The close statements are unnecessary but harmless so I have left those in. The end of the using block will close and dispose automagically. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 123 +++++++++++++++++-------- 1 file changed, 84 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index bc5df11..0299385 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1343,10 +1343,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine try { - FileStream tfs = File.Open(assemName + ".text", - FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); + using (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); } @@ -1366,9 +1368,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine try { - FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); + using (FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read)) + { + fs.Read(data, 0, data.Length); + fs.Close(); + } assem = System.Convert.ToBase64String(data); } @@ -1384,13 +1388,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine 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(); + using (FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read)) + { + using (StreamReader msr = new StreamReader(mfs)) + { + map = msr.ReadToEnd(); + msr.Close(); + } + mfs.Close(); + } } XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); @@ -1478,30 +1484,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine { 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(); + try + { + using (FileStream fs = File.Create(path)) + { + fs.Write(filedata, 0, filedata.Length); + fs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); + } + try + { + using (FileStream fs = File.Create(path + ".text")) + { + using (StreamWriter sw = new StreamWriter(fs)) + { + sw.Write(base64); + sw.Close(); + } + fs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); + } } } 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(); + try + { + using (FileStream sfs = File.Create(statepath)) + { + using (StreamWriter ssw = new StreamWriter(sfs)) + { + ssw.Write(stateE.OuterXml); + ssw.Close(); + } + sfs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); + } XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); if (mapL.Count > 0) @@ -1511,13 +1546,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine 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(); + try + { + using (FileStream mfs = File.Create(mappath)) + { + using (StreamWriter msw = new StreamWriter(mfs)) + { + msw.Write(mapE.InnerText); + msw.Close(); + } + mfs.Close(); + } + } + catch (IOException ex) + { + // if there already exists a file at that location, it may be locked. + m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); + } } return true; -- cgit v1.1 From 1169bfeaf38ea6b1f6ecaf2d634e130ad891874c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 10 Jul 2010 10:51:49 +0200 Subject: Make taken items go back to the folder they came from --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 14 ++++++++++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 3 +++ 2 files changed, 17 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 90b7b51..2057c65 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -322,6 +322,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } + // Override and put into where it came from, if it came + // from anywhere in inventory + // + if (action == DeRezAction.Take || action == DeRezAction.TakeCopy) + { + if (objectGroup.RootPart.FromFolderID != UUID.Zero) + { + InventoryFolderBase f = new InventoryFolderBase(objectGroup.RootPart.FromFolderID, userID); + folder = m_Scene.InventoryService.GetFolder(f); + } + } + if (folder == null) // None of the above { folder = new InventoryFolderBase(folderID); @@ -485,6 +497,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); + group.RootPart.FromFolderID = item.Folder; + if (!m_Scene.Permissions.CanRezObject( group.Children.Count, remoteClient.AgentId, pos) && !attachment) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 59fd805..0698411 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -180,6 +180,9 @@ namespace OpenSim.Region.Framework.Scenes public UUID FromItemID; [XmlIgnore] + public UUID FromFolderID; + + [XmlIgnore] public int STATUS_ROTATE_X; [XmlIgnore] -- cgit v1.1 From eaea89bbb74ad219a01c5dd81e1e4b5d8c1a15a4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 11 Jul 2010 13:09:11 +0100 Subject: Remove localID from script controls data. It won't transfer to another region anyway --- OpenSim/Region/Framework/Scenes/EventManager.cs | 6 +++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +--- OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index ef125cd..9db2e41 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -179,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes public event ScriptChangedEvent OnScriptChangedEvent; public delegate void ScriptChangedEvent(uint localID, uint change); - public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); + public delegate void ScriptControlEvent(UUID item, UUID avatarID, uint held, uint changed); public event ScriptControlEvent OnScriptControlEvent; public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); @@ -1595,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes } } - internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) + internal void TriggerControlEvent(UUID scriptUUID, UUID avatarID, uint held, uint _changed) { ScriptControlEvent handlerScriptControlEvent = OnScriptControlEvent; if (handlerScriptControlEvent != null) @@ -1604,7 +1604,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - d(p, scriptUUID, avatarID, held, _changed); + d(scriptUUID, avatarID, held, _changed); } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6c119c2..7f98877 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -60,7 +60,6 @@ namespace OpenSim.Region.Framework.Scenes struct ScriptControllers { public UUID itemID; - public uint objID; public ScriptControlled ignoreControls; public ScriptControlled eventControls; } @@ -3468,7 +3467,6 @@ namespace OpenSim.Region.Framework.Scenes obj.eventControls = ScriptControlled.CONTROL_ZERO; obj.itemID = Script_item_UUID; - obj.objID = Obj_localID; if (pass_on == 0 && accept == 0) { IgnoredControls |= (ScriptControlled)controls; @@ -3611,7 +3609,7 @@ namespace OpenSim.Region.Framework.Scenes if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) { // only send if still pressed or just changed - m_scene.EventManager.TriggerControlEvent(scriptControlData.objID, scriptUUID, UUID, (uint)localHeld, (uint)localChange); + m_scene.EventManager.TriggerControlEvent(scriptUUID, UUID, (uint)localHeld, (uint)localChange); } } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 09b79d0..0ac8b5c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs @@ -356,9 +356,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine // timer: not handled here // listen: not handled here - public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change) + public void control(UUID itemID, UUID agentID, uint held, uint change) { - myScriptEngine.PostObjectEvent(localID, new EventParams( + myScriptEngine.PostScriptEvent(itemID, new EventParams( "control",new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(held), -- cgit v1.1