diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs index 9dd4a2e69b..fcf041e41f 100644 --- a/OpenSim/Data/SQLite/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -328,7 +328,7 @@ namespace OpenSim.Data.SQLite public EstateSettings LoadEstateSettings(int estateID) { - string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID"; + string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); @@ -342,7 +342,7 @@ namespace OpenSim.Data.SQLite { List result = new List(); - string sql = "select EstateID from estate_settings where estate_settings.EstateName :EstateName"; + string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs index e135eaa524..bf8ee147b5 100644 --- a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs @@ -328,7 +328,7 @@ namespace OpenSim.Data.SQLiteLegacy public EstateSettings LoadEstateSettings(int estateID) { - string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID"; + string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID = :EstateID"; SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); @@ -342,7 +342,7 @@ namespace OpenSim.Data.SQLiteLegacy { List result = new List(); - string sql = "select EstateID from estate_settings where estate_settings.EstateName :EstateName"; + string sql = "select EstateID from estate_settings where estate_settings.EstateName = :EstateName"; SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 0c9759d946..e060c05a00 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -183,7 +183,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); @@ -1619,7 +1619,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) @@ -1628,7 +1628,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 e51d9ee605..5ac7755db0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -61,7 +61,6 @@ namespace OpenSim.Region.Framework.Scenes struct ScriptControllers { public UUID itemID; - public uint objID; public ScriptControlled ignoreControls; public ScriptControlled eventControls; } @@ -3945,7 +3944,6 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); obj.eventControls = ScriptControlled.CONTROL_ZERO; obj.itemID = Script_item_UUID; - obj.objID = Obj_localID; if (pass_on == 0 && accept == 0) { IgnoredControls |= (ScriptControlled)controls; @@ -4088,7 +4086,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); 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/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f996ff4c08..5492266565 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -518,7 +518,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 01141eebe7..c9049e2679 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 diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 09b79d07f2..0ac8b5c043 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), diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a6ab5e92cd..d4c17270d4 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1425,10 +1425,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); } @@ -1448,9 +1450,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); } @@ -1466,13 +1470,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", ""); @@ -1560,30 +1566,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) @@ -1593,13 +1628,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;