diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 33 |
1 files changed, 33 insertions, 0 deletions
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) |