From 5525a3ecb424ce6180198b5f4e440d6d5f065346 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 27 Aug 2008 22:53:58 +0000 Subject: [PATCH] Thank you, salahazar, for a patch that corrects the behavior of llDetectedLink(). Also a small refactor to remove an interface member from IScriptEngine. --- .../Region/Environment/Scenes/EventManager.cs | 12 ++-- .../Scenes/Scene.PacketHandlers.cs | 8 +-- .../Common/ScriptEngineBase/EventManager.cs | 8 +-- .../Common/ScriptServerInterfaces.cs | 6 +- .../ScriptEngine/Interfaces/IScriptEngine.cs | 1 - .../Shared/Instance/ScriptInstance.cs | 7 ++- .../ScriptEngine/XEngine/EventManager.cs | 60 +++++++++++++------ .../Region/ScriptEngine/XEngine/XEngine.cs | 10 +--- 8 files changed, 64 insertions(+), 48 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs index 1dd2273f07..d48ef0cc87 100644 --- a/OpenSim/Region/Environment/Scenes/EventManager.cs +++ b/OpenSim/Region/Environment/Scenes/EventManager.cs @@ -83,8 +83,8 @@ namespace OpenSim.Region.Environment.Scenes public event OnShutdownDelegate OnShutdown; - public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); - public delegate void ObjectDeGrabDelegate(uint localID, IClientAPI remoteClient); + public delegate void ObjectGrabDelegate(uint localID, uint originalID, LLVector3 offsetPos, IClientAPI remoteClient); + public delegate void ObjectDeGrabDelegate(uint localID, uint originalID, IClientAPI remoteClient); public delegate void ScriptResetDelegate(uint localID, LLUUID itemID); public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); @@ -492,21 +492,21 @@ namespace OpenSim.Region.Environment.Scenes handlerShutdown(); } - public void TriggerObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) + public void TriggerObjectGrab(uint localID, uint originalID, LLVector3 offsetPos, IClientAPI remoteClient) { handlerObjectGrab = OnObjectGrab; if (handlerObjectGrab != null) { - handlerObjectGrab(localID, offsetPos, remoteClient); + handlerObjectGrab(localID, originalID, offsetPos, remoteClient); } } - public void TriggerObjectDeGrab(uint localID, IClientAPI remoteClient) + public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient) { handlerObjectDeGrab = OnObjectDeGrab; if (handlerObjectDeGrab != null) { - handlerObjectDeGrab(localID, remoteClient); + handlerObjectDeGrab(localID, originalID, remoteClient); } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index d534ffce1d..14d6826fe8 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -243,9 +243,9 @@ namespace OpenSim.Region.Environment.Scenes // If the touched prim handles touches, deliver it // If not, deliver to root prim if ((part.ScriptEvents & scriptEvents.touch_start) != 0) - EventManager.TriggerObjectGrab(part.LocalId, part.OffsetPosition, remoteClient); + EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient); else - EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.OffsetPosition, remoteClient); + EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient); return; } @@ -274,9 +274,9 @@ namespace OpenSim.Region.Environment.Scenes // If the touched prim handles touches, deliver it // If not, deliver to root prim if ((part.ScriptEvents & scriptEvents.touch_end) != 0) - EventManager.TriggerObjectDeGrab(part.LocalId, remoteClient); + EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient); else - EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, remoteClient); + EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient); return; } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index a6bb405bf9..3fdfd8a02d 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -117,7 +117,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); } - public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) + public void touch_start(uint localID, uint originalID, LLVector3 offsetPos, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); @@ -152,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); } - public void touch_end(uint localID, IClientAPI remoteClient) + public void touch_end(uint localID, uint originalID, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); @@ -220,12 +220,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_exit", EventQueueManager.llDetectNull, new object[] { }); } - public void touch(uint localID, LLUUID itemID) + public void touch(uint localID, uint originalID, LLUUID itemID) { myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch", EventQueueManager.llDetectNull); } - public void touch_end(uint localID, LLUUID itemID) + public void touch_end(uint localID, uint originalID, LLUUID itemID) { myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) }); } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs index 9a465f6cdc..41fde02cf4 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs @@ -38,12 +38,12 @@ namespace OpenSim.Region.ScriptEngine.Common { public interface RemoteEvents { - void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); + void touch_start(uint localID, uint originalID, LLVector3 offsetPos, IClientAPI remoteClient); void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez); void OnRemoveScript(uint localID, LLUUID itemID); void state_exit(uint localID); - void touch(uint localID, LLUUID itemID); - void touch_end(uint localID, LLUUID itemID); + void touch(uint localID, uint originalID, LLUUID itemID); + void touch_end(uint localID, uint originalID, LLUUID itemID); void collision_start(uint localID, ColliderArgs col); void collision(uint localID, ColliderArgs col); void collision_end(uint localID, ColliderArgs col); diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 292858cf6a..7c22eedfa6 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs @@ -48,7 +48,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces Object AsyncCommands { get; } ILog Log { get; } string ScriptEngineName { get; } - int MaxScriptQueue { get; } bool PostScriptEvent(LLUUID itemID, EventParams parms); bool PostObjectEvent(uint localID, EventParams parms); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 30c0274642..ff5039644c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -72,6 +72,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private int m_StartParam = 0; private string m_CurrentEvent = String.Empty; private bool m_InSelfDelete = false; + private int m_MaxScriptQueue; private Dictionary m_Apis = new Dictionary(); @@ -153,7 +154,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public ScriptInstance(IScriptEngine engine, uint localID, LLUUID objectID, LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, string primName, string scriptName, - int startParam, bool postOnRez, StateSource stateSource) + int startParam, bool postOnRez, StateSource stateSource, + int maxScriptQueue) { m_Engine = engine; @@ -165,6 +167,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_ScriptName = scriptName; m_Assembly = assembly; m_StartParam = startParam; + m_MaxScriptQueue = maxScriptQueue; ApiManager am = new ApiManager(); @@ -411,7 +414,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance lock (m_EventQueue) { - if (m_EventQueue.Count >= m_Engine.MaxScriptQueue) + if (m_EventQueue.Count >= m_MaxScriptQueue) return; m_EventQueue.Enqueue(data); diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index a4b9d4c482..3a01dc6a2f 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - public void touch_start(uint localID, LLVector3 offsetPos, + public void touch_start(uint localID, uint originalID, LLVector3 offsetPos, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object @@ -89,19 +89,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine det[0].Key = remoteClient.AgentId; det[0].Populate(myScriptEngine.World); - SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart( - localID); - if (part == null) - return; - - det[0].LinkNum = part.LinkNum; + + if (originalID == 0) + { + SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); + if (part == null) + return; + det[0].LinkNum = part.LinkNum; + } + else + { + SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); + det[0].LinkNum = originalPart.LinkNum; + } + myScriptEngine.PostObjectEvent(localID, new EventParams( "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det)); } - public void touch(uint localID, LLVector3 offsetPos, + public void touch(uint localID, uint originalID, LLVector3 offsetPos, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object @@ -113,19 +121,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine offsetPos.Y, offsetPos.Z); - SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart( - localID); - if (part == null) - return; + if (originalID == 0) + { + SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); + if (part == null) + return; - det[0].LinkNum = part.LinkNum; + det[0].LinkNum = part.LinkNum; + } + else + { + SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); + det[0].LinkNum = originalPart.LinkNum; + } myScriptEngine.PostObjectEvent(localID, new EventParams( "touch", new Object[] { new LSL_Types.LSLInteger(1) }, det)); } - public void touch_end(uint localID, IClientAPI remoteClient) + public void touch_end(uint localID, uint originalID, IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object DetectParams[] det = new DetectParams[1]; @@ -133,12 +148,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine det[0].Key = remoteClient.AgentId; det[0].Populate(myScriptEngine.World); - SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart( - localID); - if (part == null) - return; + if (originalID == 0) + { + SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); + if (part == null) + return; - det[0].LinkNum = part.LinkNum; + det[0].LinkNum = part.LinkNum; + } + else + { + SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); + det[0].LinkNum = originalPart.LinkNum; + } myScriptEngine.PostObjectEvent(localID, new EventParams( "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c5bcfd5634..8fd8a1caa1 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -319,14 +319,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine get { return false; } } - // - // XEngine functions - // - public int MaxScriptQueue - { - get { return m_MaxScriptQueue; } - } - public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) { Object[] parms = new Object[] @@ -508,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_AppDomains[appDomain], part.ParentGroup.RootPart.Name, item.Name, startParam, postOnRez, - StateSource.NewRez); + StateSource.NewRez, m_MaxScriptQueue); m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", part.ParentGroup.RootPart.Name, item.Name);