From f5bdf0d9b9538b9f2ac612fcb8bce4442794fb4d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Jul 2010 00:26:26 +0100 Subject: Fix bugs in llRot2Euler() Applies patch in http://opensimulator.org/mantis/view.php?id=4482. Thanks Micheil Merlin! --- .../Shared/Api/Implementation/LSL_Api.cs | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index dbea6ef..789bbb2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -465,22 +465,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke - // Utility function for llRot2Euler - - // normalize an angle between -PI and PI (-180 to +180 degrees) - protected double NormalizeAngle(double angle) - { - if (angle > -Math.PI && angle < Math.PI) - return angle; - - int numPis = (int)(Math.PI / angle); - double remainder = angle - Math.PI * numPis; - if (numPis % 2 == 1) - return Math.PI - angle; - return remainder; - } - - // Old implementation of llRot2Euler, now normalized + // Old implementation of llRot2Euler. Normalization not required as Atan2 function will + // only return values >= -PI (-180 degrees) and <= PI (180 degrees). public LSL_Vector llRot2Euler(LSL_Rotation r) { @@ -492,13 +478,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api double n = 2 * (r.y * r.s + r.x * r.z); double p = m * m - n * n; if (p > 0) - return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), - NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), - NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); + return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), + Math.Atan2(n, Math.Sqrt(p)), + Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); else if (n > 0) - return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); + return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); else - return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); + return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); } /* From wiki: -- cgit v1.1 From 9cfa71d1bf77bcc3305bbfcd12d964496b2ce39d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Jul 2010 00:35:51 +0100 Subject: Allow use of old angle rules PSYS_SRC_INNERANGLE and PSYS_SRC_OUTERANGLE in llParticleSystem() This is a patch from http://opensimulator.org/mantis/view.php?id=3201 Thanks Micheil Martin! --- .../Shared/Api/Implementation/LSL_Api.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 789bbb2..417cef4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5859,6 +5859,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api PSYS_PART_MAX_AGE = 7, PSYS_SRC_ACCEL = 8, PSYS_SRC_PATTERN = 9, + PSYS_SRC_INNERANGLE = 10, + PSYS_SRC_OUTERANGLE = 11, PSYS_SRC_TEXTURE = 12, PSYS_SRC_BURST_RATE = 13, PSYS_SRC_BURST_PART_COUNT = 15, @@ -5991,6 +5993,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; break; + // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The + // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The + // client tells the difference between the two by looking at the 0x02 bit in + // the PartFlags variable. + case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: + tempf = (float)rules.GetLSLFloatItem(i + 1); + prules.InnerAngle = (float)tempf; + prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. + break; + + case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: + tempf = (float)rules.GetLSLFloatItem(i + 1); + prules.OuterAngle = (float)tempf; + prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. + break; + case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); break; @@ -6047,11 +6065,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.InnerAngle = (float)tempf; + prules.PartFlags |= 0x02; // Set new angle format. break; case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: tempf = (float)rules.GetLSLFloatItem(i + 1); prules.OuterAngle = (float)tempf; + prules.PartFlags |= 0x02; // Set new angle format. break; } -- cgit v1.1 From f798679b8005e532f933553007cca989112f4a1d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 19 Jul 2010 00:06:23 +0100 Subject: A stab in the dark. Revert the compile lockout temporarily. If you know what this is, you should test it. If you don't, don't use it. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0299385..bf7fed8 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -122,7 +122,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); IWorkItemResult m_CurrentCompile = null; - private Dictionary m_CompileDict = new Dictionary(); +// private Dictionary m_CompileDict = new Dictionary(); public string ScriptEngineName { @@ -488,20 +488,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (stateSource == (int)StateSource.ScriptedRez) { - lock (m_CompileDict) - { - m_CompileDict[itemID] = 0; - } +// lock (m_CompileDict) +// { +// m_CompileDict[itemID] = 0; +// } DoOnRezScript(parms); } else { m_CompileQueue.Enqueue(parms); - lock (m_CompileDict) - { - m_CompileDict[itemID] = 0; - } +// lock (m_CompileDict) +// { +// m_CompileDict[itemID] = 0; +// } if (m_CurrentCompile == null) { @@ -564,12 +564,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine bool postOnRez = (bool)p[4]; StateSource stateSource = (StateSource)p[5]; - lock(m_CompileDict) - { - if (!m_CompileDict.ContainsKey(itemID)) - return false; - m_CompileDict.Remove(itemID); - } +// lock(m_CompileDict) +// { +// if (!m_CompileDict.ContainsKey(itemID)) +// return false; +// m_CompileDict.Remove(itemID); +// } // Get the asset ID of the script, so we can check if we // already have it. @@ -814,11 +814,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void OnRemoveScript(uint localID, UUID itemID) { // If it's not yet been compiled, make sure we don't try - lock (m_CompileDict) - { - if (m_CompileDict.ContainsKey(itemID)) - m_CompileDict.Remove(itemID); - } +// lock (m_CompileDict) +// { +// if (m_CompileDict.ContainsKey(itemID)) +// m_CompileDict.Remove(itemID); +// } lock (m_Scripts) { -- cgit v1.1 From fa45d5b5faf222a8a8e976e2827dad5b65d42583 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 19 Jul 2010 01:10:57 +0100 Subject: Revert "A stab in the dark. Revert the compile lockout temporarily. If you know what" This reverts commit f798679b8005e532f933553007cca989112f4a1d. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index bf7fed8..0299385 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -122,7 +122,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); IWorkItemResult m_CurrentCompile = null; -// private Dictionary m_CompileDict = new Dictionary(); + private Dictionary m_CompileDict = new Dictionary(); public string ScriptEngineName { @@ -488,20 +488,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (stateSource == (int)StateSource.ScriptedRez) { -// lock (m_CompileDict) -// { -// m_CompileDict[itemID] = 0; -// } + lock (m_CompileDict) + { + m_CompileDict[itemID] = 0; + } DoOnRezScript(parms); } else { m_CompileQueue.Enqueue(parms); -// lock (m_CompileDict) -// { -// m_CompileDict[itemID] = 0; -// } + lock (m_CompileDict) + { + m_CompileDict[itemID] = 0; + } if (m_CurrentCompile == null) { @@ -564,12 +564,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine bool postOnRez = (bool)p[4]; StateSource stateSource = (StateSource)p[5]; -// lock(m_CompileDict) -// { -// if (!m_CompileDict.ContainsKey(itemID)) -// return false; -// m_CompileDict.Remove(itemID); -// } + lock(m_CompileDict) + { + if (!m_CompileDict.ContainsKey(itemID)) + return false; + m_CompileDict.Remove(itemID); + } // Get the asset ID of the script, so we can check if we // already have it. @@ -814,11 +814,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void OnRemoveScript(uint localID, UUID itemID) { // If it's not yet been compiled, make sure we don't try -// lock (m_CompileDict) -// { -// if (m_CompileDict.ContainsKey(itemID)) -// m_CompileDict.Remove(itemID); -// } + lock (m_CompileDict) + { + if (m_CompileDict.ContainsKey(itemID)) + m_CompileDict.Remove(itemID); + } lock (m_Scripts) { -- cgit v1.1 From 5c0c7fda6c323cfbbe76562eda3fe0b767561dd1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 19 Jul 2010 13:59:11 -0700 Subject: One more stab at http://opensimulator.org/mantis/view.php?id=4858. Eliminated the nested locks of m_Scripts and m_PrimObjects. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 66 +++++++++++++------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0299385..c436582 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -820,60 +820,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_CompileDict.Remove(itemID); } + IScriptInstance instance = null; + lock (m_Scripts) { // Do we even have it? if (!m_Scripts.ContainsKey(itemID)) return; - IScriptInstance instance=m_Scripts[itemID]; + instance=m_Scripts[itemID]; m_Scripts.Remove(itemID); + } - instance.ClearQueue(); - instance.Stop(0); - + instance.ClearQueue(); + instance.Stop(0); // bool objectRemoved = false; - lock (m_PrimObjects) + lock (m_PrimObjects) + { + // Remove the script from it's prim + if (m_PrimObjects.ContainsKey(localID)) { - // Remove the script from it's prim - if (m_PrimObjects.ContainsKey(localID)) - { - // Remove inventory item record - if (m_PrimObjects[localID].Contains(itemID)) - m_PrimObjects[localID].Remove(itemID); + // Remove inventory item record + if (m_PrimObjects[localID].Contains(itemID)) + m_PrimObjects[localID].Remove(itemID); - // If there are no more scripts, remove prim - if (m_PrimObjects[localID].Count == 0) - { - m_PrimObjects.Remove(localID); + // If there are no more scripts, remove prim + if (m_PrimObjects[localID].Count == 0) + { + m_PrimObjects.Remove(localID); // objectRemoved = true; - } } } + } - instance.RemoveState(); - instance.DestroyScriptInstance(); + instance.RemoveState(); + instance.DestroyScriptInstance(); - m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); - if (m_DomainScripts[instance.AppDomain].Count == 0) - { - m_DomainScripts.Remove(instance.AppDomain); - UnloadAppDomain(instance.AppDomain); - } - - instance = null; + m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); + if (m_DomainScripts[instance.AppDomain].Count == 0) + { + m_DomainScripts.Remove(instance.AppDomain); + UnloadAppDomain(instance.AppDomain); + } - ObjectRemoved handlerObjectRemoved = OnObjectRemoved; - if (handlerObjectRemoved != null) - { - SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); - handlerObjectRemoved(part.UUID); - } + instance = null; - CleanAssemblies(); + ObjectRemoved handlerObjectRemoved = OnObjectRemoved; + if (handlerObjectRemoved != null) + { + SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); + handlerObjectRemoved(part.UUID); } + ScriptRemoved handlerScriptRemoved = OnScriptRemoved; if (handlerScriptRemoved != null) handlerScriptRemoved(itemID); -- cgit v1.1 From ffbae52a130376ecaa04d7d475709985c62c06ed Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 19 Jul 2010 15:20:34 -0700 Subject: Another stab at http://opensimulator.org/mantis/view.php?id=4858. Eliminated more nested locks. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 64 +++++++++++++++----------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c436582..b050349 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + ScriptInstance instance = null; lock (m_Scripts) { - ScriptInstance instance = null; // Create the object record if ((!m_Scripts.ContainsKey(itemID)) || @@ -786,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_Scripts[itemID] = instance; } + } - lock (m_PrimObjects) - { - if (!m_PrimObjects.ContainsKey(localID)) - m_PrimObjects[localID] = new List(); + lock (m_PrimObjects) + { + if (!m_PrimObjects.ContainsKey(localID)) + m_PrimObjects[localID] = new List(); - if (!m_PrimObjects[localID].Contains(itemID)) - m_PrimObjects[localID].Add(itemID); + if (!m_PrimObjects[localID].Contains(itemID)) + m_PrimObjects[localID].Add(itemID); - } + } - if (!m_Assemblies.ContainsKey(assetID)) - m_Assemblies[assetID] = assembly; + if (!m_Assemblies.ContainsKey(assetID)) + m_Assemblies[assetID] = assembly; - lock (m_AddingAssemblies) - { - m_AddingAssemblies[assembly]--; - } - - if (instance!=null) - instance.Init(); + lock (m_AddingAssemblies) + { + m_AddingAssemblies[assembly]--; } + + if (instance != null) + instance.Init(); + return true; } @@ -1007,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine public bool PostObjectEvent(uint localID, EventParams p) { bool result = false; - + List uuids = null; + lock (m_PrimObjects) { if (!m_PrimObjects.ContainsKey(localID)) return false; - - foreach (UUID itemID in m_PrimObjects[localID]) + uuids = m_PrimObjects[localID]; + } + + foreach (UUID itemID in uuids) + { + IScriptInstance instance = null; + try { if (m_Scripts.ContainsKey(itemID)) - { - IScriptInstance instance = m_Scripts[itemID]; - if (instance != null) - { - instance.PostEvent(p); - result = true; - } - } + instance = m_Scripts[itemID]; + } + catch { /* ignore race conditions */ } + + if (instance != null) + { + instance.PostEvent(p); + result = true; } } + return result; } -- cgit v1.1 From c0d9ab941dd1ab88f00f6d4f2a53a4fe5c605e57 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 19 Jul 2010 16:22:29 -0700 Subject: Reverting this for now, but this needs to go in again. Revert "Another stab at http://opensimulator.org/mantis/view.php?id=4858. Eliminated more nested locks." This reverts commit ffbae52a130376ecaa04d7d475709985c62c06ed. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 64 +++++++++++--------------- 1 file changed, 28 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b050349..c436582 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - ScriptInstance instance = null; lock (m_Scripts) { + ScriptInstance instance = null; // Create the object record if ((!m_Scripts.ContainsKey(itemID)) || @@ -786,29 +786,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_Scripts[itemID] = instance; } - } - lock (m_PrimObjects) - { - if (!m_PrimObjects.ContainsKey(localID)) - m_PrimObjects[localID] = new List(); + lock (m_PrimObjects) + { + if (!m_PrimObjects.ContainsKey(localID)) + m_PrimObjects[localID] = new List(); - if (!m_PrimObjects[localID].Contains(itemID)) - m_PrimObjects[localID].Add(itemID); + if (!m_PrimObjects[localID].Contains(itemID)) + m_PrimObjects[localID].Add(itemID); - } + } - if (!m_Assemblies.ContainsKey(assetID)) - m_Assemblies[assetID] = assembly; + if (!m_Assemblies.ContainsKey(assetID)) + m_Assemblies[assetID] = assembly; - lock (m_AddingAssemblies) - { - m_AddingAssemblies[assembly]--; - } - - if (instance != null) - instance.Init(); + lock (m_AddingAssemblies) + { + m_AddingAssemblies[assembly]--; + } + if (instance!=null) + instance.Init(); + } return true; } @@ -1008,33 +1007,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine public bool PostObjectEvent(uint localID, EventParams p) { bool result = false; - List uuids = null; - + lock (m_PrimObjects) { if (!m_PrimObjects.ContainsKey(localID)) return false; - uuids = m_PrimObjects[localID]; - } - - foreach (UUID itemID in uuids) - { - IScriptInstance instance = null; - try + + foreach (UUID itemID in m_PrimObjects[localID]) { if (m_Scripts.ContainsKey(itemID)) - instance = m_Scripts[itemID]; - } - catch { /* ignore race conditions */ } - - if (instance != null) - { - instance.PostEvent(p); - result = true; + { + IScriptInstance instance = m_Scripts[itemID]; + if (instance != null) + { + instance.PostEvent(p); + result = true; + } + } } } - return result; } -- cgit v1.1 From b7f12883614ddfd253fd7020b1f9fec54023d58f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 20 Jul 2010 04:23:39 -0700 Subject: Adding it again. Revert "Reverting this for now, but this needs to go in again." This reverts commit c0d9ab941dd1ab88f00f6d4f2a53a4fe5c605e57. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 64 +++++++++++++++----------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c436582..b050349 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + ScriptInstance instance = null; lock (m_Scripts) { - ScriptInstance instance = null; // Create the object record if ((!m_Scripts.ContainsKey(itemID)) || @@ -786,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_Scripts[itemID] = instance; } + } - lock (m_PrimObjects) - { - if (!m_PrimObjects.ContainsKey(localID)) - m_PrimObjects[localID] = new List(); + lock (m_PrimObjects) + { + if (!m_PrimObjects.ContainsKey(localID)) + m_PrimObjects[localID] = new List(); - if (!m_PrimObjects[localID].Contains(itemID)) - m_PrimObjects[localID].Add(itemID); + if (!m_PrimObjects[localID].Contains(itemID)) + m_PrimObjects[localID].Add(itemID); - } + } - if (!m_Assemblies.ContainsKey(assetID)) - m_Assemblies[assetID] = assembly; + if (!m_Assemblies.ContainsKey(assetID)) + m_Assemblies[assetID] = assembly; - lock (m_AddingAssemblies) - { - m_AddingAssemblies[assembly]--; - } - - if (instance!=null) - instance.Init(); + lock (m_AddingAssemblies) + { + m_AddingAssemblies[assembly]--; } + + if (instance != null) + instance.Init(); + return true; } @@ -1007,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine public bool PostObjectEvent(uint localID, EventParams p) { bool result = false; - + List uuids = null; + lock (m_PrimObjects) { if (!m_PrimObjects.ContainsKey(localID)) return false; - - foreach (UUID itemID in m_PrimObjects[localID]) + uuids = m_PrimObjects[localID]; + } + + foreach (UUID itemID in uuids) + { + IScriptInstance instance = null; + try { if (m_Scripts.ContainsKey(itemID)) - { - IScriptInstance instance = m_Scripts[itemID]; - if (instance != null) - { - instance.PostEvent(p); - result = true; - } - } + instance = m_Scripts[itemID]; + } + catch { /* ignore race conditions */ } + + if (instance != null) + { + instance.PostEvent(p); + result = true; } } + return result; } -- cgit v1.1