From c803e0cca1ef1e81bec4dcd615aea955f3756b19 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 1 May 2008 16:39:02 +0000 Subject: * Deletes my EventReader ScriptRewriter. It isn't required to rewrite the script to publish the events anymore. * Introduces a language(regex) independent event recognizer and publishes the events the script listens. --- OpenSim/Region/ScriptEngine/Common/Executor.cs | 39 ++ OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | 101 ++++- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 3 +- .../Common/ScriptEngineBase/ScriptManager.cs | 23 + .../DotNetEngine/Compiler/LSL/Compiler.cs | 2 +- .../Compiler/LSL/EventReaderRewriter.cs | 488 --------------------- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 2 + .../Region/ScriptEngine/LSOEngine/ScriptManager.cs | 2 + 8 files changed, 166 insertions(+), 494 deletions(-) delete mode 100644 OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 8e0d6f1..56baa66 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -35,9 +35,48 @@ namespace OpenSim.Region.ScriptEngine.Common { // Cache functions by keeping a reference to them in a dictionary private Dictionary Events = new Dictionary(); + private Dictionary m_stateEvents = new Dictionary(); public Executor(IScript script) : base(script) { + initEventFlags(); + } + + + protected override scriptEvents DoGetStateEventFlags() + { + // Console.WriteLine("Get event flags for " + m_Script.State); + + // Check to see if we've already computed the flags for this state + scriptEvents eventFlags = scriptEvents.None; + if (m_stateEvents.ContainsKey(m_Script.State)) + { + m_stateEvents.TryGetValue(m_Script.State, out eventFlags); + return eventFlags; + } + + // Fill in the events for this state, cache the results in the map + foreach (KeyValuePair kvp in m_eventFlagsMap) + { + string evname = m_Script.State + "_event_" + kvp.Key; + Type type = m_Script.GetType(); + try + { + MethodInfo mi = type.GetMethod(evname); + if (mi != null) + { + // Console.WriteLine("Found handler for " + kvp.Key); + eventFlags |= kvp.Value; + } + } + catch + { + } + } + + // Save the flags we just computed and return the result + m_stateEvents.Add(m_Script.State, eventFlags); + return (eventFlags); } protected override void DoExecuteEvent(string FunctionName, object[] args) diff --git a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs index 19fb487..2e35b46 100644 --- a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs +++ b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Runtime.Remoting.Lifetime; namespace OpenSim.Region.ScriptEngine.Common @@ -54,10 +55,46 @@ namespace OpenSim.Region.ScriptEngine.Common public bool Running { get { return m_Running; } - set { - if(!m_Disable) - m_Running = value; - } + set + { + if (!m_Disable) + m_Running = value; + } + } + + protected Dictionary m_eventFlagsMap = new Dictionary(); + + [Flags] + public enum scriptEvents : int + { + None = 0, + attach = 1, + collision = 15, + collision_end = 32, + collision_start = 64, + control = 128, + dataserver = 256, + email = 512, + http_response = 1024, + land_collision = 2048, + land_collision_end = 4096, + land_collision_start = 8192, + at_target = 16384, + listen = 32768, + money = 65536, + moving_end = 131072, + moving_start = 262144, + not_at_rot_target = 524288, + not_at_target = 1048576, + remote_data = 8388608, + run_time_permissions = 268435456, + state_entry = 1073741824, + state_exit = 2, + timer = 4, + touch = 8, + touch_end = 536870912, + touch_start = 2097152, + object_rez = 4194304 } /// @@ -67,6 +104,7 @@ namespace OpenSim.Region.ScriptEngine.Common public ExecutorBase(IScript Script) { m_Script = Script; + initEventFlags(); } /// @@ -111,9 +149,21 @@ namespace OpenSim.Region.ScriptEngine.Common } DoExecuteEvent(FunctionName, args); } + protected abstract void DoExecuteEvent(string FunctionName, object[] args); /// + /// Compute the events handled by the current state of the script + /// + /// state mask + public scriptEvents GetStateEventFlags() + { + return DoGetStateEventFlags(); + } + + protected abstract scriptEvents DoGetStateEventFlags(); + + /// /// Stop script from running. Event execution will be ignored. /// public void StopScript() @@ -121,5 +171,48 @@ namespace OpenSim.Region.ScriptEngine.Common m_Running = false; m_Disable = true; } + + protected void initEventFlags() + { + // Initialize the table if it hasn't already been done + if (m_eventFlagsMap.Count > 0) + { + return; + } + + m_eventFlagsMap.Add("attach", scriptEvents.attach); + // m_eventFlagsMap.Add("at_rot_target",(long)scriptEvents.at_rot_target); + m_eventFlagsMap.Add("at_target", scriptEvents.at_target); + // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed); + m_eventFlagsMap.Add("collision", scriptEvents.collision); + m_eventFlagsMap.Add("collision_end", scriptEvents.collision_end); + m_eventFlagsMap.Add("collision_start", scriptEvents.collision_start); + m_eventFlagsMap.Add("control", scriptEvents.control); + m_eventFlagsMap.Add("dataserver", scriptEvents.dataserver); + m_eventFlagsMap.Add("email", scriptEvents.email); + m_eventFlagsMap.Add("http_response", scriptEvents.http_response); + m_eventFlagsMap.Add("land_collision", scriptEvents.land_collision); + m_eventFlagsMap.Add("land_collision_end", scriptEvents.land_collision_end); + m_eventFlagsMap.Add("land_collision_start", scriptEvents.land_collision_start); + // m_eventFlagsMap.Add("link_message",scriptEvents.link_message); + m_eventFlagsMap.Add("listen", scriptEvents.listen); + m_eventFlagsMap.Add("money", scriptEvents.money); + m_eventFlagsMap.Add("moving_end", scriptEvents.moving_end); + m_eventFlagsMap.Add("moving_start", scriptEvents.moving_start); + m_eventFlagsMap.Add("not_at_rot_target", scriptEvents.not_at_rot_target); + m_eventFlagsMap.Add("not_at_target", scriptEvents.not_at_target); + // m_eventFlagsMap.Add("no_sensor",(long)scriptEvents.no_sensor); + // m_eventFlagsMap.Add("on_rez",(long)scriptEvents.on_rez); + m_eventFlagsMap.Add("remote_data", scriptEvents.remote_data); + m_eventFlagsMap.Add("run_time_permissions", scriptEvents.run_time_permissions); + // m_eventFlagsMap.Add("sensor",(long)scriptEvents.sensor); + m_eventFlagsMap.Add("state_entry", scriptEvents.state_entry); + m_eventFlagsMap.Add("state_exit", scriptEvents.state_exit); + m_eventFlagsMap.Add("timer", scriptEvents.timer); + m_eventFlagsMap.Add("touch", scriptEvents.touch); + m_eventFlagsMap.Add("touch_end", scriptEvents.touch_end); + m_eventFlagsMap.Add("touch_start", scriptEvents.touch_start); + m_eventFlagsMap.Add("object_rez", scriptEvents.object_rez); + } } } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 31ca3f3..419ca8f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -92,8 +92,9 @@ namespace OpenSim.Region.ScriptEngine.Common m_state = value; try { + int eventFlags = m_ScriptEngine.m_ScriptManager.GetStateEventFlags(m_localID, m_itemID); + m_host.SetScriptEvents(m_itemID, eventFlags); m_ScriptEngine.m_EventManager.state_entry(m_localID); - } catch (AppDomainUnloadedException) { diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index cd2e530..7812c8c 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -319,6 +319,29 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase Script.Exec.ExecuteEvent(FunctionName, args); } + public int GetStateEventFlags(uint localID, LLUUID itemID) + { + // Console.WriteLine("GetStateEventFlags for <" + localID + "," + itemID + ">"); + try + { + IScript Script = GetScript(localID, itemID); + if (Script == null) + { + return 0; + } + ExecutorBase.scriptEvents evflags = Script.Exec.GetStateEventFlags(); + return (int)evflags; + } + catch (Exception e) + { + // Console.WriteLine("Failed to get script reference for <" + localID + "," + itemID + ">"); + // Console.WriteLine(e.ToString()); + } + + return 0; + } + + #endregion #region Internal functions to keep track of script diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index dad1b23..944f9e7 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL private static string CreateCSCompilerScript(string compileScript) { - compileScript = EventReaderRewriter.ReWriteScriptWithPublishedEventsCS(compileScript); + compileScript = String.Empty + "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs deleted file mode 100644 index 46ba850..0000000 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs +++ /dev/null @@ -1,488 +0,0 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL -{ - public static class EventReaderRewriter - { - - - public static string ReWriteScriptWithPublishedEventsCS(string Script) - { - Dictionary state_events = new Dictionary(); - // Finds out which events are in the script and writes a method call with the events in each state_entry event - - // Note the (?:)? block optional, and not returning a group. Less greedy then .* - - string[] eventmatches = new string[0]; - //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{"); - eventmatches = Regex.Split(Script, @"public void\s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^\{]+)?\{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); - for (int pos = 0; pos < eventmatches.GetUpperBound(0); pos++) - { - pos++; // garbage - - string statea = eventmatches[pos]; pos++; - string eventa = eventmatches[pos]; - scriptEvents storedEventsForState = scriptEvents.None; - if (state_events.ContainsKey(statea)) - { - storedEventsForState = state_events[statea]; - state_events[statea] |= convertnametoFlag(eventa); - } - else - { - state_events.Add(statea, convertnametoFlag(eventa)); - } - Console.WriteLine("State:" + statea + ", event: " + eventa); - } - Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0)); - // Add namespace, class name and inheritance - - // Looking *ONLY* for state entry events - string scriptCopy = ""; - - //Only match State_Entry events now - // Note the whole regex is a group, then we have the state this entry belongs to. - eventmatches = Regex.Split(Script, @"(public void\s([^_]+)_event_state_entry[\(\)](?:[^\{]+)?\{)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); - int endloop = eventmatches.GetUpperBound(0); - - // Add all the states to a list of - List unUsedStates = new List(); - - foreach (string state in state_events.Keys) - { - unUsedStates.Add(state); - } - - // If endloop is 0, then there are no state entry events in the entire script. - // Stick a default state entry in there. - if (endloop == 0) - { - if (state_events.ContainsKey("default")) - { - scriptCopy = "public void default_event_state_entry() {osSetStateEvents((int)" + (int)state_events["default"] + "); } " + Script; - unUsedStates.Remove("default"); - } - else - { - throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details."); - } - } - - // Loop over state entry events and rewrite the first line to define the events the state listens for. - for (int pos = 0; pos < endloop; pos++) - { - // Returns text before state entry match, - scriptCopy += eventmatches[pos]; pos++; - - // Returns text of state entry match, - scriptCopy += eventmatches[pos]; pos++; - - // Returns which state we're matching and writes a method call to the end of the above state_entry - scriptCopy += "osSetStateEvents((int)" + (int)state_events[eventmatches[pos]] + ");"; //pos++; - - // Remove the state from the unused list. There might be more states matched then defined, so we - // check if the state was defined first - if (unUsedStates.Contains(eventmatches[pos])) - unUsedStates.Remove(eventmatches[pos]); - - // adds the remainder of the script. - if ((pos + 1) == endloop) - { - pos++; - scriptCopy += eventmatches[pos++]; - } - - } - - // states with missing state_entry blocks won't publish their events, - // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event - foreach (string state in unUsedStates) - { - // Write the remainder states out into a blank state entry with the event setting routine - scriptCopy = "public void " + state + "_event_state_entry() {tosSetStateEvents((int)" + (int)state_events[state] + ");} " + scriptCopy; - } - - // save modified script. - unUsedStates.Clear(); - state_events.Clear(); - return scriptCopy; - } - - public static string ReWriteScriptWithPublishedEventsJS(string Script) - { - Dictionary state_events = new Dictionary(); - // Finds out which events are in the script and writes a method call with the events in each state_entry event - - // Note the (?:)? block optional, and not returning a group. Less greedy then .* - - string[] eventmatches = new string[0]; - //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{"); - eventmatches = Regex.Split(Script, @"function \s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^\{]+)?\{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); - for (int pos = 0; pos < eventmatches.GetUpperBound(0); pos++) - { - pos++; // garbage - - string statea = eventmatches[pos]; pos++; - string eventa = eventmatches[pos]; - scriptEvents storedEventsForState = scriptEvents.None; - if (state_events.ContainsKey(statea)) - { - storedEventsForState = state_events[statea]; - state_events[statea] |= convertnametoFlag(eventa); - } - else - { - state_events.Add(statea, convertnametoFlag(eventa)); - } - Console.WriteLine("State:" + statea + ", event: " + eventa); - } - Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0)); - // Add namespace, class name and inheritance - - // Looking *ONLY* for state entry events - string scriptCopy = ""; - - //Only match State_Entry events now - // Note the whole regex is a group, then we have the state this entry belongs to. - eventmatches = Regex.Split(Script, @"(function \s([^_]+)_event_state_entry[\(\)](?:[^\{]+)?\{)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); - int endloop = eventmatches.GetUpperBound(0); - - // Add all the states to a list of - List unUsedStates = new List(); - - foreach (string state in state_events.Keys) - { - unUsedStates.Add(state); - } - - // If endloop is 0, then there are no state entry events in the entire script. - // Stick a default state entry in there. - if (endloop == 0) - { - if (state_events.ContainsKey("default")) - { - scriptCopy = "function default_event_state_entry() {osSetStateEvents(" + (int)state_events["default"] + "); } " + Script; - unUsedStates.Remove("default"); - } - else - { - throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details."); - } - } - - // Loop over state entry events and rewrite the first line to define the events the state listens for. - for (int pos = 0; pos < endloop; pos++) - { - // Returns text before state entry match, - scriptCopy += eventmatches[pos]; pos++; - - // Returns text of state entry match, - scriptCopy += eventmatches[pos]; pos++; - - // Returns which state we're matching and writes a method call to the end of the above state_entry - scriptCopy += "osSetStateEvents(" + (int)state_events[eventmatches[pos]] + ");"; //pos++; - - // Remove the state from the unused list. There might be more states matched then defined, so we - // check if the state was defined first - if (unUsedStates.Contains(eventmatches[pos])) - unUsedStates.Remove(eventmatches[pos]); - - // adds the remainder of the script. - if ((pos + 1) == endloop) - { - pos++; - scriptCopy += eventmatches[pos++]; - } - - } - - // states with missing state_entry blocks won't publish their events, - // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event - foreach (string state in unUsedStates) - { - // Write the remainder states out into a blank state entry with the event setting routine - scriptCopy = "function " + state + "_event_state_entry() {tosSetStateEvents(" + (int)state_events[state] + ");} " + scriptCopy; - } - - // save modified script. - unUsedStates.Clear(); - state_events.Clear(); - return scriptCopy; - } - - - public static string ReWriteScriptWithPublishedEventsVB(string Script) - { - Dictionary state_events = new Dictionary(); - // Finds out which events are in the script and writes a method call with the events in each state_entry event - - // Note the (?:)? block optional, and not returning a group. Less greedy then .* - - string[] eventmatches = new string[0]; - //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{"); - eventmatches = Regex.Split(Script, @"Public Sub\s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^()])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); - for (int pos = 0; pos < eventmatches.GetUpperBound(0); pos++) - { - pos++; // garbage - - string statea = eventmatches[pos]; pos++; - string eventa = eventmatches[pos]; - scriptEvents storedEventsForState = scriptEvents.None; - if (state_events.ContainsKey(statea)) - { - storedEventsForState = state_events[statea]; - state_events[statea] |= convertnametoFlag(eventa); - } - else - { - state_events.Add(statea, convertnametoFlag(eventa)); - } - Console.WriteLine("State:" + statea + ", event: " + eventa); - } - Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0)); - // Add namespace, class name and inheritance - - // Looking *ONLY* for state entry events - string scriptCopy = ""; - - //Only match State_Entry events now - // Note the whole regex is a group, then we have the state this entry belongs to. - eventmatches = Regex.Split(Script, @"(Public Sub\s([^_]+)_event_state_entry(?:\s+)?\(\))", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase); - int endloop = eventmatches.GetUpperBound(0); - - // Add all the states to a list of - List unUsedStates = new List(); - - foreach (string state in state_events.Keys) - { - unUsedStates.Add(state); - } - - // If endloop is 0, then there are no state entry events in the entire script. - // Stick a default state entry in there. - if (endloop == 0) - { - if (state_events.ContainsKey("default")) - { - scriptCopy = "function default_event_state_entry() {osSetStateEvents(" + (int)state_events["default"] + "); } " + Script; - unUsedStates.Remove("default"); - } - else - { - throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details."); - } - } - - // Loop over state entry events and rewrite the first line to define the events the state listens for. - for (int pos = 0; pos < endloop; pos++) - { - // Returns text before state entry match, - scriptCopy += eventmatches[pos]; pos++; - - // Returns text of state entry match, - scriptCopy += eventmatches[pos]; pos++; - - // Returns which state we're matching and writes a method call to the end of the above state_entry - scriptCopy += "osSetStateEvents(" + (int)state_events[eventmatches[pos]] + ");"; //pos++; - - // Remove the state from the unused list. There might be more states matched then defined, so we - // check if the state was defined first - if (unUsedStates.Contains(eventmatches[pos])) - unUsedStates.Remove(eventmatches[pos]); - - // adds the remainder of the script. - if ((pos + 1) == endloop) - { - pos++; - scriptCopy += eventmatches[pos++]; - } - - } - - // states with missing state_entry blocks won't publish their events, - // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event - foreach (string state in unUsedStates) - { - // Write the remainder states out into a blank state entry with the event setting routine - scriptCopy = "function " + state + "_event_state_entry() {tosSetStateEvents(" + (int)state_events[state] + ");} " + scriptCopy; - } - - // save modified script. - unUsedStates.Clear(); - state_events.Clear(); - return scriptCopy; - } - - - private static scriptEvents convertnametoFlag(string eventname) - { - switch (eventname) - { - case "attach": - return scriptEvents.attach; - //break; - // case "at_rot_target": - //return (long)scriptEvents.at_rot_target; - //break; - case "at_target": - return scriptEvents.at_target; - //break; - //case "changed": - //return (long)scriptEvents.changed; - //break; - case "collision": - return scriptEvents.collision; - // break; - case "collision_end": - return scriptEvents.collision_end; - //break; - case "collision_start": - return scriptEvents.collision_start; - // break; - case "control": - return scriptEvents.control; - //break; - case "dataserver": - return scriptEvents.dataserver; - // break; - case "email": - return scriptEvents.email; - // break; - case "http_response": - return scriptEvents.http_response; - // break; - case "land_collision": - return scriptEvents.land_collision; - // break; - case "land_collision_end": - return scriptEvents.land_collision_end; - // break; - case "land_collision_start": - return scriptEvents.land_collision_start; - // break; - //case "link_message": - //return scriptEvents.link_message; - // break; - case "listen": - return scriptEvents.listen; - // break; - case "money": - return scriptEvents.money; - // break; - case "moving_end": - return scriptEvents.moving_end; - // break; - case "moving_start": - return scriptEvents.moving_start; - // break; - case "not_at_rot_target": - return scriptEvents.not_at_rot_target; - // break; - case "not_at_target": - return scriptEvents.not_at_target; - // break; - // case "no_sensor": - //return (long)scriptEvents.no_sensor; - //break; - //case "on_rez": - //return (long)scriptEvents.on_rez; - // break; - case "remote_data": - return scriptEvents.remote_data; - // break; - case "run_time_permissions": - return scriptEvents.run_time_permissions; - // break; - //case "sensor": - //return (long)scriptEvents.sensor; - // break; - case "state_entry": - return scriptEvents.state_entry; - // break; - case "state_exit": - return scriptEvents.state_exit; - // break; - case "timer": - return scriptEvents.timer; - // break; - case "touch": - return scriptEvents.touch; - // break; - case "touch_end": - return scriptEvents.touch_end; - // break; - case "touch_start": - return scriptEvents.touch_start; - // break; - case "object_rez": - return scriptEvents.object_rez; - default: - return 0; - //break; - } - //return 0; - } - } - [Flags] - public enum scriptEvents : int - { - None = 0, - attach = 1, - collision = 15, - collision_end = 32, - collision_start = 64, - control = 128, - dataserver = 256, - email = 512, - http_response = 1024, - land_collision = 2048, - land_collision_end = 4096, - land_collision_start = 8192, - at_target = 16384, - listen = 32768, - money = 65536, - moving_end = 131072, - moving_start = 262144, - not_at_rot_target = 524288, - not_at_target = 1048576, - remote_data = 8388608, - run_time_permissions = 268435456, - state_entry = 1073741824, - state_exit = 2, - timer = 4, - touch = 8, - touch_end = 536870912, - touch_start = 2097152, - object_rez = 4194304 - } -} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index e242748..32c98a8 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -101,6 +101,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript.Start(LSLB); // Fire the first start-event + int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID); + m_host.SetScriptEvents(itemID, eventFlags); m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); } catch (Exception e) // LEGIT: User Scripting diff --git a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs index 0434f55..20d1a58 100644 --- a/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/LSOEngine/ScriptManager.cs @@ -91,6 +91,8 @@ namespace OpenSim.Region.ScriptEngine.LSOEngine CompiledScript.Start(LSLB); // Fire the first start-event + int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID); + m_host.SetScriptEvents(itemID, eventFlags); m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); } catch (Exception e) // LEGIT - User Script Compilation -- cgit v1.1