Switches the direct event postings in the API file over to the Shared/

new style of parameter passing, using the IEventReceiver interface.
0.6.0-stable
Melanie Thielker 2008-09-23 20:02:32 +00:00
parent 0651efaafa
commit 88277366bf
4 changed files with 131 additions and 56 deletions

View File

@ -44,6 +44,7 @@ using OpenSim.Region.Environment.Modules.World.Land;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
using OpenSim.Region.ScriptEngine.Shared;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
@ -156,6 +157,59 @@ namespace OpenSim.Region.ScriptEngine.Common
return World.GetCommander(name); return World.GetCommander(name);
} }
private List<SceneObjectPart> GetLinkParts(int linkType)
{
List<SceneObjectPart> ret = new List<SceneObjectPart>();
ret.Add(m_host);
switch (linkType)
{
case BuiltIn_Commands_BaseClass.LINK_SET:
if (m_host.ParentGroup != null)
return new List<SceneObjectPart>(m_host.ParentGroup.Children.Values);
return ret;
case BuiltIn_Commands_BaseClass.LINK_ROOT:
if (m_host.ParentGroup != null)
{
ret = new List<SceneObjectPart>();
ret.Add(m_host.ParentGroup.RootPart);
return ret;
}
return ret;
case BuiltIn_Commands_BaseClass.LINK_ALL_OTHERS:
if (m_host.ParentGroup == null)
return new List<SceneObjectPart>();
ret = new List<SceneObjectPart>(m_host.ParentGroup.Children.Values);
if (ret.Contains(m_host))
ret.Remove(m_host);
return ret;
case BuiltIn_Commands_BaseClass.LINK_ALL_CHILDREN:
if (m_host.ParentGroup == null)
return new List<SceneObjectPart>();
ret = new List<SceneObjectPart>(m_host.ParentGroup.Children.Values);
if (ret.Contains(m_host.ParentGroup.RootPart))
ret.Remove(m_host.ParentGroup.RootPart);
return ret;
case BuiltIn_Commands_BaseClass.LINK_THIS:
return ret;
default:
if (linkType < 0 || m_host.ParentGroup == null)
return new List<SceneObjectPart>();
SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType);
if (target == null)
return new List<SceneObjectPart>();
ret = new List<SceneObjectPart>();
ret.Add(target);
return ret;
}
}
private UUID InventorySelf() private UUID InventorySelf()
{ {
UUID invItemID = new UUID(); UUID invItemID = new UUID();
@ -2431,19 +2485,22 @@ namespace OpenSim.Region.ScriptEngine.Common
// objects rezzed with this method are die_at_edge by default. // objects rezzed with this method are die_at_edge by default.
new_group.RootPart.SetDieAtEdge(true); new_group.RootPart.SetDieAtEdge(true);
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "object_rez", EventQueueManager.llDetectNull, new Object[] { new LSL_String(new_group.RootPart.ToString()) }); m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"object_rez", new Object[] {
new LSL_String(
new_group.RootPart.UUID.ToString()) },
new DetectParams[0]));
float groupmass = new_group.GetMass(); float groupmass = new_group.GetMass();
//Recoil. //Recoil.
llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
found = true;
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
ScriptSleep((int)((groupmass * velmag) / 10)); ScriptSleep((int)((groupmass * velmag) / 10));
// ScriptSleep(100); // ScriptSleep(100);
break; return;
} }
} }
if (!found)
llSay(0, "Could not find object " + inventory); llSay(0, "Could not find object " + inventory);
} }
@ -2807,8 +2864,10 @@ namespace OpenSim.Region.ScriptEngine.Common
m_host.TaskInventory[invItemID].PermsGranter=UUID.Zero; m_host.TaskInventory[invItemID].PermsGranter=UUID.Zero;
m_host.TaskInventory[invItemID].PermsMask=0; m_host.TaskInventory[invItemID].PermsMask=0;
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Integer(0)}); "run_time_permissions", new Object[] {
new LSL_Integer(0) },
new DetectParams[0]));
return; return;
} }
@ -2831,8 +2890,10 @@ namespace OpenSim.Region.ScriptEngine.Common
m_host.TaskInventory[invItemID].PermsGranter=agentID; m_host.TaskInventory[invItemID].PermsGranter=agentID;
m_host.TaskInventory[invItemID].PermsMask=perm; m_host.TaskInventory[invItemID].PermsMask=perm;
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Integer(perm)}); "run_time_permissions", new Object[] {
new LSL_Integer(perm) },
new DetectParams[0]));
return; return;
} }
@ -2849,8 +2910,10 @@ namespace OpenSim.Region.ScriptEngine.Common
m_host.TaskInventory[invItemID].PermsGranter=agentID; m_host.TaskInventory[invItemID].PermsGranter=agentID;
m_host.TaskInventory[invItemID].PermsMask=perm; m_host.TaskInventory[invItemID].PermsMask=perm;
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Integer(perm)}); "run_time_permissions", new Object[] {
new LSL_Integer(perm) },
new DetectParams[0]));
return; return;
} }
@ -2877,8 +2940,10 @@ namespace OpenSim.Region.ScriptEngine.Common
} }
// Requested agent is not in range, refuse perms // Requested agent is not in range, refuse perms
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Integer(0)}); "run_time_permissions", new Object[] {
new LSL_Integer(0) },
new DetectParams[0]));
} }
void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer)
@ -2894,9 +2959,14 @@ namespace OpenSim.Region.ScriptEngine.Common
client.OnScriptAnswer-=handleScriptAnswer; client.OnScriptAnswer-=handleScriptAnswer;
m_waitingForScriptAnswer=false; m_waitingForScriptAnswer=false;
if ((answer & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) == 0)
llReleaseControls();
m_host.TaskInventory[invItemID].PermsMask=answer; m_host.TaskInventory[invItemID].PermsMask=answer;
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Integer(answer)}); "run_time_permissions", new Object[] {
new LSL_Integer(answer) },
new DetectParams[0]));
} }
public LSL_String llGetPermissionsKey() public LSL_String llGetPermissionsKey()
@ -3515,9 +3585,9 @@ namespace OpenSim.Region.ScriptEngine.Common
new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id) new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
}; };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(partItemID,
partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj new EventParams("link_message",
); resobj, new DetectParams[0]));
} }
} }
@ -3532,16 +3602,16 @@ namespace OpenSim.Region.ScriptEngine.Common
{ {
if (item.Type == 10) if (item.Type == 10)
{ {
partLocalID = partInst.LocalId; // partLocalID = partInst.LocalId;
partItemID = item.ItemID; partItemID = item.ItemID;
Object[] resobj = new object[] Object[] resobj = new object[]
{ {
new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id) new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
}; };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(partItemID,
partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj new EventParams("link_message",
); resobj, new DetectParams[0]));
} }
} }
} }
@ -3560,16 +3630,16 @@ namespace OpenSim.Region.ScriptEngine.Common
{ {
if (item.Type == 10) if (item.Type == 10)
{ {
partLocalID = partInst.LocalId; // partLocalID = partInst.LocalId;
partItemID = item.ItemID; partItemID = item.ItemID;
Object[] resobj = new object[] Object[] resobj = new object[]
{ {
new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id) new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
}; };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(partItemID,
partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj new EventParams("link_message",
); resobj, new DetectParams[0]));
} }
} }
@ -3590,16 +3660,16 @@ namespace OpenSim.Region.ScriptEngine.Common
{ {
if (item.Type == 10) if (item.Type == 10)
{ {
partLocalID = partInst.LocalId; // partLocalID = partInst.LocalId;
partItemID = item.ItemID; partItemID = item.ItemID;
Object[] resobj = new object[] Object[] resobj = new object[]
{ {
new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id) new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
}; };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(partItemID,
partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj new EventParams("link_message",
); resobj, new DetectParams[0]));
} }
} }
@ -3621,9 +3691,9 @@ namespace OpenSim.Region.ScriptEngine.Common
new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id) new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
}; };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(partItemID,
m_localID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj new EventParams("link_message",
); resobj, new DetectParams[0]));
} }
} }
@ -3641,16 +3711,16 @@ namespace OpenSim.Region.ScriptEngine.Common
{ {
if (item.Type == 10) if (item.Type == 10)
{ {
partLocalID = partInst.LocalId; // partLocalID = partInst.LocalId;
partItemID = item.ItemID; partItemID = item.ItemID;
Object[] resObjDef = new object[] Object[] resObjDef = new object[]
{ {
new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id) new LSL_Integer(m_host.LinkNum), new LSL_Integer(num), new LSL_String(msg), new LSL_String(id)
}; };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( m_ScriptEngine.PostScriptEvent(partItemID,
partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resObjDef new EventParams("link_message",
); resObjDef, new DetectParams[0]));
} }
} }
@ -5589,7 +5659,9 @@ namespace OpenSim.Region.ScriptEngine.Common
{ {
UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero);
object[] resobj = new object[] { new LSL_Integer(1), new LSL_String(channelID.ToString()), new LSL_String(UUID.Zero.ToString()), new LSL_String(String.Empty), new LSL_Integer(0), new LSL_String(String.Empty) }; object[] resobj = new object[] { new LSL_Integer(1), new LSL_String(channelID.ToString()), new LSL_String(UUID.Zero.ToString()), new LSL_String(String.Empty), new LSL_Integer(0), new LSL_String(String.Empty) };
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj); m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"remote_data", resobj,
new DetectParams[0]));
} }
// ScriptSleep(1000); // ScriptSleep(1000);
} }

