aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-02-23 14:52:34 +0000
committerUbitUmarov2018-02-23 14:52:34 +0000
commit2129d941acbc5f83aca4dc4c30a62d3226888136 (patch)
treee12f2391978c923ef780f558ee5a32d857ee9124 /OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs
parentMerge branch 'master' into httptests (diff)
downloadopensim-SC-2129d941acbc5f83aca4dc4c30a62d3226888136.zip
opensim-SC-2129d941acbc5f83aca4dc4c30a62d3226888136.tar.gz
opensim-SC-2129d941acbc5f83aca4dc4c30a62d3226888136.tar.bz2
opensim-SC-2129d941acbc5f83aca4dc4c30a62d3226888136.tar.xz
rename XMREngine as Yengine (still not all done), big mess source formating changes, move state files to proper folder, fix a source file locking on errors, more changes for cross platform including from Mike,... yes yes i know a messy commit
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs (renamed from OpenSim/Region/ScriptEngine/XMREngine/XMRInstBackend.cs)407
1 files changed, 201 insertions, 206 deletions
diff --git a/OpenSim/Region/ScriptEngine/XMREngine/XMRInstBackend.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs
index a24036a..fb5c75e 100644
--- a/OpenSim/Region/ScriptEngine/XMREngine/XMRInstBackend.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs
@@ -42,13 +42,13 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
42using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 42using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
43using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; 43using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
44 44
45namespace OpenSim.Region.ScriptEngine.XMREngine 45namespace OpenSim.Region.ScriptEngine.Yengine
46{ 46{
47 /****************************************************\ 47 /****************************************************\
48 * This file contains routines called by scripts. * 48 * This file contains routines called by scripts. *
49 \****************************************************/ 49 \****************************************************/
50 50
51 public class XMRLSL_Api : LSL_Api 51 public class XMRLSL_Api: LSL_Api
52 { 52 {
53 public AsyncCommandManager acm; 53 public AsyncCommandManager acm;
54 private XMRInstance inst; 54 private XMRInstance inst;
@@ -83,38 +83,38 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
83 * -2: no av granted perms 83 * -2: no av granted perms
84 * -3: av not in region 84 * -3: av not in region
85 */ 85 */
86/* engines should not have own API 86 /* engines should not have own API
87 public int xmrSeatAvatar (bool owner) 87 public int xmrSeatAvatar (bool owner)
88 { 88 {
89 // Get avatar to be seated and make sure they have given us ANIMATION permission 89 // Get avatar to be seated and make sure they have given us ANIMATION permission
90 90
91 UUID avuuid; 91 UUID avuuid;
92 if (owner) { 92 if (owner) {
93 avuuid = inst.m_Part.OwnerID; 93 avuuid = inst.m_Part.OwnerID;
94 } else { 94 } else {
95 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) == 0) { 95 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) == 0) {
96 return -1; 96 return -1;
97 } 97 }
98 avuuid = m_item.PermsGranter; 98 avuuid = m_item.PermsGranter;
99 } 99 }
100 if (avuuid == UUID.Zero) { 100 if (avuuid == UUID.Zero) {
101 return -2; 101 return -2;
102 } 102 }
103 103
104 ScenePresence presence = World.GetScenePresence (avuuid); 104 ScenePresence presence = World.GetScenePresence (avuuid);
105 if (presence == null) { 105 if (presence == null) {
106 return -3; 106 return -3;
107 } 107 }
108 108
109 // remoteClient = not used by ScenePresence.HandleAgentRequestSit() 109 // remoteClient = not used by ScenePresence.HandleAgentRequestSit()
110 // agentID = not used by ScenePresence.HandleAgentRequestSit() 110 // agentID = not used by ScenePresence.HandleAgentRequestSit()
111 // targetID = UUID of prim to sit on 111 // targetID = UUID of prim to sit on
112 // offset = offset of sitting position 112 // offset = offset of sitting position
113 113
114 presence.HandleAgentRequestSit (null, UUID.Zero, m_host.UUID, OpenMetaverse.Vector3.Zero); 114 presence.HandleAgentRequestSit (null, UUID.Zero, m_host.UUID, OpenMetaverse.Vector3.Zero);
115 return 0; 115 return 0;
116 } 116 }
117*/ 117 */
118 /** 118 /**
119 * @brief llTeleportAgent() is broken in that if you pass it a landmark, 119 * @brief llTeleportAgent() is broken in that if you pass it a landmark,
120 * it still subjects the position to spawn points, as it always 120 * it still subjects the position to spawn points, as it always
@@ -125,80 +125,80 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
125 * @param landmark = inventory name or UUID of a landmark object 125 * @param landmark = inventory name or UUID of a landmark object
126 * @param lookat = looking direction after teleport 126 * @param lookat = looking direction after teleport
127 */ 127 */
128/* engines should not have own API 128 /* engines should not have own API
129 public void xmrTeleportAgent2Landmark (string agent, string landmark, LSL_Vector lookat) 129 public void xmrTeleportAgent2Landmark (string agent, string landmark, LSL_Vector lookat)
130 { 130 {
131 // find out about agent to be teleported 131 // find out about agent to be teleported
132 UUID agentId; 132 UUID agentId;
133 if (!UUID.TryParse (agent, out agentId)) throw new ApplicationException ("bad agent uuid"); 133 if (!UUID.TryParse (agent, out agentId)) throw new ApplicationException ("bad agent uuid");
134 134
135 ScenePresence presence = World.GetScenePresence (agentId); 135 ScenePresence presence = World.GetScenePresence (agentId);
136 if (presence == null) throw new ApplicationException ("agent not present in scene"); 136 if (presence == null) throw new ApplicationException ("agent not present in scene");
137 if (presence.IsNPC) throw new ApplicationException ("agent is an NPC"); 137 if (presence.IsNPC) throw new ApplicationException ("agent is an NPC");
138 if (presence.IsGod) throw new ApplicationException ("agent is a god"); 138 if (presence.IsGod) throw new ApplicationException ("agent is a god");
139 139
140 // prim must be owned by land owner or prim must be attached to agent 140 // prim must be owned by land owner or prim must be attached to agent
141 if (m_host.ParentGroup.AttachmentPoint == 0) { 141 if (m_host.ParentGroup.AttachmentPoint == 0) {
142 if (m_host.OwnerID != World.LandChannel.GetLandObject (presence.AbsolutePosition).LandData.OwnerID) { 142 if (m_host.OwnerID != World.LandChannel.GetLandObject (presence.AbsolutePosition).LandData.OwnerID) {
143 throw new ApplicationException ("prim not owned by land's owner"); 143 throw new ApplicationException ("prim not owned by land's owner");
144 } 144 }
145 } else { 145 } else {
146 if (m_host.OwnerID != presence.UUID) throw new ApplicationException ("prim not attached to agent"); 146 if (m_host.OwnerID != presence.UUID) throw new ApplicationException ("prim not attached to agent");
147 } 147 }
148 148
149 // find landmark in inventory or by UUID 149 // find landmark in inventory or by UUID
150 UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName (m_host, landmark); 150 UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName (m_host, landmark);
151 if (assetID == UUID.Zero) throw new ApplicationException ("no such landmark"); 151 if (assetID == UUID.Zero) throw new ApplicationException ("no such landmark");
152 152
153 // read it in and make sure it is a landmark 153 // read it in and make sure it is a landmark
154 AssetBase lma = World.AssetService.Get (assetID.ToString ()); 154 AssetBase lma = World.AssetService.Get (assetID.ToString ());
155 if ((lma == null) || (lma.Type != (sbyte)AssetType.Landmark)) throw new ApplicationException ("not a landmark"); 155 if ((lma == null) || (lma.Type != (sbyte)AssetType.Landmark)) throw new ApplicationException ("not a landmark");
156 156
157 // parse the record 157 // parse the record
158 AssetLandmark lm = new AssetLandmark (lma); 158 AssetLandmark lm = new AssetLandmark (lma);
159 159
160 // the regionhandle (based on region's world X,Y) might be out of date 160 // the regionhandle (based on region's world X,Y) might be out of date
161 // re-read the handle so we can pass it to RequestTeleportLocation() 161 // re-read the handle so we can pass it to RequestTeleportLocation()
162 var region = World.GridService.GetRegionByUUID (World.RegionInfo.ScopeID, lm.RegionID); 162 var region = World.GridService.GetRegionByUUID (World.RegionInfo.ScopeID, lm.RegionID);
163 if (region == null) throw new ApplicationException ("no such region"); 163 if (region == null) throw new ApplicationException ("no such region");
164 164
165 // finally ready to teleport 165 // finally ready to teleport
166 World.RequestTeleportLocation (presence.ControllingClient, 166 World.RequestTeleportLocation (presence.ControllingClient,
167 region.RegionHandle, 167 region.RegionHandle,
168 lm.Position, 168 lm.Position,
169 lookat, 169 lookat,
170 (uint)TeleportFlags.ViaLandmark); 170 (uint)TeleportFlags.ViaLandmark);
171 } 171 }
172*/ 172 */
173 /** 173 /**
174 * @brief Allow any member of group given by config SetParcelMusicURLGroup to set music URL. 174 * @brief Allow any member of group given by config SetParcelMusicURLGroup to set music URL.
175 * Code modelled after llSetParcelMusicURL(). 175 * Code modelled after llSetParcelMusicURL().
176 * @param newurl = new URL to set (or "" to leave it alone) 176 * @param newurl = new URL to set (or "" to leave it alone)
177 * @returns previous URL string 177 * @returns previous URL string
178 */ 178 */
179/* engines should not have own API 179 /* engines should not have own API
180 public string xmrSetParcelMusicURLGroup (string newurl) 180 public string xmrSetParcelMusicURLGroup (string newurl)
181 { 181 {
182 string groupname = m_ScriptEngine.Config.GetString ("SetParcelMusicURLGroup", ""); 182 string groupname = m_ScriptEngine.Config.GetString ("SetParcelMusicURLGroup", "");
183 if (groupname == "") throw new ApplicationException ("no SetParcelMusicURLGroup config param set"); 183 if (groupname == "") throw new ApplicationException ("no SetParcelMusicURLGroup config param set");
184 184
185 IGroupsModule igm = World.RequestModuleInterface<IGroupsModule> (); 185 IGroupsModule igm = World.RequestModuleInterface<IGroupsModule> ();
186 if (igm == null) throw new ApplicationException ("no GroupsModule loaded"); 186 if (igm == null) throw new ApplicationException ("no GroupsModule loaded");
187 187
188 GroupRecord grouprec = igm.GetGroupRecord (groupname); 188 GroupRecord grouprec = igm.GetGroupRecord (groupname);
189 if (grouprec == null) throw new ApplicationException ("no such group " + groupname); 189 if (grouprec == null) throw new ApplicationException ("no such group " + groupname);
190 190
191 GroupMembershipData gmd = igm.GetMembershipData (grouprec.GroupID, m_host.OwnerID); 191 GroupMembershipData gmd = igm.GetMembershipData (grouprec.GroupID, m_host.OwnerID);
192 if (gmd == null) throw new ApplicationException ("not a member of group " + groupname); 192 if (gmd == null) throw new ApplicationException ("not a member of group " + groupname);
193 193
194 ILandObject land = World.LandChannel.GetLandObject (m_host.AbsolutePosition); 194 ILandObject land = World.LandChannel.GetLandObject (m_host.AbsolutePosition);
195 if (land == null) throw new ApplicationException ("no land at " + m_host.AbsolutePosition.ToString ()); 195 if (land == null) throw new ApplicationException ("no land at " + m_host.AbsolutePosition.ToString ());
196 string oldurl = land.GetMusicUrl (); 196 string oldurl = land.GetMusicUrl ();
197 if (oldurl == null) oldurl = ""; 197 if (oldurl == null) oldurl = "";
198 if ((newurl != null) && (newurl != "")) land.SetMusicUrl (newurl); 198 if ((newurl != null) && (newurl != "")) land.SetMusicUrl (newurl);
199 return oldurl; 199 return oldurl;
200 } 200 }
201*/ 201 */
202 } 202 }
203 203
204 public partial class XMRInstance 204 public partial class XMRInstance
@@ -222,9 +222,9 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
222 public DetectParams GetDetectParams(int number) 222 public DetectParams GetDetectParams(int number)
223 { 223 {
224 DetectParams dp = null; 224 DetectParams dp = null;
225 if ((number >= 0) && (m_DetectParams != null) && (number < m_DetectParams.Length)) { 225 if((number >= 0) && (m_DetectParams != null) && (number < m_DetectParams.Length))
226 dp = m_DetectParams[number]; 226 dp = m_DetectParams[number];
227 } 227
228 return dp; 228 return dp;
229 } 229 }
230 230
@@ -236,7 +236,7 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
236 public void Die() 236 public void Die()
237 { 237 {
238 // llDie doesn't work in attachments! 238 // llDie doesn't work in attachments!
239 if (m_Part.ParentGroup.IsAttachment || m_DetachQuantum > 0) 239 if(m_Part.ParentGroup.IsAttachment || m_DetachQuantum > 0)
240 return; 240 return;
241 241
242 throw new ScriptDieException(); 242 throw new ScriptDieException();
@@ -247,8 +247,8 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
247 */ 247 */
248 public void Sleep(int ms) 248 public void Sleep(int ms)
249 { 249 {
250 lock (m_QueueLock) { 250 lock(m_QueueLock)
251 251 {
252 /* 252 /*
253 * Say how long to sleep. 253 * Say how long to sleep.
254 */ 254 */
@@ -306,12 +306,12 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
306 * be returned by xmrEventDequeue, to let the runtime know that the script is capable 306 * be returned by xmrEventDequeue, to let the runtime know that the script is capable
307 * of processing that event type. Otherwise, the event may not be queued to the script. 307 * of processing that event type. Otherwise, the event may not be queued to the script.
308 */ 308 */
309 private static LSL_List emptyList = new LSL_List (new object[0]); 309 private static LSL_List emptyList = new LSL_List(new object[0]);
310 310
311 public override LSL_List xmrEventDequeue (double timeout, int returnMask1, int returnMask2, 311 public override LSL_List xmrEventDequeue(double timeout, int returnMask1, int returnMask2,
312 int backgroundMask1, int backgroundMask2) 312 int backgroundMask1, int backgroundMask2)
313 { 313 {
314 DateTime sleepUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds (timeout * 1000.0); 314 DateTime sleepUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds(timeout * 1000.0);
315 EventParams evt = null; 315 EventParams evt = null;
316 int callNo, evc2; 316 int callNo, evc2;
317 int evc1 = 0; 317 int evc1 = 0;
@@ -324,45 +324,47 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
324 callNo = -1; 324 callNo = -1;
325 try 325 try
326 { 326 {
327 if (callMode == CallMode_NORMAL) goto findevent; 327 if(callMode == CallMode_NORMAL)
328 goto findevent;
328 329
329 /* 330 /*
330 * Stack frame is being restored as saved via CheckRun...(). 331 * Stack frame is being restored as saved via CheckRun...().
331 * Restore necessary values then jump to __call<n> label to resume processing. 332 * Restore necessary values then jump to __call<n> label to resume processing.
332 */ 333 */
333 sv = RestoreStackFrame ("xmrEventDequeue", out callNo); 334 sv = RestoreStackFrame("xmrEventDequeue", out callNo);
334 sleepUntil = DateTime.Parse ((string)sv[0]); 335 sleepUntil = DateTime.Parse((string)sv[0]);
335 returnMask1 = (int)sv[1]; 336 returnMask1 = (int)sv[1];
336 returnMask2 = (int)sv[2]; 337 returnMask2 = (int)sv[2];
337 mask1 = (int)sv[3]; 338 mask1 = (int)sv[3];
338 mask2 = (int)sv[4]; 339 mask2 = (int)sv[4];
339 switch (callNo) 340 switch(callNo)
340 { 341 {
341 case 0: goto __call0; 342 case 0:
343 goto __call0;
342 case 1: 344 case 1:
343 { 345 {
344 evc1 = (int)sv[5]; 346 evc1 = (int)sv[5];
345 evc = (ScriptEventCode)(int)sv[6]; 347 evc = (ScriptEventCode)(int)sv[6];
346 DetectParams[] detprms = ObjArrToDetPrms ((object[])sv[7]); 348 DetectParams[] detprms = ObjArrToDetPrms((object[])sv[7]);
347 object[] ehargs = (object[])sv[8]; 349 object[] ehargs = (object[])sv[8];
348 evt = new EventParams (evc.ToString (), ehargs, detprms); 350 evt = new EventParams(evc.ToString(), ehargs, detprms);
349 goto __call1; 351 goto __call1;
350 } 352 }
351 } 353 }
352 throw new ScriptBadCallNoException (callNo); 354 throw new ScriptBadCallNoException(callNo);
353 355
354 /* 356 /*
355 * Find first event that matches either the return or background masks. 357 * Find first event that matches either the return or background masks.
356 */ 358 */
357 findevent: 359 findevent:
358 Monitor.Enter (m_QueueLock); 360 Monitor.Enter(m_QueueLock);
359 for (lln = m_EventQueue.First; lln != null; lln = lln.Next) 361 for(lln = m_EventQueue.First; lln != null; lln = lln.Next)
360 { 362 {
361 evt = lln.Value; 363 evt = lln.Value;
362 evc = (ScriptEventCode)Enum.Parse (typeof (ScriptEventCode), evt.EventName); 364 evc = (ScriptEventCode)Enum.Parse(typeof(ScriptEventCode), evt.EventName);
363 evc1 = (int)evc; 365 evc1 = (int)evc;
364 evc2 = evc1 - 32; 366 evc2 = evc1 - 32;
365 if ((((uint)evc1 < (uint)32) && (((mask1 >> evc1) & 1) != 0)) || 367 if((((uint)evc1 < (uint)32) && (((mask1 >> evc1) & 1) != 0)) ||
366 (((uint)evc2 < (uint)32) && (((mask2 >> evc2) & 1) != 0))) 368 (((uint)evc2 < (uint)32) && (((mask2 >> evc2) & 1) != 0)))
367 goto remfromq; 369 goto remfromq;
368 } 370 }
@@ -373,51 +375,50 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
373 m_SleepUntil = sleepUntil; 375 m_SleepUntil = sleepUntil;
374 m_SleepEventMask1 = mask1; 376 m_SleepEventMask1 = mask1;
375 m_SleepEventMask2 = mask2; 377 m_SleepEventMask2 = mask2;
376 Monitor.Exit (m_QueueLock); 378 Monitor.Exit(m_QueueLock);
377 suspendOnCheckRunTemp = true; 379 suspendOnCheckRunTemp = true;
378 callNo = 0; 380 callNo = 0;
379 __call0: 381 __call0:
380 CheckRunQuick (); 382 CheckRunQuick();
381 goto checktmo; 383 goto checktmo;
382 384
383 /* 385 /*
384 * Found one, remove it from queue. 386 * Found one, remove it from queue.
385 */ 387 */
386 remfromq: 388 remfromq:
387 m_EventQueue.Remove (lln); 389 m_EventQueue.Remove(lln);
388 if ((uint)evc1 < (uint)m_EventCounts.Length) 390 if((uint)evc1 < (uint)m_EventCounts.Length)
389 m_EventCounts[evc1] --; 391 m_EventCounts[evc1]--;
390 392
391 Monitor.Exit (m_QueueLock); 393 Monitor.Exit(m_QueueLock);
392 m_InstEHEvent ++; 394 m_InstEHEvent++;
393 395
394 /* 396 /*
395 * See if returnable or background event. 397 * See if returnable or background event.
396 */ 398 */
397 if ((((uint)evc1 < (uint)32) && (((returnMask1 >> evc1) & 1) != 0)) || 399 if((((uint)evc1 < (uint)32) && (((returnMask1 >> evc1) & 1) != 0)) ||
398 (((uint)evc2 < (uint)32) && (((returnMask2 >> evc2) & 1) != 0))) 400 (((uint)evc2 < (uint)32) && (((returnMask2 >> evc2) & 1) != 0)))
399 { 401 {
400
401 /* 402 /*
402 * Returnable event, return its parameters in a list. 403 * Returnable event, return its parameters in a list.
403 * Also set the detect parameters to what the event has. 404 * Also set the detect parameters to what the event has.
404 */ 405 */
405 int plen = evt.Params.Length; 406 int plen = evt.Params.Length;
406 object[] plist = new object[plen+1]; 407 object[] plist = new object[plen + 1];
407 plist[0] = (LSL_Integer)evc1; 408 plist[0] = (LSL_Integer)evc1;
408 for (int i = 0; i < plen;) 409 for(int i = 0; i < plen;)
409 { 410 {
410 object ob = evt.Params[i]; 411 object ob = evt.Params[i];
411 if (ob is int) 412 if(ob is int)
412 ob = (LSL_Integer)(int)ob; 413 ob = (LSL_Integer)(int)ob;
413 else if (ob is double) 414 else if(ob is double)
414 ob = (LSL_Float)(double)ob; 415 ob = (LSL_Float)(double)ob;
415 else if (ob is string) 416 else if(ob is string)
416 ob = (LSL_String)(string)ob; 417 ob = (LSL_String)(string)ob;
417 plist[++i] = ob; 418 plist[++i] = ob;
418 } 419 }
419 m_DetectParams = evt.DetectParams; 420 m_DetectParams = evt.DetectParams;
420 return new LSL_List (plist); 421 return new LSL_List(plist);
421 } 422 }
422 423
423 /* 424 /*
@@ -425,35 +426,35 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
425 * then check event queue again. 426 * then check event queue again.
426 */ 427 */
427 callNo = 1; 428 callNo = 1;
428 __call1: 429 __call1:
429 ScriptEventHandler seh = m_ObjCode.scriptEventHandlerTable[stateCode,evc1]; 430 ScriptEventHandler seh = m_ObjCode.scriptEventHandlerTable[stateCode, evc1];
430 if (seh == null) 431 if(seh == null)
431 goto checktmo; 432 goto checktmo;
432 433
433 DetectParams[] saveDetParams = this.m_DetectParams; 434 DetectParams[] saveDetParams = this.m_DetectParams;
434 object[] saveEHArgs = this.ehArgs; 435 object[] saveEHArgs = this.ehArgs;
435 ScriptEventCode saveEventCode = this.eventCode; 436 ScriptEventCode saveEventCode = this.eventCode;
436 437
437 this.m_DetectParams = evt.DetectParams; 438 this.m_DetectParams = evt.DetectParams;
438 this.ehArgs = evt.Params; 439 this.ehArgs = evt.Params;
439 this.eventCode = evc; 440 this.eventCode = evc;
440 441
441 try 442 try
442 { 443 {
443 seh (this); 444 seh(this);
444 } 445 }
445 finally 446 finally
446 { 447 {
447 m_DetectParams = saveDetParams; 448 this.m_DetectParams = saveDetParams;
448 ehArgs = saveEHArgs; 449 this.ehArgs = saveEHArgs;
449 eventCode = saveEventCode; 450 this.eventCode = saveEventCode;
450 } 451 }
451 452
452 /* 453 /*
453 * Keep waiting until we find a returnable event or timeout. 454 * Keep waiting until we find a returnable event or timeout.
454 */ 455 */
455 checktmo: 456 checktmo:
456 if (DateTime.UtcNow < sleepUntil) 457 if(DateTime.UtcNow < sleepUntil)
457 goto findevent; 458 goto findevent;
458 459
459 /* 460 /*
@@ -463,7 +464,7 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
463 } 464 }
464 finally 465 finally
465 { 466 {
466 if (callMode != CallMode_NORMAL) 467 if(callMode != CallMode_NORMAL)
467 { 468 {
468 469
469 /* 470 /*
@@ -471,17 +472,17 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
471 * Save everything we need at the __call<n> labels so we can restore it 472 * Save everything we need at the __call<n> labels so we can restore it
472 * when we need to. 473 * when we need to.
473 */ 474 */
474 sv = CaptureStackFrame ("xmrEventDequeue", callNo, 9); 475 sv = CaptureStackFrame("xmrEventDequeue", callNo, 9);
475 sv[0] = sleepUntil.ToString (); // needed at __call0,__call1 476 sv[0] = sleepUntil.ToString(); // needed at __call0,__call1
476 sv[1] = returnMask1; // needed at __call0,__call1 477 sv[1] = returnMask1; // needed at __call0,__call1
477 sv[2] = returnMask2; // needed at __call0,__call1 478 sv[2] = returnMask2; // needed at __call0,__call1
478 sv[3] = mask1; // needed at __call0,__call1 479 sv[3] = mask1; // needed at __call0,__call1
479 sv[4] = mask2; // needed at __call0,__call1 480 sv[4] = mask2; // needed at __call0,__call1
480 if (callNo == 1) 481 if(callNo == 1)
481 { 482 {
482 sv[5] = evc1; // needed at __call1 483 sv[5] = evc1; // needed at __call1
483 sv[6] = (int)evc; // needed at __call1 484 sv[6] = (int)evc; // needed at __call1
484 sv[7] = DetPrmsToObjArr (evt.DetectParams); // needed at __call1 485 sv[7] = DetPrmsToObjArr(evt.DetectParams); // needed at __call1
485 sv[8] = evt.Params; // needed at __call1 486 sv[8] = evt.Params; // needed at __call1
486 } 487 }
487 } 488 }
@@ -495,16 +496,16 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
495 * are as currently set for the script (use xmrEventLoadDets to set how 496 * are as currently set for the script (use xmrEventLoadDets to set how
496 * you want them to be different). 497 * you want them to be different).
497 */ 498 */
498 public override void xmrEventEnqueue (LSL_List ev) 499 public override void xmrEventEnqueue(LSL_List ev)
499 { 500 {
500 object[] data = ev.Data; 501 object[] data = ev.Data;
501 ScriptEventCode evc = (ScriptEventCode)ListInt (data[0]); 502 ScriptEventCode evc = (ScriptEventCode)ListInt(data[0]);
502 503
503 int nargs = data.Length - 1; 504 int nargs = data.Length - 1;
504 object[] args = new object[nargs]; 505 object[] args = new object[nargs];
505 Array.Copy (data, 1, args, 0, nargs); 506 Array.Copy(data, 1, args, 0, nargs);
506 507
507 PostEvent (new EventParams (evc.ToString (), args, m_DetectParams)); 508 PostEvent(new EventParams(evc.ToString(), args, m_DetectParams));
508 } 509 }
509 510
510 /** 511 /**
@@ -513,19 +514,19 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
513 */ 514 */
514 private const int saveDPVer = 1; 515 private const int saveDPVer = 1;
515 516
516 public override LSL_List xmrEventSaveDets () 517 public override LSL_List xmrEventSaveDets()
517 { 518 {
518 object[] obs = DetPrmsToObjArr (m_DetectParams); 519 object[] obs = DetPrmsToObjArr(m_DetectParams);
519 return new LSL_List (obs); 520 return new LSL_List(obs);
520 } 521 }
521 522
522 private static object[] DetPrmsToObjArr (DetectParams[] dps) 523 private static object[] DetPrmsToObjArr(DetectParams[] dps)
523 { 524 {
524 int len = dps.Length; 525 int len = dps.Length;
525 object[] obs = new object[len*16+1]; 526 object[] obs = new object[len * 16 + 1];
526 int j = 0; 527 int j = 0;
527 obs[j++] = (LSL_Integer)saveDPVer; 528 obs[j++] = (LSL_Integer)saveDPVer;
528 for (int i = 0; i < len; i ++) 529 for(int i = 0; i < len; i++)
529 { 530 {
530 DetectParams dp = dps[i]; 531 DetectParams dp = dps[i];
531 obs[j++] = (LSL_String)dp.Key.ToString(); // UUID 532 obs[j++] = (LSL_String)dp.Key.ToString(); // UUID
@@ -548,54 +549,52 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
548 return obs; 549 return obs;
549 } 550 }
550 551
551
552 /** 552 /**
553 * @brief Load current detect params from a list 553 * @brief Load current detect params from a list
554 * @param dpList = as returned by xmrEventSaveDets() 554 * @param dpList = as returned by xmrEventSaveDets()
555 */ 555 */
556 public override void xmrEventLoadDets (LSL_List dpList) 556 public override void xmrEventLoadDets(LSL_List dpList)
557 { 557 {
558 m_DetectParams = ObjArrToDetPrms (dpList.Data); 558 m_DetectParams = ObjArrToDetPrms(dpList.Data);
559 } 559 }
560 560
561 private static DetectParams[] ObjArrToDetPrms (object[] objs) 561 private static DetectParams[] ObjArrToDetPrms(object[] objs)
562 { 562 {
563 int j = 0; 563 int j = 0;
564 if ((objs.Length % 16 != 1) || (ListInt (objs[j++]) != saveDPVer)) 564 if((objs.Length % 16 != 1) || (ListInt(objs[j++]) != saveDPVer))
565 throw new Exception ("invalid detect param format"); 565 throw new Exception("invalid detect param format");
566 566
567 int len = objs.Length / 16; 567 int len = objs.Length / 16;
568 DetectParams[] dps = new DetectParams[len]; 568 DetectParams[] dps = new DetectParams[len];
569 569
570 for (int i = 0; i < len; i ++) 570 for(int i = 0; i < len; i++)
571 { 571 {
572 DetectParams dp = new DetectParams (); 572 DetectParams dp = new DetectParams();
573 573
574 dp.Key = new UUID (ListStr (objs[j++])); 574 dp.Key = new UUID(ListStr(objs[j++]));
575 dp.OffsetPos = (LSL_Vector)objs[j++]; 575 dp.OffsetPos = (LSL_Vector)objs[j++];
576 dp.LinkNum = ListInt (objs[j++]); 576 dp.LinkNum = ListInt(objs[j++]);
577 dp.Group = new UUID (ListStr (objs[j++])); 577 dp.Group = new UUID(ListStr(objs[j++]));
578 dp.Name = ListStr (objs[j++]); 578 dp.Name = ListStr(objs[j++]);
579 dp.Owner = new UUID (ListStr (objs[j++])); 579 dp.Owner = new UUID(ListStr(objs[j++]));
580 dp.Position = (LSL_Vector)objs[j++]; 580 dp.Position = (LSL_Vector)objs[j++];
581 dp.Rotation = (LSL_Rotation)objs[j++]; 581 dp.Rotation = (LSL_Rotation)objs[j++];
582 dp.Type = ListInt (objs[j++]); 582 dp.Type = ListInt(objs[j++]);
583 dp.Velocity = (LSL_Vector)objs[j++]; 583 dp.Velocity = (LSL_Vector)objs[j++];
584 584
585 SurfaceTouchEventArgs stea = new SurfaceTouchEventArgs (); 585 SurfaceTouchEventArgs stea = new SurfaceTouchEventArgs();
586 586
587 stea.STCoord = LSLVec2OMVec ((LSL_Vector)objs[j++]); 587 stea.STCoord = LSLVec2OMVec((LSL_Vector)objs[j++]);
588 stea.Normal = LSLVec2OMVec ((LSL_Vector)objs[j++]); 588 stea.Normal = LSLVec2OMVec((LSL_Vector)objs[j++]);
589 stea.Binormal = LSLVec2OMVec ((LSL_Vector)objs[j++]); 589 stea.Binormal = LSLVec2OMVec((LSL_Vector)objs[j++]);
590 stea.Position = LSLVec2OMVec ((LSL_Vector)objs[j++]); 590 stea.Position = LSLVec2OMVec((LSL_Vector)objs[j++]);
591 stea.UVCoord = LSLVec2OMVec ((LSL_Vector)objs[j++]); 591 stea.UVCoord = LSLVec2OMVec((LSL_Vector)objs[j++]);
592 stea.FaceIndex = ListInt (objs[j++]); 592 stea.FaceIndex = ListInt(objs[j++]);
593 593
594 dp.SurfaceTouchArgs = stea; 594 dp.SurfaceTouchArgs = stea;
595 595
596 dps[i] = dp; 596 dps[i] = dp;
597 } 597 }
598
599 return dps; 598 return dps;
600 } 599 }
601 600
@@ -623,21 +622,13 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
623 /* 622 /*
624 * Clear out any old events from the queue. 623 * Clear out any old events from the queue.
625 */ 624 */
626 lock (m_QueueLock) 625 lock(m_QueueLock)
627 { 626 {
628 m_EventQueue.Clear(); 627 m_EventQueue.Clear();
629 for (int i = m_EventCounts.Length; -- i >= 0;) 628 for(int i = m_EventCounts.Length; --i >= 0;)
630 m_EventCounts[i] = 0; 629 m_EventCounts[i] = 0;
631 } 630 }
632 } 631 }
633
634 /**
635 * @brief Script is calling xmrStackLeft().
636 */
637 public override int xmrStackLeft ()
638 {
639 return microthread.StackLeft ();
640 }
641 } 632 }
642 633
643 /** 634 /**
@@ -646,12 +637,16 @@ namespace OpenSim.Region.ScriptEngine.XMREngine
646 * handler. We don't want script-level try/catch to intercept 637 * handler. We don't want script-level try/catch to intercept
647 * these so scripts can't interfere with the behavior. 638 * these so scripts can't interfere with the behavior.
648 */ 639 */
649 public class ScriptResetException : Exception, IXMRUncatchable { } 640 public class ScriptResetException: Exception, IXMRUncatchable
641 {
642 }
650 643
651 /** 644 /**
652 * @brief Thrown by things like llDie() to unconditionally unwind as 645 * @brief Thrown by things like llDie() to unconditionally unwind as
653 * script. We don't want script-level try/catch to intercept 646 * script. We don't want script-level try/catch to intercept
654 * these so scripts can't interfere with the behavior. 647 * these so scripts can't interfere with the behavior.
655 */ 648 */
656 public class ScriptDieException : Exception, IXMRUncatchable { } 649 public class ScriptDieException: Exception, IXMRUncatchable
650 {
651 }
657} 652}