From ce5122ebf3077085d1ca6967634b4e0baad94d6c Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 4 Jul 2008 00:59:38 +0000 Subject: Mantis#1659. Thank you, Melanie for a patch that: In LSL, the state command should have an immediate effect. The OpenSim script engine seems to wait until the function ends to process the state transition. --- .../Shared/Api/Implementation/LSL_Api.cs | 2 + OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 15 +++++ OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 67 ++++++++++++---------- 3 files changed, 53 insertions(+), 31 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 7887515..06f9f3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -99,6 +99,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void state(string newState) { m_ScriptEngine.SetState(m_itemID, newState); + throw new EventAbortException(); } public void llSay(int channelID, string text) @@ -2791,6 +2792,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); m_ScriptEngine.ApiResetScript(m_itemID); + throw new EventAbortException(); } public void llMessageLinked(int linknum, int num, string msg, string id) diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index fdd404d..28a2173 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -30,6 +30,7 @@ using System.IO; using System.Threading; using System.Collections; using System.Collections.Generic; +using System.Runtime.Serialization; using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Environment; @@ -37,6 +38,20 @@ using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.ScriptEngine.Shared { + [Serializable] + public class EventAbortException : Exception + { + public EventAbortException() + { + } + + protected EventAbortException( + SerializationInfo info, + StreamingContext context) + { + } + } + public class DetectParams { public DetectParams() diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 5e3b91a..cbc5112 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1296,44 +1296,49 @@ namespace OpenSim.Region.ScriptEngine.XEngine catch (Exception e) { m_InEvent = false; - if (e is System.Threading.ThreadAbortException) + m_CurrentEvent = String.Empty; + + if (!(e is TargetInvocationException) || !(e.InnerException is EventAbortException)) { - lock (m_EventQueue) + if (e is System.Threading.ThreadAbortException) { - if ((m_EventQueue.Count > 0) && m_RunEvents) + lock (m_EventQueue) { - m_CurrentResult=m_Engine.QueueEventHandler(this); - } - else - { - m_CurrentResult = null; + if ((m_EventQueue.Count > 0) && m_RunEvents) + { + m_CurrentResult=m_Engine.QueueEventHandler(this); + } + else + { + m_CurrentResult = null; + } } - } - m_DetectParams = null; + m_DetectParams = null; - return 0; - } + return 0; + } - try - { - // DISPLAY ERROR INWORLD - string text = "Runtime error:\n" + e.ToString(); - if (text.Length > 1400) - text = text.Substring(0, 1400); - m_Engine.World.SimChat(Helpers.StringToField(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); - } - catch (Exception e2) // LEGIT: User Scripting - { - m_Engine.Log.Error("[XEngine]: "+ - "Error displaying error in-world: " + - e2.ToString()); - m_Engine.Log.Error("[XEngine]: " + - "Errormessage: Error compiling script:\r\n" + - e.ToString()); + try + { + // DISPLAY ERROR INWORLD + string text = "Runtime error:\n" + e.ToString(); + if (text.Length > 1400) + text = text.Substring(0, 1400); + m_Engine.World.SimChat(Helpers.StringToField(text), + ChatTypeEnum.DebugChannel, 2147483647, + part.AbsolutePosition, + part.Name, part.UUID, false); + } + catch (Exception e2) // LEGIT: User Scripting + { + m_Engine.Log.Error("[XEngine]: "+ + "Error displaying error in-world: " + + e2.ToString()); + m_Engine.Log.Error("[XEngine]: " + + "Errormessage: Error compiling script:\r\n" + + e.ToString()); + } } } } -- cgit v1.1