From 82d43db1ccbc2b13e21c88650165f82651b657e1 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Thu, 17 Jan 2008 15:22:35 +0000 Subject: Added data structure to be passed through event execution queue so that events can use llDetect*-commands to find information about event. --- .../Common/ScriptEngineBase/EventManager.cs | 64 +++++++++++----------- .../Common/ScriptEngineBase/EventQueueManager.cs | 36 +++++++++--- .../Common/ScriptEngineBase/LSLLongCmdHandler.cs | 8 +-- .../Common/ScriptEngineBase/ScriptManager.cs | 3 +- 4 files changed, 67 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase') diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index a32a132..250a5df 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -76,13 +76,13 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void changed(uint localID, uint change) { // Add to queue for all scripts in localID, Object pass change. - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID,"changed", new object[] {(int) change}); + myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "changed", EventQueueManager.llDetectNull, new object[] { (int)change }); } public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1}); + myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", EventQueueManager.llDetectNull, new object[] { (int)1 }); } public void OnRezScript(uint localID, LLUUID itemID, string script) @@ -109,47 +109,47 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void state_exit(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit", EventQueueManager.llDetectNull); } public void touch(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch", EventQueueManager.llDetectNull); } public void touch_end(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull); } public void collision_start(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start", EventQueueManager.llDetectNull); } public void collision(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision", EventQueueManager.llDetectNull); } public void collision_end(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end", EventQueueManager.llDetectNull); } public void land_collision_start(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start", EventQueueManager.llDetectNull); } public void land_collision(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision", EventQueueManager.llDetectNull); } public void land_collision_end(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end", EventQueueManager.llDetectNull); } // Handled by long commands @@ -160,108 +160,108 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void listen(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen", EventQueueManager.llDetectNull); } public void on_rez(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull); } public void sensor(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor", EventQueueManager.llDetectNull); } public void no_sensor(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor", EventQueueManager.llDetectNull); } public void control(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull); } public void money(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money", EventQueueManager.llDetectNull); } public void email(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email", EventQueueManager.llDetectNull); } public void at_target(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target", EventQueueManager.llDetectNull); } public void not_at_target(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target", EventQueueManager.llDetectNull); } public void at_rot_target(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target", EventQueueManager.llDetectNull); } public void not_at_rot_target(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target", EventQueueManager.llDetectNull); } public void run_time_permissions(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions", EventQueueManager.llDetectNull); } public void changed(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed", EventQueueManager.llDetectNull); } public void attach(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach", EventQueueManager.llDetectNull); } public void dataserver(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver", EventQueueManager.llDetectNull); } public void link_message(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message", EventQueueManager.llDetectNull); } public void moving_start(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start", EventQueueManager.llDetectNull); } public void moving_end(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end", EventQueueManager.llDetectNull); } public void object_rez(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez", EventQueueManager.llDetectNull); } public void remote_data(uint localID, LLUUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data"); + myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data", EventQueueManager.llDetectNull); } // Handled by long commands public void http_response(uint localID, LLUUID itemID) { - // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response"); + // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response", EventQueueManager.llDetectNull); } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs index af91027..ced4863 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs @@ -96,10 +96,31 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public uint localID; public LLUUID itemID; public string functionName; + public Queue_llDetectParams_Struct llDetectParams; public object[] param; } /// + /// Shared empty llDetectNull + /// + public readonly static Queue_llDetectParams_Struct llDetectNull = new Queue_llDetectParams_Struct(); + + /// + /// Structure to hold data for llDetect* commands + /// + public struct Queue_llDetectParams_Struct + { + // More or less just a placeholder for the actual moving of additional data + // should be fixed to something better :) + public LSL_Types.key[] _key; + public LSL_Types.Quaternion[] _Quaternion; + public LSL_Types.Vector3[] _Vector3; + public bool[] _bool; + public int[] _int; + public string [] _string; + } + + /// /// List of localID locks for mutex processing of script events /// private List objectLocks = new List(); @@ -211,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase + ", QIS.functionName: " + QIS.functionName); #endif m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, - QIS.functionName, QIS.param); + QIS.functionName, QIS.llDetectParams, QIS.param); } catch (Exception e) { @@ -311,10 +332,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// /// Add event to event execution queue /// - /// + /// Region object ID /// Name of the function, will be state + "_event_" + FunctionName /// Array of parameters to match event mask - public void AddToObjectQueue(uint localID, string FunctionName, params object[] param) + public void AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) { // Determine all scripts in Object and add to their queue //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); @@ -334,18 +355,18 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { // Add to each script in that object // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter? - AddToScriptQueue(localID, itemID, FunctionName, param); + AddToScriptQueue(localID, itemID, FunctionName, qParams, param); } } /// /// Add event to event execution queue /// - /// - /// + /// Region object ID + /// Region script ID /// Name of the function, will be state + "_event_" + FunctionName /// Array of parameters to match event mask - public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, params object[] param) + public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) { lock (queueLock) { @@ -354,6 +375,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase QIS.localID = localID; QIS.itemID = itemID; QIS.functionName = FunctionName; + QIS.llDetectParams = qParams; QIS.param = param; // Add it to queue diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/LSLLongCmdHandler.cs index 7271d72..7d66638 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/LSLLongCmdHandler.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) { // Add it to queue - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, new object[] {}); // set next interval @@ -230,7 +230,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - httpInfo.localID, httpInfo.itemID, "http_response", resobj + httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj ); httpInfo.Stop(); @@ -264,7 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase rInfo.GetStrVal() }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj + rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj ); } } @@ -287,7 +287,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj + lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj ); } } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index 784e849..ea87581 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// Script ID /// Name of function /// Arguments to pass to function - internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args) + internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, EventQueueManager.Queue_llDetectParams_Struct qParams, object[] args) { #if DEBUG Console.WriteLine("ScriptEngine: Inside ExecuteEvent for event " + FunctionName); @@ -247,6 +247,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); #endif // Must be done in correct AppDomain, so leaving it up to the script itself + Script.llDetectParams = qParams; Script.Exec.ExecuteEvent(FunctionName, args); } -- cgit v1.1