Added data structure to be passed through event execution queue so that events can use llDetect*-commands to find information about event.

ThreadPoolClientBranch
Tedd Hansen 2008-01-17 15:22:35 +00:00
parent 18c959df12
commit 82d43db1cc
9 changed files with 85 additions and 47 deletions

View File

@ -26,6 +26,8 @@
*
*/
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
namespace OpenSim.Region.ScriptEngine.Common
{
public interface IScript
@ -34,5 +36,6 @@ namespace OpenSim.Region.ScriptEngine.Common
Executor Exec { get; }
string Source { get; set; }
void Start(LSL_BuiltIn_Commands_Interface BuiltIn_Commands);
EventQueueManager.Queue_llDetectParams_Struct llDetectParams { get; set; }
}
}

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Runtime.Remoting.Lifetime;
using System.Threading;
using OpenSim.Region.ScriptEngine.Common;
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
using integer = System.Int32;
using key = System.String;
using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3;
@ -64,6 +65,12 @@ namespace OpenSim.Region.ScriptEngine.Common
return lease;
}
public EventQueueManager.Queue_llDetectParams_Struct _llDetectParams;
EventQueueManager.Queue_llDetectParams_Struct IScript.llDetectParams
{
get { return _llDetectParams; }
set { _llDetectParams = value; }
}
private Executor m_Exec;
@ -127,6 +134,8 @@ namespace OpenSim.Region.ScriptEngine.Common
}
//
// DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
//

View File

@ -37,6 +37,7 @@ using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ScriptEngine.Common;
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
//using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
namespace OpenSim.Region.ScriptEngine.Common
@ -2368,7 +2369,7 @@ namespace OpenSim.Region.ScriptEngine.Common
{
LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID);
object[] resobj = new object[] { 1, channelID.ToString(), LLUUID.Zero.ToString(), String.Empty, 0, String.Empty };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", resobj);
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj);
}
}

View File

@ -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);
}
}
}

View File

@ -96,9 +96,30 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public uint localID;
public LLUUID itemID;
public string functionName;
public Queue_llDetectParams_Struct llDetectParams;
public object[] param;
}
/// <summary>
/// Shared empty llDetectNull
/// </summary>
public readonly static Queue_llDetectParams_Struct llDetectNull = new Queue_llDetectParams_Struct();
/// <summary>
/// Structure to hold data for llDetect* commands
/// </summary>
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;
}
/// <summary>
/// List of localID locks for mutex processing of script events
/// </summary>
@ -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
/// <summary>
/// Add event to event execution queue
/// </summary>
/// <param name="localID"></param>
/// <param name="localID">Region object ID</param>
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
/// <param name="param">Array of parameters to match event mask</param>
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);
}
}
/// <summary>
/// Add event to event execution queue
/// </summary>
/// <param name="localID"></param>
/// <param name="itemID"></param>
/// <param name="localID">Region object ID</param>
/// <param name="itemID">Region script ID</param>
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
/// <param name="param">Array of parameters to match event mask</param>
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

View File

@ -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
);
}
}

View File

@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <param name="itemID">Script ID</param>
/// <param name="FunctionName">Name of function</param>
/// <param name="args">Arguments to pass to function</param>
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);
}

View File

@ -36,6 +36,7 @@ using libsecondlife;
using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ScriptEngine.Common;
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
@ -99,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
CompiledScript.Start(LSLB);
// Fire the first start-event
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { });
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { });
}
catch (Exception e)
{

View File

@ -36,6 +36,7 @@ using libsecondlife;
using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ScriptEngine.Common;
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
namespace OpenSim.Region.ScriptEngine.LSOEngine
{
@ -96,7 +97,7 @@ namespace OpenSim.Region.ScriptEngine.LSOEngine
CompiledScript.Start(LSLB);
// Fire the first start-event
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { });
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { });
}
catch (Exception e)
{