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.cs1879
-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/ILSL_Api.cs1
-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.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs47
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs28
14 files changed, 1379 insertions, 729 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 3c5f2d0..05a4170 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)
@@ -288,40 +346,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
288 protected UUID InventorySelf() 346 protected UUID InventorySelf()
289 { 347 {
290 UUID invItemID = new UUID(); 348 UUID invItemID = new UUID();
291 349 bool unlock = false;
292 lock (m_host.TaskInventory) 350 if (!m_host.TaskInventory.IsReadLockedByMe())
351 {
352 m_host.TaskInventory.LockItemsForRead(true);
353 unlock = true;
354 }
355 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
293 { 356 {
294 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 357 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
295 { 358 {
296 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 359 invItemID = inv.Key;
297 { 360 break;
298 invItemID = inv.Key;
299 break;
300 }
301 } 361 }
302 } 362 }
303 363 if (unlock)
364 {
365 m_host.TaskInventory.LockItemsForRead(false);
366 }
304 return invItemID; 367 return invItemID;
305 } 368 }
306 369
307 protected UUID InventoryKey(string name, int type) 370 protected UUID InventoryKey(string name, int type)
308 { 371 {
309 m_host.AddScriptLPS(1); 372 m_host.AddScriptLPS(1);
310 373 m_host.TaskInventory.LockItemsForRead(true);
311 lock (m_host.TaskInventory) 374
375 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
312 { 376 {
313 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 377 if (inv.Value.Name == name)
314 { 378 {
315 if (inv.Value.Name == name) 379 m_host.TaskInventory.LockItemsForRead(false);
380
381 if (inv.Value.Type != type)
316 { 382 {
317 if (inv.Value.Type != type) 383 return UUID.Zero;
318 return UUID.Zero;
319
320 return inv.Value.AssetID;
321 } 384 }
385
386 return inv.Value.AssetID;
322 } 387 }
323 } 388 }
324 389
390 m_host.TaskInventory.LockItemsForRead(false);
325 return UUID.Zero; 391 return UUID.Zero;
326 } 392 }
327 393
@@ -329,17 +395,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
329 { 395 {
330 m_host.AddScriptLPS(1); 396 m_host.AddScriptLPS(1);
331 397
332 lock (m_host.TaskInventory) 398
399 m_host.TaskInventory.LockItemsForRead(true);
400
401 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
333 { 402 {
334 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 403 if (inv.Value.Name == name)
335 { 404 {
336 if (inv.Value.Name == name) 405 m_host.TaskInventory.LockItemsForRead(false);
337 { 406 return inv.Value.AssetID;
338 return inv.Value.AssetID;
339 }
340 } 407 }
341 } 408 }
342 409
410 m_host.TaskInventory.LockItemsForRead(false);
411
412
343 return UUID.Zero; 413 return UUID.Zero;
344 } 414 }
345 415
@@ -481,26 +551,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
481 551
482 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke 552 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
483 553
484 // Old implementation of llRot2Euler. Normalization not required as Atan2 function will 554 // Utility function for llRot2Euler
485 // only return values >= -PI (-180 degrees) and <= PI (180 degrees). 555
556 // normalize an angle between -PI and PI (-180 to +180 degrees)
557 protected double NormalizeAngle(double angle)
558 {
559 if (angle > -Math.PI && angle < Math.PI)
560 return angle;
561
562 int numPis = (int)(Math.PI / angle);
563 double remainder = angle - Math.PI * numPis;
564 if (numPis % 2 == 1)
565 return Math.PI - angle;
566 return remainder;
567 }
486 568
487 public LSL_Vector llRot2Euler(LSL_Rotation r) 569 public LSL_Vector llRot2Euler(LSL_Rotation q1)
488 { 570 {
489 m_host.AddScriptLPS(1); 571 m_host.AddScriptLPS(1);
490 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke 572 LSL_Vector eul = new LSL_Vector();
491 LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); 573
492 double m = (t.x + t.y + t.z + t.s); 574 double sqw = q1.s*q1.s;
493 if (m == 0) return new LSL_Vector(); 575 double sqx = q1.x*q1.x;
494 double n = 2 * (r.y * r.s + r.x * r.z); 576 double sqy = q1.z*q1.z;
495 double p = m * m - n * n; 577 double sqz = q1.y*q1.y;
496 if (p > 0) 578 double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
497 return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), 579 double test = q1.x*q1.z + q1.y*q1.s;
498 Math.Atan2(n, Math.Sqrt(p)), 580 if (test > 0.4999*unit) { // singularity at north pole
499 Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); 581 eul.z = 2 * Math.Atan2(q1.x,q1.s);
500 else if (n > 0) 582 eul.y = Math.PI/2;
501 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)); 583 eul.x = 0;
502 else 584 return eul;
503 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)); 585 }
586 if (test < -0.4999*unit) { // singularity at south pole
587 eul.z = -2 * Math.Atan2(q1.x,q1.s);
588 eul.y = -Math.PI/2;
589 eul.x = 0;
590 return eul;
591 }
592 eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw);
593 eul.y = Math.Asin(2*test/unit);
594 eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw);
595 return eul;
504 } 596 }
505 597
506 /* From wiki: 598 /* From wiki:
@@ -702,77 +794,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
702 { 794 {
703 //A and B should both be normalized 795 //A and B should both be normalized
704 m_host.AddScriptLPS(1); 796 m_host.AddScriptLPS(1);
705 LSL_Rotation rotBetween; 797 /* This method is more accurate than the SL one, and thus causes problems
706 // Check for zero vectors. If either is zero, return zero rotation. Otherwise, 798 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
707 // continue calculation. 799
708 if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) 800 double dotProduct = LSL_Vector.Dot(a, b);
709 { 801 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
710 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 802 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
711 } 803 double angle = Math.Acos(dotProduct / magProduct);
712 else 804 LSL_Vector axis = LSL_Vector.Norm(crossProduct);
713 { 805 double s = Math.Sin(angle / 2);
714 a = LSL_Vector.Norm(a); 806
715 b = LSL_Vector.Norm(b); 807 double x = axis.x * s;
716 double dotProduct = LSL_Vector.Dot(a, b); 808 double y = axis.y * s;
717 // There are two degenerate cases possible. These are for vectors 180 or 809 double z = axis.z * s;
718 // 0 degrees apart. These have to be detected and handled individually. 810 double w = Math.Cos(angle / 2);
719 // 811
720 // Check for vectors 180 degrees apart. 812 if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w))
721 // A dot product of -1 would mean the angle between vectors is 180 degrees. 813 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
722 if (dotProduct < -0.9999999f) 814
723 { 815 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
724 // First assume X axis is orthogonal to the vectors. 816 */
725 LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); 817
726 orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); 818 // This method mimics the 180 errors found in SL
727 // Check for near zero vector. A very small non-zero number here will create 819 // See www.euclideanspace.com... angleBetween
728 // a rotation in an undesired direction. 820 LSL_Vector vec_a = a;
729 if (LSL_Vector.Mag(orthoVector) > 0.0001) 821 LSL_Vector vec_b = b;
730 { 822
731 rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); 823 // Eliminate zero length
732 } 824 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
733 // If the magnitude of the vector was near zero, then assume the X axis is not 825 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
734 // orthogonal and use the Z axis instead. 826 if (vec_a_mag < 0.00001 ||
735 else 827 vec_b_mag < 0.00001)
736 { 828 {
737 // Set 180 z rotation. 829 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
738 rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); 830 }
739 } 831
740 } 832 // Normalize
741 // Check for parallel vectors. 833 vec_a = llVecNorm(vec_a);
742 // A dot product of 1 would mean the angle between vectors is 0 degrees. 834 vec_b = llVecNorm(vec_b);
743 else if (dotProduct > 0.9999999f) 835
744 { 836 // Calculate axis and rotation angle
745 // Set zero rotation. 837 LSL_Vector axis = vec_a % vec_b;
746 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 838 LSL_Float cos_theta = vec_a * vec_b;
747 } 839
748 else 840 // Check if parallel
749 { 841 if (cos_theta > 0.99999)
750 // All special checks have been performed so get the axis of rotation. 842 {
751 LSL_Vector crossProduct = LSL_Vector.Cross(a, b); 843 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
752 // Quarternion s value is the length of the unit vector + dot product. 844 }
753 double qs = 1.0 + dotProduct; 845
754 rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); 846 // Check if anti-parallel
755 // Normalize the rotation. 847 else if (cos_theta < -0.99999)
756 double mag = LSL_Rotation.Mag(rotBetween); 848 {
757 // We shouldn't have to worry about a divide by zero here. The qs value will be 849 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
758 // non-zero because we already know if we're here, then the dotProduct is not -1 so 850 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
759 // qs will not be zero. Also, we've already handled the input vectors being zero so the 851 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
760 // crossProduct vector should also not be zero. 852 }
761 rotBetween.x = rotBetween.x / mag; 853 else // other rotation
762 rotBetween.y = rotBetween.y / mag; 854 {
763 rotBetween.z = rotBetween.z / mag; 855 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
764 rotBetween.s = rotBetween.s / mag; 856 axis = llVecNorm(axis);
765 // Check for undefined values and set zero rotation if any found. This code might not actually be required 857 double x, y, z, s, t;
766 // any longer since zero vectors are checked for at the top. 858 s = Math.Cos(theta);
767 if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) 859 t = Math.Sin(theta);
768 { 860 x = axis.x * t;
769 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 861 y = axis.y * t;
770 } 862 z = axis.z * t;
771 } 863 return new LSL_Rotation(x,y,z,s);
772 } 864 }
773 return rotBetween; 865 }
774 } 866
775
776 public void llWhisper(int channelID, string text) 867 public void llWhisper(int channelID, string text)
777 { 868 {
778 m_host.AddScriptLPS(1); 869 m_host.AddScriptLPS(1);
@@ -1096,10 +1187,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1096 return detectedParams.TouchUV; 1187 return detectedParams.TouchUV;
1097 } 1188 }
1098 1189
1190 [DebuggerNonUserCode]
1099 public virtual void llDie() 1191 public virtual void llDie()
1100 { 1192 {
1101 m_host.AddScriptLPS(1); 1193 m_host.AddScriptLPS(1);
1102 throw new SelfDeleteException(); 1194 if (!m_host.IsAttachment) throw new SelfDeleteException();
1103 } 1195 }
1104 1196
1105 public LSL_Float llGround(LSL_Vector offset) 1197 public LSL_Float llGround(LSL_Vector offset)
@@ -1172,6 +1264,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1172 1264
1173 public void llSetStatus(int status, int value) 1265 public void llSetStatus(int status, int value)
1174 { 1266 {
1267 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1268 return;
1175 m_host.AddScriptLPS(1); 1269 m_host.AddScriptLPS(1);
1176 1270
1177 int statusrotationaxis = 0; 1271 int statusrotationaxis = 0;
@@ -1402,6 +1496,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1402 { 1496 {
1403 m_host.AddScriptLPS(1); 1497 m_host.AddScriptLPS(1);
1404 1498
1499 SetColor(m_host, color, face);
1500 }
1501
1502 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1503 {
1504 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1505 return;
1506
1507 Primitive.TextureEntry tex = part.Shape.Textures;
1508 Color4 texcolor;
1509 if (face >= 0 && face < GetNumberOfSides(part))
1510 {
1511 texcolor = tex.CreateFace((uint)face).RGBA;
1512 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1513 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1514 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1515 tex.FaceTextures[face].RGBA = texcolor;
1516 part.UpdateTexture(tex);
1517 return;
1518 }
1519 else if (face == ScriptBaseClass.ALL_SIDES)
1520 {
1521 for (uint i = 0; i < GetNumberOfSides(part); i++)
1522 {
1523 if (tex.FaceTextures[i] != null)
1524 {
1525 texcolor = tex.FaceTextures[i].RGBA;
1526 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1527 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1528 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1529 tex.FaceTextures[i].RGBA = texcolor;
1530 }
1531 texcolor = tex.DefaultTexture.RGBA;
1532 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1533 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1534 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1535 tex.DefaultTexture.RGBA = texcolor;
1536 }
1537 part.UpdateTexture(tex);
1538 return;
1539 }
1540
1405 if (face == ScriptBaseClass.ALL_SIDES) 1541 if (face == ScriptBaseClass.ALL_SIDES)
1406 face = SceneObjectPart.ALL_SIDES; 1542 face = SceneObjectPart.ALL_SIDES;
1407 1543
@@ -1410,6 +1546,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1410 1546
1411 public void SetTexGen(SceneObjectPart part, int face,int style) 1547 public void SetTexGen(SceneObjectPart part, int face,int style)
1412 { 1548 {
1549 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1550 return;
1551
1413 Primitive.TextureEntry tex = part.Shape.Textures; 1552 Primitive.TextureEntry tex = part.Shape.Textures;
1414 MappingType textype; 1553 MappingType textype;
1415 textype = MappingType.Default; 1554 textype = MappingType.Default;
@@ -1440,6 +1579,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1440 1579
1441 public void SetGlow(SceneObjectPart part, int face, float glow) 1580 public void SetGlow(SceneObjectPart part, int face, float glow)
1442 { 1581 {
1582 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1583 return;
1584
1443 Primitive.TextureEntry tex = part.Shape.Textures; 1585 Primitive.TextureEntry tex = part.Shape.Textures;
1444 if (face >= 0 && face < GetNumberOfSides(part)) 1586 if (face >= 0 && face < GetNumberOfSides(part))
1445 { 1587 {
@@ -1465,6 +1607,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1465 1607
1466 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1608 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1467 { 1609 {
1610 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1611 return;
1468 1612
1469 Shininess sval = new Shininess(); 1613 Shininess sval = new Shininess();
1470 1614
@@ -1515,6 +1659,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1515 1659
1516 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1660 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1517 { 1661 {
1662 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1663 return;
1664
1518 Primitive.TextureEntry tex = part.Shape.Textures; 1665 Primitive.TextureEntry tex = part.Shape.Textures;
1519 if (face >= 0 && face < GetNumberOfSides(part)) 1666 if (face >= 0 && face < GetNumberOfSides(part))
1520 { 1667 {
@@ -1575,13 +1722,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1575 m_host.AddScriptLPS(1); 1722 m_host.AddScriptLPS(1);
1576 1723
1577 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1724 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1578 1725 if (parts.Count > 0)
1579 foreach (SceneObjectPart part in parts) 1726 {
1580 SetAlpha(part, alpha, face); 1727 try
1728 {
1729 parts[0].ParentGroup.areUpdatesSuspended = true;
1730 foreach (SceneObjectPart part in parts)
1731 SetAlpha(part, alpha, face);
1732 }
1733 finally
1734 {
1735 parts[0].ParentGroup.areUpdatesSuspended = false;
1736 }
1737 }
1581 } 1738 }
1582 1739
1583 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1740 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1584 { 1741 {
1742 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1743 return;
1744
1585 Primitive.TextureEntry tex = part.Shape.Textures; 1745 Primitive.TextureEntry tex = part.Shape.Textures;
1586 Color4 texcolor; 1746 Color4 texcolor;
1587 if (face >= 0 && face < GetNumberOfSides(part)) 1747 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1627,7 +1787,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1627 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1787 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1628 float wind, float tension, LSL_Vector Force) 1788 float wind, float tension, LSL_Vector Force)
1629 { 1789 {
1630 if (part == null) 1790 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1631 return; 1791 return;
1632 1792
1633 if (flexi) 1793 if (flexi)
@@ -1662,7 +1822,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1662 /// <param name="falloff"></param> 1822 /// <param name="falloff"></param>
1663 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1823 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1664 { 1824 {
1665 if (part == null) 1825 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1666 return; 1826 return;
1667 1827
1668 if (light) 1828 if (light)
@@ -1739,15 +1899,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1739 m_host.AddScriptLPS(1); 1899 m_host.AddScriptLPS(1);
1740 1900
1741 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1901 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1742 1902 if (parts.Count > 0)
1743 foreach (SceneObjectPart part in parts) 1903 {
1744 SetTexture(part, texture, face); 1904 try
1745 1905 {
1906 parts[0].ParentGroup.areUpdatesSuspended = true;
1907 foreach (SceneObjectPart part in parts)
1908 SetTexture(part, texture, face);
1909 }
1910 finally
1911 {
1912 parts[0].ParentGroup.areUpdatesSuspended = false;
1913 }
1914 }
1746 ScriptSleep(200); 1915 ScriptSleep(200);
1747 } 1916 }
1748 1917
1749 protected void SetTexture(SceneObjectPart part, string texture, int face) 1918 protected void SetTexture(SceneObjectPart part, string texture, int face)
1750 { 1919 {
1920 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1921 return;
1922
1751 UUID textureID=new UUID(); 1923 UUID textureID=new UUID();
1752 1924
1753 if (!UUID.TryParse(texture, out textureID)) 1925 if (!UUID.TryParse(texture, out textureID))
@@ -1793,6 +1965,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1793 1965
1794 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1966 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1795 { 1967 {
1968 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1969 return;
1970
1796 Primitive.TextureEntry tex = part.Shape.Textures; 1971 Primitive.TextureEntry tex = part.Shape.Textures;
1797 if (face >= 0 && face < GetNumberOfSides(part)) 1972 if (face >= 0 && face < GetNumberOfSides(part))
1798 { 1973 {
@@ -1829,6 +2004,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1829 2004
1830 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 2005 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1831 { 2006 {
2007 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2008 return;
2009
1832 Primitive.TextureEntry tex = part.Shape.Textures; 2010 Primitive.TextureEntry tex = part.Shape.Textures;
1833 if (face >= 0 && face < GetNumberOfSides(part)) 2011 if (face >= 0 && face < GetNumberOfSides(part))
1834 { 2012 {
@@ -1865,6 +2043,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1865 2043
1866 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 2044 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1867 { 2045 {
2046 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2047 return;
2048
1868 Primitive.TextureEntry tex = part.Shape.Textures; 2049 Primitive.TextureEntry tex = part.Shape.Textures;
1869 if (face >= 0 && face < GetNumberOfSides(part)) 2050 if (face >= 0 && face < GetNumberOfSides(part))
1870 { 2051 {
@@ -1935,6 +2116,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1935 2116
1936 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 2117 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
1937 { 2118 {
2119 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2120 return;
2121
1938 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2122 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1939 LSL_Vector currentPos = GetPartLocalPos(part); 2123 LSL_Vector currentPos = GetPartLocalPos(part);
1940 2124
@@ -1951,7 +2135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1951 } 2135 }
1952 else 2136 else
1953 { 2137 {
1954 LSL_Vector rel_vec = SetPosAdjust(currentPos, targetPos); 2138 LSL_Vector rel_vec = SetPosAdjust(new LSL_Vector(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z), targetPos);
1955 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); 2139 part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
1956 SceneObjectGroup parent = part.ParentGroup; 2140 SceneObjectGroup parent = part.ParentGroup;
1957 parent.HasGroupChanged = true; 2141 parent.HasGroupChanged = true;
@@ -2003,9 +2187,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2003 m_host.AddScriptLPS(1); 2187 m_host.AddScriptLPS(1);
2004 2188
2005 // try to let this work as in SL... 2189 // try to let this work as in SL...
2006 if (m_host.ParentID == 0) 2190 if (m_host.LinkNum < 2)
2007 { 2191 {
2008 // special case: If we are root, rotate complete SOG to new rotation 2192 // Special case: If we are root, rotate complete SOG to new
2193 // rotation.
2194 // We are root if the link number is 0 (single prim) or 1
2195 // (root prim). ParentID may be nonzero in attachments and
2196 // using it would cause attachments and HUDs to rotate
2197 // to the wrong positions.
2009 SetRot(m_host, Rot2Quaternion(rot)); 2198 SetRot(m_host, Rot2Quaternion(rot));
2010 } 2199 }
2011 else 2200 else
@@ -2034,6 +2223,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2034 2223
2035 protected void SetRot(SceneObjectPart part, Quaternion rot) 2224 protected void SetRot(SceneObjectPart part, Quaternion rot)
2036 { 2225 {
2226 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2227 return;
2228
2037 part.UpdateRotation(rot); 2229 part.UpdateRotation(rot);
2038 // Update rotation does not move the object in the physics scene if it's a linkset. 2230 // Update rotation does not move the object in the physics scene if it's a linkset.
2039 2231
@@ -2653,12 +2845,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2653 2845
2654 m_host.AddScriptLPS(1); 2846 m_host.AddScriptLPS(1);
2655 2847
2848 m_host.TaskInventory.LockItemsForRead(true);
2656 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2849 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2657 2850 m_host.TaskInventory.LockItemsForRead(false);
2658 lock (m_host.TaskInventory)
2659 {
2660 item = m_host.TaskInventory[invItemID];
2661 }
2662 2851
2663 if (item.PermsGranter == UUID.Zero) 2852 if (item.PermsGranter == UUID.Zero)
2664 return 0; 2853 return 0;
@@ -2733,6 +2922,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2733 if (dist > m_ScriptDistanceFactor * 10.0f) 2922 if (dist > m_ScriptDistanceFactor * 10.0f)
2734 return; 2923 return;
2735 2924
2925 //Clone is thread-safe
2736 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2926 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2737 2927
2738 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2928 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2795,6 +2985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2795 2985
2796 public void llLookAt(LSL_Vector target, double strength, double damping) 2986 public void llLookAt(LSL_Vector target, double strength, double damping)
2797 { 2987 {
2988 /*
2798 m_host.AddScriptLPS(1); 2989 m_host.AddScriptLPS(1);
2799 // Determine where we are looking from 2990 // Determine where we are looking from
2800 LSL_Vector from = llGetPos(); 2991 LSL_Vector from = llGetPos();
@@ -2814,10 +3005,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2814 // the angles of rotation in radians into rotation value 3005 // the angles of rotation in radians into rotation value
2815 3006
2816 LSL_Types.Quaternion rot = llEuler2Rot(angle); 3007 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2817 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 3008
2818 m_host.startLookAt(rotation, (float)damping, (float)strength); 3009 // This would only work if your physics system contains an APID controller:
3010 // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
3011 // m_host.startLookAt(rotation, (float)damping, (float)strength);
3012
2819 // Orient the object to the angle calculated 3013 // Orient the object to the angle calculated
2820 //llSetRot(rot); 3014 llSetRot(rot);
3015 */
3016
3017 //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object.
3018 //There's probably a smarter way of doing this, my rotation math-fu is weak.
3019 // http://bugs.meta7.com/view.php?id=28
3020 // - Tom
3021
3022 LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d));
3023 llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos()));
3024
3025 }
3026
3027 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3028 {
3029 m_host.AddScriptLPS(1);
3030// NotImplemented("llRotLookAt");
3031 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
3032
2821 } 3033 }
2822 3034
2823 public void llStopLookAt() 3035 public void llStopLookAt()
@@ -2866,13 +3078,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2866 { 3078 {
2867 TaskInventoryItem item; 3079 TaskInventoryItem item;
2868 3080
2869 lock (m_host.TaskInventory) 3081 m_host.TaskInventory.LockItemsForRead(true);
3082 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2870 { 3083 {
2871 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3084 m_host.TaskInventory.LockItemsForRead(false);
2872 return; 3085 return;
2873 else 3086 }
2874 item = m_host.TaskInventory[InventorySelf()]; 3087 else
3088 {
3089 item = m_host.TaskInventory[InventorySelf()];
2875 } 3090 }
3091 m_host.TaskInventory.LockItemsForRead(false);
2876 3092
2877 if (item.PermsGranter != UUID.Zero) 3093 if (item.PermsGranter != UUID.Zero)
2878 { 3094 {
@@ -2894,13 +3110,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2894 { 3110 {
2895 TaskInventoryItem item; 3111 TaskInventoryItem item;
2896 3112
3113 m_host.TaskInventory.LockItemsForRead(true);
2897 lock (m_host.TaskInventory) 3114 lock (m_host.TaskInventory)
2898 { 3115 {
3116
2899 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3117 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3118 {
3119 m_host.TaskInventory.LockItemsForRead(false);
2900 return; 3120 return;
3121 }
2901 else 3122 else
3123 {
2902 item = m_host.TaskInventory[InventorySelf()]; 3124 item = m_host.TaskInventory[InventorySelf()];
3125 }
2903 } 3126 }
3127 m_host.TaskInventory.LockItemsForRead(false);
2904 3128
2905 m_host.AddScriptLPS(1); 3129 m_host.AddScriptLPS(1);
2906 3130
@@ -2932,19 +3156,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2932 { 3156 {
2933 m_host.AddScriptLPS(1); 3157 m_host.AddScriptLPS(1);
2934 3158
2935 if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
2936 return;
2937
2938 TaskInventoryItem item; 3159 TaskInventoryItem item;
2939 3160
2940 lock (m_host.TaskInventory) 3161 m_host.TaskInventory.LockItemsForRead(true);
3162
3163 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2941 { 3164 {
2942 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3165 m_host.TaskInventory.LockItemsForRead(false);
2943 return; 3166 return;
2944 else 3167 }
2945 item = m_host.TaskInventory[InventorySelf()]; 3168 else
3169 {
3170 item = m_host.TaskInventory[InventorySelf()];
2946 } 3171 }
2947 3172
3173 m_host.TaskInventory.LockItemsForRead(false);
3174
2948 if (item.PermsGranter != m_host.OwnerID) 3175 if (item.PermsGranter != m_host.OwnerID)
2949 return; 3176 return;
2950 3177
@@ -2954,10 +3181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2954 3181
2955 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3182 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
2956 3183
2957 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3184 grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false);
2958 if (attachmentsModule != null)
2959 attachmentsModule.AttachObject(presence.ControllingClient,
2960 grp, (uint)attachment, false);
2961 } 3185 }
2962 } 3186 }
2963 3187
@@ -2970,13 +3194,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2970 3194
2971 TaskInventoryItem item; 3195 TaskInventoryItem item;
2972 3196
2973 lock (m_host.TaskInventory) 3197 m_host.TaskInventory.LockItemsForRead(true);
3198
3199 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2974 { 3200 {
2975 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3201 m_host.TaskInventory.LockItemsForRead(false);
2976 return; 3202 return;
2977 else
2978 item = m_host.TaskInventory[InventorySelf()];
2979 } 3203 }
3204 else
3205 {
3206 item = m_host.TaskInventory[InventorySelf()];
3207 }
3208 m_host.TaskInventory.LockItemsForRead(false);
3209
2980 3210
2981 if (item.PermsGranter != m_host.OwnerID) 3211 if (item.PermsGranter != m_host.OwnerID)
2982 return; 3212 return;
@@ -3023,6 +3253,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3023 3253
3024 public void llInstantMessage(string user, string message) 3254 public void llInstantMessage(string user, string message)
3025 { 3255 {
3256 UUID result;
3257 if (!UUID.TryParse(user, out result))
3258 {
3259 ShoutError("An invalid key was passed to llInstantMessage");
3260 ScriptSleep(2000);
3261 return;
3262 }
3263
3264
3026 m_host.AddScriptLPS(1); 3265 m_host.AddScriptLPS(1);
3027 3266
3028 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3267 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -3037,14 +3276,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3037 UUID friendTransactionID = UUID.Random(); 3276 UUID friendTransactionID = UUID.Random();
3038 3277
3039 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3278 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
3040 3279
3041 GridInstantMessage msg = new GridInstantMessage(); 3280 GridInstantMessage msg = new GridInstantMessage();
3042 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3281 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
3043 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3282 msg.toAgentID = new Guid(user); // toAgentID.Guid;
3044 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 3283 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
3045// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 3284// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
3046// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 3285// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
3047 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 3286 DateTime dt = DateTime.UtcNow;
3287
3288 // Ticks from UtcNow, but make it look like local. Evil, huh?
3289 dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
3290
3291 try
3292 {
3293 // Convert that to the PST timezone
3294 TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
3295 dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
3296 }
3297 catch
3298 {
3299 // No logging here, as it could be VERY spammy
3300 }
3301
3302 // And make it look local again to fool the unix time util
3303 dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
3304
3305 msg.timestamp = (uint)Util.ToUnixTime(dt);
3306
3048 //if (client != null) 3307 //if (client != null)
3049 //{ 3308 //{
3050 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; 3309 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
@@ -3058,13 +3317,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3058 msg.message = message.Substring(0, 1024); 3317 msg.message = message.Substring(0, 1024);
3059 else 3318 else
3060 msg.message = message; 3319 msg.message = message;
3061 msg.dialog = (byte)19; // messgage from script ??? // dialog; 3320 msg.dialog = (byte)19; // MessageFromObject
3062 msg.fromGroup = false;// fromGroup; 3321 msg.fromGroup = false;// fromGroup;
3063 msg.offline = (byte)0; //offline; 3322 msg.offline = (byte)0; //offline;
3064 msg.ParentEstateID = 0; //ParentEstateID; 3323 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3065 msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); 3324 msg.Position = new Vector3(m_host.AbsolutePosition);
3066 msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; 3325 msg.RegionID = World.RegionInfo.RegionID.Guid;
3067 msg.binaryBucket = new byte[0];// binaryBucket; 3326 msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString());
3068 3327
3069 if (m_TransferModule != null) 3328 if (m_TransferModule != null)
3070 { 3329 {
@@ -3084,7 +3343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3084 } 3343 }
3085 3344
3086 emailModule.SendEmail(m_host.UUID, address, subject, message); 3345 emailModule.SendEmail(m_host.UUID, address, subject, message);
3087 ScriptSleep(20000); 3346 ScriptSleep(15000);
3088 } 3347 }
3089 3348
3090 public void llGetNextEmail(string address, string subject) 3349 public void llGetNextEmail(string address, string subject)
@@ -3186,13 +3445,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3186 m_host.AddScriptLPS(1); 3445 m_host.AddScriptLPS(1);
3187 } 3446 }
3188 3447
3189 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3190 {
3191 m_host.AddScriptLPS(1);
3192 Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
3193 m_host.RotLookAt(rot, (float)strength, (float)damping);
3194 }
3195
3196 public LSL_Integer llStringLength(string str) 3448 public LSL_Integer llStringLength(string str)
3197 { 3449 {
3198 m_host.AddScriptLPS(1); 3450 m_host.AddScriptLPS(1);
@@ -3216,14 +3468,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3216 3468
3217 TaskInventoryItem item; 3469 TaskInventoryItem item;
3218 3470
3219 lock (m_host.TaskInventory) 3471 m_host.TaskInventory.LockItemsForRead(true);
3472 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3220 { 3473 {
3221 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3474 m_host.TaskInventory.LockItemsForRead(false);
3222 return; 3475 return;
3223 else
3224 item = m_host.TaskInventory[InventorySelf()];
3225 } 3476 }
3226 3477 else
3478 {
3479 item = m_host.TaskInventory[InventorySelf()];
3480 }
3481 m_host.TaskInventory.LockItemsForRead(false);
3227 if (item.PermsGranter == UUID.Zero) 3482 if (item.PermsGranter == UUID.Zero)
3228 return; 3483 return;
3229 3484
@@ -3253,13 +3508,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3253 3508
3254 TaskInventoryItem item; 3509 TaskInventoryItem item;
3255 3510
3256 lock (m_host.TaskInventory) 3511 m_host.TaskInventory.LockItemsForRead(true);
3512 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3257 { 3513 {
3258 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3514 m_host.TaskInventory.LockItemsForRead(false);
3259 return; 3515 return;
3260 else 3516 }
3261 item = m_host.TaskInventory[InventorySelf()]; 3517 else
3518 {
3519 item = m_host.TaskInventory[InventorySelf()];
3262 } 3520 }
3521 m_host.TaskInventory.LockItemsForRead(false);
3522
3263 3523
3264 if (item.PermsGranter == UUID.Zero) 3524 if (item.PermsGranter == UUID.Zero)
3265 return; 3525 return;
@@ -3330,10 +3590,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3330 3590
3331 TaskInventoryItem item; 3591 TaskInventoryItem item;
3332 3592
3333 lock (m_host.TaskInventory) 3593
3594 m_host.TaskInventory.LockItemsForRead(true);
3595 if (!m_host.TaskInventory.ContainsKey(invItemID))
3596 {
3597 m_host.TaskInventory.LockItemsForRead(false);
3598 return;
3599 }
3600 else
3334 { 3601 {
3335 item = m_host.TaskInventory[invItemID]; 3602 item = m_host.TaskInventory[invItemID];
3336 } 3603 }
3604 m_host.TaskInventory.LockItemsForRead(false);
3337 3605
3338 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3606 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3339 { 3607 {
@@ -3365,11 +3633,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3365 3633
3366 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3634 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3367 { 3635 {
3368 lock (m_host.TaskInventory) 3636 m_host.TaskInventory.LockItemsForWrite(true);
3369 { 3637 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3370 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3638 m_host.TaskInventory[invItemID].PermsMask = perm;
3371 m_host.TaskInventory[invItemID].PermsMask = perm; 3639 m_host.TaskInventory.LockItemsForWrite(false);
3372 }
3373 3640
3374 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3641 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3375 "run_time_permissions", new Object[] { 3642 "run_time_permissions", new Object[] {
@@ -3389,11 +3656,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3389 3656
3390 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3657 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3391 { 3658 {
3392 lock (m_host.TaskInventory) 3659 m_host.TaskInventory.LockItemsForWrite(true);
3393 { 3660 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3394 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3661 m_host.TaskInventory[invItemID].PermsMask = perm;
3395 m_host.TaskInventory[invItemID].PermsMask = perm; 3662 m_host.TaskInventory.LockItemsForWrite(false);
3396 }
3397 3663
3398 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3664 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3399 "run_time_permissions", new Object[] { 3665 "run_time_permissions", new Object[] {
@@ -3414,11 +3680,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3414 3680
3415 if (!m_waitingForScriptAnswer) 3681 if (!m_waitingForScriptAnswer)
3416 { 3682 {
3417 lock (m_host.TaskInventory) 3683 m_host.TaskInventory.LockItemsForWrite(true);
3418 { 3684 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3419 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3685 m_host.TaskInventory[invItemID].PermsMask = 0;
3420 m_host.TaskInventory[invItemID].PermsMask = 0; 3686 m_host.TaskInventory.LockItemsForWrite(false);
3421 }
3422 3687
3423 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3688 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3424 m_waitingForScriptAnswer=true; 3689 m_waitingForScriptAnswer=true;
@@ -3453,10 +3718,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3453 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3718 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3454 llReleaseControls(); 3719 llReleaseControls();
3455 3720
3456 lock (m_host.TaskInventory) 3721
3457 { 3722 m_host.TaskInventory.LockItemsForWrite(true);
3458 m_host.TaskInventory[invItemID].PermsMask = answer; 3723 m_host.TaskInventory[invItemID].PermsMask = answer;
3459 } 3724 m_host.TaskInventory.LockItemsForWrite(false);
3725
3460 3726
3461 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3727 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3462 "run_time_permissions", new Object[] { 3728 "run_time_permissions", new Object[] {
@@ -3468,16 +3734,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3468 { 3734 {
3469 m_host.AddScriptLPS(1); 3735 m_host.AddScriptLPS(1);
3470 3736
3471 lock (m_host.TaskInventory) 3737 m_host.TaskInventory.LockItemsForRead(true);
3738
3739 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3472 { 3740 {
3473 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3741 if (item.Type == 10 && item.ItemID == m_itemID)
3474 { 3742 {
3475 if (item.Type == 10 && item.ItemID == m_itemID) 3743 m_host.TaskInventory.LockItemsForRead(false);
3476 { 3744 return item.PermsGranter.ToString();
3477 return item.PermsGranter.ToString();
3478 }
3479 } 3745 }
3480 } 3746 }
3747 m_host.TaskInventory.LockItemsForRead(false);
3481 3748
3482 return UUID.Zero.ToString(); 3749 return UUID.Zero.ToString();
3483 } 3750 }
@@ -3486,19 +3753,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3486 { 3753 {
3487 m_host.AddScriptLPS(1); 3754 m_host.AddScriptLPS(1);
3488 3755
3489 lock (m_host.TaskInventory) 3756 m_host.TaskInventory.LockItemsForRead(true);
3757
3758 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3490 { 3759 {
3491 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3760 if (item.Type == 10 && item.ItemID == m_itemID)
3492 { 3761 {
3493 if (item.Type == 10 && item.ItemID == m_itemID) 3762 int perms = item.PermsMask;
3494 { 3763 if (m_automaticLinkPermission)
3495 int perms = item.PermsMask; 3764 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3496 if (m_automaticLinkPermission) 3765 m_host.TaskInventory.LockItemsForRead(false);
3497 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3766 return perms;
3498 return perms;
3499 }
3500 } 3767 }
3501 } 3768 }
3769 m_host.TaskInventory.LockItemsForRead(false);
3502 3770
3503 return 0; 3771 return 0;
3504 } 3772 }
@@ -3520,9 +3788,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3520 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3788 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3521 { 3789 {
3522 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3790 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3523 3791 if (parts.Count > 0)
3524 foreach (SceneObjectPart part in parts) 3792 {
3525 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3793 try
3794 {
3795 parts[0].ParentGroup.areUpdatesSuspended = true;
3796 foreach (SceneObjectPart part in parts)
3797 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
3798 }
3799 finally
3800 {
3801 parts[0].ParentGroup.areUpdatesSuspended = false;
3802 }
3803 }
3526 } 3804 }
3527 3805
3528 public void llCreateLink(string target, int parent) 3806 public void llCreateLink(string target, int parent)
@@ -3535,11 +3813,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3535 return; 3813 return;
3536 3814
3537 TaskInventoryItem item; 3815 TaskInventoryItem item;
3538 lock (m_host.TaskInventory) 3816 m_host.TaskInventory.LockItemsForRead(true);
3539 { 3817 item = m_host.TaskInventory[invItemID];
3540 item = m_host.TaskInventory[invItemID]; 3818 m_host.TaskInventory.LockItemsForRead(false);
3541 } 3819
3542
3543 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3820 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3544 && !m_automaticLinkPermission) 3821 && !m_automaticLinkPermission)
3545 { 3822 {
@@ -3560,7 +3837,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3560 3837
3561 if (targetPart != null) 3838 if (targetPart != null)
3562 { 3839 {
3563 if (parent != 0) { 3840 if (parent != 0)
3841 {
3564 parentPrim = m_host.ParentGroup; 3842 parentPrim = m_host.ParentGroup;
3565 childPrim = targetPart.ParentGroup; 3843 childPrim = targetPart.ParentGroup;
3566 } 3844 }
@@ -3592,16 +3870,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3592 m_host.AddScriptLPS(1); 3870 m_host.AddScriptLPS(1);
3593 UUID invItemID = InventorySelf(); 3871 UUID invItemID = InventorySelf();
3594 3872
3595 lock (m_host.TaskInventory) 3873 m_host.TaskInventory.LockItemsForRead(true);
3596 {
3597 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3874 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3598 && !m_automaticLinkPermission) 3875 && !m_automaticLinkPermission)
3599 { 3876 {
3600 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3877 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3878 m_host.TaskInventory.LockItemsForRead(false);
3601 return; 3879 return;
3602 } 3880 }
3603 } 3881 m_host.TaskInventory.LockItemsForRead(false);
3604 3882
3605 if (linknum < ScriptBaseClass.LINK_THIS) 3883 if (linknum < ScriptBaseClass.LINK_THIS)
3606 return; 3884 return;
3607 3885
@@ -3640,10 +3918,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3640 // Restructuring Multiple Prims. 3918 // Restructuring Multiple Prims.
3641 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); 3919 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts);
3642 parts.Remove(parentPrim.RootPart); 3920 parts.Remove(parentPrim.RootPart);
3643 foreach (SceneObjectPart part in parts) 3921 if (parts.Count > 0)
3644 { 3922 {
3645 parentPrim.DelinkFromGroup(part.LocalId, true); 3923 try
3924 {
3925 parts[0].ParentGroup.areUpdatesSuspended = true;
3926 foreach (SceneObjectPart part in parts)
3927 {
3928 parentPrim.DelinkFromGroup(part.LocalId, true);
3929 }
3930 }
3931 finally
3932 {
3933 parts[0].ParentGroup.areUpdatesSuspended = false;
3934 }
3646 } 3935 }
3936
3647 parentPrim.HasGroupChanged = true; 3937 parentPrim.HasGroupChanged = true;
3648 parentPrim.ScheduleGroupForFullUpdate(); 3938 parentPrim.ScheduleGroupForFullUpdate();
3649 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3939 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3652,11 +3942,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3652 { 3942 {
3653 SceneObjectPart newRoot = parts[0]; 3943 SceneObjectPart newRoot = parts[0];
3654 parts.Remove(newRoot); 3944 parts.Remove(newRoot);
3655 foreach (SceneObjectPart part in parts) 3945
3946 try
3656 { 3947 {
3657 part.UpdateFlag = 0; 3948 parts[0].ParentGroup.areUpdatesSuspended = true;
3658 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 3949 foreach (SceneObjectPart part in parts)
3950 {
3951 part.UpdateFlag = 0;
3952 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
3953 }
3659 } 3954 }
3955 finally
3956 {
3957 parts[0].ParentGroup.areUpdatesSuspended = false;
3958 }
3959
3960
3660 newRoot.ParentGroup.HasGroupChanged = true; 3961 newRoot.ParentGroup.HasGroupChanged = true;
3661 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 3962 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3662 } 3963 }
@@ -3702,6 +4003,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3702 } 4003 }
3703 else 4004 else
3704 { 4005 {
4006 if (linknum > m_host.ParentGroup.PrimCount || (linknum == 1 && m_host.ParentGroup.PrimCount == 1))
4007 {
4008 linknum -= (m_host.ParentGroup.PrimCount) + 1;
4009
4010 if (linknum < 0)
4011 return UUID.Zero.ToString();
4012
4013 List<ScenePresence> avatars = GetLinkAvatars(ScriptBaseClass.LINK_SET);
4014 if (avatars.Count > linknum)
4015 {
4016 return avatars[linknum].UUID.ToString();
4017 }
4018 }
3705 return UUID.Zero.ToString(); 4019 return UUID.Zero.ToString();
3706 } 4020 }
3707 } 4021 }
@@ -3778,17 +4092,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3778 m_host.AddScriptLPS(1); 4092 m_host.AddScriptLPS(1);
3779 int count = 0; 4093 int count = 0;
3780 4094
3781 lock (m_host.TaskInventory) 4095 m_host.TaskInventory.LockItemsForRead(true);
4096 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3782 { 4097 {
3783 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4098 if (inv.Value.Type == type || type == -1)
3784 { 4099 {
3785 if (inv.Value.Type == type || type == -1) 4100 count = count + 1;
3786 {
3787 count = count + 1;
3788 }
3789 } 4101 }
3790 } 4102 }
3791 4103
4104 m_host.TaskInventory.LockItemsForRead(false);
3792 return count; 4105 return count;
3793 } 4106 }
3794 4107
@@ -3797,16 +4110,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3797 m_host.AddScriptLPS(1); 4110 m_host.AddScriptLPS(1);
3798 ArrayList keys = new ArrayList(); 4111 ArrayList keys = new ArrayList();
3799 4112
3800 lock (m_host.TaskInventory) 4113 m_host.TaskInventory.LockItemsForRead(true);
4114 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3801 { 4115 {
3802 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4116 if (inv.Value.Type == type || type == -1)
3803 { 4117 {
3804 if (inv.Value.Type == type || type == -1) 4118 keys.Add(inv.Value.Name);
3805 {
3806 keys.Add(inv.Value.Name);
3807 }
3808 } 4119 }
3809 } 4120 }
4121 m_host.TaskInventory.LockItemsForRead(false);
3810 4122
3811 if (keys.Count == 0) 4123 if (keys.Count == 0)
3812 { 4124 {
@@ -3843,20 +4155,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3843 } 4155 }
3844 4156
3845 // move the first object found with this inventory name 4157 // move the first object found with this inventory name
3846 lock (m_host.TaskInventory) 4158 m_host.TaskInventory.LockItemsForRead(true);
4159 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3847 { 4160 {
3848 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4161 if (inv.Value.Name == inventory)
3849 { 4162 {
3850 if (inv.Value.Name == inventory) 4163 found = true;
3851 { 4164 objId = inv.Key;
3852 found = true; 4165 assetType = inv.Value.Type;
3853 objId = inv.Key; 4166 objName = inv.Value.Name;
3854 assetType = inv.Value.Type; 4167 break;
3855 objName = inv.Value.Name;
3856 break;
3857 }
3858 } 4168 }
3859 } 4169 }
4170 m_host.TaskInventory.LockItemsForRead(false);
3860 4171
3861 if (!found) 4172 if (!found)
3862 { 4173 {
@@ -3864,9 +4175,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3864 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4175 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
3865 } 4176 }
3866 4177
3867 // check if destination is an avatar 4178 // check if destination is an object
3868 if (World.GetScenePresence(destId) != null) 4179 if (World.GetSceneObjectPart(destId) != null)
3869 { 4180 {
4181 // destination is an object
4182 World.MoveTaskInventoryItem(destId, m_host, objId);
4183 }
4184 else
4185 {
4186 ScenePresence presence = World.GetScenePresence(destId);
4187
4188 if (presence == null)
4189 {
4190 UserAccount account =
4191 World.UserAccountService.GetUserAccount(
4192 World.RegionInfo.ScopeID,
4193 destId);
4194
4195 if (account == null)
4196 {
4197 llSay(0, "Can't find destination "+destId.ToString());
4198 return;
4199 }
4200 }
4201
3870 // destination is an avatar 4202 // destination is an avatar
3871 InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4203 InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
3872 4204
@@ -3890,31 +4222,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3890 4222
3891 if (m_TransferModule != null) 4223 if (m_TransferModule != null)
3892 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 4224 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
4225
4226 //This delay should only occur when giving inventory to avatars.
4227 ScriptSleep(3000);
3893 } 4228 }
3894 else
3895 {
3896 // destination is an object
3897 World.MoveTaskInventoryItem(destId, m_host, objId);
3898 }
3899 ScriptSleep(3000);
3900 } 4229 }
3901 4230
4231 [DebuggerNonUserCode]
3902 public void llRemoveInventory(string name) 4232 public void llRemoveInventory(string name)
3903 { 4233 {
3904 m_host.AddScriptLPS(1); 4234 m_host.AddScriptLPS(1);
3905 4235
3906 lock (m_host.TaskInventory) 4236 List<TaskInventoryItem> inv;
4237 try
3907 { 4238 {
3908 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4239 m_host.TaskInventory.LockItemsForRead(true);
4240 inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values);
4241 }
4242 finally
4243 {
4244 m_host.TaskInventory.LockItemsForRead(false);
4245 }
4246 foreach (TaskInventoryItem item in inv)
4247 {
4248 if (item.Name == name)
3909 { 4249 {
3910 if (item.Name == name) 4250 if (item.ItemID == m_itemID)
3911 { 4251 throw new ScriptDeleteException();
3912 if (item.ItemID == m_itemID) 4252 else
3913 throw new ScriptDeleteException(); 4253 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3914 else 4254 return;
3915 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3916 return;
3917 }
3918 } 4255 }
3919 } 4256 }
3920 } 4257 }
@@ -3980,6 +4317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3980 ce.time = Util.EnvironmentTickCount(); 4317 ce.time = Util.EnvironmentTickCount();
3981 ce.account = account; 4318 ce.account = account;
3982 ce.pinfo = pinfo; 4319 ce.pinfo = pinfo;
4320 m_userInfoCache[uuid] = ce;
3983 } 4321 }
3984 else 4322 else
3985 { 4323 {
@@ -4055,6 +4393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4055 { 4393 {
4056 m_host.AddScriptLPS(1); 4394 m_host.AddScriptLPS(1);
4057 4395
4396 //Clone is thread safe
4058 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 4397 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
4059 4398
4060 foreach (TaskInventoryItem item in itemDictionary.Values) 4399 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -4108,6 +4447,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4108 ScenePresence presence = World.GetScenePresence(agentId); 4447 ScenePresence presence = World.GetScenePresence(agentId);
4109 if (presence != null) 4448 if (presence != null)
4110 { 4449 {
4450 // agent must not be a god
4451 if (presence.GodLevel >= 200) return;
4452
4111 // agent must be over the owners land 4453 // agent must be over the owners land
4112 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4454 if (m_host.OwnerID == World.LandChannel.GetLandObject(
4113 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 4455 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
@@ -4130,7 +4472,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4130 UUID av = new UUID(); 4472 UUID av = new UUID();
4131 if (!UUID.TryParse(agent,out av)) 4473 if (!UUID.TryParse(agent,out av))
4132 { 4474 {
4133 LSLError("First parameter to llDialog needs to be a key"); 4475 //LSLError("First parameter to llDialog needs to be a key");
4134 return; 4476 return;
4135 } 4477 }
4136 4478
@@ -4167,17 +4509,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4167 UUID soundId = UUID.Zero; 4509 UUID soundId = UUID.Zero;
4168 if (!UUID.TryParse(impact_sound, out soundId)) 4510 if (!UUID.TryParse(impact_sound, out soundId))
4169 { 4511 {
4170 lock (m_host.TaskInventory) 4512 m_host.TaskInventory.LockItemsForRead(true);
4513 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4171 { 4514 {
4172 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4515 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
4173 { 4516 {
4174 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4517 soundId = item.AssetID;
4175 { 4518 break;
4176 soundId = item.AssetID;
4177 break;
4178 }
4179 } 4519 }
4180 } 4520 }
4521 m_host.TaskInventory.LockItemsForRead(false);
4181 } 4522 }
4182 m_host.CollisionSound = soundId; 4523 m_host.CollisionSound = soundId;
4183 m_host.CollisionSoundVolume = (float)impact_volume; 4524 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4223,6 +4564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4223 UUID partItemID; 4564 UUID partItemID;
4224 foreach (SceneObjectPart part in parts) 4565 foreach (SceneObjectPart part in parts)
4225 { 4566 {
4567 //Clone is thread safe
4226 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4568 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4227 4569
4228 foreach (TaskInventoryItem item in itemsDictionary.Values) 4570 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4437,17 +4779,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4437 4779
4438 m_host.AddScriptLPS(1); 4780 m_host.AddScriptLPS(1);
4439 4781
4440 lock (m_host.TaskInventory) 4782 m_host.TaskInventory.LockItemsForRead(true);
4783 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4441 { 4784 {
4442 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4785 if (item.Type == 10 && item.ItemID == m_itemID)
4443 { 4786 {
4444 if (item.Type == 10 && item.ItemID == m_itemID) 4787 result = item.Name!=null?item.Name:String.Empty;
4445 { 4788 break;
4446 result = item.Name != null ? item.Name : String.Empty;
4447 break;
4448 }
4449 } 4789 }
4450 } 4790 }
4791 m_host.TaskInventory.LockItemsForRead(false);
4451 4792
4452 return result; 4793 return result;
4453 } 4794 }
@@ -4600,23 +4941,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4600 { 4941 {
4601 m_host.AddScriptLPS(1); 4942 m_host.AddScriptLPS(1);
4602 4943
4603 lock (m_host.TaskInventory) 4944 m_host.TaskInventory.LockItemsForRead(true);
4945 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4604 { 4946 {
4605 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4947 if (inv.Value.Name == name)
4606 { 4948 {
4607 if (inv.Value.Name == name) 4949 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4608 { 4950 {
4609 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 4951 m_host.TaskInventory.LockItemsForRead(false);
4610 { 4952 return inv.Value.AssetID.ToString();
4611 return inv.Value.AssetID.ToString(); 4953 }
4612 } 4954 else
4613 else 4955 {
4614 { 4956 m_host.TaskInventory.LockItemsForRead(false);
4615 return UUID.Zero.ToString(); 4957 return UUID.Zero.ToString();
4616 }
4617 } 4958 }
4618 } 4959 }
4619 } 4960 }
4961 m_host.TaskInventory.LockItemsForRead(false);
4620 4962
4621 return UUID.Zero.ToString(); 4963 return UUID.Zero.ToString();
4622 } 4964 }
@@ -4769,14 +5111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4769 { 5111 {
4770 m_host.AddScriptLPS(1); 5112 m_host.AddScriptLPS(1);
4771 5113
4772 if (src == null) 5114 return src.Length;
4773 {
4774 return 0;
4775 }
4776 else
4777 {
4778 return src.Length;
4779 }
4780 } 5115 }
4781 5116
4782 public LSL_Integer llList2Integer(LSL_List src, int index) 5117 public LSL_Integer llList2Integer(LSL_List src, int index)
@@ -4822,7 +5157,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4822 else if (src.Data[index] is LSL_Float) 5157 else if (src.Data[index] is LSL_Float)
4823 return Convert.ToDouble(((LSL_Float) src.Data[index]).value); 5158 return Convert.ToDouble(((LSL_Float) src.Data[index]).value);
4824 else if (src.Data[index] is LSL_String) 5159 else if (src.Data[index] is LSL_String)
4825 return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); 5160 {
5161 string str = ((LSL_String) src.Data[index]).m_string;
5162 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)");
5163 if (m != Match.Empty)
5164 {
5165 str = m.Value;
5166 double d = 0.0;
5167 if (!Double.TryParse(str, out d))
5168 return 0.0;
5169
5170 return d;
5171 }
5172 return 0.0;
5173 }
4826 return Convert.ToDouble(src.Data[index]); 5174 return Convert.ToDouble(src.Data[index]);
4827 } 5175 }
4828 catch (FormatException) 5176 catch (FormatException)
@@ -5095,7 +5443,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5095 } 5443 }
5096 } 5444 }
5097 } 5445 }
5098 else { 5446 else
5447 {
5099 object[] array = new object[src.Length]; 5448 object[] array = new object[src.Length];
5100 Array.Copy(src.Data, 0, array, 0, src.Length); 5449 Array.Copy(src.Data, 0, array, 0, src.Length);
5101 result = new LSL_List(array); 5450 result = new LSL_List(array);
@@ -5507,7 +5856,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5507 public void llSetSoundQueueing(int queue) 5856 public void llSetSoundQueueing(int queue)
5508 { 5857 {
5509 m_host.AddScriptLPS(1); 5858 m_host.AddScriptLPS(1);
5510 NotImplemented("llSetSoundQueueing");
5511 } 5859 }
5512 5860
5513 public void llSetSoundRadius(double radius) 5861 public void llSetSoundRadius(double radius)
@@ -5552,10 +5900,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5552 m_host.AddScriptLPS(1); 5900 m_host.AddScriptLPS(1);
5553 5901
5554 List<SceneObjectPart> parts = GetLinkParts(linknumber); 5902 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5555 5903 if (parts.Count > 0)
5556 foreach (var part in parts)
5557 { 5904 {
5558 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 5905 try
5906 {
5907 parts[0].ParentGroup.areUpdatesSuspended = true;
5908 foreach (var part in parts)
5909 {
5910 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
5911 }
5912 }
5913 finally
5914 {
5915 parts[0].ParentGroup.areUpdatesSuspended = false;
5916 }
5559 } 5917 }
5560 } 5918 }
5561 5919
@@ -5609,6 +5967,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5609 ScriptSleep(5000); 5967 ScriptSleep(5000);
5610 } 5968 }
5611 5969
5970 public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers)
5971 {
5972 return ParseString2List(str, separators, in_spacers, false);
5973 }
5974
5612 public LSL_Integer llOverMyLand(string id) 5975 public LSL_Integer llOverMyLand(string id)
5613 { 5976 {
5614 m_host.AddScriptLPS(1); 5977 m_host.AddScriptLPS(1);
@@ -5809,7 +6172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5809 return m_host.ParentGroup.RootPart.AttachmentPoint; 6172 return m_host.ParentGroup.RootPart.AttachmentPoint;
5810 } 6173 }
5811 6174
5812 public LSL_Integer llGetFreeMemory() 6175 public virtual LSL_Integer llGetFreeMemory()
5813 { 6176 {
5814 m_host.AddScriptLPS(1); 6177 m_host.AddScriptLPS(1);
5815 // Make scripts designed for LSO happy 6178 // Make scripts designed for LSO happy
@@ -5926,7 +6289,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5926 SetParticleSystem(m_host, rules); 6289 SetParticleSystem(m_host, rules);
5927 } 6290 }
5928 6291
5929 private void SetParticleSystem(SceneObjectPart part, LSL_List rules) { 6292 private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
6293 {
5930 6294
5931 6295
5932 if (rules.Length == 0) 6296 if (rules.Length == 0)
@@ -6120,14 +6484,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6120 6484
6121 protected UUID GetTaskInventoryItem(string name) 6485 protected UUID GetTaskInventoryItem(string name)
6122 { 6486 {
6123 lock (m_host.TaskInventory) 6487 m_host.TaskInventory.LockItemsForRead(true);
6488 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6124 { 6489 {
6125 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6490 if (inv.Value.Name == name)
6126 { 6491 {
6127 if (inv.Value.Name == name) 6492 m_host.TaskInventory.LockItemsForRead(false);
6128 return inv.Key; 6493 return inv.Key;
6129 } 6494 }
6130 } 6495 }
6496 m_host.TaskInventory.LockItemsForRead(false);
6131 6497
6132 return UUID.Zero; 6498 return UUID.Zero;
6133 } 6499 }
@@ -6368,13 +6734,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6368 UUID av = new UUID(); 6734 UUID av = new UUID();
6369 if (!UUID.TryParse(avatar,out av)) 6735 if (!UUID.TryParse(avatar,out av))
6370 { 6736 {
6371 LSLError("First parameter to llDialog needs to be a key"); 6737 //LSLError("First parameter to llDialog needs to be a key");
6372 return; 6738 return;
6373 } 6739 }
6374 if (buttons.Length < 1) 6740 if (buttons.Length < 1)
6375 { 6741 {
6376 LSLError("No less than 1 button can be shown"); 6742 buttons.Add("OK");
6377 return;
6378 } 6743 }
6379 if (buttons.Length > 12) 6744 if (buttons.Length > 12)
6380 { 6745 {
@@ -6391,7 +6756,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6391 } 6756 }
6392 if (buttons.Data[i].ToString().Length > 24) 6757 if (buttons.Data[i].ToString().Length > 24)
6393 { 6758 {
6394 LSLError("button label cannot be longer than 24 characters"); 6759 llWhisper(ScriptBaseClass.DEBUG_CHANNEL, "button label cannot be longer than 24 characters");
6395 return; 6760 return;
6396 } 6761 }
6397 buts[i] = buttons.Data[i].ToString(); 6762 buts[i] = buttons.Data[i].ToString();
@@ -6455,22 +6820,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6455 } 6820 }
6456 6821
6457 // copy the first script found with this inventory name 6822 // copy the first script found with this inventory name
6458 lock (m_host.TaskInventory) 6823 m_host.TaskInventory.LockItemsForRead(true);
6824 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6459 { 6825 {
6460 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6826 if (inv.Value.Name == name)
6461 { 6827 {
6462 if (inv.Value.Name == name) 6828 // make sure the object is a script
6829 if (10 == inv.Value.Type)
6463 { 6830 {
6464 // make sure the object is a script 6831 found = true;
6465 if (10 == inv.Value.Type) 6832 srcId = inv.Key;
6466 { 6833 break;
6467 found = true;
6468 srcId = inv.Key;
6469 break;
6470 }
6471 } 6834 }
6472 } 6835 }
6473 } 6836 }
6837 m_host.TaskInventory.LockItemsForRead(false);
6474 6838
6475 if (!found) 6839 if (!found)
6476 { 6840 {
@@ -6554,6 +6918,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6554 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6918 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
6555 { 6919 {
6556 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6920 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6921 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6922 return shapeBlock;
6557 6923
6558 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 6924 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6559 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 6925 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6629,6 +6995,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6629 6995
6630 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) 6996 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
6631 { 6997 {
6998 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6999 return;
7000
6632 ObjectShapePacket.ObjectDataBlock shapeBlock; 7001 ObjectShapePacket.ObjectDataBlock shapeBlock;
6633 7002
6634 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7003 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6678,6 +7047,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6678 7047
6679 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) 7048 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
6680 { 7049 {
7050 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7051 return;
7052
6681 ObjectShapePacket.ObjectDataBlock shapeBlock; 7053 ObjectShapePacket.ObjectDataBlock shapeBlock;
6682 7054
6683 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7055 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6720,6 +7092,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6720 7092
6721 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) 7093 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)
6722 { 7094 {
7095 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7096 return;
7097
6723 ObjectShapePacket.ObjectDataBlock shapeBlock; 7098 ObjectShapePacket.ObjectDataBlock shapeBlock;
6724 7099
6725 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7100 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6846,6 +7221,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6846 7221
6847 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) 7222 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
6848 { 7223 {
7224 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7225 return;
7226
6849 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7227 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6850 UUID sculptId; 7228 UUID sculptId;
6851 7229
@@ -6861,13 +7239,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6861 shapeBlock.PathScaleX = 100; 7239 shapeBlock.PathScaleX = 100;
6862 shapeBlock.PathScaleY = 150; 7240 shapeBlock.PathScaleY = 150;
6863 7241
6864 if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && 7242 if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 &&
6865 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && 7243 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 &&
6866 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && 7244 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 &&
6867 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) 7245 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0)
6868 { 7246 {
6869 // default 7247 // default
6870 type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; 7248 type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE;
6871 } 7249 }
6872 7250
6873 // retain pathcurve 7251 // retain pathcurve
@@ -6886,30 +7264,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6886 ScriptSleep(200); 7264 ScriptSleep(200);
6887 } 7265 }
6888 7266
6889 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7267 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
6890 { 7268 {
6891 m_host.AddScriptLPS(1); 7269 m_host.AddScriptLPS(1);
6892 7270
6893 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7271 List<SceneObjectPart> parts = GetLinkParts(linknumber);
7272 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
7273 if (parts.Count>0)
7274 {
7275 try
7276 {
7277 parts[0].ParentGroup.areUpdatesSuspended = true;
7278 foreach (SceneObjectPart part in parts)
7279 SetPrimParams(part, rules);
7280 }
7281 finally
7282 {
7283 parts[0].ParentGroup.areUpdatesSuspended = false;
7284 }
7285 }
7286 if (avatars.Count > 0)
7287 {
7288 foreach (ScenePresence avatar in avatars)
7289 SetPrimParams(avatar, rules);
7290 }
7291 }
6894 7292
6895 foreach (SceneObjectPart part in parts) 7293 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6896 SetPrimParams(part, rules); 7294 {
6897 7295 llSetLinkPrimitiveParamsFast(linknumber, rules);
6898 ScriptSleep(200); 7296 ScriptSleep(200);
6899 } 7297 }
6900 7298
6901 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7299 protected void SetPrimParams(ScenePresence av, LSL_List rules)
6902 { 7300 {
6903 m_host.AddScriptLPS(1); 7301 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7302 //We only support PRIM_POSITION and PRIM_ROTATION
6904 7303
6905 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7304 int idx = 0;
6906 7305
6907 foreach (SceneObjectPart part in parts) 7306 while (idx < rules.Length)
6908 SetPrimParams(part, rules); 7307 {
7308 int code = rules.GetLSLIntegerItem(idx++);
7309
7310 int remain = rules.Length - idx;
7311
7312
7313
7314 switch (code)
7315 {
7316 case (int)ScriptBaseClass.PRIM_POSITION:
7317 if (remain < 1)
7318 return;
7319 LSL_Vector v;
7320 v = rules.GetVector3Item(idx++);
7321 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7322 av.SendAvatarDataToAllAgents();
7323
7324 break;
7325
7326 case (int)ScriptBaseClass.PRIM_ROTATION:
7327 if (remain < 1)
7328 return;
7329 LSL_Rotation r;
7330 r = rules.GetQuaternionItem(idx++);
7331 av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7332 av.SendAvatarDataToAllAgents();
7333 break;
7334 }
7335 }
6909 } 7336 }
6910 7337
6911 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 7338 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6912 { 7339 {
7340 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7341 return;
7342
6913 int idx = 0; 7343 int idx = 0;
6914 7344
6915 while (idx < rules.Length) 7345 while (idx < rules.Length)
@@ -7444,13 +7874,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7444 public LSL_Integer llGetNumberOfPrims() 7874 public LSL_Integer llGetNumberOfPrims()
7445 { 7875 {
7446 m_host.AddScriptLPS(1); 7876 m_host.AddScriptLPS(1);
7447 int avatarCount = 0; 7877 int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count;
7448 World.ForEachScenePresence(delegate(ScenePresence presence) 7878
7449 {
7450 if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
7451 avatarCount++;
7452 });
7453
7454 return m_host.ParentGroup.PrimCount + avatarCount; 7879 return m_host.ParentGroup.PrimCount + avatarCount;
7455 } 7880 }
7456 7881
@@ -7466,55 +7891,98 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7466 m_host.AddScriptLPS(1); 7891 m_host.AddScriptLPS(1);
7467 UUID objID = UUID.Zero; 7892 UUID objID = UUID.Zero;
7468 LSL_List result = new LSL_List(); 7893 LSL_List result = new LSL_List();
7894
7895 // If the ID is not valid, return null result
7469 if (!UUID.TryParse(obj, out objID)) 7896 if (!UUID.TryParse(obj, out objID))
7470 { 7897 {
7471 result.Add(new LSL_Vector()); 7898 result.Add(new LSL_Vector());
7472 result.Add(new LSL_Vector()); 7899 result.Add(new LSL_Vector());
7473 return result; 7900 return result;
7474 } 7901 }
7902
7903 // Check if this is an attached prim. If so, replace
7904 // the UUID with the avatar UUID and report it's bounding box
7905 SceneObjectPart part = World.GetSceneObjectPart(objID);
7906 if (part != null && part.ParentGroup.IsAttachment)
7907 objID = part.ParentGroup.RootPart.AttachedAvatar;
7908
7909 // Find out if this is an avatar ID. If so, return it's box
7475 ScenePresence presence = World.GetScenePresence(objID); 7910 ScenePresence presence = World.GetScenePresence(objID);
7476 if (presence != null) 7911 if (presence != null)
7477 { 7912 {
7478 if (presence.ParentID == 0) // not sat on an object 7913 // As per LSL Wiki, there is no difference between sitting
7914 // and standing avatar since server 1.36
7915 LSL_Vector lower;
7916 LSL_Vector upper;
7917 if (presence.Animator.Animations.DefaultAnimation.AnimID
7918 == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
7479 { 7919 {
7480 LSL_Vector lower; 7920 // This is for ground sitting avatars
7481 LSL_Vector upper; 7921 float height = presence.Appearance.AvatarHeight / 2.66666667f;
7482 if (presence.Animator.Animations.DefaultAnimation.AnimID 7922 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
7483 == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) 7923 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
7484 {
7485 // This is for ground sitting avatars
7486 float height = presence.Appearance.AvatarHeight / 2.66666667f;
7487 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
7488 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
7489 }
7490 else
7491 {
7492 // This is for standing/flying avatars
7493 float height = presence.Appearance.AvatarHeight / 2.0f;
7494 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
7495 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
7496 }
7497 result.Add(lower);
7498 result.Add(upper);
7499 return result;
7500 } 7924 }
7501 else 7925 else
7502 { 7926 {
7503 // sitting on an object so we need the bounding box of that 7927 // This is for standing/flying avatars
7504 // which should include the avatar so set the UUID to the 7928 float height = presence.Appearance.AvatarHeight / 2.0f;
7505 // UUID of the object the avatar is sat on and allow it to fall through 7929 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
7506 // to processing an object 7930 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
7507 SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID);
7508 objID = p.UUID;
7509 } 7931 }
7932
7933 // Adjust to the documented error offsets (see LSL Wiki)
7934 lower += new LSL_Vector(0.05f, 0.05f, 0.05f);
7935 upper -= new LSL_Vector(0.05f, 0.05f, 0.05f);
7936
7937 if (lower.x > upper.x)
7938 lower.x = upper.x;
7939 if (lower.y > upper.y)
7940 lower.y = upper.y;
7941 if (lower.z > upper.z)
7942 lower.z = upper.z;
7943
7944 result.Add(lower);
7945 result.Add(upper);
7946 return result;
7510 } 7947 }
7511 SceneObjectPart part = World.GetSceneObjectPart(objID); 7948
7949 part = World.GetSceneObjectPart(objID);
7512 // Currently only works for single prims without a sitting avatar 7950 // Currently only works for single prims without a sitting avatar
7513 if (part != null) 7951 if (part != null)
7514 { 7952 {
7515 Vector3 halfSize = part.Scale / 2.0f; 7953 float minX;
7516 LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); 7954 float maxX;
7517 LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); 7955 float minY;
7956 float maxY;
7957 float minZ;
7958 float maxZ;
7959
7960 // This BBox is in sim coordinates, with the offset being
7961 // a contained point.
7962 Vector3[] offsets = World.GetCombinedBoundingBox(new List<SceneObjectGroup> { part.ParentGroup },
7963 out minX, out maxX, out minY, out maxY, out minZ, out maxZ);
7964
7965 minX -= offsets[0].X;
7966 maxX -= offsets[0].X;
7967 minY -= offsets[0].Y;
7968 maxY -= offsets[0].Y;
7969 minZ -= offsets[0].Z;
7970 maxZ -= offsets[0].Z;
7971
7972 LSL_Vector lower;
7973 LSL_Vector upper;
7974
7975 // Adjust to the documented error offsets (see LSL Wiki)
7976 lower = new LSL_Vector(minX + 0.05f, minY + 0.05f, minZ + 0.05f);
7977 upper = new LSL_Vector(maxX - 0.05f, maxY - 0.05f, maxZ - 0.05f);
7978
7979 if (lower.x > upper.x)
7980 lower.x = upper.x;
7981 if (lower.y > upper.y)
7982 lower.y = upper.y;
7983 if (lower.z > upper.z)
7984 lower.z = upper.z;
7985
7518 result.Add(lower); 7986 result.Add(lower);
7519 result.Add(upper); 7987 result.Add(upper);
7520 return result; 7988 return result;
@@ -7594,13 +8062,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7594 LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X, 8062 LSL_Vector v = new LSL_Vector(part.AbsolutePosition.X,
7595 part.AbsolutePosition.Y, 8063 part.AbsolutePosition.Y,
7596 part.AbsolutePosition.Z); 8064 part.AbsolutePosition.Z);
7597 // For some reason, the part.AbsolutePosition.* values do not change if the
7598 // linkset is rotated; they always reflect the child prim's world position
7599 // as though the linkset is unrotated. This is incompatible behavior with SL's
7600 // implementation, so will break scripts imported from there (not to mention it
7601 // makes it more difficult to determine a child prim's actual inworld position).
7602 if (part.ParentID != 0)
7603 v = ((v - llGetRootPosition()) * llGetRootRotation()) + llGetRootPosition();
7604 res.Add(v); 8065 res.Add(v);
7605 break; 8066 break;
7606 8067
@@ -7761,56 +8222,92 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7761 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8222 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7762 if (remain < 1) 8223 if (remain < 1)
7763 return res; 8224 return res;
7764 8225 face = (int)rules.GetLSLIntegerItem(idx++);
7765 face=(int)rules.GetLSLIntegerItem(idx++);
7766 8226
7767 tex = part.Shape.Textures; 8227 tex = part.Shape.Textures;
8228 int shiny;
7768 if (face == ScriptBaseClass.ALL_SIDES) 8229 if (face == ScriptBaseClass.ALL_SIDES)
7769 { 8230 {
7770 for (face = 0; face < GetNumberOfSides(part); face++) 8231 for (face = 0; face < GetNumberOfSides(part); face++)
7771 { 8232 {
7772 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8233 Shininess shinyness = tex.GetFace((uint)face).Shiny;
7773 // Convert Shininess to PRIM_SHINY_* 8234 if (shinyness == Shininess.High)
7774 res.Add(new LSL_Integer((uint)texface.Shiny >> 6)); 8235 {
7775 // PRIM_BUMP_* 8236 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
7776 res.Add(new LSL_Integer((int)texface.Bump)); 8237 }
8238 else if (shinyness == Shininess.Medium)
8239 {
8240 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8241 }
8242 else if (shinyness == Shininess.Low)
8243 {
8244 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8245 }
8246 else
8247 {
8248 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8249 }
8250 res.Add(new LSL_Integer(shiny));
8251 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
7777 } 8252 }
7778 } 8253 }
7779 else 8254 else
7780 { 8255 {
7781 if (face >= 0 && face < GetNumberOfSides(part)) 8256 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8257 if (shinyness == Shininess.High)
7782 { 8258 {
7783 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8259 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
7784 // Convert Shininess to PRIM_SHINY_*
7785 res.Add(new LSL_Integer((uint)texface.Shiny >> 6));
7786 // PRIM_BUMP_*
7787 res.Add(new LSL_Integer((int)texface.Bump));
7788 } 8260 }
8261 else if (shinyness == Shininess.Medium)
8262 {
8263 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8264 }
8265 else if (shinyness == Shininess.Low)
8266 {
8267 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8268 }
8269 else
8270 {
8271 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8272 }
8273 res.Add(new LSL_Integer(shiny));
8274 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
7789 } 8275 }
7790 break; 8276 break;
7791 8277
7792 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8278 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7793 if (remain < 1) 8279 if (remain < 1)
7794 return res; 8280 return res;
7795 8281 face = (int)rules.GetLSLIntegerItem(idx++);
7796 face=(int)rules.GetLSLIntegerItem(idx++);
7797 8282
7798 tex = part.Shape.Textures; 8283 tex = part.Shape.Textures;
8284 int fullbright;
7799 if (face == ScriptBaseClass.ALL_SIDES) 8285 if (face == ScriptBaseClass.ALL_SIDES)
7800 { 8286 {
7801 for (face = 0; face < GetNumberOfSides(part); face++) 8287 for (face = 0; face < GetNumberOfSides(part); face++)
7802 { 8288 {
7803 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8289 if (tex.GetFace((uint)face).Fullbright == true)
7804 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0)); 8290 {
8291 fullbright = ScriptBaseClass.TRUE;
8292 }
8293 else
8294 {
8295 fullbright = ScriptBaseClass.FALSE;
8296 }
8297 res.Add(new LSL_Integer(fullbright));
7805 } 8298 }
7806 } 8299 }
7807 else 8300 else
7808 { 8301 {
7809 if (face >= 0 && face < GetNumberOfSides(part)) 8302 if (tex.GetFace((uint)face).Fullbright == true)
7810 { 8303 {
7811 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8304 fullbright = ScriptBaseClass.TRUE;
7812 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0));
7813 } 8305 }
8306 else
8307 {
8308 fullbright = ScriptBaseClass.FALSE;
8309 }
8310 res.Add(new LSL_Integer(fullbright));
7814 } 8311 }
7815 break; 8312 break;
7816 8313
@@ -7832,27 +8329,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7832 break; 8329 break;
7833 8330
7834 case (int)ScriptBaseClass.PRIM_TEXGEN: 8331 case (int)ScriptBaseClass.PRIM_TEXGEN:
8332 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7835 if (remain < 1) 8333 if (remain < 1)
7836 return res; 8334 return res;
7837 8335 face = (int)rules.GetLSLIntegerItem(idx++);
7838 face=(int)rules.GetLSLIntegerItem(idx++);
7839 8336
7840 tex = part.Shape.Textures; 8337 tex = part.Shape.Textures;
7841 if (face == ScriptBaseClass.ALL_SIDES) 8338 if (face == ScriptBaseClass.ALL_SIDES)
7842 { 8339 {
7843 for (face = 0; face < GetNumberOfSides(part); face++) 8340 for (face = 0; face < GetNumberOfSides(part); face++)
7844 { 8341 {
7845 MappingType texgen = tex.GetFace((uint)face).TexMapType; 8342 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
7846 // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc. 8343 {
7847 res.Add(new LSL_Integer((uint)texgen >> 1)); 8344 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8345 }
8346 else
8347 {
8348 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8349 }
7848 } 8350 }
7849 } 8351 }
7850 else 8352 else
7851 { 8353 {
7852 if (face >= 0 && face < GetNumberOfSides(part)) 8354 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
7853 { 8355 {
7854 MappingType texgen = tex.GetFace((uint)face).TexMapType; 8356 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
7855 res.Add(new LSL_Integer((uint)texgen >> 1)); 8357 }
8358 else
8359 {
8360 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
7856 } 8361 }
7857 } 8362 }
7858 break; 8363 break;
@@ -7875,28 +8380,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7875 case (int)ScriptBaseClass.PRIM_GLOW: 8380 case (int)ScriptBaseClass.PRIM_GLOW:
7876 if (remain < 1) 8381 if (remain < 1)
7877 return res; 8382 return res;
7878 8383 face = (int)rules.GetLSLIntegerItem(idx++);
7879 face=(int)rules.GetLSLIntegerItem(idx++);
7880 8384
7881 tex = part.Shape.Textures; 8385 tex = part.Shape.Textures;
8386 float primglow;
7882 if (face == ScriptBaseClass.ALL_SIDES) 8387 if (face == ScriptBaseClass.ALL_SIDES)
7883 { 8388 {
7884 for (face = 0; face < GetNumberOfSides(part); face++) 8389 for (face = 0; face < GetNumberOfSides(part); face++)
7885 { 8390 {
7886 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 8391 primglow = tex.GetFace((uint)face).Glow;
7887 res.Add(new LSL_Float(texface.Glow)); 8392 res.Add(new LSL_Float(primglow));
7888 } 8393 }
7889 } 8394 }
7890 else 8395 else
7891 { 8396 {
7892 if (face >= 0 && face < GetNumberOfSides(part)) 8397 primglow = tex.GetFace((uint)face).Glow;
7893 { 8398 res.Add(new LSL_Float(primglow));
7894 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7895 res.Add(new LSL_Float(texface.Glow));
7896 }
7897 } 8399 }
7898 break; 8400 break;
7899
7900 case (int)ScriptBaseClass.PRIM_TEXT: 8401 case (int)ScriptBaseClass.PRIM_TEXT:
7901 Color4 textColor = part.GetTextColor(); 8402 Color4 textColor = part.GetTextColor();
7902 res.Add(part.Text); 8403 res.Add(part.Text);
@@ -8445,8 +8946,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8445 // The function returns an ordered list 8946 // The function returns an ordered list
8446 // representing the tokens found in the supplied 8947 // representing the tokens found in the supplied
8447 // sources string. If two successive tokenizers 8948 // sources string. If two successive tokenizers
8448 // are encountered, then a NULL entry is added 8949 // are encountered, then a null-string entry is
8449 // to the list. 8950 // added to the list.
8450 // 8951 //
8451 // It is a precondition that the source and 8952 // It is a precondition that the source and
8452 // toekizer lisst are non-null. If they are null, 8953 // toekizer lisst are non-null. If they are null,
@@ -8454,7 +8955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8454 // while their lengths are being determined. 8955 // while their lengths are being determined.
8455 // 8956 //
8456 // A small amount of working memoryis required 8957 // A small amount of working memoryis required
8457 // of approximately 8*#tokenizers. 8958 // of approximately 8*#tokenizers + 8*srcstrlen.
8458 // 8959 //
8459 // There are many ways in which this function 8960 // There are many ways in which this function
8460 // can be implemented, this implementation is 8961 // can be implemented, this implementation is
@@ -8470,155 +8971,124 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8470 // and eliminates redundant tokenizers as soon 8971 // and eliminates redundant tokenizers as soon
8471 // as is possible. 8972 // as is possible.
8472 // 8973 //
8473 // The implementation tries to avoid any copying 8974 // The implementation tries to minimize temporary
8474 // of arrays or other objects. 8975 // garbage generation.
8475 // </remarks> 8976 // </remarks>
8476 8977
8477 private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) 8978 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
8478 { 8979 {
8479 int beginning = 0; 8980 return ParseString2List(src, separators, spacers, true);
8480 int srclen = src.Length; 8981 }
8481 int seplen = separators.Length;
8482 object[] separray = separators.Data;
8483 int spclen = spacers.Length;
8484 object[] spcarray = spacers.Data;
8485 int mlen = seplen+spclen;
8486
8487 int[] offset = new int[mlen+1];
8488 bool[] active = new bool[mlen];
8489
8490 int best;
8491 int j;
8492
8493 // Initial capacity reduces resize cost
8494 8982
8495 LSL_List tokens = new LSL_List(); 8983 private LSL_List ParseString2List(string src, LSL_List separators, LSL_List spacers, bool keepNulls)
8984 {
8985 int srclen = src.Length;
8986 int seplen = separators.Length;
8987 object[] separray = separators.Data;
8988 int spclen = spacers.Length;
8989 object[] spcarray = spacers.Data;
8990 int dellen = 0;
8991 string[] delarray = new string[seplen+spclen];
8496 8992
8497 // All entries are initially valid 8993 int outlen = 0;
8994 string[] outarray = new string[srclen*2+1];
8498 8995
8499 for (int i = 0; i < mlen; i++) 8996 int i, j;
8500 active[i] = true; 8997 string d;
8501 8998
8502 offset[mlen] = srclen; 8999 m_host.AddScriptLPS(1);
8503 9000
8504 while (beginning < srclen) 9001 /*
9002 * Convert separator and spacer lists to C# strings.
9003 * Also filter out null strings so we don't hang.
9004 */
9005 for (i = 0; i < seplen; i ++)
8505 { 9006 {
9007 d = separray[i].ToString();
9008 if (d.Length > 0)
9009 {
9010 delarray[dellen++] = d;
9011 }
9012 }
9013 seplen = dellen;
8506 9014
8507 best = mlen; // as bad as it gets 9015 for (i = 0; i < spclen; i ++)
9016 {
9017 d = spcarray[i].ToString();
9018 if (d.Length > 0)
9019 {
9020 delarray[dellen++] = d;
9021 }
9022 }
8508 9023
8509 // Scan for separators 9024 /*
9025 * Scan through source string from beginning to end.
9026 */
9027 for (i = 0;;)
9028 {
8510 9029
8511 for (j = 0; j < seplen; j++) 9030 /*
9031 * Find earliest delimeter in src starting at i (if any).
9032 */
9033 int earliestDel = -1;
9034 int earliestSrc = srclen;
9035 string earliestStr = null;
9036 for (j = 0; j < dellen; j ++)
8512 { 9037 {
8513 if (separray[j].ToString() == String.Empty) 9038 d = delarray[j];
8514 active[j] = false; 9039 if (d != null)
8515
8516 if (active[j])
8517 { 9040 {
8518 // scan all of the markers 9041 int index = src.IndexOf(d, i);
8519 if ((offset[j] = src.IndexOf(separray[j].ToString(), beginning)) == -1) 9042 if (index < 0)
8520 { 9043 {
8521 // not present at all 9044 delarray[j] = null; // delim nowhere in src, don't check it anymore
8522 active[j] = false;
8523 } 9045 }
8524 else 9046 else if (index < earliestSrc)
8525 { 9047 {
8526 // present and correct 9048 earliestSrc = index; // where delimeter starts in source string
8527 if (offset[j] < offset[best]) 9049 earliestDel = j; // where delimeter is in delarray[]
8528 { 9050 earliestStr = d; // the delimeter string from delarray[]
8529 // closest so far 9051 if (index == i) break; // can't do any better than found at beg of string
8530 best = j;
8531 if (offset[best] == beginning)
8532 break;
8533 }
8534 } 9052 }
8535 } 9053 }
8536 } 9054 }
8537 9055
8538 // Scan for spacers 9056 /*
8539 9057 * Output source string starting at i through start of earliest delimeter.
8540 if (offset[best] != beginning) 9058 */
9059 if (keepNulls || (earliestSrc > i))
8541 { 9060 {
8542 for (j = seplen; (j < mlen) && (offset[best] > beginning); j++) 9061 outarray[outlen++] = src.Substring(i, earliestSrc - i);
8543 {
8544 if (spcarray[j-seplen].ToString() == String.Empty)
8545 active[j] = false;
8546
8547 if (active[j])
8548 {
8549 // scan all of the markers
8550 if ((offset[j] = src.IndexOf(spcarray[j-seplen].ToString(), beginning)) == -1)
8551 {
8552 // not present at all
8553 active[j] = false;
8554 }
8555 else
8556 {
8557 // present and correct
8558 if (offset[j] < offset[best])
8559 {
8560 // closest so far
8561 best = j;
8562 }
8563 }
8564 }
8565 }
8566 } 9062 }
8567 9063
8568 // This is the normal exit from the scanning loop 9064 /*
9065 * If no delimeter found at or after i, we're done scanning.
9066 */
9067 if (earliestDel < 0) break;
8569 9068
8570 if (best == mlen) 9069 /*
9070 * If delimeter was a spacer, output the spacer.
9071 */
9072 if (earliestDel >= seplen)
8571 { 9073 {
8572 // no markers were found on this pass 9074 outarray[outlen++] = earliestStr;
8573 // so we're pretty much done
8574 if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0))
8575 tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning)));
8576 break;
8577 } 9075 }
8578 9076
8579 // Otherwise we just add the newly delimited token 9077 /*
8580 // and recalculate where the search should continue. 9078 * Look at rest of src string following delimeter.
8581 if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) 9079 */
8582 tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); 9080 i = earliestSrc + earliestStr.Length;
8583
8584 if (best < seplen)
8585 {
8586 beginning = offset[best] + (separray[best].ToString()).Length;
8587 }
8588 else
8589 {
8590 beginning = offset[best] + (spcarray[best - seplen].ToString()).Length;
8591 string str = spcarray[best - seplen].ToString();
8592 if ((keepNulls) || ((!keepNulls) && (str.Length > 0)))
8593 tokens.Add(new LSL_String(str));
8594 }
8595 } 9081 }
8596 9082
8597 // This an awkward an not very intuitive boundary case. If the 9083 /*
8598 // last substring is a tokenizer, then there is an implied trailing 9084 * Make up an exact-sized output array suitable for an LSL_List object.
8599 // null list entry. Hopefully the single comparison will not be too 9085 */
8600 // arduous. Alternatively the 'break' could be replced with a return 9086 object[] outlist = new object[outlen];
8601 // but that's shabby programming. 9087 for (i = 0; i < outlen; i ++)
8602
8603 if ((beginning == srclen) && (keepNulls))
8604 { 9088 {
8605 if (srclen != 0) 9089 outlist[i] = new LSL_String(outarray[i]);
8606 tokens.Add(new LSL_String(""));
8607 } 9090 }
8608 9091 return new LSL_List(outlist);
8609 return tokens;
8610 }
8611
8612 public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers)
8613 {
8614 m_host.AddScriptLPS(1);
8615 return this.ParseString(src, separators, spacers, false);
8616 }
8617
8618 public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers)
8619 {
8620 m_host.AddScriptLPS(1);
8621 return this.ParseString(src, separators, spacers, true);
8622 } 9092 }
8623 9093
8624 public LSL_Integer llGetObjectPermMask(int mask) 9094 public LSL_Integer llGetObjectPermMask(int mask)
@@ -8695,28 +9165,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8695 { 9165 {
8696 m_host.AddScriptLPS(1); 9166 m_host.AddScriptLPS(1);
8697 9167
8698 lock (m_host.TaskInventory) 9168 m_host.TaskInventory.LockItemsForRead(true);
9169 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8699 { 9170 {
8700 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9171 if (inv.Value.Name == item)
8701 { 9172 {
8702 if (inv.Value.Name == item) 9173 m_host.TaskInventory.LockItemsForRead(false);
9174 switch (mask)
8703 { 9175 {
8704 switch (mask) 9176 case 0:
8705 { 9177 return (int)inv.Value.BasePermissions;
8706 case 0: 9178 case 1:
8707 return (int)inv.Value.BasePermissions; 9179 return (int)inv.Value.CurrentPermissions;
8708 case 1: 9180 case 2:
8709 return (int)inv.Value.CurrentPermissions; 9181 return (int)inv.Value.GroupPermissions;
8710 case 2: 9182 case 3:
8711 return (int)inv.Value.GroupPermissions; 9183 return (int)inv.Value.EveryonePermissions;
8712 case 3: 9184 case 4:
8713 return (int)inv.Value.EveryonePermissions; 9185 return (int)inv.Value.NextPermissions;
8714 case 4:
8715 return (int)inv.Value.NextPermissions;
8716 }
8717 } 9186 }
8718 } 9187 }
8719 } 9188 }
9189 m_host.TaskInventory.LockItemsForRead(false);
8720 9190
8721 return -1; 9191 return -1;
8722 } 9192 }
@@ -8763,16 +9233,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8763 { 9233 {
8764 m_host.AddScriptLPS(1); 9234 m_host.AddScriptLPS(1);
8765 9235
8766 lock (m_host.TaskInventory) 9236 m_host.TaskInventory.LockItemsForRead(true);
9237 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8767 { 9238 {
8768 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9239 if (inv.Value.Name == item)
8769 { 9240 {
8770 if (inv.Value.Name == item) 9241 m_host.TaskInventory.LockItemsForRead(false);
8771 { 9242 return inv.Value.CreatorID.ToString();
8772 return inv.Value.CreatorID.ToString();
8773 }
8774 } 9243 }
8775 } 9244 }
9245 m_host.TaskInventory.LockItemsForRead(false);
8776 9246
8777 llSay(0, "No item name '" + item + "'"); 9247 llSay(0, "No item name '" + item + "'");
8778 9248
@@ -9037,17 +9507,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9037 int width = 0; 9507 int width = 0;
9038 int height = 0; 9508 int height = 0;
9039 9509
9040 ParcelMediaCommandEnum? commandToSend = null; 9510 uint commandToSend = 0;
9041 float time = 0.0f; // default is from start 9511 float time = 0.0f; // default is from start
9042 9512
9043 ScenePresence presence = null; 9513 ScenePresence presence = null;
9044 9514
9045 for (int i = 0; i < commandList.Data.Length; i++) 9515 for (int i = 0; i < commandList.Data.Length; i++)
9046 { 9516 {
9047 ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; 9517 uint command = (uint)(commandList.GetLSLIntegerItem(i));
9048 switch (command) 9518 switch (command)
9049 { 9519 {
9050 case ParcelMediaCommandEnum.Agent: 9520 case (uint)ParcelMediaCommandEnum.Agent:
9051 // we send only to one agent 9521 // we send only to one agent
9052 if ((i + 1) < commandList.Length) 9522 if ((i + 1) < commandList.Length)
9053 { 9523 {
@@ -9064,25 +9534,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9064 } 9534 }
9065 break; 9535 break;
9066 9536
9067 case ParcelMediaCommandEnum.Loop: 9537 case (uint)ParcelMediaCommandEnum.Loop:
9068 loop = 1; 9538 loop = 1;
9069 commandToSend = command; 9539 commandToSend = command;
9070 update = true; //need to send the media update packet to set looping 9540 update = true; //need to send the media update packet to set looping
9071 break; 9541 break;
9072 9542
9073 case ParcelMediaCommandEnum.Play: 9543 case (uint)ParcelMediaCommandEnum.Play:
9074 loop = 0; 9544 loop = 0;
9075 commandToSend = command; 9545 commandToSend = command;
9076 update = true; //need to send the media update packet to make sure it doesn't loop 9546 update = true; //need to send the media update packet to make sure it doesn't loop
9077 break; 9547 break;
9078 9548
9079 case ParcelMediaCommandEnum.Pause: 9549 case (uint)ParcelMediaCommandEnum.Pause:
9080 case ParcelMediaCommandEnum.Stop: 9550 case (uint)ParcelMediaCommandEnum.Stop:
9081 case ParcelMediaCommandEnum.Unload: 9551 case (uint)ParcelMediaCommandEnum.Unload:
9082 commandToSend = command; 9552 commandToSend = command;
9083 break; 9553 break;
9084 9554
9085 case ParcelMediaCommandEnum.Url: 9555 case (uint)ParcelMediaCommandEnum.Url:
9086 if ((i + 1) < commandList.Length) 9556 if ((i + 1) < commandList.Length)
9087 { 9557 {
9088 if (commandList.Data[i + 1] is LSL_String) 9558 if (commandList.Data[i + 1] is LSL_String)
@@ -9095,7 +9565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9095 } 9565 }
9096 break; 9566 break;
9097 9567
9098 case ParcelMediaCommandEnum.Texture: 9568 case (uint)ParcelMediaCommandEnum.Texture:
9099 if ((i + 1) < commandList.Length) 9569 if ((i + 1) < commandList.Length)
9100 { 9570 {
9101 if (commandList.Data[i + 1] is LSL_String) 9571 if (commandList.Data[i + 1] is LSL_String)
@@ -9108,7 +9578,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9108 } 9578 }
9109 break; 9579 break;
9110 9580
9111 case ParcelMediaCommandEnum.Time: 9581 case (uint)ParcelMediaCommandEnum.Time:
9112 if ((i + 1) < commandList.Length) 9582 if ((i + 1) < commandList.Length)
9113 { 9583 {
9114 if (commandList.Data[i + 1] is LSL_Float) 9584 if (commandList.Data[i + 1] is LSL_Float)
@@ -9120,7 +9590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9120 } 9590 }
9121 break; 9591 break;
9122 9592
9123 case ParcelMediaCommandEnum.AutoAlign: 9593 case (uint)ParcelMediaCommandEnum.AutoAlign:
9124 if ((i + 1) < commandList.Length) 9594 if ((i + 1) < commandList.Length)
9125 { 9595 {
9126 if (commandList.Data[i + 1] is LSL_Integer) 9596 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9134,7 +9604,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9134 } 9604 }
9135 break; 9605 break;
9136 9606
9137 case ParcelMediaCommandEnum.Type: 9607 case (uint)ParcelMediaCommandEnum.Type:
9138 if ((i + 1) < commandList.Length) 9608 if ((i + 1) < commandList.Length)
9139 { 9609 {
9140 if (commandList.Data[i + 1] is LSL_String) 9610 if (commandList.Data[i + 1] is LSL_String)
@@ -9147,7 +9617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9147 } 9617 }
9148 break; 9618 break;
9149 9619
9150 case ParcelMediaCommandEnum.Desc: 9620 case (uint)ParcelMediaCommandEnum.Desc:
9151 if ((i + 1) < commandList.Length) 9621 if ((i + 1) < commandList.Length)
9152 { 9622 {
9153 if (commandList.Data[i + 1] is LSL_String) 9623 if (commandList.Data[i + 1] is LSL_String)
@@ -9160,7 +9630,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9160 } 9630 }
9161 break; 9631 break;
9162 9632
9163 case ParcelMediaCommandEnum.Size: 9633 case (uint)ParcelMediaCommandEnum.Size:
9164 if ((i + 2) < commandList.Length) 9634 if ((i + 2) < commandList.Length)
9165 { 9635 {
9166 if (commandList.Data[i + 1] is LSL_Integer) 9636 if (commandList.Data[i + 1] is LSL_Integer)
@@ -9230,7 +9700,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9230 } 9700 }
9231 } 9701 }
9232 9702
9233 if (commandToSend != null) 9703 if (commandToSend != 0)
9234 { 9704 {
9235 // the commandList contained a start/stop/... command, too 9705 // the commandList contained a start/stop/... command, too
9236 if (presence == null) 9706 if (presence == null)
@@ -9267,7 +9737,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9267 9737
9268 if (aList.Data[i] != null) 9738 if (aList.Data[i] != null)
9269 { 9739 {
9270 switch ((ParcelMediaCommandEnum) aList.Data[i]) 9740 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
9271 { 9741 {
9272 case ParcelMediaCommandEnum.Url: 9742 case ParcelMediaCommandEnum.Url:
9273 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); 9743 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL));
@@ -9310,16 +9780,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9310 { 9780 {
9311 m_host.AddScriptLPS(1); 9781 m_host.AddScriptLPS(1);
9312 9782
9313 lock (m_host.TaskInventory) 9783 m_host.TaskInventory.LockItemsForRead(true);
9784 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
9314 { 9785 {
9315 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9786 if (inv.Value.Name == name)
9316 { 9787 {
9317 if (inv.Value.Name == name) 9788 m_host.TaskInventory.LockItemsForRead(false);
9318 { 9789 return inv.Value.Type;
9319 return inv.Value.Type;
9320 }
9321 } 9790 }
9322 } 9791 }
9792 m_host.TaskInventory.LockItemsForRead(false);
9323 9793
9324 return -1; 9794 return -1;
9325 } 9795 }
@@ -9330,15 +9800,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9330 9800
9331 if (quick_pay_buttons.Data.Length < 4) 9801 if (quick_pay_buttons.Data.Length < 4)
9332 { 9802 {
9333 LSLError("List must have at least 4 elements"); 9803 int x;
9334 return; 9804 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
9805 {
9806 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
9807 }
9335 } 9808 }
9336 m_host.ParentGroup.RootPart.PayPrice[0]=price; 9809 int[] nPrice = new int[5];
9337 9810 nPrice[0]=price;
9338 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 9811 nPrice[1] = (LSL_Integer)Convert.ToInt32(quick_pay_buttons.Data[0]);
9339 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 9812 nPrice[2] = (LSL_Integer)Convert.ToInt32(quick_pay_buttons.Data[1]);
9340 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 9813 nPrice[3] = (LSL_Integer)Convert.ToInt32(quick_pay_buttons.Data[2]);
9341 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 9814 nPrice[4] = (LSL_Integer)Convert.ToInt32(quick_pay_buttons.Data[3]);
9815 m_host.ParentGroup.RootPart.PayPrice = nPrice;
9342 m_host.ParentGroup.HasGroupChanged = true; 9816 m_host.ParentGroup.HasGroupChanged = true;
9343 } 9817 }
9344 9818
@@ -9350,17 +9824,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9350 if (invItemID == UUID.Zero) 9824 if (invItemID == UUID.Zero)
9351 return new LSL_Vector(); 9825 return new LSL_Vector();
9352 9826
9353 lock (m_host.TaskInventory) 9827 m_host.TaskInventory.LockItemsForRead(true);
9828 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9354 { 9829 {
9355 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9830 m_host.TaskInventory.LockItemsForRead(false);
9356 return new LSL_Vector(); 9831 return new LSL_Vector();
9832 }
9357 9833
9358 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9834 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9359 { 9835 {
9360 ShoutError("No permissions to track the camera"); 9836 ShoutError("No permissions to track the camera");
9361 return new LSL_Vector(); 9837 m_host.TaskInventory.LockItemsForRead(false);
9362 } 9838 return new LSL_Vector();
9363 } 9839 }
9840 m_host.TaskInventory.LockItemsForRead(false);
9364 9841
9365 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9842 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9366 if (presence != null) 9843 if (presence != null)
@@ -9378,17 +9855,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9378 if (invItemID == UUID.Zero) 9855 if (invItemID == UUID.Zero)
9379 return new LSL_Rotation(); 9856 return new LSL_Rotation();
9380 9857
9381 lock (m_host.TaskInventory) 9858 m_host.TaskInventory.LockItemsForRead(true);
9859 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9382 { 9860 {
9383 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9861 m_host.TaskInventory.LockItemsForRead(false);
9384 return new LSL_Rotation(); 9862 return new LSL_Rotation();
9385
9386 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9387 {
9388 ShoutError("No permissions to track the camera");
9389 return new LSL_Rotation();
9390 }
9391 } 9863 }
9864 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9865 {
9866 ShoutError("No permissions to track the camera");
9867 m_host.TaskInventory.LockItemsForRead(false);
9868 return new LSL_Rotation();
9869 }
9870 m_host.TaskInventory.LockItemsForRead(false);
9392 9871
9393 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9872 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9394 if (presence != null) 9873 if (presence != null)
@@ -9450,8 +9929,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9450 { 9929 {
9451 m_host.AddScriptLPS(1); 9930 m_host.AddScriptLPS(1);
9452 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 9931 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0);
9453 if (detectedParams == null) return; // only works on the first detected avatar 9932 if (detectedParams == null)
9454 9933 {
9934 if (m_host.IsAttachment == true)
9935 {
9936 detectedParams = new DetectParams();
9937 detectedParams.Key = m_host.OwnerID;
9938 }
9939 else
9940 {
9941 return;
9942 }
9943 }
9944
9455 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 9945 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
9456 if (avatar != null) 9946 if (avatar != null)
9457 { 9947 {
@@ -9459,6 +9949,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9459 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 9949 new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
9460 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); 9950 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
9461 } 9951 }
9952
9462 ScriptSleep(1000); 9953 ScriptSleep(1000);
9463 } 9954 }
9464 9955
@@ -9538,14 +10029,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9538 if (objectID == UUID.Zero) return; 10029 if (objectID == UUID.Zero) return;
9539 10030
9540 UUID agentID; 10031 UUID agentID;
9541 lock (m_host.TaskInventory) 10032 m_host.TaskInventory.LockItemsForRead(true);
9542 { 10033 // we need the permission first, to know which avatar we want to set the camera for
9543 // we need the permission first, to know which avatar we want to set the camera for 10034 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9544 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9545 10035
9546 if (agentID == UUID.Zero) return; 10036 if (agentID == UUID.Zero)
9547 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 10037 {
10038 m_host.TaskInventory.LockItemsForRead(false);
10039 return;
9548 } 10040 }
10041 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10042 {
10043 m_host.TaskInventory.LockItemsForRead(false);
10044 return;
10045 }
10046 m_host.TaskInventory.LockItemsForRead(false);
9549 10047
9550 ScenePresence presence = World.GetScenePresence(agentID); 10048 ScenePresence presence = World.GetScenePresence(agentID);
9551 10049
@@ -9554,12 +10052,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9554 10052
9555 SortedDictionary<int, float> parameters = new SortedDictionary<int, float>(); 10053 SortedDictionary<int, float> parameters = new SortedDictionary<int, float>();
9556 object[] data = rules.Data; 10054 object[] data = rules.Data;
9557 for (int i = 0; i < data.Length; ++i) { 10055 for (int i = 0; i < data.Length; ++i)
10056 {
9558 int type = Convert.ToInt32(data[i++].ToString()); 10057 int type = Convert.ToInt32(data[i++].ToString());
9559 if (i >= data.Length) break; // odd number of entries => ignore the last 10058 if (i >= data.Length) break; // odd number of entries => ignore the last
9560 10059
9561 // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3) 10060 // some special cases: Vector parameters are split into 3 float parameters (with type+1, type+2, type+3)
9562 switch (type) { 10061 switch (type)
10062 {
9563 case ScriptBaseClass.CAMERA_FOCUS: 10063 case ScriptBaseClass.CAMERA_FOCUS:
9564 case ScriptBaseClass.CAMERA_FOCUS_OFFSET: 10064 case ScriptBaseClass.CAMERA_FOCUS_OFFSET:
9565 case ScriptBaseClass.CAMERA_POSITION: 10065 case ScriptBaseClass.CAMERA_POSITION:
@@ -9595,12 +10095,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9595 10095
9596 // we need the permission first, to know which avatar we want to clear the camera for 10096 // we need the permission first, to know which avatar we want to clear the camera for
9597 UUID agentID; 10097 UUID agentID;
9598 lock (m_host.TaskInventory) 10098 m_host.TaskInventory.LockItemsForRead(true);
10099 agentID = m_host.TaskInventory[invItemID].PermsGranter;
10100 if (agentID == UUID.Zero)
9599 { 10101 {
9600 agentID = m_host.TaskInventory[invItemID].PermsGranter; 10102 m_host.TaskInventory.LockItemsForRead(false);
9601 if (agentID == UUID.Zero) return; 10103 return;
9602 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
9603 } 10104 }
10105 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10106 {
10107 m_host.TaskInventory.LockItemsForRead(false);
10108 return;
10109 }
10110 m_host.TaskInventory.LockItemsForRead(false);
9604 10111
9605 ScenePresence presence = World.GetScenePresence(agentID); 10112 ScenePresence presence = World.GetScenePresence(agentID);
9606 10113
@@ -9667,19 +10174,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9667 public LSL_String llXorBase64StringsCorrect(string str1, string str2) 10174 public LSL_String llXorBase64StringsCorrect(string str1, string str2)
9668 { 10175 {
9669 m_host.AddScriptLPS(1); 10176 m_host.AddScriptLPS(1);
9670 string ret = String.Empty; 10177
9671 string src1 = llBase64ToString(str1); 10178 if (str1 == String.Empty)
9672 string src2 = llBase64ToString(str2); 10179 return String.Empty;
9673 int c = 0; 10180 if (str2 == String.Empty)
9674 for (int i = 0; i < src1.Length; i++) 10181 return str1;
10182
10183 int len = str2.Length;
10184 if ((len % 4) != 0) // LL is EVIL!!!!
10185 {
10186 while (str2.EndsWith("="))
10187 str2 = str2.Substring(0, str2.Length - 1);
10188
10189 len = str2.Length;
10190 int mod = len % 4;
10191
10192 if (mod == 1)
10193 str2 = str2.Substring(0, str2.Length - 1);
10194 else if (mod == 2)
10195 str2 += "==";
10196 else if (mod == 3)
10197 str2 += "=";
10198 }
10199
10200 byte[] data1;
10201 byte[] data2;
10202 try
10203 {
10204 data1 = Convert.FromBase64String(str1);
10205 data2 = Convert.FromBase64String(str2);
10206 }
10207 catch (Exception)
9675 { 10208 {
9676 ret += (char) (src1[i] ^ src2[c]); 10209 return new LSL_String(String.Empty);
10210 }
9677 10211
9678 c++; 10212 byte[] d2 = new Byte[data1.Length];
9679 if (c >= src2.Length) 10213 int pos = 0;
9680 c = 0; 10214
10215 if (data1.Length <= data2.Length)
10216 {
10217 Array.Copy(data2, 0, d2, 0, data1.Length);
9681 } 10218 }
9682 return llStringToBase64(ret); 10219 else
10220 {
10221 while (pos < data1.Length)
10222 {
10223 len = data1.Length - pos;
10224 if (len > data2.Length)
10225 len = data2.Length;
10226
10227 Array.Copy(data2, 0, d2, pos, len);
10228 pos += len;
10229 }
10230 }
10231
10232 for (pos = 0 ; pos < data1.Length ; pos++ )
10233 data1[pos] ^= d2[pos];
10234
10235 return Convert.ToBase64String(data1);
9683 } 10236 }
9684 10237
9685 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) 10238 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body)
@@ -9738,12 +10291,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9738 Regex r = new Regex(authregex); 10291 Regex r = new Regex(authregex);
9739 int[] gnums = r.GetGroupNumbers(); 10292 int[] gnums = r.GetGroupNumbers();
9740 Match m = r.Match(url); 10293 Match m = r.Match(url);
9741 if (m.Success) { 10294 if (m.Success)
9742 for (int i = 1; i < gnums.Length; i++) { 10295 {
10296 for (int i = 1; i < gnums.Length; i++)
10297 {
9743 //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]]; 10298 //System.Text.RegularExpressions.Group g = m.Groups[gnums[i]];
9744 //CaptureCollection cc = g.Captures; 10299 //CaptureCollection cc = g.Captures;
9745 } 10300 }
9746 if (m.Groups.Count == 5) { 10301 if (m.Groups.Count == 5)
10302 {
9747 httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString()))); 10303 httpHeaders["Authorization"] = String.Format("Basic {0}", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(m.Groups[2].ToString() + ":" + m.Groups[3].ToString())));
9748 url = m.Groups[1].ToString() + m.Groups[4].ToString(); 10304 url = m.Groups[1].ToString() + m.Groups[4].ToString();
9749 } 10305 }
@@ -10060,15 +10616,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10060 10616
10061 internal UUID ScriptByName(string name) 10617 internal UUID ScriptByName(string name)
10062 { 10618 {
10063 lock (m_host.TaskInventory) 10619 m_host.TaskInventory.LockItemsForRead(true);
10620
10621 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
10064 { 10622 {
10065 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 10623 if (item.Type == 10 && item.Name == name)
10066 { 10624 {
10067 if (item.Type == 10 && item.Name == name) 10625 m_host.TaskInventory.LockItemsForRead(false);
10068 return item.ItemID; 10626 return item.ItemID;
10069 } 10627 }
10070 } 10628 }
10071 10629
10630 m_host.TaskInventory.LockItemsForRead(false);
10631
10072 return UUID.Zero; 10632 return UUID.Zero;
10073 } 10633 }
10074 10634
@@ -10109,6 +10669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10109 { 10669 {
10110 m_host.AddScriptLPS(1); 10670 m_host.AddScriptLPS(1);
10111 10671
10672 //Clone is thread safe
10112 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10673 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
10113 10674
10114 UUID assetID = UUID.Zero; 10675 UUID assetID = UUID.Zero;
@@ -10171,6 +10732,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10171 { 10732 {
10172 m_host.AddScriptLPS(1); 10733 m_host.AddScriptLPS(1);
10173 10734
10735 //Clone is thread safe
10174 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10736 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
10175 10737
10176 UUID assetID = UUID.Zero; 10738 UUID assetID = UUID.Zero;
@@ -10250,6 +10812,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10250 10812
10251 return GetLinkPrimitiveParams(obj, rules); 10813 return GetLinkPrimitiveParams(obj, rules);
10252 } 10814 }
10815
10816 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
10817 {
10818 List<SceneObjectPart> parts = GetLinkParts(link);
10819 if (parts.Count < 1)
10820 return 0;
10821
10822 return GetNumberOfSides(parts[0]);
10823 }
10253 } 10824 }
10254 10825
10255 public class NotecardCache 10826 public class NotecardCache
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 3b13d06..ecd2d6f 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()
@@ -841,18 +850,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
841 if (target != null) 850 if (target != null)
842 { 851 {
843 UUID animID=UUID.Zero; 852 UUID animID=UUID.Zero;
844 lock (m_host.TaskInventory) 853 m_host.TaskInventory.LockItemsForRead(true);
854 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
845 { 855 {
846 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 856 if (inv.Value.Name == animation)
847 { 857 {
848 if (inv.Value.Name == animation) 858 if (inv.Value.Type == (int)AssetType.Animation)
849 { 859 animID = inv.Value.AssetID;
850 if (inv.Value.Type == (int)AssetType.Animation) 860 continue;
851 animID = inv.Value.AssetID;
852 continue;
853 }
854 } 861 }
855 } 862 }
863 m_host.TaskInventory.LockItemsForRead(false);
856 if (animID == UUID.Zero) 864 if (animID == UUID.Zero)
857 target.Animator.AddAnimation(animation, m_host.UUID); 865 target.Animator.AddAnimation(animation, m_host.UUID);
858 else 866 else
@@ -874,18 +882,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
874 if (target != null) 882 if (target != null)
875 { 883 {
876 UUID animID=UUID.Zero; 884 UUID animID=UUID.Zero;
877 lock (m_host.TaskInventory) 885 m_host.TaskInventory.LockItemsForRead(true);
886 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
878 { 887 {
879 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 888 if (inv.Value.Name == animation)
880 { 889 {
881 if (inv.Value.Name == animation) 890 if (inv.Value.Type == (int)AssetType.Animation)
882 { 891 animID = inv.Value.AssetID;
883 if (inv.Value.Type == (int)AssetType.Animation) 892 continue;
884 animID = inv.Value.AssetID;
885 continue;
886 }
887 } 893 }
888 } 894 }
895 m_host.TaskInventory.LockItemsForRead(false);
889 896
890 if (animID == UUID.Zero) 897 if (animID == UUID.Zero)
891 target.Animator.RemoveAnimation(animation); 898 target.Animator.RemoveAnimation(animation);
@@ -1778,6 +1785,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1778 1785
1779 if (!UUID.TryParse(name, out assetID)) 1786 if (!UUID.TryParse(name, out assetID))
1780 { 1787 {
1788 m_host.TaskInventory.LockItemsForRead(true);
1781 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1789 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1782 { 1790 {
1783 if (item.Type == 7 && item.Name == name) 1791 if (item.Type == 7 && item.Name == name)
@@ -1785,6 +1793,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1785 assetID = item.AssetID; 1793 assetID = item.AssetID;
1786 } 1794 }
1787 } 1795 }
1796 m_host.TaskInventory.LockItemsForRead(false);
1788 } 1797 }
1789 1798
1790 if (assetID == UUID.Zero) 1799 if (assetID == UUID.Zero)
@@ -1831,6 +1840,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1831 1840
1832 if (!UUID.TryParse(name, out assetID)) 1841 if (!UUID.TryParse(name, out assetID))
1833 { 1842 {
1843 m_host.TaskInventory.LockItemsForRead(true);
1834 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1844 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1835 { 1845 {
1836 if (item.Type == 7 && item.Name == name) 1846 if (item.Type == 7 && item.Name == name)
@@ -1838,6 +1848,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1838 assetID = item.AssetID; 1848 assetID = item.AssetID;
1839 } 1849 }
1840 } 1850 }
1851 m_host.TaskInventory.LockItemsForRead(false);
1841 } 1852 }
1842 1853
1843 if (assetID == UUID.Zero) 1854 if (assetID == UUID.Zero)
@@ -1888,6 +1899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1888 1899
1889 if (!UUID.TryParse(name, out assetID)) 1900 if (!UUID.TryParse(name, out assetID))
1890 { 1901 {
1902 m_host.TaskInventory.LockItemsForRead(true);
1891 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1903 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1892 { 1904 {
1893 if (item.Type == 7 && item.Name == name) 1905 if (item.Type == 7 && item.Name == name)
@@ -1895,6 +1907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1895 assetID = item.AssetID; 1907 assetID = item.AssetID;
1896 } 1908 }
1897 } 1909 }
1910 m_host.TaskInventory.LockItemsForRead(false);
1898 } 1911 }
1899 1912
1900 if (assetID == UUID.Zero) 1913 if (assetID == UUID.Zero)
@@ -2374,9 +2387,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2374 { 2387 {
2375 if (avatar.IsChildAgent == false) 2388 if (avatar.IsChildAgent == false)
2376 { 2389 {
2377 result.Add(avatar.UUID); 2390 result.Add(new LSL_Key(avatar.UUID.ToString()));
2378 result.Add(avatar.AbsolutePosition); 2391 result.Add(new LSL_Vector(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z));
2379 result.Add(avatar.Name); 2392 result.Add(new LSL_String(avatar.Name));
2380 } 2393 }
2381 } 2394 }
2382 }); 2395 });
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index fefbb35..3b7de53 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/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 561e3b3..bae7d4b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -398,6 +398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
398 LSL_Vector llWind(LSL_Vector offset); 398 LSL_Vector llWind(LSL_Vector offset);
399 LSL_String llXorBase64Strings(string str1, string str2); 399 LSL_String llXorBase64Strings(string str1, string str2);
400 LSL_String llXorBase64StringsCorrect(string str1, string str2); 400 LSL_String llXorBase64StringsCorrect(string str1, string str2);
401 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link);
401 402
402 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 403 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
403 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 404 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 63007c6..c08ad3b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
83 // Avatar Info Commands 83 // Avatar Info Commands
84 string osGetAgentIP(string agent); 84 string osGetAgentIP(string agent);
85 LSL_List osGetAgents(); 85 LSL_List osGetAgents();
86 86
87 // Teleport commands 87 // Teleport commands
88 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 88 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
89 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 89 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 b3c4d95..93d544b 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..7c26824 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();
@@ -1847,5 +1849,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1847 { 1849 {
1848 return m_LSL_Functions.llClearPrimMedia(face); 1850 return m_LSL_Functions.llClearPrimMedia(face);
1849 } 1851 }
1852
1853 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
1854 {
1855 return m_LSL_Functions.llGetLinkNumberOfSides(link);
1856 }
1850 } 1857 }
1851} 1858}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
index 143b497..2e27f16 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
@@ -72,9 +72,30 @@ 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
75 public void lsClearWindlightScene() 76 public void lsClearWindlightScene()
76 { 77 {
77 m_LS_Functions.lsClearWindlightScene(); 78 m_LS_Functions.lsClearWindlightScene();
78 } 79 }
80
81 public LSL_List cmGetWindlightScene(LSL_List rules)
82 {
83 return m_LS_Functions.lsGetWindlightScene(rules);
84 }
85
86 public int cmSetWindlightScene(LSL_List rules)
87 {
88 return m_LS_Functions.lsSetWindlightScene(rules);
89 }
90
91 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
92 {
93 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
94 }
95
96 public void cmClearWindlightScene()
97 {
98 m_LS_Functions.lsClearWindlightScene();
99 }
79 } 100 }
80} 101}
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 8e712b6..9548253 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;
@@ -55,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
55{ 56{
56 public class ScriptInstance : MarshalByRefObject, IScriptInstance 57 public class ScriptInstance : MarshalByRefObject, IScriptInstance
57 { 58 {
58 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 60
60 private IScriptEngine m_Engine; 61 private IScriptEngine m_Engine;
61 private IScriptWorkItem m_CurrentResult = null; 62 private IScriptWorkItem m_CurrentResult = null;
@@ -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();
@@ -271,9 +271,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
271 //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); 271 //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
272// lease.Register(this); 272// lease.Register(this);
273 } 273 }
274 catch (Exception) 274 catch (Exception e)
275 { 275 {
276 // m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly); 276 m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly);
277 throw;
277 } 278 }
278 279
279 try 280 try
@@ -434,14 +435,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
434 { 435 {
435 int permsMask; 436 int permsMask;
436 UUID permsGranter; 437 UUID permsGranter;
437 lock (part.TaskInventory) 438 part.TaskInventory.LockItemsForRead(true);
439 if (!part.TaskInventory.ContainsKey(m_ItemID))
438 { 440 {
439 if (!part.TaskInventory.ContainsKey(m_ItemID)) 441 part.TaskInventory.LockItemsForRead(false);
440 return; 442 return;
441
442 permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
443 permsMask = part.TaskInventory[m_ItemID].PermsMask;
444 } 443 }
444 permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
445 permsMask = part.TaskInventory[m_ItemID].PermsMask;
446 part.TaskInventory.LockItemsForRead(false);
445 447
446 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 448 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
447 { 449 {
@@ -550,6 +552,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
550 return true; 552 return true;
551 } 553 }
552 554
555 [DebuggerNonUserCode] //Prevents the debugger from farting in this function
553 public void SetState(string state) 556 public void SetState(string state)
554 { 557 {
555 if (state == State) 558 if (state == State)
@@ -561,7 +564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
561 new DetectParams[0])); 564 new DetectParams[0]));
562 PostEvent(new EventParams("state_entry", new Object[0], 565 PostEvent(new EventParams("state_entry", new Object[0],
563 new DetectParams[0])); 566 new DetectParams[0]));
564 567
565 throw new EventAbortException(); 568 throw new EventAbortException();
566 } 569 }
567 570
@@ -644,14 +647,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
644 /// <returns></returns> 647 /// <returns></returns>
645 public object EventProcessor() 648 public object EventProcessor()
646 { 649 {
647 if (m_Suspended) 650 EventParams data = null;
648 return 0;
649 651
650 lock (m_Script) 652 lock (m_EventQueue)
651 { 653 {
652 EventParams data = null; 654 if (m_Suspended)
655 return 0;
653 656
654 lock (m_EventQueue) 657 lock (m_Script)
655 { 658 {
656 data = (EventParams) m_EventQueue.Dequeue(); 659 data = (EventParams) m_EventQueue.Dequeue();
657 if (data == null) // Shouldn't happen 660 if (data == null) // Shouldn't happen
@@ -677,6 +680,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
677 if (data.EventName == "collision") 680 if (data.EventName == "collision")
678 m_CollisionInQueue = false; 681 m_CollisionInQueue = false;
679 } 682 }
683 }
684 lock(m_Script)
685 {
680 686
681 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); 687 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
682 688
@@ -833,6 +839,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
833 new Object[0], new DetectParams[0])); 839 new Object[0], new DetectParams[0]));
834 } 840 }
835 841
842 [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
836 public void ApiResetScript() 843 public void ApiResetScript()
837 { 844 {
838 // bool running = Running; 845 // 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 }