aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1738
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs1011
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs53
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs40
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs28
14 files changed, 1758 insertions, 1201 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index ee32755..61e4934 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -248,6 +248,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
248 248
249 } 249 }
250 250
251 public static void StateChange(IScriptEngine engine, uint localID, UUID itemID)
252 {
253 // Remove a specific script
254
255 // Remove dataserver events
256 m_Dataserver[engine].RemoveEvents(localID, itemID);
257
258 IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>();
259 if (comms != null)
260 comms.DeleteListener(itemID);
261
262 IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>();
263 xmlrpc.DeleteChannels(itemID);
264 xmlrpc.CancelSRDRequests(itemID);
265
266 // Remove Sensors
267 m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID);
268
269 }
270
251 public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) 271 public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID)
252 { 272 {
253 List<Object> data = new List<Object>(); 273 List<Object> data = new List<Object>();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b21e532..e3a69a8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Diagnostics; //for [DebuggerNonUserCode]
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
@@ -81,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
81 /// </summary> 82 /// </summary>
82 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi 83 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
83 { 84 {
84 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 85// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
85 protected IScriptEngine m_ScriptEngine; 86 protected IScriptEngine m_ScriptEngine;
86 protected SceneObjectPart m_host; 87 protected SceneObjectPart m_host;
87 protected uint m_localID; 88 protected uint m_localID;
@@ -99,6 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
99 protected int m_notecardLineReadCharsMax = 255; 100 protected int m_notecardLineReadCharsMax = 255;
100 protected int m_scriptConsoleChannel = 0; 101 protected int m_scriptConsoleChannel = 0;
101 protected bool m_scriptConsoleChannelEnabled = false; 102 protected bool m_scriptConsoleChannelEnabled = false;
103 protected bool m_debuggerSafe = false;
102 protected IUrlModule m_UrlModule = null; 104 protected IUrlModule m_UrlModule = null;
103 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = 105 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
104 new Dictionary<UUID, UserInfoCacheEntry>(); 106 new Dictionary<UUID, UserInfoCacheEntry>();
@@ -109,6 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
109 m_host = host; 111 m_host = host;
110 m_localID = localID; 112 m_localID = localID;
111 m_itemID = itemID; 113 m_itemID = itemID;
114 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
112 115
113 m_ScriptDelayFactor = 116 m_ScriptDelayFactor =
114 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 117 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
@@ -161,6 +164,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
161 get { return m_ScriptEngine.World; } 164 get { return m_ScriptEngine.World; }
162 } 165 }
163 166
167 [DebuggerNonUserCode]
164 public void state(string newState) 168 public void state(string newState)
165 { 169 {
166 m_ScriptEngine.SetState(m_itemID, newState); 170 m_ScriptEngine.SetState(m_itemID, newState);
@@ -170,6 +174,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
170 /// Reset the named script. The script must be present 174 /// Reset the named script. The script must be present
171 /// in the same prim. 175 /// in the same prim.
172 /// </summary> 176 /// </summary>
177 [DebuggerNonUserCode]
173 public void llResetScript() 178 public void llResetScript()
174 { 179 {
175 m_host.AddScriptLPS(1); 180 m_host.AddScriptLPS(1);
@@ -226,9 +231,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
226 } 231 }
227 } 232 }
228 233
234 public List<ScenePresence> GetLinkAvatars(int linkType)
235 {
236 List<ScenePresence> ret = new List<ScenePresence>();
237 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
238 return ret;
239
240 List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars();
241
242 switch (linkType)
243 {
244 case ScriptBaseClass.LINK_SET:
245 return avs;
246
247 case ScriptBaseClass.LINK_ROOT:
248 return ret;
249
250 case ScriptBaseClass.LINK_ALL_OTHERS:
251 return avs;
252
253 case ScriptBaseClass.LINK_ALL_CHILDREN:
254 return avs;
255
256 case ScriptBaseClass.LINK_THIS:
257 return ret;
258
259 default:
260 if (linkType < 0)
261 return ret;
262
263 int partCount = m_host.ParentGroup.GetPartCount();
264
265 if (linkType <= partCount)
266 {
267 return ret;
268 }
269 else
270 {
271 linkType = linkType - partCount;
272 if (linkType > avs.Count)
273 {
274 return ret;
275 }
276 else
277 {
278 ret.Add(avs[linkType-1]);
279 return ret;
280 }
281 }
282 }
283 }
284
229 public List<SceneObjectPart> GetLinkParts(int linkType) 285 public List<SceneObjectPart> GetLinkParts(int linkType)
230 { 286 {
231 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 287 List<SceneObjectPart> ret = new List<SceneObjectPart>();
288 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
289 return ret;
232 ret.Add(m_host); 290 ret.Add(m_host);
233 291
234 switch (linkType) 292 switch (linkType)
@@ -282,40 +340,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
282 protected UUID InventorySelf() 340 protected UUID InventorySelf()
283 { 341 {
284 UUID invItemID = new UUID(); 342 UUID invItemID = new UUID();
285 343 bool unlock = false;
286 lock (m_host.TaskInventory) 344 if (!m_host.TaskInventory.IsReadLockedByMe())
345 {
346 m_host.TaskInventory.LockItemsForRead(true);
347 unlock = true;
348 }
349 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
287 { 350 {
288 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 351 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
289 { 352 {
290 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 353 invItemID = inv.Key;
291 { 354 break;
292 invItemID = inv.Key;
293 break;
294 }
295 } 355 }
296 } 356 }
297 357 if (unlock)
358 {
359 m_host.TaskInventory.LockItemsForRead(false);
360 }
298 return invItemID; 361 return invItemID;
299 } 362 }
300 363
301 protected UUID InventoryKey(string name, int type) 364 protected UUID InventoryKey(string name, int type)
302 { 365 {
303 m_host.AddScriptLPS(1); 366 m_host.AddScriptLPS(1);
304 367 m_host.TaskInventory.LockItemsForRead(true);
305 lock (m_host.TaskInventory) 368
369 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
306 { 370 {
307 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 371 if (inv.Value.Name == name)
308 { 372 {
309 if (inv.Value.Name == name) 373 m_host.TaskInventory.LockItemsForRead(false);
374
375 if (inv.Value.Type != type)
310 { 376 {
311 if (inv.Value.Type != type) 377 return UUID.Zero;
312 return UUID.Zero;
313
314 return inv.Value.AssetID;
315 } 378 }
379
380 return inv.Value.AssetID;
316 } 381 }
317 } 382 }
318 383
384 m_host.TaskInventory.LockItemsForRead(false);
319 return UUID.Zero; 385 return UUID.Zero;
320 } 386 }
321 387
@@ -323,17 +389,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
323 { 389 {
324 m_host.AddScriptLPS(1); 390 m_host.AddScriptLPS(1);
325 391
326 lock (m_host.TaskInventory) 392
393 m_host.TaskInventory.LockItemsForRead(true);
394
395 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
327 { 396 {
328 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 397 if (inv.Value.Name == name)
329 { 398 {
330 if (inv.Value.Name == name) 399 m_host.TaskInventory.LockItemsForRead(false);
331 { 400 return inv.Value.AssetID;
332 return inv.Value.AssetID;
333 }
334 } 401 }
335 } 402 }
336 403
404 m_host.TaskInventory.LockItemsForRead(false);
405
406
337 return UUID.Zero; 407 return UUID.Zero;
338 } 408 }
339 409
@@ -475,26 +545,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
475 545
476 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 546 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
477 547
478 // Old implementation of llRot2Euler. Normalization not required as Atan2 function will 548 // Utility function for llRot2Euler
479 // only return values >= -PI (-180 degrees) and <= PI (180 degrees).
480 549
481 public LSL_Vector llRot2Euler(LSL_Rotation r) 550 // normalize an angle between -PI and PI (-180 to +180 degrees)
551 protected double NormalizeAngle(double angle)
552 {
553 if (angle > -Math.PI && angle < Math.PI)
554 return angle;
555
556 int numPis = (int)(Math.PI / angle);
557 double remainder = angle - Math.PI * numPis;
558 if (numPis % 2 == 1)
559 return Math.PI - angle;
560 return remainder;
561 }
562
563 public LSL_Vector llRot2Euler(LSL_Rotation q1)
482 { 564 {
483 m_host.AddScriptLPS(1); 565 m_host.AddScriptLPS(1);
484 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke 566 LSL_Vector eul = new LSL_Vector();
485 LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); 567
486 double m = (t.x + t.y + t.z + t.s); 568 double sqw = q1.s*q1.s;
487 if (m == 0) return new LSL_Vector(); 569 double sqx = q1.x*q1.x;
488 double n = 2 * (r.y * r.s + r.x * r.z); 570 double sqy = q1.z*q1.z;
489 double p = m * m - n * n; 571 double sqz = q1.y*q1.y;
490 if (p > 0) 572 double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
491 return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), 573 double test = q1.x*q1.z + q1.y*q1.s;
492 Math.Atan2(n, Math.Sqrt(p)), 574 if (test > 0.4999*unit) { // singularity at north pole
493 Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); 575 eul.z = 2 * Math.Atan2(q1.x,q1.s);
494 else if (n > 0) 576 eul.y = Math.PI/2;
495 return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); 577 eul.x = 0;
496 else 578 return eul;
497 return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); 579 }
580 if (test < -0.4999*unit) { // singularity at south pole
581 eul.z = -2 * Math.Atan2(q1.x,q1.s);
582 eul.y = -Math.PI/2;
583 eul.x = 0;
584 return eul;
585 }
586 eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw);
587 eul.y = Math.Asin(2*test/unit);
588 eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw);
589 return eul;
498 } 590 }
499 591
500 /* From wiki: 592 /* From wiki:
@@ -696,77 +788,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
696 { 788 {
697 //A and B should both be normalized 789 //A and B should both be normalized
698 m_host.AddScriptLPS(1); 790 m_host.AddScriptLPS(1);
699 LSL_Rotation rotBetween; 791 /* This method is more accurate than the SL one, and thus causes problems
700 // Check for zero vectors. If either is zero, return zero rotation. Otherwise, 792 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
701 // continue calculation. 793
702 if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) 794 double dotProduct = LSL_Vector.Dot(a, b);
795 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
796 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
797 double angle = Math.Acos(dotProduct / magProduct);
798 LSL_Vector axis = LSL_Vector.Norm(crossProduct);
799 double s = Math.Sin(angle / 2);
800
801 double x = axis.x * s;
802 double y = axis.y * s;
803 double z = axis.z * s;
804 double w = Math.Cos(angle / 2);
805
806 if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w))
807 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
808
809 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
810 */
811
812 // This method mimics the 180 errors found in SL
813 // See www.euclideanspace.com... angleBetween
814 LSL_Vector vec_a = a;
815 LSL_Vector vec_b = b;
816
817 // Eliminate zero length
818 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
819 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
820 if (vec_a_mag < 0.00001 ||
821 vec_b_mag < 0.00001)
703 { 822 {
704 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 823 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
705 } 824 }
706 else 825
826 // Normalize
827 vec_a = llVecNorm(vec_a);
828 vec_b = llVecNorm(vec_b);
829
830 // Calculate axis and rotation angle
831 LSL_Vector axis = vec_a % vec_b;
832 LSL_Float cos_theta = vec_a * vec_b;
833
834 // Check if parallel
835 if (cos_theta > 0.99999)
707 { 836 {
708 a = LSL_Vector.Norm(a); 837 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
709 b = LSL_Vector.Norm(b); 838 }
710 double dotProduct = LSL_Vector.Dot(a, b); 839
711 // There are two degenerate cases possible. These are for vectors 180 or 840 // Check if anti-parallel
712 // 0 degrees apart. These have to be detected and handled individually. 841 else if (cos_theta < -0.99999)
713 // 842 {
714 // Check for vectors 180 degrees apart. 843 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
715 // A dot product of -1 would mean the angle between vectors is 180 degrees. 844 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
716 if (dotProduct < -0.9999999f) 845 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
717 { 846 }
718 // First assume X axis is orthogonal to the vectors. 847 else // other rotation
719 LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); 848 {
720 orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); 849 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
721 // Check for near zero vector. A very small non-zero number here will create 850 axis = llVecNorm(axis);
722 // a rotation in an undesired direction. 851 double x, y, z, s, t;
723 if (LSL_Vector.Mag(orthoVector) > 0.0001) 852 s = Math.Cos(theta);
724 { 853 t = Math.Sin(theta);
725 rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); 854 x = axis.x * t;
726 } 855 y = axis.y * t;
727 // If the magnitude of the vector was near zero, then assume the X axis is not 856 z = axis.z * t;
728 // orthogonal and use the Z axis instead. 857 return new LSL_Rotation(x,y,z,s);
729 else
730 {
731 // Set 180 z rotation.
732 rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f);
733 }
734 }
735 // Check for parallel vectors.
736 // A dot product of 1 would mean the angle between vectors is 0 degrees.
737 else if (dotProduct > 0.9999999f)
738 {
739 // Set zero rotation.
740 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
741 }
742 else
743 {
744 // All special checks have been performed so get the axis of rotation.
745 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
746 // Quarternion s value is the length of the unit vector + dot product.
747 double qs = 1.0 + dotProduct;
748 rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs);
749 // Normalize the rotation.
750 double mag = LSL_Rotation.Mag(rotBetween);
751 // We shouldn't have to worry about a divide by zero here. The qs value will be
752 // non-zero because we already know if we're here, then the dotProduct is not -1 so
753 // qs will not be zero. Also, we've already handled the input vectors being zero so the
754 // crossProduct vector should also not be zero.
755 rotBetween.x = rotBetween.x / mag;
756 rotBetween.y = rotBetween.y / mag;
757 rotBetween.z = rotBetween.z / mag;
758 rotBetween.s = rotBetween.s / mag;
759 // Check for undefined values and set zero rotation if any found. This code might not actually be required
760 // any longer since zero vectors are checked for at the top.
761 if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s))
762 {
763 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
764 }
765 }
766 } 858 }
767 return rotBetween;
768 } 859 }
769 860
770 public void llWhisper(int channelID, string text) 861 public void llWhisper(int channelID, string text)
771 { 862 {
772 m_host.AddScriptLPS(1); 863 m_host.AddScriptLPS(1);
@@ -1090,10 +1181,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1090 return detectedParams.TouchUV; 1181 return detectedParams.TouchUV;
1091 } 1182 }
1092 1183
1184 [DebuggerNonUserCode]
1093 public virtual void llDie() 1185 public virtual void llDie()
1094 { 1186 {
1095 m_host.AddScriptLPS(1); 1187 m_host.AddScriptLPS(1);
1096 throw new SelfDeleteException(); 1188 if (!m_host.IsAttachment) throw new SelfDeleteException();
1097 } 1189 }
1098 1190
1099 public LSL_Float llGround(LSL_Vector offset) 1191 public LSL_Float llGround(LSL_Vector offset)
@@ -1166,6 +1258,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1166 1258
1167 public void llSetStatus(int status, int value) 1259 public void llSetStatus(int status, int value)
1168 { 1260 {
1261 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1262 return;
1169 m_host.AddScriptLPS(1); 1263 m_host.AddScriptLPS(1);
1170 1264
1171 int statusrotationaxis = 0; 1265 int statusrotationaxis = 0;
@@ -1395,6 +1489,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1395 { 1489 {
1396 m_host.AddScriptLPS(1); 1490 m_host.AddScriptLPS(1);
1397 1491
1492 SetColor(m_host, color, face);
1493 }
1494
1495 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1496 {
1497 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1498 return;
1499
1500 Primitive.TextureEntry tex = part.Shape.Textures;
1501 Color4 texcolor;
1502 if (face >= 0 && face < GetNumberOfSides(part))
1503 {
1504 texcolor = tex.CreateFace((uint)face).RGBA;
1505 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1506 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1507 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1508 tex.FaceTextures[face].RGBA = texcolor;
1509 part.UpdateTexture(tex);
1510 return;
1511 }
1512 else if (face == ScriptBaseClass.ALL_SIDES)
1513 {
1514 for (uint i = 0; i < GetNumberOfSides(part); i++)
1515 {
1516 if (tex.FaceTextures[i] != null)
1517 {
1518 texcolor = tex.FaceTextures[i].RGBA;
1519 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1520 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1521 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1522 tex.FaceTextures[i].RGBA = texcolor;
1523 }
1524 texcolor = tex.DefaultTexture.RGBA;
1525 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1526 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1527 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1528 tex.DefaultTexture.RGBA = texcolor;
1529 }
1530 part.UpdateTexture(tex);
1531 return;
1532 }
1533
1398 if (face == ScriptBaseClass.ALL_SIDES) 1534 if (face == ScriptBaseClass.ALL_SIDES)
1399 face = SceneObjectPart.ALL_SIDES; 1535 face = SceneObjectPart.ALL_SIDES;
1400 1536
@@ -1403,6 +1539,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1403 1539
1404 public void SetTexGen(SceneObjectPart part, int face,int style) 1540 public void SetTexGen(SceneObjectPart part, int face,int style)
1405 { 1541 {
1542 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1543 return;
1544
1406 Primitive.TextureEntry tex = part.Shape.Textures; 1545 Primitive.TextureEntry tex = part.Shape.Textures;
1407 MappingType textype; 1546 MappingType textype;
1408 textype = MappingType.Default; 1547 textype = MappingType.Default;
@@ -1433,6 +1572,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1433 1572
1434 public void SetGlow(SceneObjectPart part, int face, float glow) 1573 public void SetGlow(SceneObjectPart part, int face, float glow)
1435 { 1574 {
1575 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1576 return;
1577
1436 Primitive.TextureEntry tex = part.Shape.Textures; 1578 Primitive.TextureEntry tex = part.Shape.Textures;
1437 if (face >= 0 && face < GetNumberOfSides(part)) 1579 if (face >= 0 && face < GetNumberOfSides(part))
1438 { 1580 {
@@ -1458,6 +1600,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1458 1600
1459 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1601 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1460 { 1602 {
1603 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1604 return;
1461 1605
1462 Shininess sval = new Shininess(); 1606 Shininess sval = new Shininess();
1463 1607
@@ -1508,6 +1652,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1508 1652
1509 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1653 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1510 { 1654 {
1655 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1656 return;
1657
1511 Primitive.TextureEntry tex = part.Shape.Textures; 1658 Primitive.TextureEntry tex = part.Shape.Textures;
1512 if (face >= 0 && face < GetNumberOfSides(part)) 1659 if (face >= 0 && face < GetNumberOfSides(part))
1513 { 1660 {
@@ -1568,13 +1715,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1568 m_host.AddScriptLPS(1); 1715 m_host.AddScriptLPS(1);
1569 1716
1570 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1717 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1571 1718 if (parts.Count > 0)
1572 foreach (SceneObjectPart part in parts) 1719 {
1573 SetAlpha(part, alpha, face); 1720 try
1721 {
1722 parts[0].ParentGroup.areUpdatesSuspended = true;
1723 foreach (SceneObjectPart part in parts)
1724 SetAlpha(part, alpha, face);
1725 }
1726 finally
1727 {
1728 parts[0].ParentGroup.areUpdatesSuspended = false;
1729 }
1730 }
1574 } 1731 }
1575 1732
1576 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1733 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1577 { 1734 {
1735 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1736 return;
1737
1578 Primitive.TextureEntry tex = part.Shape.Textures; 1738 Primitive.TextureEntry tex = part.Shape.Textures;
1579 Color4 texcolor; 1739 Color4 texcolor;
1580 if (face >= 0 && face < GetNumberOfSides(part)) 1740 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1620,7 +1780,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1620 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1780 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1621 float wind, float tension, LSL_Vector Force) 1781 float wind, float tension, LSL_Vector Force)
1622 { 1782 {
1623 if (part == null) 1783 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1624 return; 1784 return;
1625 1785
1626 if (flexi) 1786 if (flexi)
@@ -1655,7 +1815,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1655 /// <param name="falloff"></param> 1815 /// <param name="falloff"></param>
1656 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1816 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1657 { 1817 {
1658 if (part == null) 1818 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1659 return; 1819 return;
1660 1820
1661 if (light) 1821 if (light)
@@ -1732,15 +1892,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1732 m_host.AddScriptLPS(1); 1892 m_host.AddScriptLPS(1);
1733 1893
1734 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1894 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1735 1895 if (parts.Count > 0)
1736 foreach (SceneObjectPart part in parts) 1896 {
1737 SetTexture(part, texture, face); 1897 try
1738 1898 {
1899 parts[0].ParentGroup.areUpdatesSuspended = true;
1900 foreach (SceneObjectPart part in parts)
1901 SetTexture(part, texture, face);
1902 }
1903 finally
1904 {
1905 parts[0].ParentGroup.areUpdatesSuspended = false;
1906 }
1907 }
1739 ScriptSleep(200); 1908 ScriptSleep(200);
1740 } 1909 }
1741 1910
1742 protected void SetTexture(SceneObjectPart part, string texture, int face) 1911 protected void SetTexture(SceneObjectPart part, string texture, int face)
1743 { 1912 {
1913 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1914 return;
1915
1744 UUID textureID=new UUID(); 1916 UUID textureID=new UUID();
1745 1917
1746 if (!UUID.TryParse(texture, out textureID)) 1918 if (!UUID.TryParse(texture, out textureID))
@@ -1786,6 +1958,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1786 1958
1787 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1959 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1788 { 1960 {
1961 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1962 return;
1963
1789 Primitive.TextureEntry tex = part.Shape.Textures; 1964 Primitive.TextureEntry tex = part.Shape.Textures;
1790 if (face >= 0 && face < GetNumberOfSides(part)) 1965 if (face >= 0 && face < GetNumberOfSides(part))
1791 { 1966 {
@@ -1822,6 +1997,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1822 1997
1823 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 1998 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1824 { 1999 {
2000 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2001 return;
2002
1825 Primitive.TextureEntry tex = part.Shape.Textures; 2003 Primitive.TextureEntry tex = part.Shape.Textures;
1826 if (face >= 0 && face < GetNumberOfSides(part)) 2004 if (face >= 0 && face < GetNumberOfSides(part))
1827 { 2005 {
@@ -1858,6 +2036,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1858 2036
1859 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 2037 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1860 { 2038 {
2039 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2040 return;
2041
1861 Primitive.TextureEntry tex = part.Shape.Textures; 2042 Primitive.TextureEntry tex = part.Shape.Textures;
1862 if (face >= 0 && face < GetNumberOfSides(part)) 2043 if (face >= 0 && face < GetNumberOfSides(part))
1863 { 2044 {
@@ -1928,6 +2109,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1928 2109
1929 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 2110 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
1930 { 2111 {
2112 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2113 return;
2114
1931 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2115 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1932 LSL_Vector currentPos = GetPartLocalPos(part); 2116 LSL_Vector currentPos = GetPartLocalPos(part);
1933 2117
@@ -1944,7 +2128,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1944 } 2128 }
1945 else 2129 else
1946 { 2130 {
1947 LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); 2131 LSL_Vector rel_vec = SetPosAdjust(new LSL_Vector(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z), targetPos);
1948 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); 2132 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
1949 SceneObjectGroup parent = part.ParentGroup; 2133 SceneObjectGroup parent = part.ParentGroup;
1950 parent.HasGroupChanged = true; 2134 parent.HasGroupChanged = true;
@@ -2018,6 +2202,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2018 2202
2019 protected void SetRot(SceneObjectPart part, Quaternion rot) 2203 protected void SetRot(SceneObjectPart part, Quaternion rot)
2020 { 2204 {
2205 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2206 return;
2207
2021 part.UpdateRotation(rot); 2208 part.UpdateRotation(rot);
2022 // Update rotation does not move the object in the physics scene if it's a linkset. 2209 // Update rotation does not move the object in the physics scene if it's a linkset.
2023 2210
@@ -2637,12 +2824,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2637 2824
2638 m_host.AddScriptLPS(1); 2825 m_host.AddScriptLPS(1);
2639 2826
2827 m_host.TaskInventory.LockItemsForRead(true);
2640 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2828 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2641 2829 m_host.TaskInventory.LockItemsForRead(false);
2642 lock (m_host.TaskInventory)
2643 {
2644 item = m_host.TaskInventory[invItemID];
2645 }
2646 2830
2647 if (item.PermsGranter == UUID.Zero) 2831 if (item.PermsGranter == UUID.Zero)
2648 return 0; 2832 return 0;
@@ -2717,6 +2901,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2717 if (dist > m_ScriptDistanceFactor * 10.0f) 2901 if (dist > m_ScriptDistanceFactor * 10.0f)
2718 return; 2902 return;
2719 2903
2904 //Clone is thread-safe
2720 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2905 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2721 2906
2722 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2907 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2779,6 +2964,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2779 2964
2780 public void llLookAt(LSL_Vector target, double strength, double damping) 2965 public void llLookAt(LSL_Vector target, double strength, double damping)
2781 { 2966 {
2967 /*
2782 m_host.AddScriptLPS(1); 2968 m_host.AddScriptLPS(1);
2783 // Determine where we are looking from 2969 // Determine where we are looking from
2784 LSL_Vector from = llGetPos(); 2970 LSL_Vector from = llGetPos();
@@ -2798,10 +2984,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2798 // the angles of rotation in radians into rotation value 2984 // the angles of rotation in radians into rotation value
2799 2985
2800 LSL_Types.Quaternion rot = llEuler2Rot(angle); 2986 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2801 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 2987
2802 m_host.startLookAt(rotation, (float)damping, (float)strength); 2988 // This would only work if your physics system contains an APID controller:
2989 // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
2990 // m_host.startLookAt(rotation, (float)damping, (float)strength);
2991
2803 // Orient the object to the angle calculated 2992 // Orient the object to the angle calculated
2804 //llSetRot(rot); 2993 llSetRot(rot);
2994 */
2995
2996 //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object.
2997 //There's probably a smarter way of doing this, my rotation math-fu is weak.
2998 // http://bugs.meta7.com/view.php?id=28
2999 // - Tom
3000
3001 LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d));
3002 llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos()));
3003
3004 }
3005
3006 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3007 {
3008 m_host.AddScriptLPS(1);
3009// NotImplemented("llRotLookAt");
3010 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
3011
2805 } 3012 }
2806 3013
2807 public void llStopLookAt() 3014 public void llStopLookAt()
@@ -2850,13 +3057,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2850 { 3057 {
2851 TaskInventoryItem item; 3058 TaskInventoryItem item;
2852 3059
2853 lock (m_host.TaskInventory) 3060 m_host.TaskInventory.LockItemsForRead(true);
3061 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2854 { 3062 {
2855 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3063 m_host.TaskInventory.LockItemsForRead(false);
2856 return; 3064 return;
2857 else 3065 }
2858 item = m_host.TaskInventory[InventorySelf()]; 3066 else
3067 {
3068 item = m_host.TaskInventory[InventorySelf()];
2859 } 3069 }
3070 m_host.TaskInventory.LockItemsForRead(false);
2860 3071
2861 if (item.PermsGranter != UUID.Zero) 3072 if (item.PermsGranter != UUID.Zero)
2862 { 3073 {
@@ -2878,13 +3089,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2878 { 3089 {
2879 TaskInventoryItem item; 3090 TaskInventoryItem item;
2880 3091
3092 m_host.TaskInventory.LockItemsForRead(true);
2881 lock (m_host.TaskInventory) 3093 lock (m_host.TaskInventory)
2882 { 3094 {
3095
2883 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3096 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3097 {
3098 m_host.TaskInventory.LockItemsForRead(false);
2884 return; 3099 return;
3100 }
2885 else 3101 else
3102 {
2886 item = m_host.TaskInventory[InventorySelf()]; 3103 item = m_host.TaskInventory[InventorySelf()];
3104 }
2887 } 3105 }
3106 m_host.TaskInventory.LockItemsForRead(false);
2888 3107
2889 m_host.AddScriptLPS(1); 3108 m_host.AddScriptLPS(1);
2890 3109
@@ -2916,18 +3135,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2916 { 3135 {
2917 m_host.AddScriptLPS(1); 3136 m_host.AddScriptLPS(1);
2918 3137
2919 if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
2920 return;
2921
2922 TaskInventoryItem item; 3138 TaskInventoryItem item;
2923 3139
2924 lock (m_host.TaskInventory) 3140 m_host.TaskInventory.LockItemsForRead(true);
3141
3142 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2925 { 3143 {
2926 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3144 m_host.TaskInventory.LockItemsForRead(false);
2927 return; 3145 return;
2928 else
2929 item = m_host.TaskInventory[InventorySelf()];
2930 } 3146 }
3147 else
3148 {
3149 item = m_host.TaskInventory[InventorySelf()];
3150 }
3151
3152 m_host.TaskInventory.LockItemsForRead(false);
2931 3153
2932 if (item.PermsGranter != m_host.OwnerID) 3154 if (item.PermsGranter != m_host.OwnerID)
2933 return; 3155 return;
@@ -2938,10 +3160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2938 3160
2939 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3161 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
2940 3162
2941 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3163 grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false);
2942 if (attachmentsModule != null)
2943 attachmentsModule.AttachObject(presence.ControllingClient,
2944 grp, (uint)attachment, false);
2945 } 3164 }
2946 } 3165 }
2947 3166
@@ -2954,13 +3173,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2954 3173
2955 TaskInventoryItem item; 3174 TaskInventoryItem item;
2956 3175
2957 lock (m_host.TaskInventory) 3176 m_host.TaskInventory.LockItemsForRead(true);
3177
3178 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2958 { 3179 {
2959 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3180 m_host.TaskInventory.LockItemsForRead(false);
2960 return; 3181 return;
2961 else
2962 item = m_host.TaskInventory[InventorySelf()];
2963 } 3182 }
3183 else
3184 {
3185 item = m_host.TaskInventory[InventorySelf()];
3186 }
3187 m_host.TaskInventory.LockItemsForRead(false);
3188
2964 3189
2965 if (item.PermsGranter != m_host.OwnerID) 3190 if (item.PermsGranter != m_host.OwnerID)
2966 return; 3191 return;
@@ -2999,6 +3224,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2999 3224
3000 public void llInstantMessage(string user, string message) 3225 public void llInstantMessage(string user, string message)
3001 { 3226 {
3227 UUID result;
3228 if (!UUID.TryParse(user, out result))
3229 {
3230 if (!m_debuggerSafe)
3231 {
3232 throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user));
3233 }
3234 return;
3235 }
3236
3237
3002 m_host.AddScriptLPS(1); 3238 m_host.AddScriptLPS(1);
3003 3239
3004 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3240 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -3013,14 +3249,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3013 UUID friendTransactionID = UUID.Random(); 3249 UUID friendTransactionID = UUID.Random();
3014 3250
3015 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3251 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
3016 3252
3017 GridInstantMessage msg = new GridInstantMessage(); 3253 GridInstantMessage msg = new GridInstantMessage();
3018 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3254 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
3019 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3255 msg.toAgentID = new Guid(user); // toAgentID.Guid;
3020 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 3256 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
3021// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 3257// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
3022// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 3258// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
3023 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 3259 DateTime dt = DateTime.UtcNow;
3260
3261 // Ticks from UtcNow, but make it look like local. Evil, huh?
3262 dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
3263
3264 try
3265 {
3266 // Convert that to the PST timezone
3267 TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
3268 dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
3269 }
3270 catch
3271 {
3272 // No logging here, as it could be VERY spammy
3273 }
3274
3275 // And make it look local again to fool the unix time util
3276 dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
3277
3278 msg.timestamp = (uint)Util.ToUnixTime(dt);
3279
3024 //if (client != null) 3280 //if (client != null)
3025 //{ 3281 //{
3026 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; 3282 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
@@ -3034,13 +3290,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3034 msg.message = message.Substring(0, 1024); 3290 msg.message = message.Substring(0, 1024);
3035 else 3291 else
3036 msg.message = message; 3292 msg.message = message;
3037 msg.dialog = (byte)19; // messgage from script ??? // dialog; 3293 msg.dialog = (byte)19; // MessageFromObject
3038 msg.fromGroup = false;// fromGroup; 3294 msg.fromGroup = false;// fromGroup;
3039 msg.offline = (byte)0; //offline; 3295 msg.offline = (byte)0; //offline;
3040 msg.ParentEstateID = 0; //ParentEstateID; 3296 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3041 msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); 3297 msg.Position = new Vector3(m_host.AbsolutePosition);
3042 msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; 3298 msg.RegionID = World.RegionInfo.RegionID.Guid;
3043 msg.binaryBucket = new byte[0];// binaryBucket; 3299 msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString());
3044 3300
3045 if (m_TransferModule != null) 3301 if (m_TransferModule != null)
3046 { 3302 {
@@ -3060,7 +3316,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3060 } 3316 }
3061 3317
3062 emailModule.SendEmail(m_host.UUID, address, subject, message); 3318 emailModule.SendEmail(m_host.UUID, address, subject, message);
3063 ScriptSleep(20000); 3319 ScriptSleep(15000);
3064 } 3320 }
3065 3321
3066 public void llGetNextEmail(string address, string subject) 3322 public void llGetNextEmail(string address, string subject)
@@ -3162,13 +3418,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3162 m_host.AddScriptLPS(1); 3418 m_host.AddScriptLPS(1);
3163 } 3419 }
3164 3420
3165 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3166 {
3167 m_host.AddScriptLPS(1);
3168 Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
3169 m_host.RotLookAt(rot, (float)strength, (float)damping);
3170 }
3171
3172 public LSL_Integer llStringLength(string str) 3421 public LSL_Integer llStringLength(string str)
3173 { 3422 {
3174 m_host.AddScriptLPS(1); 3423 m_host.AddScriptLPS(1);
@@ -3192,14 +3441,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3192 3441
3193 TaskInventoryItem item; 3442 TaskInventoryItem item;
3194 3443
3195 lock (m_host.TaskInventory) 3444 m_host.TaskInventory.LockItemsForRead(true);
3445 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3196 { 3446 {
3197 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3447 m_host.TaskInventory.LockItemsForRead(false);
3198 return; 3448 return;
3199 else
3200 item = m_host.TaskInventory[InventorySelf()];
3201 } 3449 }
3202 3450 else
3451 {
3452 item = m_host.TaskInventory[InventorySelf()];
3453 }
3454 m_host.TaskInventory.LockItemsForRead(false);
3203 if (item.PermsGranter == UUID.Zero) 3455 if (item.PermsGranter == UUID.Zero)
3204 return; 3456 return;
3205 3457
@@ -3229,13 +3481,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3229 3481
3230 TaskInventoryItem item; 3482 TaskInventoryItem item;
3231 3483
3232 lock (m_host.TaskInventory) 3484 m_host.TaskInventory.LockItemsForRead(true);
3485 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3233 { 3486 {
3234 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3487 m_host.TaskInventory.LockItemsForRead(false);
3235 return; 3488 return;
3236 else 3489 }
3237 item = m_host.TaskInventory[InventorySelf()]; 3490 else
3491 {
3492 item = m_host.TaskInventory[InventorySelf()];
3238 } 3493 }
3494 m_host.TaskInventory.LockItemsForRead(false);
3495
3239 3496
3240 if (item.PermsGranter == UUID.Zero) 3497 if (item.PermsGranter == UUID.Zero)
3241 return; 3498 return;
@@ -3306,10 +3563,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3306 3563
3307 TaskInventoryItem item; 3564 TaskInventoryItem item;
3308 3565
3309 lock (m_host.TaskInventory) 3566
3567 m_host.TaskInventory.LockItemsForRead(true);
3568 if (!m_host.TaskInventory.ContainsKey(invItemID))
3569 {
3570 m_host.TaskInventory.LockItemsForRead(false);
3571 return;
3572 }
3573 else
3310 { 3574 {
3311 item = m_host.TaskInventory[invItemID]; 3575 item = m_host.TaskInventory[invItemID];
3312 } 3576 }
3577 m_host.TaskInventory.LockItemsForRead(false);
3313 3578
3314 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3579 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3315 { 3580 {
@@ -3341,11 +3606,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3341 3606
3342 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3607 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3343 { 3608 {
3344 lock (m_host.TaskInventory) 3609 m_host.TaskInventory.LockItemsForWrite(true);
3345 { 3610 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3346 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3611 m_host.TaskInventory[invItemID].PermsMask = perm;
3347 m_host.TaskInventory[invItemID].PermsMask = perm; 3612 m_host.TaskInventory.LockItemsForWrite(false);
3348 }
3349 3613
3350 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3614 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3351 "run_time_permissions", new Object[] { 3615 "run_time_permissions", new Object[] {
@@ -3365,11 +3629,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3365 3629
3366 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3630 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3367 { 3631 {
3368 lock (m_host.TaskInventory) 3632 m_host.TaskInventory.LockItemsForWrite(true);
3369 { 3633 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3370 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3634 m_host.TaskInventory[invItemID].PermsMask = perm;
3371 m_host.TaskInventory[invItemID].PermsMask = perm; 3635 m_host.TaskInventory.LockItemsForWrite(false);
3372 }
3373 3636
3374 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3637 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3375 "run_time_permissions", new Object[] { 3638 "run_time_permissions", new Object[] {
@@ -3390,11 +3653,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3390 3653
3391 if (!m_waitingForScriptAnswer) 3654 if (!m_waitingForScriptAnswer)
3392 { 3655 {
3393 lock (m_host.TaskInventory) 3656 m_host.TaskInventory.LockItemsForWrite(true);
3394 { 3657 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3395 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3658 m_host.TaskInventory[invItemID].PermsMask = 0;
3396 m_host.TaskInventory[invItemID].PermsMask = 0; 3659 m_host.TaskInventory.LockItemsForWrite(false);
3397 }
3398 3660
3399 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3661 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3400 m_waitingForScriptAnswer=true; 3662 m_waitingForScriptAnswer=true;
@@ -3429,10 +3691,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3429 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3691 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3430 llReleaseControls(); 3692 llReleaseControls();
3431 3693
3432 lock (m_host.TaskInventory) 3694
3433 { 3695 m_host.TaskInventory.LockItemsForWrite(true);
3434 m_host.TaskInventory[invItemID].PermsMask = answer; 3696 m_host.TaskInventory[invItemID].PermsMask = answer;
3435 } 3697 m_host.TaskInventory.LockItemsForWrite(false);
3698
3436 3699
3437 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3700 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3438 "run_time_permissions", new Object[] { 3701 "run_time_permissions", new Object[] {
@@ -3444,16 +3707,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3444 { 3707 {
3445 m_host.AddScriptLPS(1); 3708 m_host.AddScriptLPS(1);
3446 3709
3447 lock (m_host.TaskInventory) 3710 m_host.TaskInventory.LockItemsForRead(true);
3711
3712 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3448 { 3713 {
3449 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3714 if (item.Type == 10 && item.ItemID == m_itemID)
3450 { 3715 {
3451 if (item.Type == 10 && item.ItemID == m_itemID) 3716 m_host.TaskInventory.LockItemsForRead(false);
3452 { 3717 return item.PermsGranter.ToString();
3453 return item.PermsGranter.ToString();
3454 }
3455 } 3718 }
3456 } 3719 }
3720 m_host.TaskInventory.LockItemsForRead(false);
3457 3721
3458 return UUID.Zero.ToString(); 3722 return UUID.Zero.ToString();
3459 } 3723 }
@@ -3462,19 +3726,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3462 { 3726 {
3463 m_host.AddScriptLPS(1); 3727 m_host.AddScriptLPS(1);
3464 3728
3465 lock (m_host.TaskInventory) 3729 m_host.TaskInventory.LockItemsForRead(true);
3730
3731 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3466 { 3732 {
3467 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3733 if (item.Type == 10 && item.ItemID == m_itemID)
3468 { 3734 {
3469 if (item.Type == 10 && item.ItemID == m_itemID) 3735 int perms = item.PermsMask;
3470 { 3736 if (m_automaticLinkPermission)
3471 int perms = item.PermsMask; 3737 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3472 if (m_automaticLinkPermission) 3738 m_host.TaskInventory.LockItemsForRead(false);
3473 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3739 return perms;
3474 return perms;
3475 }
3476 } 3740 }
3477 } 3741 }
3742 m_host.TaskInventory.LockItemsForRead(false);
3478 3743
3479 return 0; 3744 return 0;
3480 } 3745 }
@@ -3496,9 +3761,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3496 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3761 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3497 { 3762 {
3498 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3763 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3499 3764 if (parts.Count > 0)
3500 foreach (SceneObjectPart part in parts) 3765 {
3501 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3766 try
3767 {
3768 parts[0].ParentGroup.areUpdatesSuspended = true;
3769 foreach (SceneObjectPart part in parts)
3770 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
3771 }
3772 finally
3773 {
3774 parts[0].ParentGroup.areUpdatesSuspended = false;
3775 }
3776 }
3502 } 3777 }
3503 3778
3504 public void llCreateLink(string target, int parent) 3779 public void llCreateLink(string target, int parent)
@@ -3507,11 +3782,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3507 UUID invItemID = InventorySelf(); 3782 UUID invItemID = InventorySelf();
3508 3783
3509 TaskInventoryItem item; 3784 TaskInventoryItem item;
3510 lock (m_host.TaskInventory) 3785 m_host.TaskInventory.LockItemsForRead(true);
3511 { 3786 item = m_host.TaskInventory[invItemID];
3512 item = m_host.TaskInventory[invItemID]; 3787 m_host.TaskInventory.LockItemsForRead(false);
3513 } 3788
3514
3515 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3789 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3516 && !m_automaticLinkPermission) 3790 && !m_automaticLinkPermission)
3517 { 3791 {
@@ -3564,16 +3838,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3564 m_host.AddScriptLPS(1); 3838 m_host.AddScriptLPS(1);
3565 UUID invItemID = InventorySelf(); 3839 UUID invItemID = InventorySelf();
3566 3840
3567 lock (m_host.TaskInventory) 3841 m_host.TaskInventory.LockItemsForRead(true);
3568 {
3569 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3842 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3570 && !m_automaticLinkPermission) 3843 && !m_automaticLinkPermission)
3571 { 3844 {
3572 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3845 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3846 m_host.TaskInventory.LockItemsForRead(false);
3573 return; 3847 return;
3574 } 3848 }
3575 } 3849 m_host.TaskInventory.LockItemsForRead(false);
3576 3850
3577 if (linknum < ScriptBaseClass.LINK_THIS) 3851 if (linknum < ScriptBaseClass.LINK_THIS)
3578 return; 3852 return;
3579 3853
@@ -3612,10 +3886,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3612 // Restructuring Multiple Prims. 3886 // Restructuring Multiple Prims.
3613 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3887 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3614 parts.Remove(parentPrim.RootPart); 3888 parts.Remove(parentPrim.RootPart);
3615 foreach (SceneObjectPart part in parts) 3889 if (parts.Count > 0)
3616 { 3890 {
3617 parentPrim.DelinkFromGroup(part.LocalId, true); 3891 try
3892 {
3893 parts[0].ParentGroup.areUpdatesSuspended = true;
3894 foreach (SceneObjectPart part in parts)
3895 {
3896 parentPrim.DelinkFromGroup(part.LocalId, true);
3897 }
3898 }
3899 finally
3900 {
3901 parts[0].ParentGroup.areUpdatesSuspended = false;
3902 }
3618 } 3903 }
3904
3619 parentPrim.HasGroupChanged = true; 3905 parentPrim.HasGroupChanged = true;
3620 parentPrim.ScheduleGroupForFullUpdate(); 3906 parentPrim.ScheduleGroupForFullUpdate();
3621 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3907 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3624,11 +3910,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3624 { 3910 {
3625 SceneObjectPart newRoot = parts[0]; 3911 SceneObjectPart newRoot = parts[0];
3626 parts.Remove(newRoot); 3912 parts.Remove(newRoot);
3627 foreach (SceneObjectPart part in parts) 3913
3914 try
3628 { 3915 {
3629 part.UpdateFlag = 0; 3916 parts[0].ParentGroup.areUpdatesSuspended = true;
3630 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 3917 foreach (SceneObjectPart part in parts)
3918 {
3919 part.UpdateFlag = 0;
3920 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
3921 }
3631 } 3922 }
3923 finally
3924 {
3925 parts[0].ParentGroup.areUpdatesSuspended = false;
3926 }
3927
3928
3632 newRoot.ParentGroup.HasGroupChanged = true; 3929 newRoot.ParentGroup.HasGroupChanged = true;
3633 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 3930 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3634 } 3931 }
@@ -3654,11 +3951,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3654 3951
3655 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3952 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3656 parts.Remove(parentPrim.RootPart); 3953 parts.Remove(parentPrim.RootPart);
3657 3954 if (parts.Count > 0)
3658 foreach (SceneObjectPart part in parts)
3659 { 3955 {
3660 parentPrim.DelinkFromGroup(part.LocalId, true); 3956 try
3661 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3957 {
3958 parts[0].ParentGroup.areUpdatesSuspended = true;
3959 foreach (SceneObjectPart part in parts)
3960 {
3961 parentPrim.DelinkFromGroup(part.LocalId, true);
3962 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3963 }
3964 }
3965 finally
3966 {
3967 parts[0].ParentGroup.areUpdatesSuspended = false;
3968 }
3662 } 3969 }
3663 parentPrim.HasGroupChanged = true; 3970 parentPrim.HasGroupChanged = true;
3664 parentPrim.ScheduleGroupForFullUpdate(); 3971 parentPrim.ScheduleGroupForFullUpdate();
@@ -3750,17 +4057,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3750 m_host.AddScriptLPS(1); 4057 m_host.AddScriptLPS(1);
3751 int count = 0; 4058 int count = 0;
3752 4059
3753 lock (m_host.TaskInventory) 4060 m_host.TaskInventory.LockItemsForRead(true);
4061 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3754 { 4062 {
3755 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4063 if (inv.Value.Type == type || type == -1)
3756 { 4064 {
3757 if (inv.Value.Type == type || type == -1) 4065 count = count + 1;
3758 {
3759 count = count + 1;
3760 }
3761 } 4066 }
3762 } 4067 }
3763 4068
4069 m_host.TaskInventory.LockItemsForRead(false);
3764 return count; 4070 return count;
3765 } 4071 }
3766 4072
@@ -3769,16 +4075,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3769 m_host.AddScriptLPS(1); 4075 m_host.AddScriptLPS(1);
3770 ArrayList keys = new ArrayList(); 4076 ArrayList keys = new ArrayList();
3771 4077
3772 lock (m_host.TaskInventory) 4078 m_host.TaskInventory.LockItemsForRead(true);
4079 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3773 { 4080 {
3774 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4081 if (inv.Value.Type == type || type == -1)
3775 { 4082 {
3776 if (inv.Value.Type == type || type == -1) 4083 keys.Add(inv.Value.Name);
3777 {
3778 keys.Add(inv.Value.Name);
3779 }
3780 } 4084 }
3781 } 4085 }
4086 m_host.TaskInventory.LockItemsForRead(false);
3782 4087
3783 if (keys.Count == 0) 4088 if (keys.Count == 0)
3784 { 4089 {
@@ -3815,20 +4120,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3815 } 4120 }
3816 4121
3817 // move the first object found with this inventory name 4122 // move the first object found with this inventory name
3818 lock (m_host.TaskInventory) 4123 m_host.TaskInventory.LockItemsForRead(true);
4124 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3819 { 4125 {
3820 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4126 if (inv.Value.Name == inventory)
3821 { 4127 {
3822 if (inv.Value.Name == inventory) 4128 found = true;
3823 { 4129 objId = inv.Key;
3824 found = true; 4130 assetType = inv.Value.Type;
3825 objId = inv.Key; 4131 objName = inv.Value.Name;
3826 assetType = inv.Value.Type; 4132 break;
3827 objName = inv.Value.Name;
3828 break;
3829 }
3830 } 4133 }
3831 } 4134 }
4135 m_host.TaskInventory.LockItemsForRead(false);
3832 4136
3833 if (!found) 4137 if (!found)
3834 { 4138 {
@@ -3836,9 +4140,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3836 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4140 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
3837 } 4141 }
3838 4142
3839 // check if destination is an avatar 4143 // check if destination is an object
3840 if (World.GetScenePresence(destId) != null) 4144 if (World.GetSceneObjectPart(destId) != null)
4145 {
4146 // destination is an object
4147 World.MoveTaskInventoryItem(destId, m_host, objId);
4148 }
4149 else
3841 { 4150 {
4151 ScenePresence presence = World.GetScenePresence(destId);
4152
4153 if (presence == null)
4154 {
4155 UserAccount account =
4156 World.UserAccountService.GetUserAccount(
4157 World.RegionInfo.ScopeID,
4158 destId);
4159
4160 if (account == null)
4161 {
4162 llSay(0, "Can't find destination "+destId.ToString());
4163 return;
4164 }
4165 }
4166
3842 // destination is an avatar 4167 // destination is an avatar
3843 InventoryItemBase agentItem = 4168 InventoryItemBase agentItem =
3844 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4169 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
@@ -3848,7 +4173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3848 4173
3849 byte[] bucket = new byte[17]; 4174 byte[] bucket = new byte[17];
3850 bucket[0] = (byte)assetType; 4175 bucket[0] = (byte)assetType;
3851 byte[] objBytes = objId.GetBytes(); 4176 byte[] objBytes = agentItem.ID.GetBytes();
3852 Array.Copy(objBytes, 0, bucket, 1, 16); 4177 Array.Copy(objBytes, 0, bucket, 1, 16);
3853 4178
3854 Console.WriteLine("Giving inventory"); 4179 Console.WriteLine("Giving inventory");
@@ -3864,31 +4189,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3864 4189
3865 if (m_TransferModule != null) 4190 if (m_TransferModule != null)
3866 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 4191 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
4192
4193 //This delay should only occur when giving inventory to avatars.
4194 ScriptSleep(3000);
3867 } 4195 }
3868 else
3869 {
3870 // destination is an object
3871 World.MoveTaskInventoryItem(destId, m_host, objId);
3872 }
3873 ScriptSleep(3000);
3874 } 4196 }
3875 4197
4198 [DebuggerNonUserCode]
3876 public void llRemoveInventory(string name) 4199 public void llRemoveInventory(string name)
3877 { 4200 {
3878 m_host.AddScriptLPS(1); 4201 m_host.AddScriptLPS(1);
3879 4202
3880 lock (m_host.TaskInventory) 4203 List<TaskInventoryItem> inv;
4204 try
3881 { 4205 {
3882 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4206 m_host.TaskInventory.LockItemsForRead(true);
4207 inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values);
4208 }
4209 finally
4210 {
4211 m_host.TaskInventory.LockItemsForRead(false);
4212 }
4213 foreach (TaskInventoryItem item in inv)
4214 {
4215 if (item.Name == name)
3883 { 4216 {
3884 if (item.Name == name) 4217 if (item.ItemID == m_itemID)
3885 { 4218 throw new ScriptDeleteException();
3886 if (item.ItemID == m_itemID) 4219 else
3887 throw new ScriptDeleteException(); 4220 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3888 else 4221 return;
3889 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3890 return;
3891 }
3892 } 4222 }
3893 } 4223 }
3894 } 4224 }
@@ -3946,6 +4276,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3946 ce.time = Util.EnvironmentTickCount(); 4276 ce.time = Util.EnvironmentTickCount();
3947 ce.account = account; 4277 ce.account = account;
3948 ce.pinfo = pinfo; 4278 ce.pinfo = pinfo;
4279 m_userInfoCache[uuid] = ce;
3949 } 4280 }
3950 else 4281 else
3951 { 4282 {
@@ -4013,6 +4344,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4013 { 4344 {
4014 m_host.AddScriptLPS(1); 4345 m_host.AddScriptLPS(1);
4015 4346
4347 //Clone is thread safe
4016 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 4348 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
4017 4349
4018 foreach (TaskInventoryItem item in itemDictionary.Values) 4350 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -4066,6 +4398,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4066 ScenePresence presence = World.GetScenePresence(agentId); 4398 ScenePresence presence = World.GetScenePresence(agentId);
4067 if (presence != null) 4399 if (presence != null)
4068 { 4400 {
4401 // agent must not be a god
4402 if (presence.GodLevel >= 200) return;
4403
4069 // agent must be over the owners land 4404 // agent must be over the owners land
4070 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4405 if (m_host.OwnerID == World.LandChannel.GetLandObject(
4071 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 4406 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
@@ -4125,17 +4460,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4125 UUID soundId = UUID.Zero; 4460 UUID soundId = UUID.Zero;
4126 if (!UUID.TryParse(impact_sound, out soundId)) 4461 if (!UUID.TryParse(impact_sound, out soundId))
4127 { 4462 {
4128 lock (m_host.TaskInventory) 4463 m_host.TaskInventory.LockItemsForRead(true);
4464 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4129 { 4465 {
4130 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4466 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
4131 { 4467 {
4132 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4468 soundId = item.AssetID;
4133 { 4469 break;
4134 soundId = item.AssetID;
4135 break;
4136 }
4137 } 4470 }
4138 } 4471 }
4472 m_host.TaskInventory.LockItemsForRead(false);
4139 } 4473 }
4140 m_host.CollisionSound = soundId; 4474 m_host.CollisionSound = soundId;
4141 m_host.CollisionSoundVolume = (float)impact_volume; 4475 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4181,6 +4515,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4181 UUID partItemID; 4515 UUID partItemID;
4182 foreach (SceneObjectPart part in parts) 4516 foreach (SceneObjectPart part in parts)
4183 { 4517 {
4518 //Clone is thread safe
4184 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4519 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4185 4520
4186 foreach (TaskInventoryItem item in itemsDictionary.Values) 4521 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4395,17 +4730,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4395 4730
4396 m_host.AddScriptLPS(1); 4731 m_host.AddScriptLPS(1);
4397 4732
4398 lock (m_host.TaskInventory) 4733 m_host.TaskInventory.LockItemsForRead(true);
4734 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4399 { 4735 {
4400 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4736 if (item.Type == 10 && item.ItemID == m_itemID)
4401 { 4737 {
4402 if (item.Type == 10 && item.ItemID == m_itemID) 4738 result = item.Name!=null?item.Name:String.Empty;
4403 { 4739 break;
4404 result = item.Name != null ? item.Name : String.Empty;
4405 break;
4406 }
4407 } 4740 }
4408 } 4741 }
4742 m_host.TaskInventory.LockItemsForRead(false);
4409 4743
4410 return result; 4744 return result;
4411 } 4745 }
@@ -4558,23 +4892,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4558 { 4892 {
4559 m_host.AddScriptLPS(1); 4893 m_host.AddScriptLPS(1);
4560 4894
4561 lock (m_host.TaskInventory) 4895 m_host.TaskInventory.LockItemsForRead(true);
4896 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4562 { 4897 {
4563 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4898 if (inv.Value.Name == name)
4564 { 4899 {
4565 if (inv.Value.Name == name) 4900 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4566 { 4901 {
4567 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 4902 m_host.TaskInventory.LockItemsForRead(false);
4568 { 4903 return inv.Value.AssetID.ToString();
4569 return inv.Value.AssetID.ToString(); 4904 }
4570 } 4905 else
4571 else 4906 {
4572 { 4907 m_host.TaskInventory.LockItemsForRead(false);
4573 return UUID.Zero.ToString(); 4908 return UUID.Zero.ToString();
4574 }
4575 } 4909 }
4576 } 4910 }
4577 } 4911 }
4912 m_host.TaskInventory.LockItemsForRead(false);
4578 4913
4579 return UUID.Zero.ToString(); 4914 return UUID.Zero.ToString();
4580 } 4915 }
@@ -4727,14 +5062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4727 { 5062 {
4728 m_host.AddScriptLPS(1); 5063 m_host.AddScriptLPS(1);
4729 5064
4730 if (src == null) 5065 return src.Length;
4731 {
4732 return 0;
4733 }
4734 else
4735 {
4736 return src.Length;
4737 }
4738 } 5066 }
4739 5067
4740 public LSL_Integer llList2Integer(LSL_List src, int index) 5068 public LSL_Integer llList2Integer(LSL_List src, int index)
@@ -5510,10 +5838,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5510 m_host.AddScriptLPS(1); 5838 m_host.AddScriptLPS(1);
5511 5839
5512 List<SceneObjectPart> parts = GetLinkParts(linknumber); 5840 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5513 5841 if (parts.Count > 0)
5514 foreach (var part in parts)
5515 { 5842 {
5516 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 5843 try
5844 {
5845 parts[0].ParentGroup.areUpdatesSuspended = true;
5846 foreach (var part in parts)
5847 {
5848 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
5849 }
5850 }
5851 finally
5852 {
5853 parts[0].ParentGroup.areUpdatesSuspended = false;
5854 }
5517 } 5855 }
5518 } 5856 }
5519 5857
@@ -5569,74 +5907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5569 5907
5570 public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) 5908 public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers)
5571 { 5909 {
5572 m_host.AddScriptLPS(1); 5910 return ParseString2List(str, separators, in_spacers, false);
5573 LSL_List ret = new LSL_List();
5574 LSL_List spacers = new LSL_List();
5575 if (in_spacers.Length > 0 && separators.Length > 0)
5576 {
5577 for (int i = 0; i < in_spacers.Length; i++)
5578 {
5579 object s = in_spacers.Data[i];
5580 for (int j = 0; j < separators.Length; j++)
5581 {
5582 if (separators.Data[j].ToString() == s.ToString())
5583 {
5584 s = null;
5585 break;
5586 }
5587 }
5588 if (s != null)
5589 {
5590 spacers.Add(s);
5591 }
5592 }
5593 }
5594 object[] delimiters = new object[separators.Length + spacers.Length];
5595 separators.Data.CopyTo(delimiters, 0);
5596 spacers.Data.CopyTo(delimiters, separators.Length);
5597 bool dfound = false;
5598 do
5599 {
5600 dfound = false;
5601 int cindex = -1;
5602 string cdeli = "";
5603 for (int i = 0; i < delimiters.Length; i++)
5604 {
5605 int index = str.IndexOf(delimiters[i].ToString());
5606 bool found = index != -1;
5607 if (found && String.Empty != delimiters[i].ToString())
5608 {
5609 if ((cindex > index) || (cindex == -1))
5610 {
5611 cindex = index;
5612 cdeli = delimiters[i].ToString();
5613 }
5614 dfound = dfound || found;
5615 }
5616 }
5617 if (cindex != -1)
5618 {
5619 if (cindex > 0)
5620 {
5621 ret.Add(new LSL_String(str.Substring(0, cindex)));
5622 }
5623 // Cannot use spacers.Contains() because spacers may be either type String or LSLString
5624 for (int j = 0; j < spacers.Length; j++)
5625 {
5626 if (spacers.Data[j].ToString() == cdeli)
5627 {
5628 ret.Add(new LSL_String(cdeli));
5629 break;
5630 }
5631 }
5632 str = str.Substring(cindex + cdeli.Length);
5633 }
5634 } while (dfound);
5635 if (str != "")
5636 {
5637 ret.Add(new LSL_String(str));
5638 }
5639 return ret;
5640 } 5911 }
5641 5912
5642 public LSL_Integer llOverMyLand(string id) 5913 public LSL_Integer llOverMyLand(string id)
@@ -5839,7 +6110,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5839 return m_host.ParentGroup.RootPart.AttachmentPoint; 6110 return m_host.ParentGroup.RootPart.AttachmentPoint;
5840 } 6111 }
5841 6112
5842 public LSL_Integer llGetFreeMemory() 6113 public virtual LSL_Integer llGetFreeMemory()
5843 { 6114 {
5844 m_host.AddScriptLPS(1); 6115 m_host.AddScriptLPS(1);
5845 // Make scripts designed for LSO happy 6116 // Make scripts designed for LSO happy
@@ -6150,14 +6421,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6150 6421
6151 protected UUID GetTaskInventoryItem(string name) 6422 protected UUID GetTaskInventoryItem(string name)
6152 { 6423 {
6153 lock (m_host.TaskInventory) 6424 m_host.TaskInventory.LockItemsForRead(true);
6425 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6154 { 6426 {
6155 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6427 if (inv.Value.Name == name)
6156 { 6428 {
6157 if (inv.Value.Name == name) 6429 m_host.TaskInventory.LockItemsForRead(false);
6158 return inv.Key; 6430 return inv.Key;
6159 } 6431 }
6160 } 6432 }
6433 m_host.TaskInventory.LockItemsForRead(false);
6161 6434
6162 return UUID.Zero; 6435 return UUID.Zero;
6163 } 6436 }
@@ -6485,22 +6758,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6485 } 6758 }
6486 6759
6487 // copy the first script found with this inventory name 6760 // copy the first script found with this inventory name
6488 lock (m_host.TaskInventory) 6761 m_host.TaskInventory.LockItemsForRead(true);
6762 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6489 { 6763 {
6490 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6764 if (inv.Value.Name == name)
6491 { 6765 {
6492 if (inv.Value.Name == name) 6766 // make sure the object is a script
6767 if (10 == inv.Value.Type)
6493 { 6768 {
6494 // make sure the object is a script 6769 found = true;
6495 if (10 == inv.Value.Type) 6770 srcId = inv.Key;
6496 { 6771 break;
6497 found = true;
6498 srcId = inv.Key;
6499 break;
6500 }
6501 } 6772 }
6502 } 6773 }
6503 } 6774 }
6775 m_host.TaskInventory.LockItemsForRead(false);
6504 6776
6505 if (!found) 6777 if (!found)
6506 { 6778 {
@@ -6584,6 +6856,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6584 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6856 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
6585 { 6857 {
6586 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6858 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6859 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6860 return shapeBlock;
6587 6861
6588 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 6862 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6589 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 6863 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6659,6 +6933,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6659 6933
6660 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) 6934 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
6661 { 6935 {
6936 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6937 return;
6938
6662 ObjectShapePacket.ObjectDataBlock shapeBlock; 6939 ObjectShapePacket.ObjectDataBlock shapeBlock;
6663 6940
6664 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6941 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6708,6 +6985,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6708 6985
6709 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) 6986 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
6710 { 6987 {
6988 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6989 return;
6990
6711 ObjectShapePacket.ObjectDataBlock shapeBlock; 6991 ObjectShapePacket.ObjectDataBlock shapeBlock;
6712 6992
6713 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6993 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6750,6 +7030,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6750 7030
6751 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) 7031 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge)
6752 { 7032 {
7033 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7034 return;
7035
6753 ObjectShapePacket.ObjectDataBlock shapeBlock; 7036 ObjectShapePacket.ObjectDataBlock shapeBlock;
6754 7037
6755 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7038 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6876,6 +7159,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6876 7159
6877 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) 7160 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
6878 { 7161 {
7162 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7163 return;
7164
6879 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7165 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6880 UUID sculptId; 7166 UUID sculptId;
6881 7167
@@ -6891,13 +7177,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6891 shapeBlock.PathScaleX = 100; 7177 shapeBlock.PathScaleX = 100;
6892 shapeBlock.PathScaleY = 150; 7178 shapeBlock.PathScaleY = 150;
6893 7179
6894 if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && 7180 if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 &&
6895 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && 7181 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 &&
6896 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && 7182 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 &&
6897 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) 7183 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0)
6898 { 7184 {
6899 // default 7185 // default
6900 type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; 7186 type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE;
6901 } 7187 }
6902 7188
6903 // retain pathcurve 7189 // retain pathcurve
@@ -6914,23 +7200,83 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6914 SetPrimParams(m_host, rules); 7200 SetPrimParams(m_host, rules);
6915 } 7201 }
6916 7202
6917 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7203 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
6918 { 7204 {
6919 m_host.AddScriptLPS(1); 7205 m_host.AddScriptLPS(1);
6920 7206
6921 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7207 List<SceneObjectPart> parts = GetLinkParts(linknumber);
7208 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
7209 if (parts.Count>0)
7210 {
7211 try
7212 {
7213 parts[0].ParentGroup.areUpdatesSuspended = true;
7214 foreach (SceneObjectPart part in parts)
7215 SetPrimParams(part, rules);
7216 }
7217 finally
7218 {
7219 parts[0].ParentGroup.areUpdatesSuspended = false;
7220 }
7221 }
7222 if (avatars.Count > 0)
7223 {
7224 foreach (ScenePresence avatar in avatars)
7225 SetPrimParams(avatar, rules);
7226 }
7227 }
6922 7228
6923 foreach (SceneObjectPart part in parts) 7229 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6924 SetPrimParams(part, rules); 7230 {
7231 llSetLinkPrimitiveParamsFast(linknumber, rules);
7232 ScriptSleep(200);
6925 } 7233 }
6926 7234
6927 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7235 protected void SetPrimParams(ScenePresence av, LSL_List rules)
6928 { 7236 {
6929 llSetLinkPrimitiveParams(linknumber, rules); 7237 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7238 //We only support PRIM_POSITION and PRIM_ROTATION
7239
7240 int idx = 0;
7241
7242 while (idx < rules.Length)
7243 {
7244 int code = rules.GetLSLIntegerItem(idx++);
7245
7246 int remain = rules.Length - idx;
7247
7248
7249
7250 switch (code)
7251 {
7252 case (int)ScriptBaseClass.PRIM_POSITION:
7253 if (remain < 1)
7254 return;
7255 LSL_Vector v;
7256 v = rules.GetVector3Item(idx++);
7257 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7258 av.SendFullUpdateToAllClients();
7259
7260 break;
7261
7262 case (int)ScriptBaseClass.PRIM_ROTATION:
7263 if (remain < 1)
7264 return;
7265 LSL_Rotation r;
7266 r = rules.GetQuaternionItem(idx++);
7267 av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7268 av.SendFullUpdateToAllClients();
7269 break;
7270 }
7271 }
7272
6930 } 7273 }
6931 7274
6932 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 7275 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6933 { 7276 {
7277 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7278 return;
7279
6934 int idx = 0; 7280 int idx = 0;
6935 7281
6936 while (idx < rules.Length) 7282 while (idx < rules.Length)
@@ -7762,24 +8108,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7762 break; 8108 break;
7763 8109
7764 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8110 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7765 // TODO--------------
7766 if (remain < 1) 8111 if (remain < 1)
7767 return res; 8112 return res;
8113 face = (int)rules.GetLSLIntegerItem(idx++);
7768 8114
7769 face=(int)rules.GetLSLIntegerItem(idx++); 8115 tex = part.Shape.Textures;
7770 8116 int shiny;
7771 res.Add(new LSL_Integer(0)); 8117 if (face == ScriptBaseClass.ALL_SIDES)
7772 res.Add(new LSL_Integer(0)); 8118 {
8119 for (face = 0; face < GetNumberOfSides(part); face++)
8120 {
8121 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8122 if (shinyness == Shininess.High)
8123 {
8124 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8125 }
8126 else if (shinyness == Shininess.Medium)
8127 {
8128 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8129 }
8130 else if (shinyness == Shininess.Low)
8131 {
8132 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8133 }
8134 else
8135 {
8136 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8137 }
8138 res.Add(new LSL_Integer(shiny));
8139 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8140 }
8141 }
8142 else
8143 {
8144 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8145 if (shinyness == Shininess.High)
8146 {
8147 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8148 }
8149 else if (shinyness == Shininess.Medium)
8150 {
8151 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8152 }
8153 else if (shinyness == Shininess.Low)
8154 {
8155 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8156 }
8157 else
8158 {
8159 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8160 }
8161 res.Add(new LSL_Integer(shiny));
8162 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8163 }
7773 break; 8164 break;
7774 8165
7775 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8166 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7776 // TODO--------------
7777 if (remain < 1) 8167 if (remain < 1)
7778 return res; 8168 return res;
8169 face = (int)rules.GetLSLIntegerItem(idx++);
7779 8170
7780 face=(int)rules.GetLSLIntegerItem(idx++); 8171 tex = part.Shape.Textures;
7781 8172 int fullbright;
7782 res.Add(new LSL_Integer(0)); 8173 if (face == ScriptBaseClass.ALL_SIDES)
8174 {
8175 for (face = 0; face < GetNumberOfSides(part); face++)
8176 {
8177 if (tex.GetFace((uint)face).Fullbright == true)
8178 {
8179 fullbright = ScriptBaseClass.TRUE;
8180 }
8181 else
8182 {
8183 fullbright = ScriptBaseClass.FALSE;
8184 }
8185 res.Add(new LSL_Integer(fullbright));
8186 }
8187 }
8188 else
8189 {
8190 if (tex.GetFace((uint)face).Fullbright == true)
8191 {
8192 fullbright = ScriptBaseClass.TRUE;
8193 }
8194 else
8195 {
8196 fullbright = ScriptBaseClass.FALSE;
8197 }
8198 res.Add(new LSL_Integer(fullbright));
8199 }
7783 break; 8200 break;
7784 8201
7785 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 8202 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
@@ -7800,14 +8217,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7800 break; 8217 break;
7801 8218
7802 case (int)ScriptBaseClass.PRIM_TEXGEN: 8219 case (int)ScriptBaseClass.PRIM_TEXGEN:
7803 // TODO--------------
7804 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) 8220 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7805 if (remain < 1) 8221 if (remain < 1)
7806 return res; 8222 return res;
8223 face = (int)rules.GetLSLIntegerItem(idx++);
7807 8224
7808 face=(int)rules.GetLSLIntegerItem(idx++); 8225 tex = part.Shape.Textures;
7809 8226 if (face == ScriptBaseClass.ALL_SIDES)
7810 res.Add(new LSL_Integer(0)); 8227 {
8228 for (face = 0; face < GetNumberOfSides(part); face++)
8229 {
8230 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8231 {
8232 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8233 }
8234 else
8235 {
8236 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8237 }
8238 }
8239 }
8240 else
8241 {
8242 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8243 {
8244 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8245 }
8246 else
8247 {
8248 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8249 }
8250 }
7811 break; 8251 break;
7812 8252
7813 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 8253 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
@@ -7826,13 +8266,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7826 break; 8266 break;
7827 8267
7828 case (int)ScriptBaseClass.PRIM_GLOW: 8268 case (int)ScriptBaseClass.PRIM_GLOW:
7829 // TODO--------------
7830 if (remain < 1) 8269 if (remain < 1)
7831 return res; 8270 return res;
8271 face = (int)rules.GetLSLIntegerItem(idx++);
7832 8272
7833 face=(int)rules.GetLSLIntegerItem(idx++); 8273 tex = part.Shape.Textures;
7834 8274 float primglow;
7835 res.Add(new LSL_Float(0)); 8275 if (face == ScriptBaseClass.ALL_SIDES)
8276 {
8277 for (face = 0; face < GetNumberOfSides(part); face++)
8278 {
8279 primglow = tex.GetFace((uint)face).Glow;
8280 res.Add(new LSL_Float(primglow));
8281 }
8282 }
8283 else
8284 {
8285 primglow = tex.GetFace((uint)face).Glow;
8286 res.Add(new LSL_Float(primglow));
8287 }
7836 break; 8288 break;
7837 case (int)ScriptBaseClass.PRIM_TEXT: 8289 case (int)ScriptBaseClass.PRIM_TEXT:
7838 Color4 textColor = part.GetTextColor(); 8290 Color4 textColor = part.GetTextColor();
@@ -8373,8 +8825,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8373 // The function returns an ordered list 8825 // The function returns an ordered list
8374 // representing the tokens found in the supplied 8826 // representing the tokens found in the supplied
8375 // sources string. If two successive tokenizers 8827 // sources string. If two successive tokenizers
8376 // are encountered, then a NULL entry is added 8828 // are encountered, then a null-string entry is
8377 // to the list. 8829 // added to the list.
8378 // 8830 //
8379 // It is a precondition that the source and 8831 // It is a precondition that the source and
8380 // toekizer lisst are non-null. If they are null, 8832 // toekizer lisst are non-null. If they are null,
@@ -8382,7 +8834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8382 // while their lengths are being determined. 8834 // while their lengths are being determined.
8383 // 8835 //
8384 // A small amount of working memoryis required 8836 // A small amount of working memoryis required
8385 // of approximately 8*#tokenizers. 8837 // of approximately 8*#tokenizers + 8*srcstrlen.
8386 // 8838 //
8387 // There are many ways in which this function 8839 // There are many ways in which this function
8388 // can be implemented, this implementation is 8840 // can be implemented, this implementation is
@@ -8398,136 +8850,111 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8398 // and eliminates redundant tokenizers as soon 8850 // and eliminates redundant tokenizers as soon
8399 // as is possible. 8851 // as is possible.
8400 // 8852 //
8401 // The implementation tries to avoid any copying 8853 // The implementation tries to minimize temporary
8402 // of arrays or other objects. 8854 // garbage generation.
8403 // </remarks> 8855 // </remarks>
8404 8856
8405 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) 8857 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
8406 { 8858 {
8407 int beginning = 0; 8859 return ParseString2List(src, separators, spacers, true);
8408 int srclen = src.Length; 8860 }
8409 int seplen = separators.Length;
8410 object[] separray = separators.Data;
8411 int spclen = spacers.Length;
8412 object[] spcarray = spacers.Data;
8413 int mlen = seplen+spclen;
8414
8415 int[] offset = new int[mlen+1];
8416 bool[] active = new bool[mlen];
8417 8861
8418 int best; 8862 private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls)
8419 int j; 8863 {
8864 int srclen = src.Length;
8865 int seplen = separators.Length;
8866 object[] separray = separators.Data;
8867 int spclen = spacers.Length;
8868 object[] spcarray = spacers.Data;
8869 int dellen = 0;
8870 string[] delarray = new string[seplen+spclen];
8420 8871
8421 // Initial capacity reduces resize cost 8872 int outlen = 0;
8873 string[] outarray = new string[srclen*2+1];
8422 8874
8423 LSL_List tokens = new LSL_List(); 8875 int i, j;
8876 string d;
8424 8877
8425 m_host.AddScriptLPS(1); 8878 m_host.AddScriptLPS(1);
8426 8879
8427 // All entries are initially valid 8880 /*
8428 8881 * Convert separator and spacer lists to C# strings.
8429 for (int i = 0; i < mlen; i++) 8882 * Also filter out null strings so we don't hang.
8430 active[i] = true; 8883 */
8431 8884 for (i = 0; i < seplen; i ++) {
8432 offset[mlen] = srclen; 8885 d = separray[i].ToString();
8433 8886 if (d.Length > 0) {
8434 while (beginning < srclen) 8887 delarray[dellen++] = d;
8435 { 8888 }
8436 8889 }
8437 best = mlen; // as bad as it gets 8890 seplen = dellen;
8438
8439 // Scan for separators
8440 8891
8441 for (j = 0; j < seplen; j++) 8892 for (i = 0; i < spclen; i ++) {
8442 { 8893 d = spcarray[i].ToString();
8443 if (active[j]) 8894 if (d.Length > 0) {
8444 { 8895 delarray[dellen++] = d;
8445 // scan all of the markers
8446 if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1)
8447 {
8448 // not present at all
8449 active[j] = false;
8450 }
8451 else
8452 {
8453 // present and correct
8454 if (offset[j] < offset[best])
8455 {
8456 // closest so far
8457 best = j;
8458 if (offset[best] == beginning)
8459 break;
8460 }
8461 }
8462 }
8463 } 8896 }
8897 }
8464 8898
8465 // Scan for spacers 8899 /*
8900 * Scan through source string from beginning to end.
8901 */
8902 for (i = 0;;) {
8466 8903
8467 if (offset[best] != beginning) 8904 /*
8468 { 8905 * Find earliest delimeter in src starting at i (if any).
8469 for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) 8906 */
8470 { 8907 int earliestDel = -1;
8471 if (active[j]) 8908 int earliestSrc = srclen;
8472 { 8909 string earliestStr = null;
8473 // scan all of the markers 8910 for (j = 0; j < dellen; j ++) {
8474 if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1) 8911 d = delarray[j];
8475 { 8912 if (d != null) {
8476 // not present at all 8913 int index = src.IndexOf(d, i);
8477 active[j] = false; 8914 if (index < 0) {
8478 } 8915 delarray[j] = null; // delim nowhere in src, don't check it anymore
8479 else 8916 } else if (index < earliestSrc) {
8480 { 8917 earliestSrc = index; // where delimeter starts in source string
8481 // present and correct 8918 earliestDel = j; // where delimeter is in delarray[]
8482 if (offset[j] < offset[best]) 8919 earliestStr = d; // the delimeter string from delarray[]
8483 { 8920 if (index == i) break; // can't do any better than found at beg of string
8484 // closest so far
8485 best = j;
8486 }
8487 }
8488 } 8921 }
8489 } 8922 }
8490 } 8923 }
8491 8924
8492 // This is the normal exit from the scanning loop 8925 /*
8493 8926 * Output source string starting at i through start of earliest delimeter.
8494 if (best == mlen) 8927 */
8495 { 8928 if (keepNulls || (earliestSrc > i)) {
8496 // no markers were found on this pass 8929 outarray[outlen++] = src.Substring(i, earliestSrc - i);
8497 // so we're pretty much done
8498 tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning)));
8499 break;
8500 } 8930 }
8501 8931
8502 // Otherwise we just add the newly delimited token 8932 /*
8503 // and recalculate where the search should continue. 8933 * If no delimeter found at or after i, we're done scanning.
8504 8934 */
8505 tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); 8935 if (earliestDel < 0) break;
8506 8936
8507 if (best < seplen) 8937 /*
8508 { 8938 * If delimeter was a spacer, output the spacer.
8509 beginning = offset[best] + (separray[best].ToString()).Length; 8939 */
8940 if (earliestDel >= seplen) {
8941 outarray[outlen++] = earliestStr;
8510 } 8942 }
8511 else
8512 {
8513 beginning = offset[best] + (spcarray[best - seplen].ToString()).Length;
8514 tokens.Add(new LSL_String(spcarray[best - seplen].ToString()));
8515 }
8516 }
8517
8518 // This an awkward an not very intuitive boundary case. If the
8519 // last substring is a tokenizer, then there is an implied trailing
8520 // null list entry. Hopefully the single comparison will not be too
8521 // arduous. Alternatively the 'break' could be replced with a return
8522 // but that's shabby programming.
8523 8943
8524 if (beginning == srclen) 8944 /*
8525 { 8945 * Look at rest of src string following delimeter.
8526 if (srclen != 0) 8946 */
8527 tokens.Add(new LSL_String("")); 8947 i = earliestSrc + earliestStr.Length;
8528 } 8948 }
8529 8949
8530 return tokens; 8950 /*
8951 * Make up an exact-sized output array suitable for an LSL_List object.
8952 */
8953 object[] outlist = new object[outlen];
8954 for (i = 0; i < outlen; i ++) {
8955 outlist[i] = new LSL_String(outarray[i]);
8956 }
8957 return new LSL_List(outlist);
8531 } 8958 }
8532 8959
8533 public LSL_Integer llGetObjectPermMask(int mask) 8960 public LSL_Integer llGetObjectPermMask(int mask)
@@ -8604,28 +9031,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8604 { 9031 {
8605 m_host.AddScriptLPS(1); 9032 m_host.AddScriptLPS(1);
8606 9033
8607 lock (m_host.TaskInventory) 9034 m_host.TaskInventory.LockItemsForRead(true);
9035 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8608 { 9036 {
8609 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9037 if (inv.Value.Name == item)
8610 { 9038 {
8611 if (inv.Value.Name == item) 9039 m_host.TaskInventory.LockItemsForRead(false);
9040 switch (mask)
8612 { 9041 {
8613 switch (mask) 9042 case 0:
8614 { 9043 return (int)inv.Value.BasePermissions;
8615 case 0: 9044 case 1:
8616 return (int)inv.Value.BasePermissions; 9045 return (int)inv.Value.CurrentPermissions;
8617 case 1: 9046 case 2:
8618 return (int)inv.Value.CurrentPermissions; 9047 return (int)inv.Value.GroupPermissions;
8619 case 2: 9048 case 3:
8620 return (int)inv.Value.GroupPermissions; 9049 return (int)inv.Value.EveryonePermissions;
8621 case 3: 9050 case 4:
8622 return (int)inv.Value.EveryonePermissions; 9051 return (int)inv.Value.NextPermissions;
8623 case 4:
8624 return (int)inv.Value.NextPermissions;
8625 }
8626 } 9052 }
8627 } 9053 }
8628 } 9054 }
9055 m_host.TaskInventory.LockItemsForRead(false);
8629 9056
8630 return -1; 9057 return -1;
8631 } 9058 }
@@ -8672,16 +9099,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8672 { 9099 {
8673 m_host.AddScriptLPS(1); 9100 m_host.AddScriptLPS(1);
8674 9101
8675 lock (m_host.TaskInventory) 9102 m_host.TaskInventory.LockItemsForRead(true);
9103 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8676 { 9104 {
8677 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9105 if (inv.Value.Name == item)
8678 { 9106 {
8679 if (inv.Value.Name == item) 9107 m_host.TaskInventory.LockItemsForRead(false);
8680 { 9108 return inv.Value.CreatorID.ToString();
8681 return inv.Value.CreatorID.ToString();
8682 }
8683 } 9109 }
8684 } 9110 }
9111 m_host.TaskInventory.LockItemsForRead(false);
8685 9112
8686 llSay(0, "No item name '" + item + "'"); 9113 llSay(0, "No item name '" + item + "'");
8687 9114
@@ -8727,8 +9154,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8727 return UUID.Zero.ToString(); 9154 return UUID.Zero.ToString();
8728 } 9155 }
8729 reply = new LSL_Vector( 9156 reply = new LSL_Vector(
8730 info.RegionLocX * Constants.RegionSize, 9157 info.RegionLocX,
8731 info.RegionLocY * Constants.RegionSize, 9158 info.RegionLocY,
8732 0).ToString(); 9159 0).ToString();
8733 break; 9160 break;
8734 case 6: // DATA_SIM_STATUS 9161 case 6: // DATA_SIM_STATUS
@@ -8941,17 +9368,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8941 int width = 0; 9368 int width = 0;
8942 int height = 0; 9369 int height = 0;
8943 9370
8944 ParcelMediaCommandEnum? commandToSend = null; 9371 uint commandToSend = 0;
8945 float time = 0.0f; // default is from start 9372 float time = 0.0f; // default is from start
8946 9373
8947 ScenePresence presence = null; 9374 ScenePresence presence = null;
8948 9375
8949 for (int i = 0; i < commandList.Data.Length; i++) 9376 for (int i = 0; i < commandList.Data.Length; i++)
8950 { 9377 {
8951 ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; 9378 uint command = (uint)(commandList.GetLSLIntegerItem(i));
8952 switch (command) 9379 switch (command)
8953 { 9380 {
8954 case ParcelMediaCommandEnum.Agent: 9381 case (uint)ParcelMediaCommandEnum.Agent:
8955 // we send only to one agent 9382 // we send only to one agent
8956 if ((i + 1) < commandList.Length) 9383 if ((i + 1) < commandList.Length)
8957 { 9384 {
@@ -8968,25 +9395,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8968 } 9395 }
8969 break; 9396 break;
8970 9397
8971 case ParcelMediaCommandEnum.Loop: 9398 case (uint)ParcelMediaCommandEnum.Loop:
8972 loop = 1; 9399 loop = 1;
8973 commandToSend = command; 9400 commandToSend = command;
8974 update = true; //need to send the media update packet to set looping 9401 update = true; //need to send the media update packet to set looping
8975 break; 9402 break;
8976 9403
8977 case ParcelMediaCommandEnum.Play: 9404 case (uint)ParcelMediaCommandEnum.Play:
8978 loop = 0; 9405 loop = 0;
8979 commandToSend = command; 9406 commandToSend = command;
8980 update = true; //need to send the media update packet to make sure it doesn't loop 9407 update = true; //need to send the media update packet to make sure it doesn't loop
8981 break; 9408 break;
8982 9409
8983 case ParcelMediaCommandEnum.Pause: 9410 case (uint)ParcelMediaCommandEnum.Pause:
8984 case ParcelMediaCommandEnum.Stop: 9411 case (uint)ParcelMediaCommandEnum.Stop:
8985 case ParcelMediaCommandEnum.Unload: 9412 case (uint)ParcelMediaCommandEnum.Unload:
8986 commandToSend = command; 9413 commandToSend = command;
8987 break; 9414 break;
8988 9415
8989 case ParcelMediaCommandEnum.Url: 9416 case (uint)ParcelMediaCommandEnum.Url:
8990 if ((i + 1) < commandList.Length) 9417 if ((i + 1) < commandList.Length)
8991 { 9418 {
8992 if (commandList.Data[i + 1] is LSL_String) 9419 if (commandList.Data[i + 1] is LSL_String)
@@ -8999,7 +9426,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8999 } 9426 }
9000 break; 9427 break;
9001 9428
9002 case ParcelMediaCommandEnum.Texture: 9429 case (uint)ParcelMediaCommandEnum.Texture:
9003 if ((i + 1) < commandList.Length) 9430 if ((i + 1) < commandList.Length)
9004 { 9431 {
9005 if (commandList.Data[i + 1] is LSL_String) 9432 if (commandList.Data[i + 1] is LSL_String)
@@ -9012,7 +9439,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9012 } 9439 }
9013 break; 9440 break;
9014 9441
9015 case ParcelMediaCommandEnum.Time: 9442 case (uint)ParcelMediaCommandEnum.Time:
9016 if ((i + 1) < commandList.Length) 9443 if ((i + 1) < commandList.Length)
9017 { 9444 {
9018 if (commandList.Data[i + 1] is LSL_Float) 9445 if (commandList.Data[i + 1] is LSL_Float)
@@ -9024,7 +9451,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9024 } 9451 }
9025 break; 9452 break;
9026 9453
9027 case ParcelMediaCommandEnum.AutoAlign: 9454 case (uint)ParcelMediaCommandEnum.AutoAlign:
9028 if ((i + 1) < commandList.Length) 9455 if ((i + 1) < commandList.Length)
9029 { 9456 {
9030 if (commandList.Data[i + 1] is LSL_Integer) 9457 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9038,7 +9465,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9038 } 9465 }
9039 break; 9466 break;
9040 9467
9041 case ParcelMediaCommandEnum.Type: 9468 case (uint)ParcelMediaCommandEnum.Type:
9042 if ((i + 1) < commandList.Length) 9469 if ((i + 1) < commandList.Length)
9043 { 9470 {
9044 if (commandList.Data[i + 1] is LSL_String) 9471 if (commandList.Data[i + 1] is LSL_String)
@@ -9051,7 +9478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9051 } 9478 }
9052 break; 9479 break;
9053 9480
9054 case ParcelMediaCommandEnum.Desc: 9481 case (uint)ParcelMediaCommandEnum.Desc:
9055 if ((i + 1) < commandList.Length) 9482 if ((i + 1) < commandList.Length)
9056 { 9483 {
9057 if (commandList.Data[i + 1] is LSL_String) 9484 if (commandList.Data[i + 1] is LSL_String)
@@ -9064,7 +9491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9064 } 9491 }
9065 break; 9492 break;
9066 9493
9067 case ParcelMediaCommandEnum.Size: 9494 case (uint)ParcelMediaCommandEnum.Size:
9068 if ((i + 2) < commandList.Length) 9495 if ((i + 2) < commandList.Length)
9069 { 9496 {
9070 if (commandList.Data[i + 1] is LSL_Integer) 9497 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9134,7 +9561,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9134 } 9561 }
9135 } 9562 }
9136 9563
9137 if (commandToSend != null) 9564 if (commandToSend != 0)
9138 { 9565 {
9139 // the commandList contained a start/stop/... command, too 9566 // the commandList contained a start/stop/... command, too
9140 if (presence == null) 9567 if (presence == null)
@@ -9171,7 +9598,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9171 9598
9172 if (aList.Data[i] != null) 9599 if (aList.Data[i] != null)
9173 { 9600 {
9174 switch ((ParcelMediaCommandEnum) aList.Data[i]) 9601 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
9175 { 9602 {
9176 case ParcelMediaCommandEnum.Url: 9603 case ParcelMediaCommandEnum.Url:
9177 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); 9604 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL));
@@ -9214,16 +9641,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9214 { 9641 {
9215 m_host.AddScriptLPS(1); 9642 m_host.AddScriptLPS(1);
9216 9643
9217 lock (m_host.TaskInventory) 9644 m_host.TaskInventory.LockItemsForRead(true);
9645 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
9218 { 9646 {
9219 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9647 if (inv.Value.Name == name)
9220 { 9648 {
9221 if (inv.Value.Name == name) 9649 m_host.TaskInventory.LockItemsForRead(false);
9222 { 9650 return inv.Value.Type;
9223 return inv.Value.Type;
9224 }
9225 } 9651 }
9226 } 9652 }
9653 m_host.TaskInventory.LockItemsForRead(false);
9227 9654
9228 return -1; 9655 return -1;
9229 } 9656 }
@@ -9234,15 +9661,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9234 9661
9235 if (quick_pay_buttons.Data.Length < 4) 9662 if (quick_pay_buttons.Data.Length < 4)
9236 { 9663 {
9237 LSLError("List must have at least 4 elements"); 9664 int x;
9238 return; 9665 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
9666 {
9667 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
9668 }
9239 } 9669 }
9240 m_host.ParentGroup.RootPart.PayPrice[0]=price; 9670 int[] nPrice = new int[5];
9241 9671 nPrice[0]=price;
9242 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 9672 nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0];
9243 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 9673 nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1];
9244 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 9674 nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2];
9245 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 9675 nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3];
9676 m_host.ParentGroup.RootPart.PayPrice = nPrice;
9246 m_host.ParentGroup.HasGroupChanged = true; 9677 m_host.ParentGroup.HasGroupChanged = true;
9247 } 9678 }
9248 9679
@@ -9254,17 +9685,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9254 if (invItemID == UUID.Zero) 9685 if (invItemID == UUID.Zero)
9255 return new LSL_Vector(); 9686 return new LSL_Vector();
9256 9687
9257 lock (m_host.TaskInventory) 9688 m_host.TaskInventory.LockItemsForRead(true);
9689 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9258 { 9690 {
9259 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9691 m_host.TaskInventory.LockItemsForRead(false);
9260 return new LSL_Vector(); 9692 return new LSL_Vector();
9693 }
9261 9694
9262 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9695 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9263 { 9696 {
9264 ShoutError("No permissions to track the camera"); 9697 ShoutError("No permissions to track the camera");
9265 return new LSL_Vector(); 9698 m_host.TaskInventory.LockItemsForRead(false);
9266 } 9699 return new LSL_Vector();
9267 } 9700 }
9701 m_host.TaskInventory.LockItemsForRead(false);
9268 9702
9269 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9703 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9270 if (presence != null) 9704 if (presence != null)
@@ -9282,17 +9716,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9282 if (invItemID == UUID.Zero) 9716 if (invItemID == UUID.Zero)
9283 return new LSL_Rotation(); 9717 return new LSL_Rotation();
9284 9718
9285 lock (m_host.TaskInventory) 9719 m_host.TaskInventory.LockItemsForRead(true);
9720 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9286 { 9721 {
9287 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9722 m_host.TaskInventory.LockItemsForRead(false);
9288 return new LSL_Rotation(); 9723 return new LSL_Rotation();
9289 9724 }
9290 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9725 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9291 { 9726 {
9292 ShoutError("No permissions to track the camera"); 9727 ShoutError("No permissions to track the camera");
9293 return new LSL_Rotation(); 9728 m_host.TaskInventory.LockItemsForRead(false);
9294 } 9729 return new LSL_Rotation();
9295 } 9730 }
9731 m_host.TaskInventory.LockItemsForRead(false);
9296 9732
9297 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9733 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9298 if (presence != null) 9734 if (presence != null)
@@ -9354,8 +9790,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9354 { 9790 {
9355 m_host.AddScriptLPS(1); 9791 m_host.AddScriptLPS(1);
9356 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 9792 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0);
9357 if (detectedParams == null) return; // only works on the first detected avatar 9793 if (detectedParams == null)
9358 9794 {
9795 if (m_host.IsAttachment == true)
9796 {
9797 detectedParams = new DetectParams();
9798 detectedParams.Key = m_host.OwnerID;
9799 }
9800 else
9801 {
9802 return;
9803 }
9804 }
9805
9359 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 9806 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
9360 if (avatar != null) 9807 if (avatar != null)
9361 { 9808 {
@@ -9363,6 +9810,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9363 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 9810 new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
9364 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); 9811 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
9365 } 9812 }
9813
9366 ScriptSleep(1000); 9814 ScriptSleep(1000);
9367 } 9815 }
9368 9816
@@ -9442,14 +9890,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9442 if (objectID == UUID.Zero) return; 9890 if (objectID == UUID.Zero) return;
9443 9891
9444 UUID agentID; 9892 UUID agentID;
9445 lock (m_host.TaskInventory) 9893 m_host.TaskInventory.LockItemsForRead(true);
9446 { 9894 // we need the permission first, to know which avatar we want to set the camera for
9447 // we need the permission first, to know which avatar we want to set the camera for 9895 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9448 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9449 9896
9450 if (agentID == UUID.Zero) return; 9897 if (agentID == UUID.Zero)
9451 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9898 {
9899 m_host.TaskInventory.LockItemsForRead(false);
9900 return;
9901 }
9902 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9903 {
9904 m_host.TaskInventory.LockItemsForRead(false);
9905 return;
9452 } 9906 }
9907 m_host.TaskInventory.LockItemsForRead(false);
9453 9908
9454 ScenePresence presence = World.GetScenePresence(agentID); 9909 ScenePresence presence = World.GetScenePresence(agentID);
9455 9910
@@ -9499,12 +9954,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9499 9954
9500 // we need the permission first, to know which avatar we want to clear the camera for 9955 // we need the permission first, to know which avatar we want to clear the camera for
9501 UUID agentID; 9956 UUID agentID;
9502 lock (m_host.TaskInventory) 9957 m_host.TaskInventory.LockItemsForRead(true);
9958 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9959 if (agentID == UUID.Zero)
9960 {
9961 m_host.TaskInventory.LockItemsForRead(false);
9962 return;
9963 }
9964 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9503 { 9965 {
9504 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9966 m_host.TaskInventory.LockItemsForRead(false);
9505 if (agentID == UUID.Zero) return; 9967 return;
9506 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
9507 } 9968 }
9969 m_host.TaskInventory.LockItemsForRead(false);
9508 9970
9509 ScenePresence presence = World.GetScenePresence(agentID); 9971 ScenePresence presence = World.GetScenePresence(agentID);
9510 9972
@@ -9571,19 +10033,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9571 public LSL_String llXorBase64StringsCorrect(string str1, string str2) 10033 public LSL_String llXorBase64StringsCorrect(string str1, string str2)
9572 { 10034 {
9573 m_host.AddScriptLPS(1); 10035 m_host.AddScriptLPS(1);
9574 string ret = String.Empty; 10036
9575 string src1 = llBase64ToString(str1); 10037 if (str1 == String.Empty)
9576 string src2 = llBase64ToString(str2); 10038 return String.Empty;
9577 int c = 0; 10039 if (str2 == String.Empty)
9578 for (int i = 0; i < src1.Length; i++) 10040 return str1;
10041
10042 byte[] data1 = Convert.FromBase64String(str1);
10043 byte[] data2 = Convert.FromBase64String(str2);
10044
10045 byte[] d2 = new Byte[data1.Length];
10046 int pos = 0;
10047
10048 if (data1.Length <= data2.Length)
9579 { 10049 {
9580 ret += (char) (src1[i] ^ src2[c]); 10050 Array.Copy(data2, 0, d2, 0, data1.Length);
10051 }
10052 else
10053 {
10054 while (pos < data1.Length)
10055 {
10056 int len = data1.Length - pos;
10057 if (len > data2.Length)
10058 len = data2.Length;
9581 10059
9582 c++; 10060 Array.Copy(data2, 0, d2, pos, len);
9583 if (c >= src2.Length) 10061 pos += len;
9584 c = 0; 10062 }
9585 } 10063 }
9586 return llStringToBase64(ret); 10064
10065 for (pos = 0 ; pos < data1.Length ; pos++ )
10066 data1[pos] ^= d2[pos];
10067
10068 return Convert.ToBase64String(data1);
9587 } 10069 }
9588 10070
9589 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) 10071 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body)
@@ -9961,15 +10443,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9961 10443
9962 internal UUID ScriptByName(string name) 10444 internal UUID ScriptByName(string name)
9963 { 10445 {
9964 lock (m_host.TaskInventory) 10446 m_host.TaskInventory.LockItemsForRead(true);
10447
10448 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
9965 { 10449 {
9966 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 10450 if (item.Type == 10 && item.Name == name)
9967 { 10451 {
9968 if (item.Type == 10 && item.Name == name) 10452 m_host.TaskInventory.LockItemsForRead(false);
9969 return item.ItemID; 10453 return item.ItemID;
9970 } 10454 }
9971 } 10455 }
9972 10456
10457 m_host.TaskInventory.LockItemsForRead(false);
10458
9973 return UUID.Zero; 10459 return UUID.Zero;
9974 } 10460 }
9975 10461
@@ -10010,6 +10496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10010 { 10496 {
10011 m_host.AddScriptLPS(1); 10497 m_host.AddScriptLPS(1);
10012 10498
10499 //Clone is thread safe
10013 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10500 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
10014 10501
10015 UUID assetID = UUID.Zero; 10502 UUID assetID = UUID.Zero;
@@ -10072,6 +10559,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10072 { 10559 {
10073 m_host.AddScriptLPS(1); 10560 m_host.AddScriptLPS(1);
10074 10561
10562 //Clone is thread safe
10075 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10563 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
10076 10564
10077 UUID assetID = UUID.Zero; 10565 UUID assetID = UUID.Zero;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 5ae6439..f0384f8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -1,504 +1,507 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
33using OpenMetaverse; 33using OpenMetaverse;
34using Nini.Config; 34using Nini.Config;
35using OpenSim; 35using OpenSim;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.World.LightShare; 37using OpenSim.Region.CoreModules.World.LightShare;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.ScriptEngine.Shared; 40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 41using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
42using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 42using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
43using OpenSim.Region.ScriptEngine.Interfaces; 43using OpenSim.Region.ScriptEngine.Interfaces;
44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; 44using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
45 45
46using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 46using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
47using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; 47using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
48using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 48using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
49using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; 49using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
50using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; 50using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
51using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 51using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
52using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; 52using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
53 53
54namespace OpenSim.Region.ScriptEngine.Shared.Api 54namespace OpenSim.Region.ScriptEngine.Shared.Api
55{ 55{
56 [Serializable] 56 [Serializable]
57 public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi 57 public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi
58 { 58 {
59 internal IScriptEngine m_ScriptEngine; 59 internal IScriptEngine m_ScriptEngine;
60 internal SceneObjectPart m_host; 60 internal SceneObjectPart m_host;
61 internal uint m_localID; 61 internal uint m_localID;
62 internal UUID m_itemID; 62 internal UUID m_itemID;
63 internal bool m_LSFunctionsEnabled = false; 63 internal bool m_LSFunctionsEnabled = false;
64 internal IScriptModuleComms m_comms = null; 64 internal IScriptModuleComms m_comms = null;
65 65
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
67 { 67 {
68 m_ScriptEngine = ScriptEngine; 68 m_ScriptEngine = ScriptEngine;
69 m_host = host; 69 m_host = host;
70 m_localID = localID; 70 m_localID = localID;
71 m_itemID = itemID; 71 m_itemID = itemID;
72 72
73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
74 m_LSFunctionsEnabled = true; 74 m_LSFunctionsEnabled = true;
75 75
76 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); 76 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
77 if (m_comms == null) 77 m_LSFunctionsEnabled = true;
78 m_LSFunctionsEnabled = false; 78
79 } 79 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
80 80 if (m_comms == null)
81 public override Object InitializeLifetimeService() 81 m_LSFunctionsEnabled = false;
82 { 82 }
83 ILease lease = (ILease)base.InitializeLifetimeService(); 83
84 84 public override Object InitializeLifetimeService()
85 if (lease.CurrentState == LeaseState.Initial) 85 {
86 { 86 ILease lease = (ILease)base.InitializeLifetimeService();
87 lease.InitialLeaseTime = TimeSpan.FromMinutes(0); 87
88 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); 88 if (lease.CurrentState == LeaseState.Initial)
89 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); 89 {
90 } 90 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
91 return lease; 91 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
92 } 92 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
93 93 }
94 public Scene World 94 return lease;
95 { 95 }
96 get { return m_ScriptEngine.World; } 96
97 } 97 public Scene World
98 98 {
99 // 99 get { return m_ScriptEngine.World; }
100 //Dumps an error message on the debug console. 100 }
101 // 101
102 102 //
103 internal void LSShoutError(string message) 103 //Dumps an error message on the debug console.
104 { 104 //
105 if (message.Length > 1023) 105
106 message = message.Substring(0, 1023); 106 internal void LSShoutError(string message)
107 107 {
108 World.SimChat(Utils.StringToBytes(message), 108 if (message.Length > 1023)
109 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); 109 message = message.Substring(0, 1023);
110 110
111 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 111 World.SimChat(Utils.StringToBytes(message),
112 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); 112 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
113 } 113
114 114 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
115 /// <summary> 115 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
116 /// Get the current Windlight scene 116 }
117 /// </summary> 117
118 /// <returns>List of windlight parameters</returns> 118 /// <summary>
119 public LSL_List lsGetWindlightScene(LSL_List rules) 119 /// Get the current Windlight scene
120 { 120 /// </summary>
121 if (!m_LSFunctionsEnabled) 121 /// <returns>List of windlight parameters</returns>
122 { 122 public LSL_List lsGetWindlightScene(LSL_List rules)
123 LSShoutError("LightShare functions are not enabled."); 123 {
124 return new LSL_List(); 124 if (!m_LSFunctionsEnabled)
125 } 125 {
126 m_host.AddScriptLPS(1); 126 LSShoutError("LightShare functions are not enabled.");
127 RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; 127 return new LSL_List();
128 128 }
129 LSL_List values = new LSL_List(); 129 m_host.AddScriptLPS(1);
130 int idx = 0; 130 RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
131 while (idx < rules.Length) 131
132 { 132 LSL_List values = new LSL_List();
133 uint rule = (uint)rules.GetLSLIntegerItem(idx); 133 int idx = 0;
134 LSL_List toadd = new LSL_List(); 134 while (idx < rules.Length)
135 135 {
136 switch (rule) 136 uint rule = (uint)rules.GetLSLIntegerItem(idx);
137 { 137 LSL_List toadd = new LSL_List();
138 case (int)ScriptBaseClass.WL_AMBIENT: 138
139 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); 139 switch (rule)
140 break; 140 {
141 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: 141 case (int)ScriptBaseClass.WL_AMBIENT:
142 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); 142 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
143 break; 143 break;
144 case (int)ScriptBaseClass.WL_BLUE_DENSITY: 144 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
145 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); 145 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
146 break; 146 break;
147 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: 147 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
148 toadd.Add(new LSL_Float(wl.blurMultiplier)); 148 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
149 break; 149 break;
150 case (int)ScriptBaseClass.WL_CLOUD_COLOR: 150 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
151 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); 151 toadd.Add(new LSL_Float(wl.blurMultiplier));
152 break; 152 break;
153 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: 153 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
154 toadd.Add(new LSL_Float(wl.cloudCoverage)); 154 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
155 break; 155 break;
156 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: 156 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
157 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); 157 toadd.Add(new LSL_Float(wl.cloudCoverage));
158 break; 158 break;
159 case (int)ScriptBaseClass.WL_CLOUD_SCALE: 159 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
160 toadd.Add(new LSL_Float(wl.cloudScale)); 160 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
161 break; 161 break;
162 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: 162 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
163 toadd.Add(new LSL_Float(wl.cloudScrollX)); 163 toadd.Add(new LSL_Float(wl.cloudScale));
164 break; 164 break;
165 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: 165 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
166 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); 166 toadd.Add(new LSL_Float(wl.cloudScrollX));
167 break; 167 break;
168 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: 168 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
169 toadd.Add(new LSL_Float(wl.cloudScrollY)); 169 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
170 break; 170 break;
171 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: 171 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
172 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); 172 toadd.Add(new LSL_Float(wl.cloudScrollY));
173 break; 173 break;
174 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: 174 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
175 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); 175 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
176 break; 176 break;
177 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: 177 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
178 toadd.Add(new LSL_Float(wl.densityMultiplier)); 178 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
179 break; 179 break;
180 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: 180 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
181 toadd.Add(new LSL_Float(wl.distanceMultiplier)); 181 toadd.Add(new LSL_Float(wl.densityMultiplier));
182 break; 182 break;
183 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: 183 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
184 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); 184 toadd.Add(new LSL_Float(wl.distanceMultiplier));
185 break; 185 break;
186 case (int)ScriptBaseClass.WL_EAST_ANGLE: 186 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
187 toadd.Add(new LSL_Float(wl.eastAngle)); 187 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
188 break; 188 break;
189 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: 189 case (int)ScriptBaseClass.WL_EAST_ANGLE:
190 toadd.Add(new LSL_Float(wl.fresnelOffset)); 190 toadd.Add(new LSL_Float(wl.eastAngle));
191 break; 191 break;
192 case (int)ScriptBaseClass.WL_FRESNEL_SCALE: 192 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
193 toadd.Add(new LSL_Float(wl.fresnelScale)); 193 toadd.Add(new LSL_Float(wl.fresnelOffset));
194 break; 194 break;
195 case (int)ScriptBaseClass.WL_HAZE_DENSITY: 195 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
196 toadd.Add(new LSL_Float(wl.hazeDensity)); 196 toadd.Add(new LSL_Float(wl.fresnelScale));
197 break; 197 break;
198 case (int)ScriptBaseClass.WL_HAZE_HORIZON: 198 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
199 toadd.Add(new LSL_Float(wl.hazeHorizon)); 199 toadd.Add(new LSL_Float(wl.hazeDensity));
200 break; 200 break;
201 case (int)ScriptBaseClass.WL_HORIZON: 201 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
202 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); 202 toadd.Add(new LSL_Float(wl.hazeHorizon));
203 break; 203 break;
204 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: 204 case (int)ScriptBaseClass.WL_HORIZON:
205 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); 205 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
206 break; 206 break;
207 case (int)ScriptBaseClass.WL_MAX_ALTITUDE: 207 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
208 toadd.Add(new LSL_Integer(wl.maxAltitude)); 208 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
209 break; 209 break;
210 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: 210 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
211 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); 211 toadd.Add(new LSL_Integer(wl.maxAltitude));
212 break; 212 break;
213 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: 213 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
214 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); 214 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
215 break; 215 break;
216 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: 216 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
217 toadd.Add(new LSL_Float(wl.refractScaleAbove)); 217 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
218 break; 218 break;
219 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: 219 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
220 toadd.Add(new LSL_Float(wl.refractScaleBelow)); 220 toadd.Add(new LSL_Float(wl.refractScaleAbove));
221 break; 221 break;
222 case (int)ScriptBaseClass.WL_SCENE_GAMMA: 222 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
223 toadd.Add(new LSL_Float(wl.sceneGamma)); 223 toadd.Add(new LSL_Float(wl.refractScaleBelow));
224 break; 224 break;
225 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: 225 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
226 toadd.Add(new LSL_Float(wl.starBrightness)); 226 toadd.Add(new LSL_Float(wl.sceneGamma));
227 break; 227 break;
228 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: 228 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
229 toadd.Add(new LSL_Float(wl.sunGlowFocus)); 229 toadd.Add(new LSL_Float(wl.starBrightness));
230 break; 230 break;
231 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: 231 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
232 toadd.Add(new LSL_Float(wl.sunGlowSize)); 232 toadd.Add(new LSL_Float(wl.sunGlowFocus));
233 break; 233 break;
234 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: 234 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
235 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); 235 toadd.Add(new LSL_Float(wl.sunGlowSize));
236 break; 236 break;
237 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: 237 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
238 toadd.Add(new LSL_Float(wl.underwaterFogModifier)); 238 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
239 break; 239 break;
240 case (int)ScriptBaseClass.WL_WATER_COLOR: 240 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
241 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); 241 toadd.Add(new LSL_Float(wl.underwaterFogModifier));
242 break; 242 break;
243 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: 243 case (int)ScriptBaseClass.WL_WATER_COLOR:
244 toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); 244 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
245 break; 245 break;
246 } 246 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
247 247 toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
248 if (toadd.Length > 0) 248 break;
249 { 249 }
250 values.Add(rule); 250
251 values.Add(toadd.Data[0]); 251 if (toadd.Length > 0)
252 } 252 {
253 idx++; 253 values.Add(new LSL_Integer(rule));
254 } 254 values.Add(toadd.Data[0]);
255 255 }
256 256 idx++;
257 return values; 257 }
258 258
259 } 259
260 260 return values;
261 private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) 261
262 { 262 }
263 RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); 263
264 264 private RegionLightShareData getWindlightProfileFromRules(LSL_List rules)
265 LSL_List values = new LSL_List(); 265 {
266 int idx = 0; 266 RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
267 while (idx < rules.Length) 267
268 { 268 LSL_List values = new LSL_List();
269 uint rule = (uint)rules.GetLSLIntegerItem(idx); 269 int idx = 0;
270 LSL_Types.Quaternion iQ; 270 while (idx < rules.Length)
271 LSL_Types.Vector3 iV; 271 {
272 switch (rule) 272 uint rule = (uint)rules.GetLSLIntegerItem(idx);
273 { 273 LSL_Types.Quaternion iQ;
274 case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: 274 LSL_Types.Vector3 iV;
275 idx++; 275 switch (rule)
276 wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); 276 {
277 break; 277 case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
278 case (int)ScriptBaseClass.WL_AMBIENT: 278 idx++;
279 idx++; 279 wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
280 iQ = rules.GetQuaternionItem(idx); 280 break;
281 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 281 case (int)ScriptBaseClass.WL_AMBIENT:
282 break; 282 idx++;
283 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: 283 iQ = rules.GetQuaternionItem(idx);
284 idx++; 284 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
285 iV = rules.GetVector3Item(idx); 285 break;
286 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); 286 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
287 break; 287 idx++;
288 case (int)ScriptBaseClass.WL_BLUE_DENSITY: 288 iV = rules.GetVector3Item(idx);
289 idx++; 289 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
290 iQ = rules.GetQuaternionItem(idx); 290 break;
291 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 291 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
292 break; 292 idx++;
293 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: 293 iQ = rules.GetQuaternionItem(idx);
294 idx++; 294 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
295 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); 295 break;
296 break; 296 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
297 case (int)ScriptBaseClass.WL_CLOUD_COLOR: 297 idx++;
298 idx++; 298 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
299 iQ = rules.GetQuaternionItem(idx); 299 break;
300 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 300 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
301 break; 301 idx++;
302 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: 302 iQ = rules.GetQuaternionItem(idx);
303 idx++; 303 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
304 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); 304 break;
305 break; 305 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
306 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: 306 idx++;
307 idx++; 307 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
308 iV = rules.GetVector3Item(idx); 308 break;
309 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 309 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
310 break; 310 idx++;
311 case (int)ScriptBaseClass.WL_CLOUD_SCALE: 311 iV = rules.GetVector3Item(idx);
312 idx++; 312 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
313 wl.cloudScale = (float)rules.GetLSLFloatItem(idx); 313 break;
314 break; 314 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
315 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: 315 idx++;
316 idx++; 316 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
317 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); 317 break;
318 break; 318 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
319 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: 319 idx++;
320 idx++; 320 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
321 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; 321 break;
322 break; 322 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
323 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: 323 idx++;
324 idx++; 324 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
325 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); 325 break;
326 break; 326 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
327 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: 327 idx++;
328 idx++; 328 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
329 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; 329 break;
330 break; 330 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
331 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: 331 idx++;
332 idx++; 332 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
333 iV = rules.GetVector3Item(idx); 333 break;
334 wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 334 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
335 break; 335 idx++;
336 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: 336 iV = rules.GetVector3Item(idx);
337 idx++; 337 wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
338 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); 338 break;
339 break; 339 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
340 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: 340 idx++;
341 idx++; 341 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
342 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); 342 break;
343 break; 343 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
344 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: 344 idx++;
345 idx++; 345 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
346 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; 346 break;
347 break; 347 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
348 case (int)ScriptBaseClass.WL_EAST_ANGLE: 348 idx++;
349 idx++; 349 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
350 wl.eastAngle = (float)rules.GetLSLFloatItem(idx); 350 break;
351 break; 351 case (int)ScriptBaseClass.WL_EAST_ANGLE:
352 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: 352 idx++;
353 idx++; 353 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
354 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); 354 break;
355 break; 355 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
356 case (int)ScriptBaseClass.WL_FRESNEL_SCALE: 356 idx++;
357 idx++; 357 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
358 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); 358 break;
359 break; 359 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
360 case (int)ScriptBaseClass.WL_HAZE_DENSITY: 360 idx++;
361 idx++; 361 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
362 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); 362 break;
363 break; 363 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
364 case (int)ScriptBaseClass.WL_HAZE_HORIZON: 364 idx++;
365 idx++; 365 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
366 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); 366 break;
367 break; 367 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
368 case (int)ScriptBaseClass.WL_HORIZON: 368 idx++;
369 idx++; 369 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
370 iQ = rules.GetQuaternionItem(idx); 370 break;
371 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 371 case (int)ScriptBaseClass.WL_HORIZON:
372 break; 372 idx++;
373 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: 373 iQ = rules.GetQuaternionItem(idx);
374 idx++; 374 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
375 iV = rules.GetVector3Item(idx); 375 break;
376 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); 376 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
377 break; 377 idx++;
378 case (int)ScriptBaseClass.WL_MAX_ALTITUDE: 378 iV = rules.GetVector3Item(idx);
379 idx++; 379 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
380 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; 380 break;
381 break; 381 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
382 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: 382 idx++;
383 idx++; 383 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
384 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); 384 break;
385 break; 385 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
386 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: 386 idx++;
387 idx++; 387 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
388 iV = rules.GetVector3Item(idx); 388 break;
389 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 389 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
390 break; 390 idx++;
391 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: 391 iV = rules.GetVector3Item(idx);
392 idx++; 392 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
393 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); 393 break;
394 break; 394 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
395 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: 395 idx++;
396 idx++; 396 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
397 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); 397 break;
398 break; 398 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
399 case (int)ScriptBaseClass.WL_SCENE_GAMMA: 399 idx++;
400 idx++; 400 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
401 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); 401 break;
402 break; 402 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
403 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: 403 idx++;
404 idx++; 404 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
405 wl.starBrightness = (float)rules.GetLSLFloatItem(idx); 405 break;
406 break; 406 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
407 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: 407 idx++;
408 idx++; 408 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
409 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); 409 break;
410 break; 410 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
411 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: 411 idx++;
412 idx++; 412 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
413 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); 413 break;
414 break; 414 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
415 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: 415 idx++;
416 idx++; 416 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
417 iQ = rules.GetQuaternionItem(idx); 417 break;
418 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 418 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
419 break; 419 idx++;
420 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: 420 iQ = rules.GetQuaternionItem(idx);
421 idx++; 421 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
422 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); 422 break;
423 break; 423 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
424 case (int)ScriptBaseClass.WL_WATER_COLOR: 424 idx++;
425 idx++; 425 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
426 iV = rules.GetVector3Item(idx); 426 break;
427 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 427 case (int)ScriptBaseClass.WL_WATER_COLOR:
428 break; 428 idx++;
429 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: 429 iV = rules.GetVector3Item(idx);
430 idx++; 430 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
431 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); 431 break;
432 break; 432 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
433 } 433 idx++;
434 idx++; 434 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
435 } 435 break;
436 return wl; 436 }
437 } 437 idx++;
438 /// <summary> 438 }
439 /// Set the current Windlight scene 439 return wl;
440 /// </summary> 440 }
441 /// <param name="rules"></param> 441 /// <summary>
442 /// <returns>success: true or false</returns> 442 /// Set the current Windlight scene
443 public int lsSetWindlightScene(LSL_List rules) 443 /// </summary>
444 { 444 /// <param name="rules"></param>
445 if (!m_LSFunctionsEnabled) 445 /// <returns>success: true or false</returns>
446 { 446 public int lsSetWindlightScene(LSL_List rules)
447 LSShoutError("LightShare functions are not enabled."); 447 {
448 return 0; 448 if (!m_LSFunctionsEnabled)
449 } 449 {
450 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 450 LSShoutError("LightShare functions are not enabled.");
451 { 451 return 0;
452 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 452 }
453 return 0; 453 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
454 } 454 {
455 int success = 0; 455 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
456 m_host.AddScriptLPS(1); 456 return 0;
457 if (LightShareModule.EnableWindlight) 457 }
458 { 458 int success = 0;
459 RegionLightShareData wl = getWindlightProfileFromRules(rules); 459 m_host.AddScriptLPS(1);
460 m_host.ParentGroup.Scene.StoreWindlightProfile(wl); 460 if (LightShareModule.EnableWindlight)
461 success = 1; 461 {
462 } 462 RegionLightShareData wl = getWindlightProfileFromRules(rules);
463 else 463 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
464 { 464 success = 1;
465 LSShoutError("Windlight module is disabled"); 465 }
466 return 0; 466 else
467 } 467 {
468 return success; 468 LSShoutError("Windlight module is disabled");
469 } 469 return 0;
470 /// <summary> 470 }
471 /// Set the current Windlight scene to a target avatar 471 return success;
472 /// </summary> 472 }
473 /// <param name="rules"></param> 473 /// <summary>
474 /// <returns>success: true or false</returns> 474 /// Set the current Windlight scene to a target avatar
475 public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) 475 /// </summary>
476 { 476 /// <param name="rules"></param>
477 if (!m_LSFunctionsEnabled) 477 /// <returns>success: true or false</returns>
478 { 478 public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
479 LSShoutError("LightShare functions are not enabled."); 479 {
480 return 0; 480 if (!m_LSFunctionsEnabled)
481 } 481 {
482 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 482 LSShoutError("LightShare functions are not enabled.");
483 { 483 return 0;
484 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); 484 }
485 return 0; 485 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
486 } 486 {
487 int success = 0; 487 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
488 m_host.AddScriptLPS(1); 488 return 0;
489 if (LightShareModule.EnableWindlight) 489 }
490 { 490 int success = 0;
491 RegionLightShareData wl = getWindlightProfileFromRules(rules); 491 m_host.AddScriptLPS(1);
492 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); 492 if (LightShareModule.EnableWindlight)
493 success = 1; 493 {
494 } 494 RegionLightShareData wl = getWindlightProfileFromRules(rules);
495 else 495 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
496 { 496 success = 1;
497 LSShoutError("Windlight module is disabled"); 497 }
498 return 0; 498 else
499 } 499 {
500 return success; 500 LSShoutError("Windlight module is disabled");
501 } 501 return 0;
502 502 }
503 } 503 return success;
504} 504 }
505
506 }
507}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index a529a94..a08b135 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -129,6 +129,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
129 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 129 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
130 internal float m_ScriptDelayFactor = 1.0f; 130 internal float m_ScriptDelayFactor = 1.0f;
131 internal float m_ScriptDistanceFactor = 1.0f; 131 internal float m_ScriptDistanceFactor = 1.0f;
132 internal bool m_debuggerSafe = false;
132 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 133 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
133 134
134 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 135 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
@@ -137,6 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
137 m_host = host; 138 m_host = host;
138 m_localID = localID; 139 m_localID = localID;
139 m_itemID = itemID; 140 m_itemID = itemID;
141 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
140 142
141 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 143 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
142 m_OSFunctionsEnabled = true; 144 m_OSFunctionsEnabled = true;
@@ -195,7 +197,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
195 197
196 internal void OSSLError(string msg) 198 internal void OSSLError(string msg)
197 { 199 {
198 throw new Exception("OSSL Runtime Error: " + msg); 200 if (m_debuggerSafe)
201 {
202 OSSLShoutError(msg);
203 }
204 else
205 {
206 throw new Exception("OSSL Runtime Error: " + msg);
207 }
199 } 208 }
200 209
201 private void InitLSL() 210 private void InitLSL()
@@ -767,18 +776,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
767 if (target != null) 776 if (target != null)
768 { 777 {
769 UUID animID=UUID.Zero; 778 UUID animID=UUID.Zero;
770 lock (m_host.TaskInventory) 779 m_host.TaskInventory.LockItemsForRead(true);
780 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
771 { 781 {
772 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 782 if (inv.Value.Name == animation)
773 { 783 {
774 if (inv.Value.Name == animation) 784 if (inv.Value.Type == (int)AssetType.Animation)
775 { 785 animID = inv.Value.AssetID;
776 if (inv.Value.Type == (int)AssetType.Animation) 786 continue;
777 animID = inv.Value.AssetID;
778 continue;
779 }
780 } 787 }
781 } 788 }
789 m_host.TaskInventory.LockItemsForRead(false);
782 if (animID == UUID.Zero) 790 if (animID == UUID.Zero)
783 target.Animator.AddAnimation(animation, m_host.UUID); 791 target.Animator.AddAnimation(animation, m_host.UUID);
784 else 792 else
@@ -800,18 +808,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
800 if (target != null) 808 if (target != null)
801 { 809 {
802 UUID animID=UUID.Zero; 810 UUID animID=UUID.Zero;
803 lock (m_host.TaskInventory) 811 m_host.TaskInventory.LockItemsForRead(true);
812 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
804 { 813 {
805 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 814 if (inv.Value.Name == animation)
806 { 815 {
807 if (inv.Value.Name == animation) 816 if (inv.Value.Type == (int)AssetType.Animation)
808 { 817 animID = inv.Value.AssetID;
809 if (inv.Value.Type == (int)AssetType.Animation) 818 continue;
810 animID = inv.Value.AssetID;
811 continue;
812 }
813 } 819 }
814 } 820 }
821 m_host.TaskInventory.LockItemsForRead(false);
815 822
816 if (animID == UUID.Zero) 823 if (animID == UUID.Zero)
817 target.Animator.RemoveAnimation(animation); 824 target.Animator.RemoveAnimation(animation);
@@ -1662,6 +1669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1662 1669
1663 if (!UUID.TryParse(name, out assetID)) 1670 if (!UUID.TryParse(name, out assetID))
1664 { 1671 {
1672 m_host.TaskInventory.LockItemsForRead(true);
1665 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1673 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1666 { 1674 {
1667 if (item.Type == 7 && item.Name == name) 1675 if (item.Type == 7 && item.Name == name)
@@ -1669,6 +1677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1669 assetID = item.AssetID; 1677 assetID = item.AssetID;
1670 } 1678 }
1671 } 1679 }
1680 m_host.TaskInventory.LockItemsForRead(false);
1672 } 1681 }
1673 1682
1674 if (assetID == UUID.Zero) 1683 if (assetID == UUID.Zero)
@@ -1715,6 +1724,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1715 1724
1716 if (!UUID.TryParse(name, out assetID)) 1725 if (!UUID.TryParse(name, out assetID))
1717 { 1726 {
1727 m_host.TaskInventory.LockItemsForRead(true);
1718 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1728 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1719 { 1729 {
1720 if (item.Type == 7 && item.Name == name) 1730 if (item.Type == 7 && item.Name == name)
@@ -1722,6 +1732,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1722 assetID = item.AssetID; 1732 assetID = item.AssetID;
1723 } 1733 }
1724 } 1734 }
1735 m_host.TaskInventory.LockItemsForRead(false);
1725 } 1736 }
1726 1737
1727 if (assetID == UUID.Zero) 1738 if (assetID == UUID.Zero)
@@ -1772,6 +1783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1772 1783
1773 if (!UUID.TryParse(name, out assetID)) 1784 if (!UUID.TryParse(name, out assetID))
1774 { 1785 {
1786 m_host.TaskInventory.LockItemsForRead(true);
1775 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1787 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1776 { 1788 {
1777 if (item.Type == 7 && item.Name == name) 1789 if (item.Type == 7 && item.Name == name)
@@ -1779,6 +1791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1779 assetID = item.AssetID; 1791 assetID = item.AssetID;
1780 } 1792 }
1781 } 1793 }
1794 m_host.TaskInventory.LockItemsForRead(false);
1782 } 1795 }
1783 1796
1784 if (assetID == UUID.Zero) 1797 if (assetID == UUID.Zero)
@@ -2216,9 +2229,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2216 { 2229 {
2217 if (avatar.IsChildAgent == false) 2230 if (avatar.IsChildAgent == false)
2218 { 2231 {
2219 result.Add(avatar.UUID); 2232 result.Add(new LSL_Key(avatar.UUID.ToString()));
2220 result.Add(avatar.AbsolutePosition); 2233 result.Add(new LSL_Vector(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z));
2221 result.Add(avatar.Name); 2234 result.Add(new LSL_String(avatar.Name));
2222 } 2235 }
2223 } 2236 }
2224 }); 2237 });
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 5c2abd5..a5b1124 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
204 // Is the sensor type is AGENT and not SCRIPTED then include agents 204 // Is the sensor type is AGENT and not SCRIPTED then include agents
205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) 205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0)
206 { 206 {
207 sensedEntities.AddRange(doAgentSensor(ts)); 207 sensedEntities.AddRange(doAgentSensor(ts));
208 } 208 }
209 209
210 // If SCRIPTED or PASSIVE or ACTIVE check objects 210 // If SCRIPTED or PASSIVE or ACTIVE check objects
@@ -309,6 +309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
309 // in mouselook. 309 // in mouselook.
310 310
311 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); 311 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar);
312 fromRegionPos = avatar.AbsolutePosition;
312 q = avatar.Rotation; 313 q = avatar.Rotation;
313 } 314 }
314 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 315 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
@@ -422,6 +423,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
422 SceneObjectPart SensePoint = ts.host; 423 SceneObjectPart SensePoint = ts.host;
423 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 424 Vector3 fromRegionPos = SensePoint.AbsolutePosition;
424 Quaternion q = SensePoint.RotationOffset; 425 Quaternion q = SensePoint.RotationOffset;
426 if (SensePoint.ParentGroup.RootPart.IsAttachment)
427 {
428 // In attachments, the sensor cone always orients with the
429 // avatar rotation. This may include a nonzero elevation if
430 // in mouselook.
431
432 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar);
433 fromRegionPos = avatar.AbsolutePosition;
434 q = avatar.Rotation;
435 }
425 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 436 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
426 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 437 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
427 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 438 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index eeb59d9..2fd33fe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
109 if (Timers.Count == 0) 109 if (Timers.Count == 0)
110 return; 110 return;
111 111
112 Dictionary<string, TimerClass>.ValueCollection tvals;
112 lock (TimerListLock) 113 lock (TimerListLock)
113 { 114 {
114 // Go through all timers 115 // Go through all timers
115 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 116 tvals = Timers.Values;
116 foreach (TimerClass ts in tvals) 117 }
118
119 foreach (TimerClass ts in tvals)
120 {
121 // Time has passed?
122 if (ts.next < DateTime.Now.Ticks)
117 { 123 {
118 // Time has passed? 124 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
119 if (ts.next < DateTime.Now.Ticks) 125 // Add it to queue
120 { 126 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
121 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 127 new EventParams("timer", new Object[0],
122 // Add it to queue 128 new DetectParams[0]));
123 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 129 // set next interval
124 new EventParams("timer", new Object[0], 130
125 new DetectParams[0])); 131 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
126 // set next interval 132 ts.next = DateTime.Now.Ticks + ts.interval;
127
128 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
129 ts.next = DateTime.Now.Ticks + ts.interval;
130 }
131 } 133 }
132 } 134 }
133 } 135 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 78ee43c..c8f3623 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
81 // Avatar Info Commands 81 // Avatar Info Commands
82 string osGetAgentIP(string agent); 82 string osGetAgentIP(string agent);
83 LSL_List osGetAgents(); 83 LSL_List osGetAgents();
84 84
85 // Teleport commands 85 // Teleport commands
86 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 86 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
87 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 87 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 9615315..943d7a2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Reflection; 31using System.Reflection;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using OpenSim.Region.ScriptEngine.Shared; 33using OpenSim.Region.ScriptEngine.Shared;
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
132 return (eventFlags); 133 return (eventFlags);
133 } 134 }
134 135
136 [DebuggerNonUserCode]
135 public void ExecuteEvent(string state, string FunctionName, object[] args) 137 public void ExecuteEvent(string state, string FunctionName, object[] args)
136 { 138 {
137 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 139 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 5da6bb9..6e8435d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -279,6 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
279 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART 279 public const int CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
280 public const int CHANGED_MEDIA = 2048; 280 public const int CHANGED_MEDIA = 2048;
281 public const int CHANGED_ANIMATION = 16384; 281 public const int CHANGED_ANIMATION = 16384;
282 public const int CHANGED_POSITION = 32768;
282 public const int TYPE_INVALID = 0; 283 public const int TYPE_INVALID = 0;
283 public const int TYPE_INTEGER = 1; 284 public const int TYPE_INTEGER = 1;
284 public const int TYPE_FLOAT = 2; 285 public const int TYPE_FLOAT = 2;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 451163f..f14967e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Diagnostics; //for [DebuggerNonUserCode]
29using System.Runtime.Remoting.Lifetime; 30using System.Runtime.Remoting.Lifetime;
30using System.Threading; 31using System.Threading;
31using System.Reflection; 32using System.Reflection;
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
309 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); 310 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
310 } 311 }
311 312
313 [DebuggerNonUserCode]
312 public void llDie() 314 public void llDie()
313 { 315 {
314 m_LSL_Functions.llDie(); 316 m_LSL_Functions.llDie();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
index f8dbe03..8280ca5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
@@ -72,5 +72,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
72 { 72 {
73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); 73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
74 } 74 }
75
76 public LSL_List cmGetWindlightScene(LSL_List rules)
77 {
78 return m_LS_Functions.lsGetWindlightScene(rules);
79 }
80
81 public int cmSetWindlightScene(LSL_List rules)
82 {
83 return m_LS_Functions.lsSetWindlightScene(rules);
84 }
85
86 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
87 {
88 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
89 }
75 } 90 }
76} 91}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index edbbc2a..b138da3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
33using System.Reflection; 33using System.Reflection;
34using System.Collections; 34using System.Collections;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.Diagnostics; //for [DebuggerNonUserCode]
36using OpenSim.Region.ScriptEngine.Interfaces; 37using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared; 38using OpenSim.Region.ScriptEngine.Shared;
38using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; 39using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
90 return (int)m_Executor.GetStateEventFlags(state); 91 return (int)m_Executor.GetStateEventFlags(state);
91 } 92 }
92 93
94 [DebuggerNonUserCode]
93 public void ExecuteEvent(string state, string FunctionName, object[] args) 95 public void ExecuteEvent(string state, string FunctionName, object[] args)
94 { 96 {
95 m_Executor.ExecuteEvent(state, FunctionName, args); 97 m_Executor.ExecuteEvent(state, FunctionName, args);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 6663aa5..b4da246 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Runtime.Remoting; 31using System.Runtime.Remoting;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Threading; 33using System.Threading;
@@ -238,13 +239,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
238 239
239 if (part != null) 240 if (part != null)
240 { 241 {
241 lock (part.TaskInventory) 242 part.TaskInventory.LockItemsForRead(true);
243 if (part.TaskInventory.ContainsKey(m_ItemID))
242 { 244 {
243 if (part.TaskInventory.ContainsKey(m_ItemID)) 245 m_thisScriptTask = part.TaskInventory[m_ItemID];
244 {
245 m_thisScriptTask = part.TaskInventory[m_ItemID];
246 }
247 } 246 }
247 part.TaskInventory.LockItemsForRead(false);
248 } 248 }
249 249
250 ApiManager am = new ApiManager(); 250 ApiManager am = new ApiManager();
@@ -429,14 +429,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
429 { 429 {
430 int permsMask; 430 int permsMask;
431 UUID permsGranter; 431 UUID permsGranter;
432 lock (part.TaskInventory) 432 part.TaskInventory.LockItemsForRead(true);
433 if (!part.TaskInventory.ContainsKey(m_ItemID))
433 { 434 {
434 if (!part.TaskInventory.ContainsKey(m_ItemID)) 435 part.TaskInventory.LockItemsForRead(false);
435 return; 436 return;
436
437 permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
438 permsMask = part.TaskInventory[m_ItemID].PermsMask;
439 } 437 }
438 permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
439 permsMask = part.TaskInventory[m_ItemID].PermsMask;
440 part.TaskInventory.LockItemsForRead(false);
440 441
441 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 442 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
442 { 443 {
@@ -545,6 +546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
545 return true; 546 return true;
546 } 547 }
547 548
549 [DebuggerNonUserCode] //Prevents the debugger from farting in this function
548 public void SetState(string state) 550 public void SetState(string state)
549 { 551 {
550 if (state == State) 552 if (state == State)
@@ -556,7 +558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
556 new DetectParams[0])); 558 new DetectParams[0]));
557 PostEvent(new EventParams("state_entry", new Object[0], 559 PostEvent(new EventParams("state_entry", new Object[0],
558 new DetectParams[0])); 560 new DetectParams[0]));
559 561
560 throw new EventAbortException(); 562 throw new EventAbortException();
561 } 563 }
562 564
@@ -639,14 +641,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
639 /// <returns></returns> 641 /// <returns></returns>
640 public object EventProcessor() 642 public object EventProcessor()
641 { 643 {
642 if (m_Suspended) 644 EventParams data = null;
643 return 0;
644 645
645 lock (m_Script) 646 lock (m_EventQueue)
646 { 647 {
647 EventParams data = null; 648 if (m_Suspended)
649 return 0;
648 650
649 lock (m_EventQueue) 651 lock (m_Script)
650 { 652 {
651 data = (EventParams) m_EventQueue.Dequeue(); 653 data = (EventParams) m_EventQueue.Dequeue();
652 if (data == null) // Shouldn't happen 654 if (data == null) // Shouldn't happen
@@ -672,6 +674,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
672 if (data.EventName == "collision") 674 if (data.EventName == "collision")
673 m_CollisionInQueue = false; 675 m_CollisionInQueue = false;
674 } 676 }
677 }
678 lock(m_Script)
679 {
675 680
676 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); 681 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
677 682
@@ -828,6 +833,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
828 new Object[0], new DetectParams[0])); 833 new Object[0], new DetectParams[0]));
829 } 834 }
830 835
836 [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
831 public void ApiResetScript() 837 public void ApiResetScript()
832 { 838 {
833 // bool running = Running; 839 // bool running = Running;
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 91e03ac..a3a2fdf 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -83,19 +83,19 @@ namespace OpenSim.Region.ScriptEngine.Shared
83 83
84 public override string ToString() 84 public override string ToString()
85 { 85 {
86 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z); 86 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z);
87 return s; 87 return s;
88 } 88 }
89 89
90 public static explicit operator LSLString(Vector3 vec) 90 public static explicit operator LSLString(Vector3 vec)
91 { 91 {
92 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); 92 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z);
93 return new LSLString(s); 93 return new LSLString(s);
94 } 94 }
95 95
96 public static explicit operator string(Vector3 vec) 96 public static explicit operator string(Vector3 vec)
97 { 97 {
98 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z); 98 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}>", vec.x, vec.y, vec.z);
99 return s; 99 return s;
100 } 100 }
101 101
@@ -342,19 +342,19 @@ namespace OpenSim.Region.ScriptEngine.Shared
342 342
343 public override string ToString() 343 public override string ToString()
344 { 344 {
345 string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); 345 string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s);
346 return st; 346 return st;
347 } 347 }
348 348
349 public static explicit operator string(Quaternion r) 349 public static explicit operator string(Quaternion r)
350 { 350 {
351 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); 351 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s);
352 return s; 352 return s;
353 } 353 }
354 354
355 public static explicit operator LSLString(Quaternion r) 355 public static explicit operator LSLString(Quaternion r)
356 { 356 {
357 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); 357 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s);
358 return new LSLString(s); 358 return new LSLString(s);
359 } 359 }
360 360
@@ -613,24 +613,16 @@ namespace OpenSim.Region.ScriptEngine.Shared
613 613
614 public static bool operator ==(list a, list b) 614 public static bool operator ==(list a, list b)
615 { 615 {
616 int la = -1; 616 int la = a.Length;
617 int lb = -1; 617 int lb = b.Length;
618 try { la = a.Length; }
619 catch (NullReferenceException) { }
620 try { lb = b.Length; }
621 catch (NullReferenceException) { }
622 618
623 return la == lb; 619 return la == lb;
624 } 620 }
625 621
626 public static bool operator !=(list a, list b) 622 public static bool operator !=(list a, list b)
627 { 623 {
628 int la = -1; 624 int la = a.Length;
629 int lb = -1; 625 int lb = b.Length;
630 try { la = a.Length; }
631 catch (NullReferenceException) { }
632 try {lb = b.Length;}
633 catch (NullReferenceException) { }
634 626
635 return la != lb; 627 return la != lb;
636 } 628 }