aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTedd Hansen2008-02-20 17:35:28 +0000
committerTedd Hansen2008-02-20 17:35:28 +0000
commit416d75282900ebd4af5434a95f70765f078a5b69 (patch)
tree356f78522da99f38ae25c5e0f9c32ee9cfaf2bb7 /OpenSim/Region
parent* Report 'asset not found' situations back to UserTextureDownloadService (diff)
downloadopensim-SC-416d75282900ebd4af5434a95f70765f078a5b69.zip
opensim-SC-416d75282900ebd4af5434a95f70765f078a5b69.tar.gz
opensim-SC-416d75282900ebd4af5434a95f70765f078a5b69.tar.bz2
opensim-SC-416d75282900ebd4af5434a95f70765f078a5b69.tar.xz
llSetTimerEvent updated to use ticks instead of DateTime for internal timing.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Executor.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncLSLCommandManager.cs57
3 files changed, 41 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs
index 21cca6b..ac2164a 100644
--- a/OpenSim/Region/ScriptEngine/Common/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs
@@ -49,9 +49,9 @@ namespace OpenSim.Region.ScriptEngine.Common
49 49
50 string EventName = m_Script.State + "_event_" + FunctionName; 50 string EventName = m_Script.State + "_event_" + FunctionName;
51 51
52#if DEBUG 52//#if DEBUG
53 Console.WriteLine("ScriptEngine: Script event function name: " + EventName); 53// Console.WriteLine("ScriptEngine: Script event function name: " + EventName);
54#endif 54//#endif
55 55
56 if (Events.ContainsKey(EventName) == false) 56 if (Events.ContainsKey(EventName) == false)
57 { 57 {
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index c14a74f..1ab2a43 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -1244,7 +1244,7 @@ namespace OpenSim.Region.ScriptEngine.Common
1244 { 1244 {
1245 m_host.AddScriptLPS(1); 1245 m_host.AddScriptLPS(1);
1246 // Setting timer repeat 1246 // Setting timer repeat
1247 m_ScriptEngine.m_ASYNCLSLCommandManager.SetTimerEvent(m_localID, m_itemID, sec / 1000); 1247 m_ScriptEngine.m_ASYNCLSLCommandManager.SetTimerEvent(m_localID, m_itemID, sec);
1248 } 1248 }
1249 1249
1250 public void llSleep(double sec) 1250 public void llSleep(double sec)
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
29using System; 29using System;
30using System.Collections;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using System.Threading; 32using System.Threading;
32using libsecondlife; 33using 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