View File

@ -355,10 +355,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
/// <param name="param">Array of parameters to match event mask</param> /// <param name="param">Array of parameters to match event mask</param>
public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param)
{ {
List<UUID> keylist = new List<UUID>(m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID)); List<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
System.Console.WriteLine("==> got {0} keys", keylist.Count);
if (!keylist.Contains(itemID)) // We don't manage that script if (!keylist.Contains(itemID)) // We don't manage that script
{
System.Console.WriteLine("==> Script not found");
return false; return false;
}
lock (eventQueue) lock (eventQueue)
{ {
@ -379,6 +383,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
// Add it to queue // Add it to queue
eventQueue.Enqueue(QIS); eventQueue.Enqueue(QIS);
System.Console.WriteLine("==> PostedEvent");
} }
return true; return true;
} }

View File

@ -197,7 +197,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public bool PostScriptEvent(UUID itemID, EventParams p) public bool PostScriptEvent(UUID itemID, EventParams p)
{ {
return m_EventQueueManager.AddToScriptQueue(0, itemID, p.EventName, EventQueueManager.llDetectNull, p.Params); uint localID = m_ScriptManager.GetLocalID(itemID);
return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, EventQueueManager.llDetectNull, p.Params);
} }
#endregion #endregion

View File

@ -341,6 +341,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
Script.Exec.ExecuteEvent(FunctionName, args); Script.Exec.ExecuteEvent(FunctionName, args);
} }
public uint GetLocalID(UUID itemID)
{
foreach (KeyValuePair<uint, Dictionary<UUID, IScript> > k in Scripts)
{
if (k.Value.ContainsKey(itemID))
return k.Key;
}
return 0;
}
public int GetStateEventFlags(uint localID, UUID itemID) public int GetStateEventFlags(uint localID, UUID itemID)
{ {
// Console.WriteLine("GetStateEventFlags for <" + localID + "," + itemID + ">"); // Console.WriteLine("GetStateEventFlags for <" + localID + "," + itemID + ">");
@ -368,22 +378,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
public List<UUID> GetScriptKeys(uint localID) public List<UUID> GetScriptKeys(uint localID)
{ {
if (localID == 0) // Find it
{
List<UUID> keylist = new List<UUID>();
foreach (Dictionary<UUID, IScript> d in Scripts.Values)
{
foreach (UUID id in d.Keys)
{
if (!keylist.Contains(id))
keylist.Add(id);
}
}
}
if (Scripts.ContainsKey(localID) == false) if (Scripts.ContainsKey(localID) == false)
return null; return new List<UUID>();
Dictionary<UUID, IScript> Obj; Dictionary<UUID, IScript> Obj;
Scripts.TryGetValue(localID, out Obj); Scripts.TryGetValue(localID, out Obj);
@ -395,6 +391,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
{ {
lock (scriptLock) lock (scriptLock)
{ {
IScript Script = null;
if (Scripts.ContainsKey(localID) == false) if (Scripts.ContainsKey(localID) == false)
return null; return null;
@ -404,7 +402,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
return null; return null;
// Get script // Get script
IScript Script;
Obj.TryGetValue(itemID, out Script); Obj.TryGetValue(itemID, out Script);
return Script; return Script;
} }