diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs index baab096..830ca99 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | ||
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Threading; | 32 | using System.Threading; |
32 | using libsecondlife; | 33 | using libsecondlife; |
@@ -128,7 +129,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
128 | xmlrpc.DeleteChannels(itemID); | 129 | xmlrpc.DeleteChannels(itemID); |
129 | 130 | ||
130 | xmlrpc.CancelSRDRequests(itemID); | 131 | xmlrpc.CancelSRDRequests(itemID); |
131 | 132 | ||
132 | } | 133 | } |
133 | 134 | ||
134 | #region TIMER | 135 | #region TIMER |
@@ -140,8 +141,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
140 | { | 141 | { |
141 | public uint localID; | 142 | public uint localID; |
142 | public LLUUID itemID; | 143 | public LLUUID itemID; |
143 | public double interval; | 144 | //public double interval; |
144 | public DateTime next; | 145 | public long interval; |
146 | //public DateTime next; | ||
147 | public long next; | ||
145 | } | 148 | } |
146 | 149 | ||
147 | private List<TimerClass> Timers = new List<TimerClass>(); | 150 | private List<TimerClass> Timers = new List<TimerClass>(); |
@@ -160,8 +163,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
160 | TimerClass ts = new TimerClass(); | 163 | TimerClass ts = new TimerClass(); |
161 | ts.localID = m_localID; | 164 | ts.localID = m_localID; |
162 | ts.itemID = m_itemID; | 165 | ts.itemID = m_itemID; |
163 | ts.interval = sec / 1000; | 166 | ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait |
164 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 167 | // 2193386136332921 ticks |
168 | // 219338613 seconds | ||
169 | |||
170 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
171 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
165 | lock (TimerListLock) | 172 | lock (TimerListLock) |
166 | { | 173 | { |
167 | Timers.Add(ts); | 174 | Timers.Add(ts); |
@@ -173,17 +180,25 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
173 | // Remove from timer | 180 | // Remove from timer |
174 | lock (TimerListLock) | 181 | lock (TimerListLock) |
175 | { | 182 | { |
176 | List<TimerClass> NewTimers = new List<TimerClass>(); | 183 | foreach (TimerClass ts in new ArrayList(Timers)) |
177 | foreach (TimerClass ts in Timers) | ||
178 | { | 184 | { |
179 | if (ts.localID != m_localID && ts.itemID != m_itemID) | 185 | if (ts.localID == m_localID && ts.itemID == m_itemID) |
180 | { | 186 | Timers.Remove(ts); |
181 | NewTimers.Add(ts); | ||
182 | } | ||
183 | } | 187 | } |
184 | Timers.Clear(); | ||
185 | Timers = NewTimers; | ||
186 | } | 188 | } |
189 | |||
190 | // Old method: Create new list | ||
191 | //List<TimerClass> NewTimers = new List<TimerClass>(); | ||
192 | //foreach (TimerClass ts in Timers) | ||
193 | //{ | ||
194 | // if (ts.localID != m_localID && ts.itemID != m_itemID) | ||
195 | // { | ||
196 | // NewTimers.Add(ts); | ||
197 | // } | ||
198 | //} | ||
199 | //Timers.Clear(); | ||
200 | //Timers = NewTimers; | ||
201 | //} | ||
187 | } | 202 | } |
188 | 203 | ||
189 | public void CheckTimerEvents() | 204 | public void CheckTimerEvents() |
@@ -198,15 +213,17 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
198 | foreach (TimerClass ts in Timers) | 213 | foreach (TimerClass ts in Timers) |
199 | { | 214 | { |
200 | // Time has passed? | 215 | // Time has passed? |
201 | if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) | 216 | if (ts.next < DateTime.Now.Ticks) |
202 | { | 217 | { |
218 | |||
219 | Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | ||
203 | // Add it to queue | 220 | // Add it to queue |
204 | m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, | 221 | m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", EventQueueManager.llDetectNull, |
205 | new object[] {}); | 222 | null); |
206 | // set next interval | 223 | // set next interval |
207 | 224 | ||
208 | 225 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | |
209 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 226 | ts.next = DateTime.Now.Ticks + ts.interval; |
210 | } | 227 | } |
211 | } | 228 | } |
212 | } // lock | 229 | } // lock |
@@ -322,7 +339,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
322 | 339 | ||
323 | } | 340 | } |
324 | 341 | ||
325 | 342 | ||
326 | } | 343 | } |
327 | } | 344 | } |
328 | 345 | ||
@@ -356,7 +373,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
356 | ); | 373 | ); |
357 | } | 374 | } |
358 | 375 | ||
359 | } | 376 | } |
360 | } | 377 | } |
361 | } | 378 | } |
362 | 379 | ||