From f3c8963c86dbc969541ede80ae37eb59d26b7809 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 25 Sep 2008 05:13:44 +0000 Subject: Convergence is almost complete. This brings the diff between the API to < 10k and makes it use a common set of types in both engine. Fixes the issues with running both engines and HTTP requests / listens / timers etc.. Also fixes a couple of minor Scene issues and a CTB by nullref. --- .../Common/ScriptEngineBase/AsyncCommandManager.cs | 234 -------------- .../AsyncCommandPlugins/Dataserver.cs | 127 -------- .../AsyncCommandPlugins/HttpRequest.cs | 98 ------ .../AsyncCommandPlugins/Listener.cs | 76 ----- .../AsyncCommandPlugins/SensorRepeat.cs | 334 -------------------- .../ScriptEngineBase/AsyncCommandPlugins/Timer.cs | 139 --------- .../AsyncCommandPlugins/XmlRequest.cs | 130 -------- .../Common/ScriptEngineBase/EventManager.cs | 345 ++++++++++----------- .../Common/ScriptEngineBase/EventQueueManager.cs | 28 +- .../Common/ScriptEngineBase/ScriptEngine.cs | 25 +- .../Common/ScriptEngineBase/ScriptManager.cs | 19 +- 11 files changed, 210 insertions(+), 1345 deletions(-) delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs delete mode 100644 OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase') diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs deleted file mode 100644 index 5fa6010..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs +++ /dev/null @@ -1,234 +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.Collections; -using System.Threading; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; -using Timer=OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins.Timer; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase -{ - /// - /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. - /// - public class AsyncCommandManager : iScriptEngineFunctionModule - { - private static Thread cmdHandlerThread; - private static int cmdHandlerThreadCycleSleepms; - - public ScriptEngine m_ScriptEngine; - - private Timer m_Timer; - private HttpRequest m_HttpRequest; - private Listener m_Listener; - private SensorRepeat m_SensorRepeat; - private XmlRequest m_XmlRequest; - private Dataserver m_Dataserver; - - public Dataserver DataserverPlugin - { - get { return m_Dataserver; } - } - - public Timer TimerPlugin - { - get { return m_Timer; } - } - - public HttpRequest HttpRequestPlugin - { - get { return m_HttpRequest; } - } - - public Listener ListenerPlugin - { - get { return m_Listener; } - } - - public SensorRepeat SensorRepeatPlugin - { - get { return m_SensorRepeat; } - } - - public XmlRequest XmlRequestPlugin - { - get { return m_XmlRequest; } - } - - public AsyncCommandManager(ScriptEngine _ScriptEngine) - { - m_ScriptEngine = _ScriptEngine; - ReadConfig(); - - // Create instances of all plugins - m_Timer = new Timer(this); - m_HttpRequest = new HttpRequest(this); - m_Listener = new Listener(this); - m_SensorRepeat = new SensorRepeat(this); - m_XmlRequest = new XmlRequest(this); - m_Dataserver = new Dataserver(this); - - StartThread(); - } - - private static void StartThread() - { - if (cmdHandlerThread == null) - { - // Start the thread that will be doing the work - cmdHandlerThread = new Thread(CmdHandlerThreadLoop); - cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread"; - cmdHandlerThread.Priority = ThreadPriority.BelowNormal; - cmdHandlerThread.IsBackground = true; - cmdHandlerThread.Start(); - ThreadTracker.Add(cmdHandlerThread); - } - } - - public void ReadConfig() - { - cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100); - } - - ~AsyncCommandManager() - { - // Shut down thread - try - { - if (cmdHandlerThread != null) - { - if (cmdHandlerThread.IsAlive == true) - { - cmdHandlerThread.Abort(); - //cmdHandlerThread.Join(); - } - } - } - catch - { - } - } - - private static void CmdHandlerThreadLoop() - { - while (true) - { - try - { - while (true) - { - Thread.Sleep(cmdHandlerThreadCycleSleepms); - //lock (ScriptEngine.ScriptEngines) - //{ - foreach (ScriptEngine se in new ArrayList(ScriptEngine.ScriptEngines)) - { - se.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass(); - } - //} - // Sleep before next cycle - //Thread.Sleep(cmdHandlerThreadCycleSleepms); - } - } - catch - { - } - } - } - - internal void DoOneCmdHandlerPass() - { - // Check timers - m_Timer.CheckTimerEvents(); - // Check HttpRequests - m_HttpRequest.CheckHttpRequests(); - // Check XMLRPCRequests - m_XmlRequest.CheckXMLRPCRequests(); - // Check Listeners - m_Listener.CheckListeners(); - // Check Sensors - m_SensorRepeat.CheckSenseRepeaterEvents(); - // Check dataserver - m_Dataserver.ExpireRequests(); - } - - /// - /// Remove a specific script (and all its pending commands) - /// - /// - /// - public void RemoveScript(uint localID, UUID itemID) - { - // Remove a specific script - - // Remove from: Timers - m_Timer.UnSetTimerEvents(localID, itemID); - - // Remove from: HttpRequest - IHttpRequests iHttpReq = - m_ScriptEngine.World.RequestModuleInterface(); - iHttpReq.StopHttpRequest(localID, itemID); - - IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface(); - comms.DeleteListener(itemID); - - IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface(); - xmlrpc.DeleteChannels(itemID); - xmlrpc.CancelSRDRequests(itemID); - - // Remove Sensors - m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID); - - // Remove queries - m_Dataserver.RemoveEvents(localID, itemID); - - } - - - #region Check llRemoteData channels - - - #endregion - - #region Check llListeners - - - #endregion - - /// - /// If set to true then threads and stuff should try to make a graceful exit - /// - public bool PleaseShutdown - { - get { return _PleaseShutdown; } - set { _PleaseShutdown = value; } - } - private bool _PleaseShutdown = false; - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs deleted file mode 100644 index 96d7b30..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Dataserver.cs +++ /dev/null @@ -1,127 +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; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins - -{ - public class Dataserver - { - public AsyncCommandManager m_CmdManager; - - private Dictionary DataserverRequests = - new Dictionary(); - - public Dataserver(AsyncCommandManager CmdManager) - { - m_CmdManager = CmdManager; - } - - private class DataserverRequest - { - public uint localID; - public UUID itemID; - - public UUID ID; - public string handle; - - public DateTime startTime; - } - - public UUID RegisterRequest(uint localID, UUID itemID, - string identifier) - { - lock (DataserverRequests) - { - if (DataserverRequests.ContainsKey(identifier)) - return UUID.Zero; - - DataserverRequest ds = new DataserverRequest(); - - ds.localID = localID; - ds.itemID = itemID; - - ds.ID = UUID.Random(); - ds.handle = identifier; - - ds.startTime = DateTime.Now; - - DataserverRequests[identifier]=ds; - - return ds.ID; - } - } - - public void DataserverReply(string identifier, string reply) - { - DataserverRequest ds; - - lock (DataserverRequests) - { - if (!DataserverRequests.ContainsKey(identifier)) - return; - - ds=DataserverRequests[identifier]; - DataserverRequests.Remove(identifier); - } - - m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToObjectQueue( - ds.localID, "dataserver", EventQueueManager.llDetectNull, - new Object[] { new LSL_Types.LSLString(ds.ID.ToString()), - new LSL_Types.LSLString(reply)}); - } - - public void RemoveEvents(uint localID, UUID itemID) - { - lock (DataserverRequests) - { - foreach (DataserverRequest ds in new List(DataserverRequests.Values)) - { - if (ds.itemID == itemID) - DataserverRequests.Remove(ds.handle); - } - } - } - - public void ExpireRequests() - { - lock (DataserverRequests) - { - foreach (DataserverRequest ds in new List(DataserverRequests.Values)) - { - if (ds.startTime > DateTime.Now.AddSeconds(30)) - DataserverRequests.Remove(ds.handle); - } - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs deleted file mode 100644 index 5b4cb83..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs +++ /dev/null @@ -1,98 +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 OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.Scripting.HttpRequest; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins -{ - public class HttpRequest - { - public AsyncCommandManager m_CmdManager; - - public HttpRequest(AsyncCommandManager CmdManager) - { - m_CmdManager = CmdManager; - } - - public void CheckHttpRequests() - { - if (m_CmdManager.m_ScriptEngine.World == null) - return; - - IHttpRequests iHttpReq = - m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - HttpRequestClass httpInfo = null; - - if (iHttpReq != null) - httpInfo = iHttpReq.GetNextCompletedRequest(); - - while (httpInfo != null) - { - //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status); - - // Deliver data to prim's remote_data handler - // - // TODO: Returning null for metadata, since the lsl function - // only returns the byte for HTTP_BODY_TRUNCATED, which is not - // implemented here yet anyway. Should be fixed if/when maxsize - // is supported - - bool handled = false; - iHttpReq.RemoveCompletedRequest(httpInfo.reqID); - foreach (ScriptEngine sman in ScriptEngine.ScriptEngines) - { - if (sman.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null) - { - object[] resobj = new object[] - { - new LSL_Types.LSLString(httpInfo.reqID.ToString()), new LSL_Types.LSLInteger(httpInfo.status), null, new LSL_Types.LSLString(httpInfo.response_body) - }; - - sman.m_EventQueueManager.AddToScriptQueue( - httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj - ); - - handled = true; - break; - //Thread.Sleep(2500); - } - } - - if (!handled) - { - Console.WriteLine("Unhandled http_response: " + httpInfo.reqID); - } - - httpInfo = iHttpReq.GetNextCompletedRequest(); - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs deleted file mode 100644 index 0bac22c..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs +++ /dev/null @@ -1,76 +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 OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.Scripting.WorldComm; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins -{ - public class Listener - { - // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - public AsyncCommandManager m_CmdManager; - - public Listener(AsyncCommandManager CmdManager) - { - m_CmdManager = CmdManager; - } - - public void CheckListeners() - { - if (m_CmdManager.m_ScriptEngine.World == null) - return; - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - if (comms != null) - { - while (comms.HasMessages()) - { - ListenerInfo lInfo = comms.GetNextMessage(); - if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript( - lInfo.GetLocalID(), lInfo.GetItemID()) != null) - { - //Deliver data to prim's listen handler - object[] resobj = new object[] - { - //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() - new LSL_Types.LSLInteger(lInfo.GetChannel()), new LSL_Types.LSLString(lInfo.GetName()), new LSL_Types.LSLString(lInfo.GetID().ToString()), new LSL_Types.LSLString(lInfo.GetMessage()) - }; - - m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( - lInfo.GetLocalID(), lInfo.GetItemID(), "listen", EventQueueManager.llDetectNull, resobj - ); - } - // else - // m_log.Info("[ScriptEngineBase.AsyncCommandPlugins: received a listen event for a (no longer) existing script ("+lInfo.GetLocalID().AsString()+")"); - } - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs deleted file mode 100644 index 7059a1b..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs +++ /dev/null @@ -1,334 +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. - */ -//#define SPAM -using System; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins -{ - public class SensorRepeat - { - public AsyncCommandManager m_CmdManager; - - public SensorRepeat(AsyncCommandManager CmdManager) - { - m_CmdManager = CmdManager; - } - - public Dictionary> SenseEvents = - new Dictionary>(); - private Object SenseLock = new Object(); - - // - // SenseRepeater and Sensors - // - private class SenseRepeatClass - { - public uint localID; - public UUID itemID; - public double interval; - public DateTime next; - - public string name; - public UUID keyID; - public int type; - public double range; - public double arc; - public SceneObjectPart host; - } - - private List SenseRepeaters = new List(); - private object SenseRepeatListLock = new object(); - - public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID, - string name, UUID keyID, int type, double range, double arc, double sec, SceneObjectPart host) - { - #if SPAM - Console.WriteLine("SetSensorEvent"); - #endif - // Always remove first, in case this is a re-set - UnSetSenseRepeaterEvents(m_localID, m_itemID); - if (sec == 0) // Disabling timer - return; - - // Add to timer - SenseRepeatClass ts = new SenseRepeatClass(); - ts.localID = m_localID; - ts.itemID = m_itemID; - ts.interval = sec; - ts.name = name; - ts.keyID = keyID; - ts.type = type; - ts.range = range; - ts.arc = arc; - ts.host = host; - - ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - lock (SenseRepeatListLock) - { - SenseRepeaters.Add(ts); - } - } - - public void UnSetSenseRepeaterEvents(uint m_localID, UUID m_itemID) - { - // Remove from timer - lock (SenseRepeatListLock) - { - List NewSensors = new List(); - foreach (SenseRepeatClass ts in SenseRepeaters) - { - if (ts.localID != m_localID && ts.itemID != m_itemID) - { - NewSensors.Add(ts); - } - } - SenseRepeaters.Clear(); - SenseRepeaters = NewSensors; - } - } - - public void CheckSenseRepeaterEvents() - { - // Nothing to do here? - if (SenseRepeaters.Count == 0) - return; - - lock (SenseRepeatListLock) - { - // Go through all timers - foreach (SenseRepeatClass ts in SenseRepeaters) - { - // Time has passed? - if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) - { - SensorSweep(ts); - // set next interval - ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - } - } - } // lock - } - - public void SenseOnce(uint m_localID, UUID m_itemID, - string name, UUID keyID, int type, - double range, double arc, SceneObjectPart host) - { - // Add to timer - SenseRepeatClass ts = new SenseRepeatClass(); - ts.localID = m_localID; - ts.itemID = m_itemID; - ts.interval = 0; - ts.name = name; - ts.keyID = keyID; - ts.type = type; - ts.range = range; - ts.arc = arc; - ts.host = host; - SensorSweep(ts); - } - - public LSL_Types.list GetSensorList(uint m_localID, UUID m_itemID) - { - lock (SenseLock) - { - Dictionary Obj = null; - if (!SenseEvents.TryGetValue(m_localID, out Obj)) - { - #if SPAM - m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID); - #endif - return null; - } - lock (Obj) - { - // Get script - LSL_Types.list SenseList = null; - if (!Obj.TryGetValue(m_itemID, out SenseList)) - { - #if SPAM - m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID); - #endif - return null; - } - return SenseList; - } - } - } - - private void SensorSweep(SenseRepeatClass ts) - { - //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep"); - SceneObjectPart SensePoint = ts.host; - - if (SensePoint == null) - { - - #if SPAM - //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString()); - #endif - return; - } - //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan"); - - Vector3 sensorPos = SensePoint.AbsolutePosition; - Vector3 regionPos = new Vector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0); - Vector3 fromRegionPos = sensorPos + regionPos; - - Quaternion q = SensePoint.RotationOffset; - LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); - LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); - double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); - - // Here we should do some smart culling ... - // math seems quicker than strings so try that first - LSL_Types.list SensedObjects = new LSL_Types.list(); - LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0); - - foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values) - { - Vector3 toRegionPos = ent.AbsolutePosition + regionPos; - double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos)); - if (dis <= ts.range) - { - // In Range, is it the right Type ? - int objtype = 0; - - if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor - if (ent.Velocity.Equals(ZeroVector)) - objtype |= 0x04; // passive non-moving - else - objtype |= 0x02; // active moving - if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ... - - if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type)) - { - // docs claim AGENT|ACTIVE should find agent objects OR active objects - // so the bitwise AND with object type should be non-zero - - // Right type too, what about the other params , key and name ? - bool keep = true; - if (ts.arc < Math.PI) - { - // not omni-directional. Can you see it ? - // vec forward_dir = llRot2Fwd(llGetRot()) - // vec obj_dir = toRegionPos-fromRegionPos - // dot=dot(forward_dir,obj_dir) - // mag_fwd = mag(forward_dir) - // mag_obj = mag(obj_dir) - // ang = acos(dot /(mag_fwd*mag_obj)) - double ang_obj = 0; - try - { - Vector3 diff = toRegionPos - fromRegionPos; - LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); - double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); - double mag_obj = LSL_Types.Vector3.Mag(obj_dir); - ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); - } - catch - { - } - - if (ang_obj > ts.arc) keep = false; - } - - if (keep && (ts.keyID != UUID.Zero) && (ts.keyID != ent.UUID)) - { - keep = false; - } - - if (keep && (ts.name.Length > 0)) - { - string avatarname=null; - string objectname=null; - string entname =ent.Name; - - // try avatar username surname - CachedUserInfo profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserProfileCacheService.GetUserDetails(ent.UUID); - if (profile != null && profile.UserProfile != null) - { - avatarname = profile.UserProfile.FirstName + " " + profile.UserProfile.SurName; - } - // try an scene object - SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID); - if (SOP != null) - { - objectname = SOP.Name; - } - - if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname)) - { - keep = false; - } - } - - if (keep == true) SensedObjects.Add(ent.UUID); - } - } - } - #if SPAM - //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock"); - #endif - lock (SenseLock) - { - // Create object if it doesn't exist - if (SenseEvents.ContainsKey(ts.localID) == false) - { - SenseEvents.Add(ts.localID, new Dictionary()); - } - // clear if previous traces exist - Dictionary Obj; - SenseEvents.TryGetValue(ts.localID, out Obj); - if (Obj.ContainsKey(ts.itemID) == true) - Obj.Remove(ts.itemID); - - // note list may be zero length - Obj.Add(ts.itemID, SensedObjects); - - if (SensedObjects.Length == 0) - { - // send a "no_sensor" - // Add it to queue - m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "no_sensor", EventQueueManager.llDetectNull, - new object[] { }); - } - else - { - m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull, - new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) }); - } - m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ts.interval); - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs deleted file mode 100644 index 7940b36..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Timer.cs +++ /dev/null @@ -1,139 +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; -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins -{ - public class Timer - { - public AsyncCommandManager m_CmdManager; - - public Timer(AsyncCommandManager CmdManager) - { - m_CmdManager = CmdManager; - } - - // - // TIMER - // - private class TimerClass - { - public uint localID; - public UUID itemID; - //public double interval; - public long interval; - //public DateTime next; - public long next; - } - - private List Timers = new List(); - private object TimerListLock = new object(); - - public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec) - { - // Console.WriteLine("SetTimerEvent"); - - // Always remove first, in case this is a re-set - UnSetTimerEvents(m_localID, m_itemID); - if (sec == 0) // Disabling timer - return; - - // Add to timer - TimerClass ts = new TimerClass(); - ts.localID = m_localID; - ts.itemID = m_itemID; - ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait - // 2193386136332921 ticks - // 219338613 seconds - - //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - ts.next = DateTime.Now.Ticks + ts.interval; - lock (TimerListLock) - { - Timers.Add(ts); - } - } - - public void UnSetTimerEvents(uint m_localID, UUID m_itemID) - { - // Remove from timer - lock (TimerListLock) - { - foreach (TimerClass ts in new ArrayList(Timers)) - { - if (ts.localID == m_localID && ts.itemID == m_itemID) - Timers.Remove(ts); - } - } - - // Old method: Create new list - //List NewTimers = new List(); - //foreach (TimerClass ts in Timers) - //{ - // if (ts.localID != m_localID && ts.itemID != m_itemID) - // { - // NewTimers.Add(ts); - // } - //} - //Timers.Clear(); - //Timers = NewTimers; - //} - } - - public void CheckTimerEvents() - { - // Nothing to do here? - if (Timers.Count == 0) - return; - - lock (TimerListLock) - { - // Go through all timers - foreach (TimerClass ts in Timers) - { - // Time has passed? - if (ts.next < DateTime.Now.Ticks) - { - // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); - // Add it to queue - m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, - null); - m_CmdManager.m_ScriptEngine.World.EventManager.TriggerTimerEvent(ts.localID, ((double)ts.interval / 10000000)); - // set next interval - - //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); - ts.next = DateTime.Now.Ticks + ts.interval; - } - } - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs deleted file mode 100644 index 9a01cc4..0000000 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs +++ /dev/null @@ -1,130 +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 OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.Scripting.XMLRPC; -using OpenSim.Region.ScriptEngine.Shared; - -namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins -{ - public class XmlRequest - { - public AsyncCommandManager m_CmdManager; - - public XmlRequest(AsyncCommandManager CmdManager) - { - m_CmdManager = CmdManager; - } - - public void CheckXMLRPCRequests() - { - if (m_CmdManager.m_ScriptEngine.World == null) - return; - - IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - if (null == xmlrpc) - return; - - // Process the completed request queue - RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest(); - - while (rInfo != null) - { - bool handled = false; - - // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely - xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID()); - - // And since the xmlrpc request queue is actually shared among all regions on the simulator, we need - // to look in each one for the appropriate handler - foreach (ScriptEngine sman in ScriptEngine.ScriptEngines) { - if (sman.m_ScriptManager.GetScript(rInfo.GetLocalID(),rInfo.GetItemID()) != null) { - - //Deliver data to prim's remote_data handler - object[] resobj = new object[] - { - new LSL_Types.LSLInteger(2), new LSL_Types.LSLString(rInfo.GetChannelKey().ToString()), new LSL_Types.LSLString(rInfo.GetMessageID().ToString()), new LSL_Types.LSLString(String.Empty), - new LSL_Types.LSLInteger(rInfo.GetIntValue()), - new LSL_Types.LSLString(rInfo.GetStrVal()) - }; - sman.m_EventQueueManager.AddToScriptQueue( - rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj - ); - - handled = true; - } - } - - if (! handled) - { - Console.WriteLine("Unhandled xml_request: " + rInfo.GetItemID()); - } - - rInfo = xmlrpc.GetNextCompletedRequest(); - } - - // Process the send queue - SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest(); - - while (srdInfo != null) - { - bool handled = false; - - // Request must be taken out of the queue in case there is no handler, otherwise we loop infinitely - xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID()); - - // And this is another shared queue... so we check each of the script engines for a handler - foreach (ScriptEngine sman in ScriptEngine.ScriptEngines) - { - if (sman.m_ScriptManager.GetScript(srdInfo.m_localID,srdInfo.m_itemID) != null) { - - //Deliver data to prim's remote_data handler - object[] resobj = new object[] - { - new LSL_Types.LSLInteger(3), new LSL_Types.LSLString(srdInfo.channel.ToString()), new LSL_Types.LSLString(srdInfo.GetReqID().ToString()), new LSL_Types.LSLString(String.Empty), - new LSL_Types.LSLInteger(srdInfo.idata), - new LSL_Types.LSLString(srdInfo.sdata) - }; - sman.m_EventQueueManager.AddToScriptQueue( - srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj - ); - - handled = true; - } - } - - if (! handled) - { - Console.WriteLine("Unhandled xml_srdrequest: " + srdInfo.GetReqID()); - } - - srdInfo = xmlrpc.GetNextCompletedSRDRequest(); - } - } - } -} diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index d52b642..c8c9cd8 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -114,83 +114,103 @@ 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", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(change) }); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "changed",new object[] { new LSL_Types.LSLInteger(change) }, + new DetectParams[0])); } public void state_entry(uint localID) { // Add to queue for all scripts in ObjectID object - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "state_entry",new object[] { }, + new DetectParams[0])); } - public void touch_start(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient) + public void touch_start(uint localID, uint originalID, Vector3 offsetPos, + IClientAPI remoteClient) { // Add to queue for all scripts in ObjectID object - EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); - detstruct._key = new LSL_Types.key[1]; - detstruct._key2 = new LSL_Types.key[1]; - detstruct._string = new string[1]; - detstruct._Vector3 = new LSL_Types.Vector3[1]; - detstruct._Vector32 = new LSL_Types.Vector3[1]; - detstruct._Quaternion = new LSL_Types.Quaternion[1]; - detstruct._int = new int[1]; - ScenePresence av = myScriptEngine.World.GetScenePresence(remoteClient.AgentId); - if (av != null) + DetectParams[] det = new DetectParams[1]; + det[0] = new DetectParams(); + det[0].Key = remoteClient.AgentId; + det[0].Populate(myScriptEngine.World); + + 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, uint originalID, Vector3 offsetPos, + IClientAPI remoteClient) + { + // Add to queue for all scripts in ObjectID object + DetectParams[] det = new DetectParams[1]; + det[0] = new DetectParams(); + det[0].Key = remoteClient.AgentId; + det[0].Populate(myScriptEngine.World); + det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, + offsetPos.Y, + offsetPos.Z); + + if (originalID == 0) { - detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._string[0] = remoteClient.Name; - detstruct._int[0] = 0; - detstruct._Quaternion[0] = new LSL_Types.Quaternion(av.Rotation.X,av.Rotation.Y,av.Rotation.Z,av.Rotation.W); - detstruct._Vector3[0] = new LSL_Types.Vector3(av.AbsolutePosition.X,av.AbsolutePosition.Y,av.AbsolutePosition.Z); - detstruct._Vector32[0] = new LSL_Types.Vector3(av.Velocity.X,av.Velocity.Y,av.Velocity.Z); + SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); + if (part == null) + return; + + det[0].LinkNum = part.LinkNum; } else { - detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._string[0] = remoteClient.Name; - detstruct._int[0] = 0; - detstruct._Quaternion[0] = new LSL_Types.Quaternion(0, 0, 0, 1); - detstruct._Vector3[0] = new LSL_Types.Vector3(0, 0, 0); - detstruct._Vector32[0] = new LSL_Types.Vector3(0, 0, 0); + SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); + det[0].LinkNum = originalPart.LinkNum; } - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); + + myScriptEngine.PostObjectEvent(localID, new EventParams( + "touch", new Object[] { new LSL_Types.LSLInteger(1) }, + det)); } 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(); - detstruct._key = new LSL_Types.key[1]; - detstruct._key2 = new LSL_Types.key[1]; - detstruct._string = new string[1]; - detstruct._Vector3 = new LSL_Types.Vector3[1]; - detstruct._Vector32 = new LSL_Types.Vector3[1]; - detstruct._Quaternion = new LSL_Types.Quaternion[1]; - detstruct._int = new int[1]; - ScenePresence av = myScriptEngine.World.GetScenePresence(remoteClient.AgentId); - if (av != null) + DetectParams[] det = new DetectParams[1]; + det[0] = new DetectParams(); + det[0].Key = remoteClient.AgentId; + det[0].Populate(myScriptEngine.World); + + if (originalID == 0) { - detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._string[0] = remoteClient.Name; - detstruct._int[0] = 0; - detstruct._Quaternion[0] = new LSL_Types.Quaternion(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W); - detstruct._Vector3[0] = new LSL_Types.Vector3(av.AbsolutePosition.X, av.AbsolutePosition.Y, av.AbsolutePosition.Z); - detstruct._Vector32[0] = new LSL_Types.Vector3(av.Velocity.X, av.Velocity.Y, av.Velocity.Z); + SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); + if (part == null) + return; + + det[0].LinkNum = part.LinkNum; } else { - detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._key2[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); - detstruct._string[0] = remoteClient.Name; - detstruct._int[0] = 0; - detstruct._Quaternion[0] = new LSL_Types.Quaternion(0, 0, 0, 1); - detstruct._Vector3[0] = new LSL_Types.Vector3(0, 0, 0); - detstruct._Vector32[0] = new LSL_Types.Vector3(0, 0, 0); + SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); + det[0].LinkNum = originalPart.LinkNum; } - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) }); + + myScriptEngine.PostObjectEvent(localID, new EventParams( + "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, + det)); } public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) @@ -228,7 +248,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void money(uint localID, UUID agentID, int amount) { - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "money", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(amount) }); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "money", new object[] { + new LSL_Types.LSLString(agentID.ToString()), + new LSL_Types.LSLInteger(amount) }, + new DetectParams[0])); } // TODO: Replace placeholders below @@ -239,225 +263,196 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void state_exit(uint localID) { - // Add to queue for all scripts in ObjectID object - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_exit", EventQueueManager.llDetectNull, new object[] { }); - } - - public void touch(uint localID, uint originalID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch", EventQueueManager.llDetectNull); - } - - public void touch_end(uint localID, uint originalID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) }); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "state_exit", new object[] { }, + new DetectParams[0])); } public void collision_start(uint localID, ColliderArgs col) { - EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); - detstruct._string = new string[col.Colliders.Count]; - detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count]; - detstruct._int = new int[col.Colliders.Count]; - detstruct._key = new LSL_Types.key[col.Colliders.Count]; - detstruct._key2 = new LSL_Types.key[col.Colliders.Count]; - detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count]; - detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count]; - detstruct._bool = new bool[col.Colliders.Count]; - - int i = 0; + // Add to queue for all scripts in ObjectID object + List det = new List(); + foreach (DetectedObject detobj in col.Colliders) { - detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString()); - detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString()); - detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W); - detstruct._string[i] = detobj.nameStr; - detstruct._int[i] = detobj.colliderType; - detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z); - detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z); - detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry... - i++; + DetectParams d = new DetectParams(); + d.Key =detobj.keyUUID; + d.Populate(myScriptEngine.World); + det.Add(d); } - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision_start", detstruct, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) }); + if (det.Count > 0) + myScriptEngine.PostObjectEvent(localID, new EventParams( + "collision_start", + new Object[] { new LSL_Types.LSLInteger(det.Count) }, + det.ToArray())); } public void collision(uint localID, ColliderArgs col) { - EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); - detstruct._string = new string[col.Colliders.Count]; - detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count]; - detstruct._int = new int[col.Colliders.Count]; - detstruct._key = new LSL_Types.key[col.Colliders.Count]; - detstruct._key2 = new LSL_Types.key[col.Colliders.Count]; - detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count]; - detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count]; - detstruct._bool = new bool[col.Colliders.Count]; - - int i = 0; + // Add to queue for all scripts in ObjectID object + List det = new List(); + foreach (DetectedObject detobj in col.Colliders) { - detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString()); - detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString()); - detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W); - detstruct._string[i] = detobj.nameStr; - detstruct._int[i] = detobj.colliderType; - detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z); - detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z); - detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry... i++; + DetectParams d = new DetectParams(); + d.Key =detobj.keyUUID; + d.Populate(myScriptEngine.World); + det.Add(d); } - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision", detstruct, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) }); + + if (det.Count > 0) + myScriptEngine.PostObjectEvent(localID, new EventParams( + "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) }, + det.ToArray())); } public void collision_end(uint localID, ColliderArgs col) { - EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); - detstruct._string = new string[col.Colliders.Count]; - detstruct._Quaternion = new LSL_Types.Quaternion[col.Colliders.Count]; - detstruct._int = new int[col.Colliders.Count]; - detstruct._key = new LSL_Types.key[col.Colliders.Count]; - detstruct._key2 = new LSL_Types.key[col.Colliders.Count]; - detstruct._Vector3 = new LSL_Types.Vector3[col.Colliders.Count]; - detstruct._Vector32 = new LSL_Types.Vector3[col.Colliders.Count]; - detstruct._bool = new bool[col.Colliders.Count]; - - int i = 0; + // Add to queue for all scripts in ObjectID object + List det = new List(); + foreach (DetectedObject detobj in col.Colliders) { - detstruct._key[i] = new LSL_Types.key(detobj.keyUUID.ToString()); - detstruct._key2[i] = new LSL_Types.key(detobj.ownerUUID.ToString()); - detstruct._Quaternion[i] = new LSL_Types.Quaternion(detobj.rotQuat.X, detobj.rotQuat.Y, detobj.rotQuat.Z, detobj.rotQuat.W); - detstruct._string[i] = detobj.nameStr; - detstruct._int[i] = detobj.colliderType; - detstruct._Vector3[i] = new LSL_Types.Vector3(detobj.posVector.X, detobj.posVector.Y, detobj.posVector.Z); - detstruct._Vector32[i] = new LSL_Types.Vector3(detobj.velVector.X, detobj.velVector.Y, detobj.velVector.Z); - detstruct._bool[i] = true; // Apparently the script engine uses this to see if this is a valid entry... - i++; + DetectParams d = new DetectParams(); + d.Key =detobj.keyUUID; + d.Populate(myScriptEngine.World); + det.Add(d); } - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "collision_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(col.Colliders.Count) }); + + if (det.Count > 0) + myScriptEngine.PostObjectEvent(localID, new EventParams( + "collision_end", + new Object[] { new LSL_Types.LSLInteger(det.Count) }, + det.ToArray())); } public void land_collision_start(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "land_collision_start", + new object[0], + new DetectParams[0])); } - public void land_collision(uint localID, ColliderArgs col) + public void land_collision(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "land_collision", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "land_collision", + new object[0], + new DetectParams[0])); } public void land_collision_end(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "land_collision_end", + new object[0], + new DetectParams[0])); } // Handled by long commands public void timer(uint localID, UUID itemID) { - //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, String.Empty); } public void listen(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen", EventQueueManager.llDetectNull); - } - - public void on_rez(uint localID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull); - } - - public void sensor(uint localID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor", EventQueueManager.llDetectNull); - } - - public void no_sensor(uint localID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor", EventQueueManager.llDetectNull); } public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change) { if ((change == 0) && (myScriptEngine.m_EventQueueManager.CheckEeventQueueForEvent(localID,"control"))) return; - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLString(agentID.ToString()), new LSL_Types.LSLInteger(held), new LSL_Types.LSLInteger(change)}); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "control",new object[] { + new LSL_Types.LSLString(agentID.ToString()), + new LSL_Types.LSLInteger(held), + new LSL_Types.LSLInteger(change)}, + new DetectParams[0])); } - public void email(uint localID, UUID itemID) + public void email(uint localID, UUID itemID, string timeSent, + string address, string subject, string message, int numLeft) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "email",new object[] { + new LSL_Types.LSLString(timeSent), + new LSL_Types.LSLString(address), + new LSL_Types.LSLString(subject), + new LSL_Types.LSLString(message), + new LSL_Types.LSLInteger(numLeft)}, + new DetectParams[0])); } - public void at_target(uint localID, uint handle, Vector3 targetpos, Vector3 atpos) + public void at_target(uint localID, uint handle, Vector3 targetpos, + Vector3 atpos) { - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "at_target", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(handle), new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "at_target", new object[] { + new LSL_Types.LSLInteger(handle), + new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), + new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, + new DetectParams[0])); } public void not_at_target(uint localID) { - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "not_at_target", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "not_at_target",new object[0], + new DetectParams[0])); } public void at_rot_target(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "at_rot_target",new object[0], + new DetectParams[0])); } public void not_at_rot_target(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target", EventQueueManager.llDetectNull); - } - - public void run_time_permissions(uint localID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions", EventQueueManager.llDetectNull); - } - - public void changed(uint localID, UUID itemID) - { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "not_at_rot_target",new object[0], + new DetectParams[0])); } public void attach(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach", EventQueueManager.llDetectNull); } public void dataserver(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver", EventQueueManager.llDetectNull); } public void link_message(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message", EventQueueManager.llDetectNull); } public void moving_start(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "moving_start",new object[0], + new DetectParams[0])); } public void moving_end(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end", EventQueueManager.llDetectNull); + myScriptEngine.PostObjectEvent(localID, new EventParams( + "moving_end",new object[0], + new DetectParams[0])); } public void object_rez(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez", EventQueueManager.llDetectNull); } public void remote_data(uint localID, UUID itemID) { - myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data", EventQueueManager.llDetectNull); } // Handled by long commands public void http_response(uint localID, UUID itemID) { - // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response", EventQueueManager.llDetectNull); } /// diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs index 8c7834a..b13ab21 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueManager.cs @@ -137,32 +137,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public uint localID; public UUID itemID; public string functionName; - public Queue_llDetectParams_Struct llDetectParams; + public DetectParams[] 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 - /// - [Serializable] - 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; // detected key - public LSL_Types.key[] _key2; // ownerkey - public LSL_Types.Quaternion[] _Quaternion; - public LSL_Types.Vector3[] _Vector3; // Pos - public LSL_Types.Vector3[] _Vector32; // Vel - public bool[] _bool; - public int[] _int; - public string[] _string; - } #endregion #region " Initialization / Startup " @@ -322,7 +300,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// Region object ID /// Name of the function, will be state + "_event_" + FunctionName /// Array of parameters to match event mask - public bool AddToObjectQueue(uint localID, string FunctionName, Queue_llDetectParams_Struct qParams, params object[] param) + public bool AddToObjectQueue(uint localID, string FunctionName, DetectParams[] qParams, params object[] param) { // Determine all scripts in Object and add to their queue //myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); @@ -353,7 +331,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// Region script ID /// Name of the function, will be state + "_event_" + FunctionName /// Array of parameters to match event mask - 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, DetectParams[] qParams, params object[] param) { List keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID); diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs index c972683..b09a30b 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs @@ -57,7 +57,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public EventQueueManager m_EventQueueManager; // Executes events, handles script threads public ScriptManager m_ScriptManager; // Load, unload and execute scripts public AppDomainManager m_AppDomainManager; // Handles loading/unloading of scripts into AppDomains - public AsyncCommandManager m_ASYNCLSLCommandManager; // Asyncronous LSL commands (commands that returns with an event) public static MaintenanceThread m_MaintenanceThread; // Thread that does different kinds of maintenance, for example refreshing config and killing scripts that has been running too long public IConfigSource ConfigSource; @@ -121,7 +120,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase // We need to start it m_ScriptManager = newScriptManager; m_AppDomainManager = new AppDomainManager(this); - m_ASYNCLSLCommandManager = new AsyncCommandManager(this); if (m_MaintenanceThread == null) m_MaintenanceThread = new MaintenanceThread(); @@ -172,7 +170,6 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase if (m_EventManager != null) m_EventManager.ReadConfig(); if (m_ScriptManager != null) m_ScriptManager.ReadConfig(); if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig(); - if (m_ASYNCLSLCommandManager != null) m_ASYNCLSLCommandManager.ReadConfig(); if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig(); } @@ -196,15 +193,33 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public bool PostObjectEvent(uint localID, EventParams p) { - return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, EventQueueManager.llDetectNull, p.Params); + return m_EventQueueManager.AddToObjectQueue(localID, p.EventName, p.DetectParams, p.Params); } public bool PostScriptEvent(UUID itemID, EventParams p) { uint localID = m_ScriptManager.GetLocalID(itemID); - return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, EventQueueManager.llDetectNull, p.Params); + return m_EventQueueManager.AddToScriptQueue(localID, itemID, p.EventName, p.DetectParams, p.Params); } + public DetectParams GetDetectParams(UUID itemID, int number) + { + uint localID = m_ScriptManager.GetLocalID(itemID); + if (localID == 0) + return null; + + IScript Script = m_ScriptManager.GetScript(localID, itemID); + + if (Script == null) + return null; + + DetectParams[] det = m_ScriptManager.GetDetectParams(Script); + + if (number < 0 || number >= det.Length) + return null; + + return det[number]; + } #endregion } } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index ff8e16f..095e11f 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -33,6 +33,7 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Threading; using OpenMetaverse; using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ScriptEngine.Shared; namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { @@ -65,6 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase private int LoadUnloadMaxQueueSize; private Object scriptLock = new Object(); private bool m_started = false; + private Dictionary detparms = new Dictionary(); // Load/Unload structure private struct LUStruct @@ -228,6 +230,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase if (item.Action == LUType.Unload) { _StopScript(item.localID, item.itemID); + RemoveScript(item.localID, item.itemID); } else if (item.Action == LUType.Load) { @@ -318,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// Script ID /// Name of function /// Arguments to pass to function - internal void ExecuteEvent(uint localID, UUID itemID, string FunctionName, EventQueueManager.Queue_llDetectParams_Struct qParams, object[] args) + internal void ExecuteEvent(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, object[] args) { //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined ///#if DEBUG @@ -337,8 +340,9 @@ 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; + detparms[Script] = qParams; Script.Exec.ExecuteEvent(FunctionName, args); + detparms.Remove(Script); } public uint GetLocalID(UUID itemID) @@ -430,6 +434,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void RemoveScript(uint localID, UUID itemID) { + if (localID == 0) + localID = GetLocalID(itemID); + // Don't have that object? if (Scripts.ContainsKey(localID) == false) return; @@ -486,5 +493,13 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase // set { _PleaseShutdown = value; } //} //private bool _PleaseShutdown = false; + + public DetectParams[] GetDetectParams(IScript script) + { + if (detparms.ContainsKey(script)) + return detparms[script]; + + return null; + } } } -- cgit v1.1