diff options
author | idb | 2008-12-21 19:04:06 +0000 |
---|---|---|
committer | idb | 2008-12-21 19:04:06 +0000 |
commit | 3fe966d6b32f858da37a263e0568f28c7700b03b (patch) | |
tree | 22eda52e5c004d6ff2b519974137d54e11bfb942 | |
parent | Slowing TPs down a bit further. (diff) | |
download | opensim-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 '')
7 files changed, 71 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index 269afaa..28e1278 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs | |||
@@ -240,6 +240,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
240 | { | 240 | { |
241 | return m_ScriptManager.GetStartParameter(itemID); | 241 | return m_ScriptManager.GetStartParameter(itemID); |
242 | } | 242 | } |
243 | |||
244 | public void SetMinEventDelay(UUID itemID, double delay) | ||
245 | { | ||
246 | // TODO in DotNet, done in XEngine | ||
247 | throw new NotImplementedException(); | ||
248 | } | ||
249 | |||
243 | #endregion | 250 | #endregion |
244 | 251 | ||
245 | public void SetState(UUID itemID, string state) | 252 | public void SetState(UUID itemID, string state) |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index db05d47..04af705 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs | |||
@@ -61,6 +61,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
61 | bool PostObjectEvent(uint localID, EventParams parms); | 61 | bool PostObjectEvent(uint localID, EventParams parms); |
62 | 62 | ||
63 | DetectParams GetDetectParams(UUID item, int number); | 63 | DetectParams GetDetectParams(UUID item, int number); |
64 | void SetMinEventDelay(UUID itemID, double delay); | ||
64 | int GetStartParameter(UUID itemID); | 65 | int GetStartParameter(UUID itemID); |
65 | 66 | ||
66 | void SetScriptState(UUID itemID, bool state); | 67 | void SetScriptState(UUID itemID, bool state); |
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 31202e2..3367b77 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -102,5 +102,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
102 | 102 | ||
103 | string GetAssemblyName(); | 103 | string GetAssemblyName(); |
104 | string GetXMLState(); | 104 | string GetXMLState(); |
105 | double MinEventDelay { set; } | ||
105 | } | 106 | } |
106 | } | 107 | } |
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 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 6ad8923..32714b2 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -891,6 +891,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
891 | return null; | 891 | return null; |
892 | } | 892 | } |
893 | 893 | ||
894 | public void SetMinEventDelay(UUID itemID, double delay) | ||
895 | { | ||
896 | IScriptInstance instance = GetInstance(itemID); | ||
897 | if (instance != null) | ||
898 | instance.MinEventDelay = delay; | ||
899 | } | ||
900 | |||
894 | public UUID GetDetectID(UUID itemID, int idx) | 901 | public UUID GetDetectID(UUID itemID, int idx) |
895 | { | 902 | { |
896 | IScriptInstance instance = GetInstance(itemID); | 903 | IScriptInstance instance = GetInstance(itemID); |