aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authoridb2008-12-21 19:04:06 +0000
committeridb2008-12-21 19:04:06 +0000
commit3fe966d6b32f858da37a263e0568f28c7700b03b (patch)
tree22eda52e5c004d6ff2b519974137d54e11bfb942 /OpenSim/Region/ScriptEngine/Shared
parentSlowing TPs down a bit further. (diff)
downloadopensim-SC_OLD-3fe966d6b32f858da37a263e0568f28c7700b03b.zip
opensim-SC_OLD-3fe966d6b32f858da37a263e0568f28c7700b03b.tar.gz
opensim-SC_OLD-3fe966d6b32f858da37a263e0568f28c7700b03b.tar.bz2
opensim-SC_OLD-3fe966d6b32f858da37a263e0568f28c7700b03b.tar.xz
An initial implementation of llMinEventDelay in XEngine.
Not implemented yet in DotNetEngine. Fixes Mantis #2830
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs14
3 files changed, 55 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5ef9471..a005b01 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2756,7 +2756,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2756 public void llMinEventDelay(double delay) 2756 public void llMinEventDelay(double delay)
2757 { 2757 {
2758 m_host.AddScriptLPS(1); 2758 m_host.AddScriptLPS(1);
2759 NotImplemented("llMinEventDelay"); 2759 try
2760 {
2761 m_ScriptEngine.SetMinEventDelay(m_itemID, delay);
2762 }
2763 catch (NotImplementedException)
2764 {
2765 // Currently not implemented in DotNetEngine only XEngine
2766 NotImplemented("llMinEventDelay in DotNetEngine");
2767 }
2760 } 2768 }
2761 2769
2762 /// <summary> 2770 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 1f57c13..8d6966f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -84,6 +84,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
84 private int m_LastControlLevel = 0; 84 private int m_LastControlLevel = 0;
85 private bool m_CollisionInQueue = false; 85 private bool m_CollisionInQueue = false;
86 private TaskInventoryItem m_thisScriptTask; 86 private TaskInventoryItem m_thisScriptTask;
87 // The following is for setting a minimum delay between events
88 private double m_minEventDelay = 0;
89 private long m_eventDelayTicks = 0;
90 private long m_nextEventTimeTicks = 0;
87 91
88 //private ISponsor m_ScriptSponsor; 92 //private ISponsor m_ScriptSponsor;
89 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> 93 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
@@ -103,6 +107,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
103 107
104 public Object[] PluginData = new Object[0]; 108 public Object[] PluginData = new Object[0];
105 109
110 /// <summary>
111 /// Used by llMinEventDelay to suppress events happening any faster than this speed.
112 /// This currently restricts all events in one go. Not sure if each event type has
113 /// its own check so take the simple route first.
114 /// </summary>
115 public double MinEventDelay
116 {
117 get { return m_minEventDelay; }
118 set
119 {
120 if (value > 0.001)
121 m_minEventDelay = value;
122 else
123 m_minEventDelay = 0.0;
124 m_eventDelayTicks = (long)(m_minEventDelay * 10000000L);
125 m_nextEventTimeTicks = DateTime.Now.Ticks;
126 }
127 }
128
106 public bool Running 129 public bool Running
107 { 130 {
108 get { return m_RunEvents; } 131 get { return m_RunEvents; }
@@ -498,6 +521,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
498 if (!Running) 521 if (!Running)
499 return; 522 return;
500 523
524 // If min event delay is set then ignore any events untill the time has expired
525 // This currently only allows 1 event of any type in the given time period.
526 // This may need extending to allow for a time for each individual event type.
527 if (m_eventDelayTicks != 0)
528 {
529 if (DateTime.Now.Ticks < m_nextEventTimeTicks)
530 return;
531 m_nextEventTimeTicks = DateTime.Now.Ticks + m_eventDelayTicks;
532 }
533
501 lock (m_EventQueue) 534 lock (m_EventQueue)
502 { 535 {
503 if (m_EventQueue.Count >= m_MaxScriptQueue) 536 if (m_EventQueue.Count >= m_MaxScriptQueue)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
index 0ec039b..c06960b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
@@ -194,6 +194,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
194 } 194 }
195 } 195 }
196 196
197 if (instance.MinEventDelay > 0.0)
198 {
199 XmlElement eventDelay = xmldoc.CreateElement("", "MinEventDelay", "");
200 eventDelay.AppendChild(xmldoc.CreateTextNode(instance.MinEventDelay.ToString()));
201 rootElement.AppendChild(eventDelay);
202 }
203
197 return xmldoc.InnerXml; 204 return xmldoc.InnerXml;
198 } 205 }
199 206
@@ -380,8 +387,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
380 } 387 }
381 } 388 }
382 break; 389 break;
383 } 390 case "MinEventDelay":
391 double minEventDelay = 0.0;
392 double.TryParse(part.InnerText, out minEventDelay);
393 instance.MinEventDelay = minEventDelay;
394 break;
384 } 395 }
396 }
385 } 397 }
386 } 398 }
387 399