mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
This commit is contained in:
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
||||
public interface IScriptWorkItem
|
||||
{
|
||||
bool Cancel();
|
||||
void Abort();
|
||||
bool Abort();
|
||||
|
||||
/// <summary>
|
||||
/// Wait for the work item to complete.
|
||||
|
||||
@@ -37,6 +37,8 @@ using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
||||
using Timer=OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
@@ -45,15 +47,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// </summary>
|
||||
public class AsyncCommandManager
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static Thread cmdHandlerThread;
|
||||
private static int cmdHandlerThreadCycleSleepms;
|
||||
|
||||
private static List<IScene> m_Scenes = new List<IScene>();
|
||||
/// <summary>
|
||||
/// Lock for reading/writing static components of AsyncCommandManager.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This lock exists so that multiple threads from different engines and/or different copies of the same engine
|
||||
/// are prevented from running non-thread safe code (e.g. read/write of lists) concurrently.
|
||||
/// </remarks>
|
||||
private static object staticLock = new object();
|
||||
|
||||
private static List<IScriptEngine> m_ScriptEngines =
|
||||
new List<IScriptEngine>();
|
||||
|
||||
public IScriptEngine m_ScriptEngine;
|
||||
private IScene m_Scene;
|
||||
|
||||
private static Dictionary<IScriptEngine, Dataserver> m_Dataserver =
|
||||
new Dictionary<IScriptEngine, Dataserver>();
|
||||
@@ -70,67 +81,99 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public Dataserver DataserverPlugin
|
||||
{
|
||||
get { return m_Dataserver[m_ScriptEngine]; }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_Dataserver[m_ScriptEngine];
|
||||
}
|
||||
}
|
||||
|
||||
public Timer TimerPlugin
|
||||
{
|
||||
get { return m_Timer[m_ScriptEngine]; }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_Timer[m_ScriptEngine];
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequest HttpRequestPlugin
|
||||
{
|
||||
get { return m_HttpRequest[m_ScriptEngine]; }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_HttpRequest[m_ScriptEngine];
|
||||
}
|
||||
}
|
||||
|
||||
public Listener ListenerPlugin
|
||||
{
|
||||
get { return m_Listener[m_ScriptEngine]; }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_Listener[m_ScriptEngine];
|
||||
}
|
||||
}
|
||||
|
||||
public SensorRepeat SensorRepeatPlugin
|
||||
{
|
||||
get { return m_SensorRepeat[m_ScriptEngine]; }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_SensorRepeat[m_ScriptEngine];
|
||||
}
|
||||
}
|
||||
|
||||
public XmlRequest XmlRequestPlugin
|
||||
{
|
||||
get { return m_XmlRequest[m_ScriptEngine]; }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_XmlRequest[m_ScriptEngine];
|
||||
}
|
||||
}
|
||||
|
||||
public IScriptEngine[] ScriptEngines
|
||||
{
|
||||
get { return m_ScriptEngines.ToArray(); }
|
||||
get
|
||||
{
|
||||
lock (staticLock)
|
||||
return m_ScriptEngines.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public AsyncCommandManager(IScriptEngine _ScriptEngine)
|
||||
{
|
||||
m_ScriptEngine = _ScriptEngine;
|
||||
m_Scene = m_ScriptEngine.World;
|
||||
|
||||
if (m_Scenes.Count == 0)
|
||||
ReadConfig();
|
||||
// If there is more than one scene in the simulator or multiple script engines are used on the same region
|
||||
// then more than one thread could arrive at this block of code simultaneously. However, it cannot be
|
||||
// executed concurrently both because concurrent list operations are not thread-safe and because of other
|
||||
// race conditions such as the later check of cmdHandlerThread == null.
|
||||
lock (staticLock)
|
||||
{
|
||||
if (m_ScriptEngines.Count == 0)
|
||||
ReadConfig();
|
||||
|
||||
if (!m_Scenes.Contains(m_Scene))
|
||||
m_Scenes.Add(m_Scene);
|
||||
if (!m_ScriptEngines.Contains(m_ScriptEngine))
|
||||
m_ScriptEngines.Add(m_ScriptEngine);
|
||||
if (!m_ScriptEngines.Contains(m_ScriptEngine))
|
||||
m_ScriptEngines.Add(m_ScriptEngine);
|
||||
|
||||
// Create instances of all plugins
|
||||
if (!m_Dataserver.ContainsKey(m_ScriptEngine))
|
||||
m_Dataserver[m_ScriptEngine] = new Dataserver(this);
|
||||
if (!m_Timer.ContainsKey(m_ScriptEngine))
|
||||
m_Timer[m_ScriptEngine] = new Timer(this);
|
||||
if (!m_HttpRequest.ContainsKey(m_ScriptEngine))
|
||||
m_HttpRequest[m_ScriptEngine] = new HttpRequest(this);
|
||||
if (!m_Listener.ContainsKey(m_ScriptEngine))
|
||||
m_Listener[m_ScriptEngine] = new Listener(this);
|
||||
if (!m_SensorRepeat.ContainsKey(m_ScriptEngine))
|
||||
m_SensorRepeat[m_ScriptEngine] = new SensorRepeat(this);
|
||||
if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
|
||||
m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
|
||||
// Create instances of all plugins
|
||||
if (!m_Dataserver.ContainsKey(m_ScriptEngine))
|
||||
m_Dataserver[m_ScriptEngine] = new Dataserver(this);
|
||||
if (!m_Timer.ContainsKey(m_ScriptEngine))
|
||||
m_Timer[m_ScriptEngine] = new Timer(this);
|
||||
if (!m_HttpRequest.ContainsKey(m_ScriptEngine))
|
||||
m_HttpRequest[m_ScriptEngine] = new HttpRequest(this);
|
||||
if (!m_Listener.ContainsKey(m_ScriptEngine))
|
||||
m_Listener[m_ScriptEngine] = new Listener(this);
|
||||
if (!m_SensorRepeat.ContainsKey(m_ScriptEngine))
|
||||
m_SensorRepeat[m_ScriptEngine] = new SensorRepeat(this);
|
||||
if (!m_XmlRequest.ContainsKey(m_ScriptEngine))
|
||||
m_XmlRequest[m_ScriptEngine] = new XmlRequest(this);
|
||||
|
||||
StartThread();
|
||||
StartThread();
|
||||
}
|
||||
}
|
||||
|
||||
private static void StartThread()
|
||||
@@ -179,42 +222,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||
Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||
|
||||
DoOneCmdHandlerPass();
|
||||
DoOneCmdHandlerPass();
|
||||
|
||||
Watchdog.UpdateThread();
|
||||
}
|
||||
Watchdog.UpdateThread();
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[ASYNC COMMAND MANAGER]: Exception in command handler pass: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DoOneCmdHandlerPass()
|
||||
{
|
||||
// Check HttpRequests
|
||||
m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests();
|
||||
|
||||
// Check XMLRPCRequests
|
||||
m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests();
|
||||
|
||||
foreach (IScriptEngine s in m_ScriptEngines)
|
||||
lock (staticLock)
|
||||
{
|
||||
// Check Listeners
|
||||
m_Listener[s].CheckListeners();
|
||||
// Check HttpRequests
|
||||
m_HttpRequest[m_ScriptEngines[0]].CheckHttpRequests();
|
||||
|
||||
// Check timers
|
||||
m_Timer[s].CheckTimerEvents();
|
||||
// Check XMLRPCRequests
|
||||
m_XmlRequest[m_ScriptEngines[0]].CheckXMLRPCRequests();
|
||||
|
||||
// Check Sensors
|
||||
m_SensorRepeat[s].CheckSenseRepeaterEvents();
|
||||
foreach (IScriptEngine s in m_ScriptEngines)
|
||||
{
|
||||
// Check Listeners
|
||||
m_Listener[s].CheckListeners();
|
||||
|
||||
// Check dataserver
|
||||
m_Dataserver[s].ExpireRequests();
|
||||
// Check timers
|
||||
m_Timer[s].CheckTimerEvents();
|
||||
|
||||
// Check Sensors
|
||||
m_SensorRepeat[s].CheckSenseRepeaterEvents();
|
||||
|
||||
// Check dataserver
|
||||
m_Dataserver[s].ExpireRequests();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,31 +270,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public static void RemoveScript(IScriptEngine engine, uint localID, UUID itemID)
|
||||
{
|
||||
// Remove a specific script
|
||||
// m_log.DebugFormat("[ASYNC COMMAND MANAGER]: Removing facilities for script {0}", itemID);
|
||||
|
||||
// Remove dataserver events
|
||||
m_Dataserver[engine].RemoveEvents(localID, itemID);
|
||||
|
||||
// Remove from: Timers
|
||||
m_Timer[engine].UnSetTimerEvents(localID, itemID);
|
||||
|
||||
// Remove from: HttpRequest
|
||||
IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>();
|
||||
if (iHttpReq != null)
|
||||
iHttpReq.StopHttpRequest(localID, itemID);
|
||||
|
||||
IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
|
||||
if (comms != null)
|
||||
comms.DeleteListener(itemID);
|
||||
|
||||
IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
|
||||
if (xmlrpc != null)
|
||||
lock (staticLock)
|
||||
{
|
||||
xmlrpc.DeleteChannels(itemID);
|
||||
xmlrpc.CancelSRDRequests(itemID);
|
||||
}
|
||||
// Remove dataserver events
|
||||
m_Dataserver[engine].RemoveEvents(localID, itemID);
|
||||
|
||||
// Remove Sensors
|
||||
m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
|
||||
// Remove from: Timers
|
||||
m_Timer[engine].UnSetTimerEvents(localID, itemID);
|
||||
|
||||
// Remove from: HttpRequest
|
||||
IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>();
|
||||
if (iHttpReq != null)
|
||||
iHttpReq.StopHttpRequest(localID, itemID);
|
||||
|
||||
IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
|
||||
if (comms != null)
|
||||
comms.DeleteListener(itemID);
|
||||
|
||||
IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
|
||||
if (xmlrpc != null)
|
||||
{
|
||||
xmlrpc.DeleteChannels(itemID);
|
||||
xmlrpc.CancelSRDRequests(itemID);
|
||||
}
|
||||
|
||||
// Remove Sensors
|
||||
m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -260,10 +308,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// <returns></returns>
|
||||
public static SensorRepeat GetSensorRepeatPlugin(IScriptEngine engine)
|
||||
{
|
||||
if (m_SensorRepeat.ContainsKey(engine))
|
||||
return m_SensorRepeat[engine];
|
||||
else
|
||||
return null;
|
||||
lock (staticLock)
|
||||
{
|
||||
if (m_SensorRepeat.ContainsKey(engine))
|
||||
return m_SensorRepeat[engine];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -273,10 +324,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// <returns></returns>
|
||||
public static Dataserver GetDataserverPlugin(IScriptEngine engine)
|
||||
{
|
||||
if (m_Dataserver.ContainsKey(engine))
|
||||
return m_Dataserver[engine];
|
||||
else
|
||||
return null;
|
||||
lock (staticLock)
|
||||
{
|
||||
if (m_Dataserver.ContainsKey(engine))
|
||||
return m_Dataserver[engine];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -286,10 +340,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// <returns></returns>
|
||||
public static Timer GetTimerPlugin(IScriptEngine engine)
|
||||
{
|
||||
if (m_Timer.ContainsKey(engine))
|
||||
return m_Timer[engine];
|
||||
else
|
||||
return null;
|
||||
lock (staticLock)
|
||||
{
|
||||
if (m_Timer.ContainsKey(engine))
|
||||
return m_Timer[engine];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -299,10 +356,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// <returns></returns>
|
||||
public static Listener GetListenerPlugin(IScriptEngine engine)
|
||||
{
|
||||
if (m_Listener.ContainsKey(engine))
|
||||
return m_Listener[engine];
|
||||
else
|
||||
return null;
|
||||
lock (staticLock)
|
||||
{
|
||||
if (m_Listener.ContainsKey(engine))
|
||||
return m_Listener[engine];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void StateChange(IScriptEngine engine, uint localID, UUID itemID)
|
||||
@@ -332,28 +392,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
List<Object> data = new List<Object>();
|
||||
|
||||
Object[] listeners = m_Listener[engine].GetSerializationData(itemID);
|
||||
if (listeners.Length > 0)
|
||||
lock (staticLock)
|
||||
{
|
||||
data.Add("listener");
|
||||
data.Add(listeners.Length);
|
||||
data.AddRange(listeners);
|
||||
}
|
||||
Object[] listeners = m_Listener[engine].GetSerializationData(itemID);
|
||||
if (listeners.Length > 0)
|
||||
{
|
||||
data.Add("listener");
|
||||
data.Add(listeners.Length);
|
||||
data.AddRange(listeners);
|
||||
}
|
||||
|
||||
Object[] timers=m_Timer[engine].GetSerializationData(itemID);
|
||||
if (timers.Length > 0)
|
||||
{
|
||||
data.Add("timer");
|
||||
data.Add(timers.Length);
|
||||
data.AddRange(timers);
|
||||
}
|
||||
Object[] timers=m_Timer[engine].GetSerializationData(itemID);
|
||||
if (timers.Length > 0)
|
||||
{
|
||||
data.Add("timer");
|
||||
data.Add(timers.Length);
|
||||
data.AddRange(timers);
|
||||
}
|
||||
|
||||
Object[] sensors = m_SensorRepeat[engine].GetSerializationData(itemID);
|
||||
if (sensors.Length > 0)
|
||||
{
|
||||
data.Add("sensor");
|
||||
data.Add(sensors.Length);
|
||||
data.AddRange(sensors);
|
||||
Object[] sensors = m_SensorRepeat[engine].GetSerializationData(itemID);
|
||||
if (sensors.Length > 0)
|
||||
{
|
||||
data.Add("sensor");
|
||||
data.Add(sensors.Length);
|
||||
data.AddRange(sensors);
|
||||
}
|
||||
}
|
||||
|
||||
return data.ToArray();
|
||||
@@ -378,41 +441,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
idx+=len;
|
||||
|
||||
lock (staticLock)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "listener":
|
||||
m_Listener[engine].CreateFromData(localID, itemID,
|
||||
hostID, item);
|
||||
break;
|
||||
case "timer":
|
||||
m_Timer[engine].CreateFromData(localID, itemID,
|
||||
hostID, item);
|
||||
break;
|
||||
case "sensor":
|
||||
m_SensorRepeat[engine].CreateFromData(localID,
|
||||
itemID, hostID, item);
|
||||
break;
|
||||
case "listener":
|
||||
m_Listener[engine].CreateFromData(localID, itemID,
|
||||
hostID, item);
|
||||
break;
|
||||
case "timer":
|
||||
m_Timer[engine].CreateFromData(localID, itemID,
|
||||
hostID, item);
|
||||
break;
|
||||
case "sensor":
|
||||
m_SensorRepeat[engine].CreateFromData(localID,
|
||||
itemID, hostID, item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1664,6 +1664,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.SetFaceColorAlpha(face, color, null);
|
||||
}
|
||||
|
||||
/*
|
||||
public void llSetContentType(LSL_Key id, LSL_Integer type)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (m_UrlModule == null)
|
||||
return;
|
||||
|
||||
// Make sure the content type is text/plain to start with
|
||||
m_UrlModule.HttpContentType(new UUID(id), "text/plain");
|
||||
|
||||
// Is the object owner online and in the region
|
||||
ScenePresence agent = World.GetScenePresence(m_host.ParentGroup.OwnerID);
|
||||
if (agent == null || agent.IsChildAgent)
|
||||
return; // Fail if the owner is not in the same region
|
||||
|
||||
// Is it the embeded browser?
|
||||
string userAgent = m_UrlModule.GetHttpHeader(new UUID(id), "user-agent");
|
||||
if (userAgent.IndexOf("SecondLife") < 0)
|
||||
return; // Not the embedded browser. Is this check good enough?
|
||||
|
||||
// Use the IP address of the client and check against the request
|
||||
// seperate logins from the same IP will allow all of them to get non-text/plain as long
|
||||
// as the owner is in the region. Same as SL!
|
||||
string logonFromIPAddress = agent.ControllingClient.RemoteEndPoint.Address.ToString();
|
||||
string requestFromIPAddress = m_UrlModule.GetHttpHeader(new UUID(id), "remote_addr");
|
||||
//m_log.Debug("IP from header='" + requestFromIPAddress + "' IP from endpoint='" + logonFromIPAddress + "'");
|
||||
if (requestFromIPAddress == null || requestFromIPAddress.Trim() == "")
|
||||
return;
|
||||
if (logonFromIPAddress == null || logonFromIPAddress.Trim() == "")
|
||||
return;
|
||||
|
||||
// If the request isnt from the same IP address then the request cannot be from the owner
|
||||
if (!requestFromIPAddress.Trim().Equals(logonFromIPAddress.Trim()))
|
||||
return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ScriptBaseClass.CONTENT_TYPE_HTML:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "text/html");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_XML:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/xml");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_XHTML:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/xhtml+xml");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_ATOM:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/atom+xml");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_JSON:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/json");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_LLSD:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/llsd+xml");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_FORM:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/x-www-form-urlencoded");
|
||||
break;
|
||||
case ScriptBaseClass.CONTENT_TYPE_RSS:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "application/rss+xml");
|
||||
break;
|
||||
default:
|
||||
m_UrlModule.HttpContentType(new UUID(id), "text/plain");
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public void SetTexGen(SceneObjectPart part, int face,int style)
|
||||
{
|
||||
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
|
||||
@@ -2772,9 +2841,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// send the sound, once, to all clients in range
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0,
|
||||
0, false, false);
|
||||
m_SoundModule.SendSound(
|
||||
m_host.UUID,
|
||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound),
|
||||
volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None,
|
||||
0, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3176,46 +3247,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// need the magnitude later
|
||||
// float velmag = (float)Util.GetMagnitude(llvel);
|
||||
|
||||
SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param);
|
||||
List<SceneObjectGroup> new_groups = World.RezObject(m_host, item, pos, rot, vel, param);
|
||||
|
||||
// If either of these are null, then there was an unknown error.
|
||||
if (new_group == null)
|
||||
if (new_groups == null)
|
||||
return;
|
||||
|
||||
// objects rezzed with this method are die_at_edge by default.
|
||||
new_group.RootPart.SetDieAtEdge(true);
|
||||
|
||||
new_group.ResumeScripts();
|
||||
|
||||
m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
|
||||
"object_rez", new Object[] {
|
||||
new LSL_String(
|
||||
new_group.RootPart.UUID.ToString()) },
|
||||
new DetectParams[0]));
|
||||
|
||||
// do recoil
|
||||
SceneObjectGroup hostgrp = m_host.ParentGroup;
|
||||
if (hostgrp == null)
|
||||
return;
|
||||
|
||||
if (hostgrp.IsAttachment) // don't recoil avatars
|
||||
return;
|
||||
|
||||
PhysicsActor pa = new_group.RootPart.PhysActor;
|
||||
|
||||
//Recoil.
|
||||
if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
|
||||
foreach (SceneObjectGroup group in new_groups)
|
||||
{
|
||||
float groupmass = new_group.GetMass();
|
||||
Vector3 recoil = -vel * groupmass * m_recoilScaleFactor;
|
||||
if (recoil != Vector3.Zero)
|
||||
{
|
||||
llApplyImpulse(recoil, 0);
|
||||
}
|
||||
}
|
||||
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
|
||||
return;
|
||||
// objects rezzed with this method are die_at_edge by default.
|
||||
group.RootPart.SetDieAtEdge(true);
|
||||
|
||||
group.ResumeScripts();
|
||||
|
||||
m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
|
||||
"object_rez", new Object[] {
|
||||
new LSL_String(
|
||||
group.RootPart.UUID.ToString()) },
|
||||
new DetectParams[0]));
|
||||
|
||||
float groupmass = group.GetMass();
|
||||
|
||||
PhysicsActor pa = group.RootPart.PhysActor;
|
||||
|
||||
//Recoil.
|
||||
if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
|
||||
{
|
||||
Vector3 recoil = -vel * groupmass * m_recoilScaleFactor;
|
||||
if (recoil != Vector3.Zero)
|
||||
{
|
||||
llApplyImpulse(recoil, 0);
|
||||
}
|
||||
}
|
||||
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
|
||||
}
|
||||
return;
|
||||
});
|
||||
|
||||
//ScriptSleep((int)((groupmass * velmag) / 10));
|
||||
@@ -4746,6 +4812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
UUID av = new UUID();
|
||||
if (!UUID.TryParse(agent,out av))
|
||||
{
|
||||
LSLError("First parameter to llTextBox needs to be a key");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5108,6 +5175,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
s = Math.Cos(angle * 0.5);
|
||||
t = Math.Sin(angle * 0.5); // temp value to avoid 2 more sin() calcs
|
||||
axis = LSL_Vector.Norm(axis);
|
||||
x = axis.x * t;
|
||||
y = axis.y * t;
|
||||
z = axis.z * t;
|
||||
@@ -5115,41 +5183,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return new LSL_Rotation(x,y,z,s);
|
||||
}
|
||||
|
||||
|
||||
// Xantor 29/apr/2008
|
||||
// converts a Quaternion to X,Y,Z axis rotations
|
||||
/// <summary>
|
||||
/// Returns the axis of rotation for a quaternion
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <param name='rot'></param>
|
||||
public LSL_Vector llRot2Axis(LSL_Rotation rot)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
double x,y,z;
|
||||
|
||||
if (rot.s > 1) // normalization needed
|
||||
{
|
||||
double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
|
||||
rot.z * rot.z + rot.s * rot.s);
|
||||
if (Math.Abs(rot.s) > 1) // normalization needed
|
||||
rot.Normalize();
|
||||
|
||||
rot.x /= length;
|
||||
rot.y /= length;
|
||||
rot.z /= length;
|
||||
rot.s /= length;
|
||||
|
||||
}
|
||||
|
||||
// double angle = 2 * Math.Acos(rot.s);
|
||||
double s = Math.Sqrt(1 - rot.s * rot.s);
|
||||
if (s < 0.001)
|
||||
{
|
||||
x = 1;
|
||||
y = z = 0;
|
||||
return new LSL_Vector(1, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = rot.x / s; // normalise axis
|
||||
y = rot.y / s;
|
||||
z = rot.z / s;
|
||||
double invS = 1.0 / s;
|
||||
if (rot.s < 0) invS = -invS;
|
||||
return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS);
|
||||
}
|
||||
|
||||
return new LSL_Vector(x,y,z);
|
||||
}
|
||||
|
||||
|
||||
@@ -5158,18 +5214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (rot.s > 1) // normalization needed
|
||||
{
|
||||
double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
|
||||
rot.z * rot.z + rot.s * rot.s);
|
||||
|
||||
rot.x /= length;
|
||||
rot.y /= length;
|
||||
rot.z /= length;
|
||||
rot.s /= length;
|
||||
}
|
||||
if (Math.Abs(rot.s) > 1) // normalization needed
|
||||
rot.Normalize();
|
||||
|
||||
double angle = 2 * Math.Acos(rot.s);
|
||||
if (angle > Math.PI)
|
||||
angle = 2 * Math.PI - angle;
|
||||
|
||||
return angle;
|
||||
}
|
||||
@@ -6687,7 +6737,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
PSYS_SRC_TARGET_KEY = 20,
|
||||
PSYS_SRC_OMEGA = 21,
|
||||
PSYS_SRC_ANGLE_BEGIN = 22,
|
||||
PSYS_SRC_ANGLE_END = 23
|
||||
PSYS_SRC_ANGLE_END = 23,
|
||||
PSYS_PART_BLEND_FUNC_SOURCE = 24,
|
||||
PSYS_PART_BLEND_FUNC_DEST = 25,
|
||||
PSYS_PART_START_GLOW = 26,
|
||||
PSYS_PART_END_GLOW = 27
|
||||
}
|
||||
|
||||
internal Primitive.ParticleSystem.ParticleDataFlags ConvertUINTtoFlags(uint flags)
|
||||
@@ -6713,6 +6767,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
ps.BurstRate = 0.1f;
|
||||
ps.PartMaxAge = 10.0f;
|
||||
ps.BurstPartCount = 1;
|
||||
ps.BlendFuncSource = ScriptBaseClass.PSYS_PART_BF_SOURCE_ALPHA;
|
||||
ps.BlendFuncDest = ScriptBaseClass.PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA;
|
||||
ps.PartStartGlow = 0.0f;
|
||||
ps.PartEndGlow = 0.0f;
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
||||
@@ -6747,6 +6806,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSL_Vector tempv = new LSL_Vector();
|
||||
|
||||
float tempf = 0;
|
||||
int tmpi = 0;
|
||||
|
||||
for (int i = 0; i < rules.Length; i += 2)
|
||||
{
|
||||
@@ -6805,7 +6865,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_PATTERN:
|
||||
int tmpi = (int)rules.GetLSLIntegerItem(i + 1);
|
||||
tmpi = (int)rules.GetLSLIntegerItem(i + 1);
|
||||
prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
|
||||
break;
|
||||
|
||||
@@ -6825,6 +6885,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off.
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_PART_BLEND_FUNC_SOURCE:
|
||||
tmpi = (int)rules.GetLSLIntegerItem(i + 1);
|
||||
prules.BlendFuncSource = (byte)tmpi;
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_PART_BLEND_FUNC_DEST:
|
||||
tmpi = (int)rules.GetLSLIntegerItem(i + 1);
|
||||
prules.BlendFuncDest = (byte)tmpi;
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_PART_START_GLOW:
|
||||
tempf = (float)rules.GetLSLFloatItem(i + 1);
|
||||
prules.PartStartGlow = (float)tempf;
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_PART_END_GLOW:
|
||||
tempf = (float)rules.GetLSLFloatItem(i + 1);
|
||||
prules.PartEndGlow = (float)tempf;
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
|
||||
prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1));
|
||||
break;
|
||||
@@ -8255,7 +8335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return null;
|
||||
|
||||
string ph = rules.Data[idx++].ToString();
|
||||
parentgrp.ScriptSetPhantomStatus(ph.Equals("1"));
|
||||
part.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1"));
|
||||
|
||||
break;
|
||||
|
||||
@@ -8308,7 +8388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return null;
|
||||
string temp = rules.Data[idx++].ToString();
|
||||
|
||||
parentgrp.ScriptSetTemporaryStatus(temp.Equals("1"));
|
||||
part.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1"));
|
||||
|
||||
break;
|
||||
|
||||
@@ -8846,8 +8926,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
int idx=0;
|
||||
while (idx < rules.Length)
|
||||
{
|
||||
int code=(int)rules.GetLSLIntegerItem(idx++);
|
||||
int remain=rules.Length-idx;
|
||||
int code = (int)rules.GetLSLIntegerItem(idx++);
|
||||
int remain = rules.Length - idx;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
@@ -8920,7 +9000,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_TYPE_SCULPT:
|
||||
res.Add(Shape.SculptTexture.ToString());
|
||||
res.Add(new LSL_String(Shape.SculptTexture.ToString()));
|
||||
res.Add(new LSL_Integer(Shape.SculptType));
|
||||
break;
|
||||
|
||||
@@ -9262,7 +9342,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
));
|
||||
break;
|
||||
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
|
||||
if(remain < 3)
|
||||
|
||||
// TODO: Should be issuing a runtime script warning in this case.
|
||||
if (remain < 2)
|
||||
return null;
|
||||
|
||||
return rules.GetSublist(idx, -1);
|
||||
@@ -12673,6 +12755,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public void llSetSoundQueueing(int queue)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (m_SoundModule != null)
|
||||
m_SoundModule.SetSoundQueueing(m_host.UUID, queue == ScriptBaseClass.TRUE.value);
|
||||
}
|
||||
|
||||
public void llCollisionSprite(string impact_sprite)
|
||||
|
||||
@@ -434,6 +434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
return wl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the current Windlight scene
|
||||
/// </summary>
|
||||
@@ -446,13 +447,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSShoutError("LightShare functions are not enabled.");
|
||||
return 0;
|
||||
}
|
||||
if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
|
||||
|
||||
if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
|
||||
{
|
||||
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
|
||||
return 0;
|
||||
ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
|
||||
|
||||
if (sp == null || sp.GodLevel < 200)
|
||||
{
|
||||
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int success = 0;
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (LightShareModule.EnableWindlight)
|
||||
{
|
||||
RegionLightShareData wl = getWindlightProfileFromRules(rules);
|
||||
@@ -465,8 +474,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSShoutError("Windlight module is disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public void lsClearWindlightScene()
|
||||
{
|
||||
if (!m_LSFunctionsEnabled)
|
||||
@@ -474,17 +485,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSShoutError("LightShare functions are not enabled.");
|
||||
return;
|
||||
}
|
||||
if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
|
||||
|
||||
if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
|
||||
{
|
||||
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
|
||||
return;
|
||||
ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
|
||||
|
||||
if (sp == null || sp.GodLevel < 200)
|
||||
{
|
||||
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false;
|
||||
if (m_host.ParentGroup.Scene.SimulationDataService != null)
|
||||
m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID);
|
||||
|
||||
m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the current Windlight scene to a target avatar
|
||||
/// </summary>
|
||||
@@ -497,13 +516,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSShoutError("LightShare functions are not enabled.");
|
||||
return 0;
|
||||
}
|
||||
if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
|
||||
|
||||
if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
|
||||
{
|
||||
LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
|
||||
return 0;
|
||||
ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
|
||||
|
||||
if (sp == null || sp.GodLevel < 200)
|
||||
{
|
||||
LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int success = 0;
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (LightShareModule.EnableWindlight)
|
||||
{
|
||||
RegionLightShareData wl = getWindlightProfileFromRules(rules);
|
||||
@@ -515,8 +542,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSShoutError("Windlight module is disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
object[] convertedParms = new object[parms.Length];
|
||||
for (int i = 0; i < parms.Length; i++)
|
||||
convertedParms[i] = ConvertFromLSL(parms[i],signature[i], fname);
|
||||
convertedParms[i] = ConvertFromLSL(parms[i], signature[i], fname);
|
||||
|
||||
// now call the function, the contract with the function is that it will always return
|
||||
// non-null but don't trust it completely
|
||||
@@ -448,7 +448,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
}
|
||||
|
||||
MODError(String.Format("{1}: parameter type mismatch; expecting {0}",type.Name, fname));
|
||||
MODError(String.Format("{0}: parameter type mismatch; expecting {1}, type(parm)={2}", fname, type.Name, lslparm.GetType()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -3005,6 +3005,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LSL_Vector osGetRegionSize()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osGetRegionSize");
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
bool isMegaregion;
|
||||
IRegionCombinerModule rcMod = World.RequestModuleInterface<IRegionCombinerModule>();
|
||||
if (rcMod != null)
|
||||
isMegaregion = rcMod.IsRootForMegaregion(World.RegionInfo.RegionID);
|
||||
else
|
||||
isMegaregion = false;
|
||||
|
||||
if (isMegaregion)
|
||||
{
|
||||
Vector2 size = rcMod.GetSizeOfMegaregion(World.RegionInfo.RegionID);
|
||||
return new LSL_Vector(size.X, size.Y, Constants.RegionHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LSL_Vector((float)Constants.RegionSize, (float)Constants.RegionSize, Constants.RegionHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public int osGetSimulatorMemory()
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osGetSimulatorMemory");
|
||||
@@ -3043,7 +3066,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
sp.ControllingClient.Kick(alert);
|
||||
|
||||
// ...and close on our side
|
||||
sp.Scene.IncomingCloseAgent(sp.UUID, false);
|
||||
sp.Scene.CloseAgent(sp.UUID, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -353,6 +353,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
// Position of a sensor in a child prim attached to an avatar
|
||||
// will be still wrong.
|
||||
ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
|
||||
|
||||
// Don't proceed if the avatar for this attachment has since been removed from the scene.
|
||||
if (avatar == null)
|
||||
return sensedEntities;
|
||||
|
||||
fromRegionPos = avatar.AbsolutePosition;
|
||||
q = avatar.Rotation;
|
||||
}
|
||||
@@ -363,7 +368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
|
||||
Vector3 ZeroVector = new Vector3(0, 0, 0);
|
||||
|
||||
bool nameSearch = (ts.name != null && ts.name != "");
|
||||
bool nameSearch = !string.IsNullOrEmpty(ts.name);
|
||||
|
||||
foreach (EntityBase ent in Entities)
|
||||
{
|
||||
@@ -483,6 +488,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
// Position of a sensor in a child prim attached to an avatar
|
||||
// will be still wrong.
|
||||
ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
|
||||
|
||||
// Don't proceed if the avatar for this attachment has since been removed from the scene.
|
||||
if (avatar == null)
|
||||
return sensedEntities;
|
||||
fromRegionPos = avatar.AbsolutePosition;
|
||||
@@ -601,7 +608,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
return sensedEntities;
|
||||
senseEntity(sp);
|
||||
}
|
||||
else if (ts.name != null && ts.name != "")
|
||||
else if (!string.IsNullOrEmpty(ts.name))
|
||||
{
|
||||
ScenePresence sp;
|
||||
// Try lookup by name will return if/when found
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -332,7 +332,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llSensorRemove();
|
||||
void llSensorRepeat(string name, string id, int type, double range, double arc, double rate);
|
||||
void llSetAlpha(double alpha, int face);
|
||||
void llSetAngularVelocity(LSL_Vector angvelocity, int local);
|
||||
void llSetBuoyancy(double buoyancy);
|
||||
void llSetCameraAtOffset(LSL_Vector offset);
|
||||
void llSetCameraEyeOffset(LSL_Vector offset);
|
||||
@@ -340,9 +339,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llSetCameraParams(LSL_List rules);
|
||||
void llSetClickAction(int action);
|
||||
void llSetColor(LSL_Vector color, int face);
|
||||
void llSetContentType(LSL_Key id, LSL_Integer type);
|
||||
void llSetDamage(double damage);
|
||||
void llSetForce(LSL_Vector force, int local);
|
||||
void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local);
|
||||
void llSetAngularVelocity(LSL_Vector angularVelocity, int local);
|
||||
void llSetHoverHeight(double height, int water, double tau);
|
||||
void llSetInventoryPermMask(string item, int mask, int value);
|
||||
void llSetLinkAlpha(int linknumber, double alpha, int face);
|
||||
@@ -383,7 +384,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llSetVehicleRotationParam(int param, LSL_Rotation rot);
|
||||
void llSetVehicleType(int type);
|
||||
void llSetVehicleVectorParam(int param, LSL_Vector vec);
|
||||
void llSetVelocity(LSL_Vector velocity, int local);
|
||||
void llShout(int channelID, string text);
|
||||
LSL_Float llSin(double f);
|
||||
void llSitTarget(LSL_Vector offset, LSL_Rotation rot);
|
||||
@@ -434,6 +434,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void llSetKeyframedMotion(LSL_List frames, LSL_List options);
|
||||
LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
|
||||
LSL_List llGetPhysicsMaterial();
|
||||
void llSetContentType(LSL_Key id, LSL_Integer content_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +336,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
key osGetMapTexture();
|
||||
key osGetRegionMapTexture(string regionName);
|
||||
LSL_List osGetRegionStats();
|
||||
vector osGetRegionSize();
|
||||
|
||||
int osGetSimulatorMemory();
|
||||
void osKickAvatar(string FirstName,string SurName,string alert);
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int PSYS_PART_TARGET_POS_MASK = 64;
|
||||
public const int PSYS_PART_TARGET_LINEAR_MASK = 128;
|
||||
public const int PSYS_PART_EMISSIVE_MASK = 256;
|
||||
public const int PSYS_PART_RIBBON_MASK = 1024;
|
||||
public const int PSYS_PART_FLAGS = 0;
|
||||
public const int PSYS_PART_START_COLOR = 1;
|
||||
public const int PSYS_PART_START_ALPHA = 2;
|
||||
@@ -130,6 +131,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int PSYS_SRC_OMEGA = 21;
|
||||
public const int PSYS_SRC_ANGLE_BEGIN = 22;
|
||||
public const int PSYS_SRC_ANGLE_END = 23;
|
||||
public const int PSYS_PART_BLEND_FUNC_SOURCE = 24;
|
||||
public const int PSYS_PART_BLEND_FUNC_DEST = 25;
|
||||
public const int PSYS_PART_START_GLOW = 26;
|
||||
public const int PSYS_PART_END_GLOW = 27;
|
||||
public const int PSYS_PART_BF_ONE = 0;
|
||||
public const int PSYS_PART_BF_ZERO = 1;
|
||||
public const int PSYS_PART_BF_DEST_COLOR = 2;
|
||||
public const int PSYS_PART_BF_SOURCE_COLOR = 3;
|
||||
public const int PSYS_PART_BF_ONE_MINUS_DEST_COLOR = 4;
|
||||
public const int PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR = 5;
|
||||
public const int PSYS_PART_BF_SOURCE_ALPHA = 7;
|
||||
public const int PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA = 9;
|
||||
public const int PSYS_SRC_PATTERN_DROP = 1;
|
||||
public const int PSYS_SRC_PATTERN_EXPLODE = 2;
|
||||
public const int PSYS_SRC_PATTERN_ANGLE = 4;
|
||||
@@ -361,6 +374,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int HTTP_CUSTOM_HEADER = 5;
|
||||
public const int HTTP_PRAGMA_NO_CACHE = 6;
|
||||
|
||||
// llSetContentType
|
||||
public const int CONTENT_TYPE_TEXT = 0; //text/plain
|
||||
public const int CONTENT_TYPE_HTML = 1; //text/html
|
||||
public const int CONTENT_TYPE_XML = 2; //application/xml
|
||||
public const int CONTENT_TYPE_XHTML = 3; //application/xhtml+xml
|
||||
public const int CONTENT_TYPE_ATOM = 4; //application/atom+xml
|
||||
public const int CONTENT_TYPE_JSON = 5; //application/json
|
||||
public const int CONTENT_TYPE_LLSD = 6; //application/llsd+xml
|
||||
public const int CONTENT_TYPE_FORM = 7; //application/x-www-form-urlencoded
|
||||
public const int CONTENT_TYPE_RSS = 8; //application/rss+xml
|
||||
|
||||
public const int PRIM_MATERIAL = 2;
|
||||
public const int PRIM_PHYSICS = 3;
|
||||
public const int PRIM_TEMP_ON_REZ = 4;
|
||||
@@ -772,8 +796,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
/// process message parameter as regex
|
||||
/// </summary>
|
||||
public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
|
||||
|
||||
public const int CONTENT_TYPE_TEXT = 0;
|
||||
public const int CONTENT_TYPE_HTML = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1495,11 +1495,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_LSL_Functions.llSetAlpha(alpha, face);
|
||||
}
|
||||
|
||||
public void llSetAngularVelocity(LSL_Vector angvelocity, int local)
|
||||
{
|
||||
m_LSL_Functions.llSetAngularVelocity(angvelocity, local);
|
||||
}
|
||||
|
||||
public void llSetBuoyancy(double buoyancy)
|
||||
{
|
||||
m_LSL_Functions.llSetBuoyancy(buoyancy);
|
||||
@@ -1535,6 +1530,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_LSL_Functions.llSetColor(color, face);
|
||||
}
|
||||
|
||||
public void llSetContentType(LSL_Key id, LSL_Integer type)
|
||||
{
|
||||
m_LSL_Functions.llSetContentType(id, type);
|
||||
}
|
||||
|
||||
public void llSetDamage(double damage)
|
||||
{
|
||||
m_LSL_Functions.llSetDamage(damage);
|
||||
@@ -1550,6 +1550,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_LSL_Functions.llSetForceAndTorque(force, torque, local);
|
||||
}
|
||||
|
||||
public void llSetAngularVelocity(LSL_Vector force, int local)
|
||||
{
|
||||
m_LSL_Functions.llSetAngularVelocity(force, local);
|
||||
}
|
||||
|
||||
public void llSetHoverHeight(double height, int water, double tau)
|
||||
{
|
||||
m_LSL_Functions.llSetHoverHeight(height, water, tau);
|
||||
@@ -1740,11 +1745,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_LSL_Functions.llSetVehicleVectorParam(param, vec);
|
||||
}
|
||||
|
||||
public void llSetVelocity(LSL_Vector velocity, int local)
|
||||
{
|
||||
m_LSL_Functions.llSetVelocity(velocity, local);
|
||||
}
|
||||
|
||||
public void llShout(int channelID, string text)
|
||||
{
|
||||
m_LSL_Functions.llShout(channelID, text);
|
||||
@@ -2014,10 +2014,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
{
|
||||
return m_LSL_Functions.llGetPhysicsMaterial();
|
||||
}
|
||||
|
||||
public void llSetContentType(LSL_Key id, LSL_Integer content_type)
|
||||
{
|
||||
m_LSL_Functions.llSetContentType(id, content_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,6 +858,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
return m_OSSL_Functions.osGetRegionStats();
|
||||
}
|
||||
|
||||
public vector osGetRegionSize()
|
||||
{
|
||||
return m_OSSL_Functions.osGetRegionSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of memory in use by the Simulator Daemon.
|
||||
/// Amount in bytes - if >= 4GB, returns 4GB. (LSL is not 64-bit aware)
|
||||
|
||||
@@ -937,7 +937,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||
{
|
||||
string retval = null;
|
||||
if (value is int)
|
||||
retval = ((int)value).ToString();
|
||||
retval = String.Format("new LSL_Types.LSLInteger({0})",((int)value).ToString());
|
||||
else if (value is float)
|
||||
retval = String.Format("new LSL_Types.LSLFloat({0})",((float)value).ToString());
|
||||
else if (value is string)
|
||||
|
||||
@@ -610,6 +610,7 @@ namespace SecondLife
|
||||
results = CScodeProvider.CompileAssemblyFromSource(
|
||||
parameters, Script);
|
||||
}
|
||||
|
||||
// Deal with an occasional segv in the compiler.
|
||||
// Rarely, if ever, occurs twice in succession.
|
||||
// Line # == 0 and no file name are indications that
|
||||
@@ -617,7 +618,7 @@ namespace SecondLife
|
||||
// error log.
|
||||
if (results.Errors.Count > 0)
|
||||
{
|
||||
if (!retried && (results.Errors[0].FileName == null || results.Errors[0].FileName == String.Empty) &&
|
||||
if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) &&
|
||||
results.Errors[0].Line == 0)
|
||||
{
|
||||
// System.Console.WriteLine("retrying failed compilation");
|
||||
@@ -647,15 +648,19 @@ namespace SecondLife
|
||||
"language type \"" + lang.ToString() + "\"");
|
||||
}
|
||||
|
||||
// Check result
|
||||
// Go through errors
|
||||
// foreach (Type type in results.CompiledAssembly.GetTypes())
|
||||
// {
|
||||
// foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
|
||||
// {
|
||||
// m_log.DebugFormat("[COMPILER]: {0}.{1}", type.FullName, method.Name);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// WARNINGS AND ERRORS
|
||||
//
|
||||
bool hadErrors = false;
|
||||
string errtext = String.Empty;
|
||||
|
||||
if (results.Errors.Count > 0)
|
||||
{
|
||||
foreach (CompilerError CompErr in results.Errors)
|
||||
|
||||
@@ -27,12 +27,16 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Tools;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||
{
|
||||
public class LSL2CSCodeTransformer
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private SYMBOL m_astRoot = null;
|
||||
private static Dictionary<string, string> m_datatypeLSL2OpenSim = null;
|
||||
|
||||
@@ -78,6 +82,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||
/// <param name="s">The current node to transform.</param>
|
||||
private void TransformNode(SYMBOL s)
|
||||
{
|
||||
// m_log.DebugFormat("[LSL2CSCODETRANSFORMER]: Tranforming node {0}", s);
|
||||
|
||||
// make sure to put type lower in the inheritance hierarchy first
|
||||
// ie: since IdentConstant and StringConstant inherit from Constant,
|
||||
// put IdentConstant and StringConstant before Constant
|
||||
@@ -103,10 +109,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||
// We need to check for that here.
|
||||
if (null != s.kids[i])
|
||||
{
|
||||
// m_log.Debug("[LSL2CSCODETRANSFORMER]: Moving down level");
|
||||
|
||||
if (!(s is Assignment || s is ArgumentDeclarationList) && s.kids[i] is Declaration)
|
||||
AddImplicitInitialization(s, i);
|
||||
|
||||
TransformNode((SYMBOL) s.kids[i]);
|
||||
|
||||
// m_log.Debug("[LSL2CSCODETRANSFORMER]: Moving up level");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -762,6 +762,7 @@ default
|
||||
public void TestIfStatement()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
string input = @"// let's test if statements
|
||||
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* 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 OpenSimulator 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.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using NUnit.Framework;
|
||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
||||
using OpenSim.Tests.Common;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
{
|
||||
public class LSL_EventTests : OpenSimTestCase
|
||||
{
|
||||
CSCodeGenerator m_cg = new CSCodeGenerator();
|
||||
|
||||
[Test]
|
||||
public void TestBadEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestCompile("default { bad() {} }", true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAttachEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestKeyArgEvent("attach");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestObjectRezEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestKeyArgEvent("object_rez");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMovingEndEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("moving_end");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMovingStartEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("moving_start");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoSensorEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("no_sensor");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotAtRotTargetEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("not_at_rot_target");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotAtTargetEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("not_at_target");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStateEntryEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("state_entry");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStateExitEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("state_exit");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTimerEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVoidArgEvent("timer");
|
||||
}
|
||||
|
||||
private void TestVoidArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "() {} }", false);
|
||||
TestCompile("default { " + eventName + "(integer n) {} }", true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangedEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("changed");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCollisionEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("collision");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCollisionStartEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("collision_start");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCollisionEndEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("collision_end");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnRezEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("on_rez");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRunTimePermissionsEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("run_time_permissions");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSensorEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("sensor");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTouchEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("touch");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTouchStartEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("touch_start");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTouchEndEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntArgEvent("touch_end");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLandCollisionEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVectorArgEvent("land_collision");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLandCollisionStartEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVectorArgEvent("land_collision_start");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLandCollisionEndEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestVectorArgEvent("land_collision_end");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAtRotTargetEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntRotRotArgEvent("at_rot_target");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAtTargetEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestIntVecVecArgEvent("at_target");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestControlEvent()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
TestKeyIntIntArgEvent("control");
|
||||
}
|
||||
|
||||
private void TestIntArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "(integer n) {} }", false);
|
||||
TestCompile("default { " + eventName + "{{}} }", true);
|
||||
TestCompile("default { " + eventName + "(string s) {{}} }", true);
|
||||
TestCompile("default { " + eventName + "(integer n, integer o) {{}} }", true);
|
||||
}
|
||||
|
||||
private void TestKeyArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "(key k) {} }", false);
|
||||
TestCompile("default { " + eventName + "{{}} }", true);
|
||||
TestCompile("default { " + eventName + "(string s) {{}} }", true);
|
||||
TestCompile("default { " + eventName + "(key k, key l) {{}} }", true);
|
||||
}
|
||||
|
||||
private void TestVectorArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "(vector v) {} }", false);
|
||||
TestCompile("default { " + eventName + "{{}} }", true);
|
||||
TestCompile("default { " + eventName + "(string s) {{}} }", true);
|
||||
TestCompile("default { " + eventName + "(vector v, vector w) {{}} }", true);
|
||||
}
|
||||
|
||||
private void TestIntRotRotArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "(integer n, rotation r, rotation s) {} }", false);
|
||||
TestCompile("default { " + eventName + "{{}} }", true);
|
||||
TestCompile("default { " + eventName + "(string s) {{}} }", true);
|
||||
TestCompile("default { " + eventName + "(integer n, rotation r, rotation s, rotation t) {{}} }", true);
|
||||
}
|
||||
|
||||
private void TestIntVecVecArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "(integer n, vector v, vector w) {} }", false);
|
||||
TestCompile("default { " + eventName + "{{}} }", true);
|
||||
TestCompile("default { " + eventName + "(string s) {{}} }", true);
|
||||
TestCompile("default { " + eventName + "(integer n, vector v, vector w, vector x) {{}} }", true);
|
||||
}
|
||||
|
||||
private void TestKeyIntIntArgEvent(string eventName)
|
||||
{
|
||||
TestCompile("default { " + eventName + "(key k, integer n, integer o) {} }", false);
|
||||
TestCompile("default { " + eventName + "{{}} }", true);
|
||||
TestCompile("default { " + eventName + "(string s) {{}} }", true);
|
||||
TestCompile("default { " + eventName + "(key k, integer n, integer o, integer p) {{}} }", true);
|
||||
}
|
||||
|
||||
private void TestCompile(string script, bool expectException)
|
||||
{
|
||||
bool gotException = false;
|
||||
Exception ge = null;
|
||||
|
||||
try
|
||||
{
|
||||
m_cg.Convert(script);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
gotException = true;
|
||||
ge = e;
|
||||
}
|
||||
|
||||
Assert.That(
|
||||
gotException,
|
||||
Is.EqualTo(expectException),
|
||||
"Failed on {0}, exception {1}", script, ge != null ? ge.ToString() : "n/a");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op")
|
||||
{
|
||||
m_coopTermination = true;
|
||||
m_coopSleepHandle = new AutoResetEvent(false);
|
||||
m_coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,8 +529,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
{
|
||||
File.Delete(savedState);
|
||||
}
|
||||
catch(Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn(
|
||||
string.Format(
|
||||
"[SCRIPT INSTANCE]: Could not delete script state {0} for script {1} (id {2}) in part {3} (id {4}) in object {5} in {6}. Exception ",
|
||||
savedState, ScriptTask.Name, ScriptTask.ItemID, Part.Name, Part.UUID, Part.ParentGroup.Name, Engine.World.Name),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,9 +573,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
|
||||
public bool Stop(int timeout)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[SCRIPT INSTANCE]: Stopping script {0} {1} in {2} {3} with timeout {4} {5} {6}",
|
||||
// ScriptName, ItemID, PrimName, ObjectID, timeout, m_InSelfDelete, DateTime.Now.Ticks);
|
||||
if (DebugLevel >= 1)
|
||||
m_log.DebugFormat(
|
||||
"[SCRIPT INSTANCE]: Stopping script {0} {1} in {2} {3} with timeout {4} {5} {6}",
|
||||
ScriptName, ItemID, PrimName, ObjectID, timeout, m_InSelfDelete, DateTime.Now.Ticks);
|
||||
|
||||
IScriptWorkItem workItem;
|
||||
|
||||
@@ -1216,4 +1222,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
Suspended = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Xengine event wait handle.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class exists becase XEngineScriptBase gets a reference to this wait handle. We need to make sure that
|
||||
/// when scripts are running in different AppDomains the lease does not expire.
|
||||
/// FIXME: Like LSL_Api, etc., this effectively leaks memory since the GC will never collect it. To avoid this,
|
||||
/// proper remoting sponsorship needs to be implemented across the board.
|
||||
/// </remarks>
|
||||
public class XEngineEventWaitHandle : EventWaitHandle
|
||||
{
|
||||
public XEngineEventWaitHandle(bool initialState, EventResetMode mode) : base(initialState, mode) {}
|
||||
|
||||
public override Object InitializeLifetimeService()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,6 +371,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public Quaternion Normalize()
|
||||
{
|
||||
double length = Math.Sqrt(x * x + y * y + z * z + s * s);
|
||||
if (length < float.Epsilon)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
s = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
double invLength = 1.0 / length;
|
||||
x *= invLength;
|
||||
y *= invLength;
|
||||
z *= invLength;
|
||||
s *= invLength;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overriders
|
||||
|
||||
public override int GetHashCode()
|
||||
@@ -546,21 +571,33 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
|
||||
set {m_data = value; }
|
||||
}
|
||||
// Function to obtain LSL type from an index. This is needed
|
||||
// because LSL lists allow for multiple types, and safely
|
||||
// iterating in them requires a type check.
|
||||
|
||||
/// <summary>
|
||||
/// Obtain LSL type from an index.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is needed because LSL lists allow for multiple types, and safely
|
||||
/// iterating in them requires a type check.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='itemIndex'></param>
|
||||
public Type GetLSLListItemType(int itemIndex)
|
||||
{
|
||||
return m_data[itemIndex].GetType();
|
||||
}
|
||||
|
||||
// Member functions to obtain item as specific types.
|
||||
// For cases where implicit conversions would apply if items
|
||||
// were not in a list (e.g. integer to float, but not float
|
||||
// to integer) functions check for alternate types so as to
|
||||
// down-cast from Object to the correct type.
|
||||
// Note: no checks for item index being valid are performed
|
||||
|
||||
/// <summary>
|
||||
/// Obtain float from an index.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For cases where implicit conversions would apply if items
|
||||
/// were not in a list (e.g. integer to float, but not float
|
||||
/// to integer) functions check for alternate types so as to
|
||||
/// down-cast from Object to the correct type.
|
||||
/// Note: no checks for item index being valid are performed
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
/// <param name='itemIndex'></param>
|
||||
public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex)
|
||||
{
|
||||
if (m_data[itemIndex] is LSL_Types.LSLInteger)
|
||||
@@ -591,26 +628,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
|
||||
public LSL_Types.LSLString GetLSLStringItem(int itemIndex)
|
||||
{
|
||||
if (m_data[itemIndex] is LSL_Types.key)
|
||||
{
|
||||
return (LSL_Types.key)m_data[itemIndex];
|
||||
}
|
||||
else if (m_data[itemIndex] is String)
|
||||
{
|
||||
return new LSL_Types.LSLString((string)m_data[itemIndex]);
|
||||
}
|
||||
else if (m_data[itemIndex] is LSL_Types.LSLFloat)
|
||||
{
|
||||
return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]);
|
||||
}
|
||||
else if (m_data[itemIndex] is LSL_Types.LSLInteger)
|
||||
{
|
||||
return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (LSL_Types.LSLString)m_data[itemIndex];
|
||||
}
|
||||
if (m_data[itemIndex] is LSL_Types.key)
|
||||
{
|
||||
return (LSL_Types.key)m_data[itemIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LSL_Types.LSLString(m_data[itemIndex].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
string[] ncLines = { "One", "Two", "Three" };
|
||||
string[] ncLines = { "One", "Twoè", "Three" };
|
||||
|
||||
TaskInventoryItem ncItem
|
||||
= TaskInventoryHelpers.AddNotecard(m_scene, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines));
|
||||
|
||||
399
OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs
Normal file
399
OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs
Normal file
@@ -0,0 +1,399 @@
|
||||
/*
|
||||
* 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 OpenSimulator 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.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Assets;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
||||
using OpenSim.Region.OptionalModules.World.NPC;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Instance;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
|
||||
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class LSL_ApiObjectTests : OpenSimTestCase
|
||||
{
|
||||
private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
|
||||
private const float FLOAT_ACCURACY = 0.00005f;
|
||||
|
||||
protected Scene m_scene;
|
||||
protected XEngine.XEngine m_engine;
|
||||
|
||||
[SetUp]
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
IConfigSource initConfigSource = new IniConfigSource();
|
||||
IConfig config = initConfigSource.AddConfig("XEngine");
|
||||
config.Set("Enabled", "true");
|
||||
|
||||
m_scene = new SceneHelpers().SetupScene();
|
||||
SceneHelpers.SetupSceneModules(m_scene, initConfigSource);
|
||||
|
||||
m_engine = new XEngine.XEngine();
|
||||
m_engine.Initialise(initConfigSource);
|
||||
m_engine.AddRegion(m_scene);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestllGetLinkPrimitiveParams()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
TestHelpers.EnableLogging();
|
||||
|
||||
UUID ownerId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10);
|
||||
grp1.AbsolutePosition = new Vector3(10, 11, 12);
|
||||
m_scene.AddSceneObject(grp1);
|
||||
|
||||
LSL_Api apiGrp1 = new LSL_Api();
|
||||
apiGrp1.Initialize(m_engine, grp1.RootPart, null, null);
|
||||
|
||||
// Check simple 1 prim case
|
||||
{
|
||||
LSL_List resList
|
||||
= apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
|
||||
|
||||
Assert.That(resList.Length, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
// Check 2 prim case
|
||||
{
|
||||
LSL_List resList
|
||||
= apiGrp1.llGetLinkPrimitiveParams(
|
||||
1,
|
||||
new LSL_List(
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
|
||||
new LSL_Integer(2),
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
|
||||
|
||||
Assert.That(resList.Length, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
// Check invalid parameters are ignored
|
||||
{
|
||||
LSL_List resList
|
||||
= apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
|
||||
|
||||
Assert.That(resList.Length, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
// Check all parameters are ignored if an initial bad link is given
|
||||
{
|
||||
LSL_List resList
|
||||
= apiGrp1.llGetLinkPrimitiveParams(
|
||||
3,
|
||||
new LSL_List(
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
|
||||
new LSL_Integer(1),
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
|
||||
|
||||
Assert.That(resList.Length, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
// Check only subsequent parameters are ignored when we hit the first bad link number
|
||||
{
|
||||
LSL_List resList
|
||||
= apiGrp1.llGetLinkPrimitiveParams(
|
||||
1,
|
||||
new LSL_List(
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
|
||||
new LSL_Integer(3),
|
||||
new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
|
||||
|
||||
Assert.That(resList.Length, Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
// llSetPrimitiveParams and llGetPrimitiveParams test.
|
||||
public void TestllSetPrimitiveParams()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
// Create Prim1.
|
||||
Scene scene = new SceneHelpers().SetupScene();
|
||||
string obj1Name = "Prim1";
|
||||
UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
|
||||
SceneObjectPart part1 =
|
||||
new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
|
||||
Vector3.Zero, Quaternion.Identity,
|
||||
Vector3.Zero) { Name = obj1Name, UUID = objUuid };
|
||||
Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);
|
||||
|
||||
LSL_Api apiGrp1 = new LSL_Api();
|
||||
apiGrp1.Initialize(m_engine, part1, null, null);
|
||||
|
||||
// Note that prim hollow check is passed with the other prim params in order to allow the
|
||||
// specification of a different check value from the prim param. A cylinder, prism, sphere,
|
||||
// torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below
|
||||
// specifies a value of 95% and checks to see if 70% was properly returned.
|
||||
|
||||
// Test a sphere.
|
||||
CheckllSetPrimitiveParams(
|
||||
apiGrp1,
|
||||
"test 1", // Prim test identification string
|
||||
new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
|
||||
0.80f, // Prim hollow
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple
|
||||
0.80f); // Prim hollow check
|
||||
|
||||
// Test a prism.
|
||||
CheckllSetPrimitiveParams(
|
||||
apiGrp1,
|
||||
"test 2", // Prim test identification string
|
||||
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.90f, // Prim hollow
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
|
||||
0.90f); // Prim hollow check
|
||||
|
||||
// Test a box.
|
||||
CheckllSetPrimitiveParams(
|
||||
apiGrp1,
|
||||
"test 3", // Prim test identification string
|
||||
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.95f, // Prim hollow
|
||||
new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
|
||||
0.95f); // Prim hollow check
|
||||
|
||||
// Test a tube.
|
||||
CheckllSetPrimitiveParams(
|
||||
apiGrp1,
|
||||
"test 4", // Prim test identification string
|
||||
new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.00f, // Prim hollow
|
||||
new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size
|
||||
// Expression for y selected to test precision problems during byte
|
||||
// cast in SetPrimitiveShapeParams.
|
||||
new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
|
||||
// Expression for y selected to test precision problems during sbyte
|
||||
// cast in SetPrimitiveShapeParams.
|
||||
new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper
|
||||
1.11f, // Prim revolutions
|
||||
0.88f, // Prim radius
|
||||
0.95f, // Prim skew
|
||||
0.00f); // Prim hollow check
|
||||
|
||||
// Test a prism.
|
||||
CheckllSetPrimitiveParams(
|
||||
apiGrp1,
|
||||
"test 5", // Prim test identification string
|
||||
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.95f, // Prim hollow
|
||||
// Expression for x selected to test precision problems during sbyte
|
||||
// cast in SetPrimitiveShapeBlockParams.
|
||||
new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist
|
||||
// Expression for y selected to test precision problems during sbyte
|
||||
// cast in SetPrimitiveShapeParams.
|
||||
new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
|
||||
0.70f); // Prim hollow check
|
||||
|
||||
// Test a sculpted prim.
|
||||
CheckllSetPrimitiveParams(
|
||||
apiGrp1,
|
||||
"test 6", // Prim test identification string
|
||||
new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type
|
||||
"be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map
|
||||
ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type
|
||||
}
|
||||
|
||||
// Set prim params for a box, cylinder or prism and check results.
|
||||
public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
|
||||
float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear,
|
||||
float primHollowCheck)
|
||||
{
|
||||
// Set the prim params.
|
||||
api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
|
||||
primCut, primHollow, primTwist, primTaper, primShear));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Validate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
|
||||
CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut");
|
||||
Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
|
||||
CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist");
|
||||
CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 6), primTest + " prim taper");
|
||||
CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear");
|
||||
}
|
||||
|
||||
// Set prim params for a sphere and check results.
|
||||
public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
|
||||
float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck)
|
||||
{
|
||||
// Set the prim params.
|
||||
api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
|
||||
primCut, primHollow, primTwist, primDimple));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Validate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
|
||||
CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut");
|
||||
Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
|
||||
CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist");
|
||||
CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple");
|
||||
}
|
||||
|
||||
// Set prim params for a torus, tube or ring and check results.
|
||||
public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
|
||||
float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
|
||||
LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
|
||||
float primRev, float primRadius, float primSkew, float primHollowCheck)
|
||||
{
|
||||
// Set the prim params.
|
||||
api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
|
||||
primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
|
||||
primTaper, primRev, primRadius, primSkew));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Valdate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
|
||||
CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut");
|
||||
Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
|
||||
CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist");
|
||||
CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size");
|
||||
CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear");
|
||||
CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut");
|
||||
CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper");
|
||||
Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim revolutions fail");
|
||||
Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim radius fail");
|
||||
Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim skew fail");
|
||||
}
|
||||
|
||||
// Set prim params for a sculpted prim and check results.
|
||||
public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType)
|
||||
{
|
||||
// Set the prim params.
|
||||
api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Validate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim map check fail");
|
||||
Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail");
|
||||
}
|
||||
|
||||
public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
|
||||
{
|
||||
// Check each vector component against expected result.
|
||||
Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + msg + " vector check fail on x component");
|
||||
Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + msg + " vector check fail on y component");
|
||||
Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + msg + " vector check fail on z component");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -47,9 +47,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
[TestFixture, LongRunning]
|
||||
public class LSL_ApiTest
|
||||
{
|
||||
private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
|
||||
private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
|
||||
private const float FLOAT_ACCURACY = 0.00005f;
|
||||
private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
|
||||
private LSL_Api m_lslApi;
|
||||
|
||||
[SetUp]
|
||||
@@ -254,241 +253,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
Assert.AreEqual(0.0, check.z, VECTOR_COMPONENT_ACCURACY, "TestllRot2Euler Z bounds check fail");
|
||||
}
|
||||
|
||||
[Test]
|
||||
// llSetPrimitiveParams and llGetPrimitiveParams test.
|
||||
public void TestllSetPrimitiveParams()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
// Create Prim1.
|
||||
Scene scene = new SceneHelpers().SetupScene();
|
||||
string obj1Name = "Prim1";
|
||||
UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
|
||||
SceneObjectPart part1 =
|
||||
new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
|
||||
Vector3.Zero, Quaternion.Identity,
|
||||
Vector3.Zero) { Name = obj1Name, UUID = objUuid };
|
||||
Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);
|
||||
|
||||
// Note that prim hollow check is passed with the other prim params in order to allow the
|
||||
// specification of a different check value from the prim param. A cylinder, prism, sphere,
|
||||
// torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below
|
||||
// specifies a value of 95% and checks to see if 70% was properly returned.
|
||||
|
||||
// Test a sphere.
|
||||
CheckllSetPrimitiveParams(
|
||||
"test 1", // Prim test identification string
|
||||
new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
|
||||
0.80f, // Prim hollow
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple
|
||||
0.80f); // Prim hollow check
|
||||
|
||||
// Test a prism.
|
||||
CheckllSetPrimitiveParams(
|
||||
"test 2", // Prim test identification string
|
||||
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.90f, // Prim hollow
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
|
||||
0.90f); // Prim hollow check
|
||||
|
||||
// Test a box.
|
||||
CheckllSetPrimitiveParams(
|
||||
"test 3", // Prim test identification string
|
||||
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.95f, // Prim hollow
|
||||
new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
|
||||
0.95f); // Prim hollow check
|
||||
|
||||
// Test a tube.
|
||||
CheckllSetPrimitiveParams(
|
||||
"test 4", // Prim test identification string
|
||||
new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.00f, // Prim hollow
|
||||
new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
|
||||
new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size
|
||||
// Expression for y selected to test precision problems during byte
|
||||
// cast in SetPrimitiveShapeParams.
|
||||
new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
|
||||
// Expression for y selected to test precision problems during sbyte
|
||||
// cast in SetPrimitiveShapeParams.
|
||||
new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper
|
||||
1.11f, // Prim revolutions
|
||||
0.88f, // Prim radius
|
||||
0.95f, // Prim skew
|
||||
0.00f); // Prim hollow check
|
||||
|
||||
// Test a prism.
|
||||
CheckllSetPrimitiveParams(
|
||||
"test 5", // Prim test identification string
|
||||
new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
|
||||
ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
|
||||
new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
|
||||
0.95f, // Prim hollow
|
||||
// Expression for x selected to test precision problems during sbyte
|
||||
// cast in SetPrimitiveShapeBlockParams.
|
||||
new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist
|
||||
// Expression for y selected to test precision problems during sbyte
|
||||
// cast in SetPrimitiveShapeParams.
|
||||
new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper
|
||||
new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
|
||||
0.70f); // Prim hollow check
|
||||
|
||||
// Test a sculpted prim.
|
||||
CheckllSetPrimitiveParams(
|
||||
"test 6", // Prim test identification string
|
||||
new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size
|
||||
ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type
|
||||
"be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map
|
||||
ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type
|
||||
}
|
||||
|
||||
// Set prim params for a box, cylinder or prism and check results.
|
||||
public void CheckllSetPrimitiveParams(string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
|
||||
float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear,
|
||||
float primHollowCheck)
|
||||
{
|
||||
// Set the prim params.
|
||||
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
|
||||
primCut, primHollow, primTwist, primTaper, primShear));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Validate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
|
||||
CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
|
||||
Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
|
||||
CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
|
||||
CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper");
|
||||
CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
|
||||
}
|
||||
|
||||
// Set prim params for a sphere and check results.
|
||||
public void CheckllSetPrimitiveParams(string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
|
||||
float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck)
|
||||
{
|
||||
// Set the prim params.
|
||||
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
|
||||
primCut, primHollow, primTwist, primDimple));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Validate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
|
||||
CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
|
||||
Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
|
||||
CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
|
||||
CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple");
|
||||
}
|
||||
|
||||
// Set prim params for a torus, tube or ring and check results.
|
||||
public void CheckllSetPrimitiveParams(string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
|
||||
float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
|
||||
LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
|
||||
float primRev, float primRadius, float primSkew, float primHollowCheck)
|
||||
{
|
||||
// Set the prim params.
|
||||
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
|
||||
primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
|
||||
primTaper, primRev, primRadius, primSkew));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Valdate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
|
||||
CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
|
||||
Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
|
||||
CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
|
||||
CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size");
|
||||
CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
|
||||
CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut");
|
||||
CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper");
|
||||
Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim revolutions fail");
|
||||
Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim radius fail");
|
||||
Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + primTest + " prim skew fail");
|
||||
}
|
||||
|
||||
// Set prim params for a sculpted prim and check results.
|
||||
public void CheckllSetPrimitiveParams(string primTest,
|
||||
LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType)
|
||||
{
|
||||
// Set the prim params.
|
||||
m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
|
||||
ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType));
|
||||
|
||||
// Get params for prim to validate settings.
|
||||
LSL_Types.list primParams =
|
||||
m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
|
||||
|
||||
// Validate settings.
|
||||
CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
|
||||
Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type check fail");
|
||||
Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim map check fail");
|
||||
Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3),
|
||||
"TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail");
|
||||
}
|
||||
|
||||
public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
|
||||
{
|
||||
// Check each vector component against expected result.
|
||||
Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + msg + " vector check fail on x component");
|
||||
Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + msg + " vector check fail on y component");
|
||||
Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
|
||||
"TestllSetPrimitiveParams " + msg + " vector check fail on z component");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestllVecNorm()
|
||||
{
|
||||
|
||||
@@ -180,6 +180,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||
public void TestOsNpcLoadAppearance()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
//TestHelpers.EnableLogging();
|
||||
|
||||
// Store an avatar with a different height from default in a notecard.
|
||||
UUID userId = TestHelpers.ParseTail(0x1);
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.0.*")]
|
||||
|
||||
|
||||
@@ -551,7 +551,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
/// <param name="instance"></param>
|
||||
/// <param name="keySelector">Basis on which to sort output. Can be null if no sort needs to take place</param>
|
||||
private void HandleScriptsAction<TKey>(
|
||||
string[] cmdparams, Action<IScriptInstance> action, Func<IScriptInstance, TKey> keySelector)
|
||||
string[] cmdparams, Action<IScriptInstance> action, System.Func<IScriptInstance, TKey> keySelector)
|
||||
{
|
||||
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
|
||||
return;
|
||||
@@ -1633,7 +1633,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
startInfo.MaxWorkerThreads = maxThreads;
|
||||
startInfo.MinWorkerThreads = minThreads;
|
||||
startInfo.ThreadPriority = threadPriority;;
|
||||
startInfo.StackSize = stackSize;
|
||||
startInfo.MaxStackSize = stackSize;
|
||||
startInfo.StartSuspended = true;
|
||||
|
||||
m_ThreadPool = new SmartThreadPool(startInfo);
|
||||
@@ -1827,9 +1827,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
public bool GetScriptState(UUID itemID)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance != null)
|
||||
return instance.Running;
|
||||
return false;
|
||||
return instance != null && instance.Running;
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode]
|
||||
@@ -1874,9 +1872,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
public DetectParams GetDetectParams(UUID itemID, int idx)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance != null)
|
||||
return instance.GetDetectParams(idx);
|
||||
return null;
|
||||
return instance != null ? instance.GetDetectParams(idx) : null;
|
||||
}
|
||||
|
||||
public void SetMinEventDelay(UUID itemID, double delay)
|
||||
@@ -1889,9 +1885,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
public UUID GetDetectID(UUID itemID, int idx)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance != null)
|
||||
return instance.GetDetectID(idx);
|
||||
return UUID.Zero;
|
||||
return instance != null ? instance.GetDetectID(idx) : UUID.Zero;
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode]
|
||||
@@ -1906,9 +1900,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
public int GetStartParameter(UUID itemID)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance == null)
|
||||
return 0;
|
||||
return instance.StartParam;
|
||||
return instance == null ? 0 : instance.StartParam;
|
||||
}
|
||||
|
||||
public void OnShutdown()
|
||||
@@ -1941,9 +1933,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
public IScriptApi GetApi(UUID itemID, string name)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance == null)
|
||||
return null;
|
||||
return instance.GetApi(name);
|
||||
return instance == null ? null : instance.GetApi(name);
|
||||
}
|
||||
|
||||
public void OnGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
|
||||
|
||||
@@ -52,16 +52,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
return wr.Cancel();
|
||||
}
|
||||
|
||||
public void Abort()
|
||||
public bool Abort()
|
||||
{
|
||||
wr.Abort();
|
||||
return wr.Cancel(true);
|
||||
}
|
||||
|
||||
public bool Wait(int t)
|
||||
{
|
||||
// We use the integer version of WaitAll because the current version of SmartThreadPool has a bug with the
|
||||
// TimeSpan version. The number of milliseconds in TimeSpan is an int64 so when STP casts it down to an
|
||||
// int (32-bit) we can end up with bad values. This occurs on Windows though curious not on Mono 2.10.8
|
||||
// int (32-bit) we can end up with bad values. This occurs on Windows though curiously not on Mono 2.10.8
|
||||
// (or very likely other versions of Mono at least up until 3.0.3).
|
||||
return SmartThreadPool.WaitAll(new IWorkItemResult[] {wr}, t, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user