An initial implementation of llMinEventDelay in XEngine.

Not implemented yet in DotNetEngine.
Fixes Mantis #2830
0.6.2-post-fixes
idb 2008-12-21 19:04:06 +00:00
parent 7d837a9bea
commit 3fe966d6b3
7 changed files with 71 additions and 2 deletions

View File

@ -240,6 +240,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
return m_ScriptManager.GetStartParameter(itemID);
}
public void SetMinEventDelay(UUID itemID, double delay)
{
// TODO in DotNet, done in XEngine
throw new NotImplementedException();
}
#endregion
public void SetState(UUID itemID, string state)

View File

@ -61,6 +61,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
bool PostObjectEvent(uint localID, EventParams parms);
DetectParams GetDetectParams(UUID item, int number);
void SetMinEventDelay(UUID itemID, double delay);
int GetStartParameter(UUID itemID);
void SetScriptState(UUID itemID, bool state);

View File

@ -102,5 +102,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
string GetAssemblyName();
string GetXMLState();
double MinEventDelay { set; }
}
}

View File

@ -2756,7 +2756,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llMinEventDelay(double delay)
{
m_host.AddScriptLPS(1);
NotImplemented("llMinEventDelay");
try
{
m_ScriptEngine.SetMinEventDelay(m_itemID, delay);
}
catch (NotImplementedException)
{
// Currently not implemented in DotNetEngine only XEngine
NotImplemented("llMinEventDelay in DotNetEngine");
}
}
/// <summary>

View File

@ -84,6 +84,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private int m_LastControlLevel = 0;
private bool m_CollisionInQueue = false;
private TaskInventoryItem m_thisScriptTask;
// The following is for setting a minimum delay between events
private double m_minEventDelay = 0;
private long m_eventDelayTicks = 0;
private long m_nextEventTimeTicks = 0;
//private ISponsor m_ScriptSponsor;
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
@ -103,6 +107,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public Object[] PluginData = new Object[0];
/// <summary>
/// Used by llMinEventDelay to suppress events happening any faster than this speed.
/// This currently restricts all events in one go. Not sure if each event type has
/// its own check so take the simple route first.
/// </summary>
public double MinEventDelay
{
get { return m_minEventDelay; }
set
{
if (value > 0.001)
m_minEventDelay = value;
else
m_minEventDelay = 0.0;
m_eventDelayTicks = (long)(m_minEventDelay * 10000000L);
m_nextEventTimeTicks = DateTime.Now.Ticks;
}
}
public bool Running
{
get { return m_RunEvents; }
@ -498,6 +521,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (!Running)
return;
// If min event delay is set then ignore any events untill the time has expired
// This currently only allows 1 event of any type in the given time period.
// This may need extending to allow for a time for each individual event type.
if (m_eventDelayTicks != 0)
{
if (DateTime.Now.Ticks < m_nextEventTimeTicks)
return;
m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks;
}
lock (m_EventQueue)
{
if (m_EventQueue.Count >= m_MaxScriptQueue)

View File

@ -194,6 +194,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
}
if (instance.MinEventDelay > 0.0)
{
XmlElement eventDelay = xmldoc.CreateElement("", "MinEventDelay", "");
eventDelay.AppendChild(xmldoc.CreateTextNode(instance.MinEventDelay.ToString()));
rootElement.AppendChild(eventDelay);
}
return xmldoc.InnerXml;
}
@ -380,8 +387,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
}
break;
}
case "MinEventDelay":
double minEventDelay = 0.0;
double.TryParse(part.InnerText, out minEventDelay);
instance.MinEventDelay = minEventDelay;
break;
}
}
}
}

View File

@ -891,6 +891,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return null;
}
public void SetMinEventDelay(UUID itemID, double delay)
{
IScriptInstance instance = GetInstance(itemID);
if (instance != null)
instance.MinEventDelay = delay;
}
public UUID GetDetectID(UUID itemID, int idx)
{
IScriptInstance instance = GetInstance(itemID);