mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
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.
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a specific script (and all its pending commands)
|
||||
/// </summary>
|
||||
/// <param name="localID"></param>
|
||||
/// <param name="itemID"></param>
|
||||
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<IHttpRequests>();
|
||||
iHttpReq.StopHttpRequest(localID, itemID);
|
||||
|
||||
IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
|
||||
comms.DeleteListener(itemID);
|
||||
|
||||
IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// If set to true then threads and stuff should try to make a graceful exit
|
||||
/// </summary>
|
||||
public bool PleaseShutdown
|
||||
{
|
||||
get { return _PleaseShutdown; }
|
||||
set { _PleaseShutdown = value; }
|
||||
}
|
||||
private bool _PleaseShutdown = false;
|
||||
}
|
||||
}
|
||||
@@ -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<string, DataserverRequest> DataserverRequests =
|
||||
new Dictionary<string, DataserverRequest>();
|
||||
|
||||
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<DataserverRequest>(DataserverRequests.Values))
|
||||
{
|
||||
if (ds.itemID == itemID)
|
||||
DataserverRequests.Remove(ds.handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ExpireRequests()
|
||||
{
|
||||
lock (DataserverRequests)
|
||||
{
|
||||
foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
|
||||
{
|
||||
if (ds.startTime > DateTime.Now.AddSeconds(30))
|
||||
DataserverRequests.Remove(ds.handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IHttpRequests>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IWorldComm>();
|
||||
|
||||
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()+")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<uint, Dictionary<UUID, LSL_Types.list>> SenseEvents =
|
||||
new Dictionary<uint, Dictionary<UUID, LSL_Types.list>>();
|
||||
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<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
|
||||
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<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>();
|
||||
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<UUID, LSL_Types.list> 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<UUID, LSL_Types.list>());
|
||||
}
|
||||
// clear if previous traces exist
|
||||
Dictionary<UUID, LSL_Types.list> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<TimerClass> Timers = new List<TimerClass>();
|
||||
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<TimerClass> NewTimers = new List<TimerClass>();
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IXMLRPC>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
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_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)
|
||||
{
|
||||
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", 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];
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
List<DetectParams> det = new List<DetectParams>();
|
||||
|
||||
int i = 0;
|
||||
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];
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
List<DetectParams> det = new List<DetectParams>();
|
||||
|
||||
int i = 0;
|
||||
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];
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
List<DetectParams> det = new List<DetectParams>();
|
||||
|
||||
int i = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shared empty llDetectNull
|
||||
/// </summary>
|
||||
public readonly static Queue_llDetectParams_Struct llDetectNull = new Queue_llDetectParams_Struct();
|
||||
|
||||
/// <summary>
|
||||
/// Structure to hold data for llDetect* commands
|
||||
/// </summary>
|
||||
[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
|
||||
/// <param name="localID">Region object ID</param>
|
||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
||||
/// <param name="param">Array of parameters to match event mask</param>
|
||||
public 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
|
||||
/// <param name="itemID">Region script ID</param>
|
||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
||||
/// <param name="param">Array of parameters to match event mask</param>
|
||||
public 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<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<IScript, DetectParams[]> detparms = new Dictionary<IScript, DetectParams[]>();
|
||||
|
||||
// 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
|
||||
/// <param name="itemID">Script ID</param>
|
||||
/// <param name="FunctionName">Name of function</param>
|
||||
/// <param name="args">Arguments to pass to function</param>
|
||||
internal void ExecuteEvent(uint localID, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user