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/LSL_Api.cs1456
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs32
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs40
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs12
13 files changed, 1121 insertions, 495 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0a8d7cb..f153504 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;
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
151 get { return m_ScriptEngine.World; } 152 get { return m_ScriptEngine.World; }
152 } 153 }
153 154
155 [DebuggerNonUserCode]
154 public void state(string newState) 156 public void state(string newState)
155 { 157 {
156 m_ScriptEngine.SetState(m_itemID, newState); 158 m_ScriptEngine.SetState(m_itemID, newState);
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
160 /// Reset the named script. The script must be present 162 /// Reset the named script. The script must be present
161 /// in the same prim. 163 /// in the same prim.
162 /// </summary> 164 /// </summary>
165 [DebuggerNonUserCode]
163 public void llResetScript() 166 public void llResetScript()
164 { 167 {
165 m_host.AddScriptLPS(1); 168 m_host.AddScriptLPS(1);
@@ -216,9 +219,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
216 } 219 }
217 } 220 }
218 221
222 public List<ScenePresence> GetLinkAvatars(int linkType)
223 {
224 List<ScenePresence> ret = new List<ScenePresence>();
225 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
226 return ret;
227
228 List<ScenePresence> avs = m_host.ParentGroup.GetLinkedAvatars();
229
230 switch (linkType)
231 {
232 case ScriptBaseClass.LINK_SET:
233 return avs;
234
235 case ScriptBaseClass.LINK_ROOT:
236 return ret;
237
238 case ScriptBaseClass.LINK_ALL_OTHERS:
239 return avs;
240
241 case ScriptBaseClass.LINK_ALL_CHILDREN:
242 return avs;
243
244 case ScriptBaseClass.LINK_THIS:
245 return ret;
246
247 default:
248 if (linkType < 0)
249 return ret;
250
251 int partCount = m_host.ParentGroup.GetPartCount();
252
253 if (linkType <= partCount)
254 {
255 return ret;
256 }
257 else
258 {
259 linkType = linkType - partCount;
260 if (linkType > avs.Count)
261 {
262 return ret;
263 }
264 else
265 {
266 ret.Add(avs[linkType-1]);
267 return ret;
268 }
269 }
270 }
271 }
272
219 public List<SceneObjectPart> GetLinkParts(int linkType) 273 public List<SceneObjectPart> GetLinkParts(int linkType)
220 { 274 {
221 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 275 List<SceneObjectPart> ret = new List<SceneObjectPart>();
276 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
277 return ret;
222 ret.Add(m_host); 278 ret.Add(m_host);
223 279
224 switch (linkType) 280 switch (linkType)
@@ -272,40 +328,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
272 protected UUID InventorySelf() 328 protected UUID InventorySelf()
273 { 329 {
274 UUID invItemID = new UUID(); 330 UUID invItemID = new UUID();
275 331 bool unlock = false;
276 lock (m_host.TaskInventory) 332 if (!m_host.TaskInventory.IsReadLockedByMe())
333 {
334 m_host.TaskInventory.LockItemsForRead(true);
335 unlock = true;
336 }
337 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
277 { 338 {
278 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 339 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
279 { 340 {
280 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 341 invItemID = inv.Key;
281 { 342 break;
282 invItemID = inv.Key;
283 break;
284 }
285 } 343 }
286 } 344 }
287 345 if (unlock)
346 {
347 m_host.TaskInventory.LockItemsForRead(false);
348 }
288 return invItemID; 349 return invItemID;
289 } 350 }
290 351
291 protected UUID InventoryKey(string name, int type) 352 protected UUID InventoryKey(string name, int type)
292 { 353 {
293 m_host.AddScriptLPS(1); 354 m_host.AddScriptLPS(1);
294 355 m_host.TaskInventory.LockItemsForRead(true);
295 lock (m_host.TaskInventory) 356
357 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
296 { 358 {
297 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 359 if (inv.Value.Name == name)
298 { 360 {
299 if (inv.Value.Name == name) 361 m_host.TaskInventory.LockItemsForRead(false);
362
363 if (inv.Value.Type != type)
300 { 364 {
301 if (inv.Value.Type != type) 365 return UUID.Zero;
302 return UUID.Zero;
303
304 return inv.Value.AssetID;
305 } 366 }
367
368 return inv.Value.AssetID;
306 } 369 }
307 } 370 }
308 371
372 m_host.TaskInventory.LockItemsForRead(false);
309 return UUID.Zero; 373 return UUID.Zero;
310 } 374 }
311 375
@@ -313,17 +377,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
313 { 377 {
314 m_host.AddScriptLPS(1); 378 m_host.AddScriptLPS(1);
315 379
316 lock (m_host.TaskInventory) 380
381 m_host.TaskInventory.LockItemsForRead(true);
382
383 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
317 { 384 {
318 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 385 if (inv.Value.Name == name)
319 { 386 {
320 if (inv.Value.Name == name) 387 m_host.TaskInventory.LockItemsForRead(false);
321 { 388 return inv.Value.AssetID;
322 return inv.Value.AssetID;
323 }
324 } 389 }
325 } 390 }
326 391
392 m_host.TaskInventory.LockItemsForRead(false);
393
394
327 return UUID.Zero; 395 return UUID.Zero;
328 } 396 }
329 397
@@ -485,25 +553,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
485 return remainder; 553 return remainder;
486 } 554 }
487 555
488 // Old implementation of llRot2Euler, now normalized 556 public LSL_Vector llRot2Euler(LSL_Rotation q1)
489
490 public LSL_Vector llRot2Euler(LSL_Rotation r)
491 { 557 {
492 m_host.AddScriptLPS(1); 558 m_host.AddScriptLPS(1);
493 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke 559 LSL_Vector eul = new LSL_Vector();
494 LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); 560
495 double m = (t.x + t.y + t.z + t.s); 561 double sqw = q1.s*q1.s;
496 if (m == 0) return new LSL_Vector(); 562 double sqx = q1.x*q1.x;
497 double n = 2 * (r.y * r.s + r.x * r.z); 563 double sqy = q1.z*q1.z;
498 double p = m * m - n * n; 564 double sqz = q1.y*q1.y;
499 if (p > 0) 565 double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor
500 return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), 566 double test = q1.x*q1.z + q1.y*q1.s;
501 NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), 567 if (test > 0.4999*unit) { // singularity at north pole
502 NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); 568 eul.z = 2 * Math.Atan2(q1.x,q1.s);
503 else if (n > 0) 569 eul.y = Math.PI/2;
504 return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 570 eul.x = 0;
505 else 571 return eul;
506 return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 572 }
573 if (test < -0.4999*unit) { // singularity at south pole
574 eul.z = -2 * Math.Atan2(q1.x,q1.s);
575 eul.y = -Math.PI/2;
576 eul.x = 0;
577 return eul;
578 }
579 eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw);
580 eul.y = Math.Asin(2*test/unit);
581 eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw);
582 return eul;
507 } 583 }
508 584
509 /* From wiki: 585 /* From wiki:
@@ -705,77 +781,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
705 { 781 {
706 //A and B should both be normalized 782 //A and B should both be normalized
707 m_host.AddScriptLPS(1); 783 m_host.AddScriptLPS(1);
708 LSL_Rotation rotBetween; 784 /* This method is more accurate than the SL one, and thus causes problems
709 // Check for zero vectors. If either is zero, return zero rotation. Otherwise, 785 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
710 // continue calculation. 786
711 if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f)) 787 double dotProduct = LSL_Vector.Dot(a, b);
712 { 788 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
713 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 789 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
714 } 790 double angle = Math.Acos(dotProduct / magProduct);
715 else 791 LSL_Vector axis = LSL_Vector.Norm(crossProduct);
716 { 792 double s = Math.Sin(angle / 2);
717 a = LSL_Vector.Norm(a); 793
718 b = LSL_Vector.Norm(b); 794 double x = axis.x * s;
719 double dotProduct = LSL_Vector.Dot(a, b); 795 double y = axis.y * s;
720 // There are two degenerate cases possible. These are for vectors 180 or 796 double z = axis.z * s;
721 // 0 degrees apart. These have to be detected and handled individually. 797 double w = Math.Cos(angle / 2);
722 // 798
723 // Check for vectors 180 degrees apart. 799 if (Double.IsNaN(x) || Double.IsNaN(y) || Double.IsNaN(z) || Double.IsNaN(w))
724 // A dot product of -1 would mean the angle between vectors is 180 degrees. 800 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
725 if (dotProduct < -0.9999999f) 801
726 { 802 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
727 // First assume X axis is orthogonal to the vectors. 803 */
728 LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f); 804
729 orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a)); 805 // This method mimics the 180 errors found in SL
730 // Check for near zero vector. A very small non-zero number here will create 806 // See www.euclideanspace.com... angleBetween
731 // a rotation in an undesired direction. 807 LSL_Vector vec_a = a;
732 if (LSL_Vector.Mag(orthoVector) > 0.0001) 808 LSL_Vector vec_b = b;
733 { 809
734 rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f); 810 // Eliminate zero length
735 } 811 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
736 // If the magnitude of the vector was near zero, then assume the X axis is not 812 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
737 // orthogonal and use the Z axis instead. 813 if (vec_a_mag < 0.00001 ||
738 else 814 vec_b_mag < 0.00001)
739 { 815 {
740 // Set 180 z rotation. 816 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
741 rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f); 817 }
742 } 818
743 } 819 // Normalize
744 // Check for parallel vectors. 820 vec_a = llVecNorm(vec_a);
745 // A dot product of 1 would mean the angle between vectors is 0 degrees. 821 vec_b = llVecNorm(vec_b);
746 else if (dotProduct > 0.9999999f) 822
747 { 823 // Calculate axis and rotation angle
748 // Set zero rotation. 824 LSL_Vector axis = vec_a % vec_b;
749 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 825 LSL_Float cos_theta = vec_a * vec_b;
750 } 826
751 else 827 // Check if parallel
752 { 828 if (cos_theta > 0.99999)
753 // All special checks have been performed so get the axis of rotation. 829 {
754 LSL_Vector crossProduct = LSL_Vector.Cross(a, b); 830 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
755 // Quarternion s value is the length of the unit vector + dot product. 831 }
756 double qs = 1.0 + dotProduct; 832
757 rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs); 833 // Check if anti-parallel
758 // Normalize the rotation. 834 else if (cos_theta < -0.99999)
759 double mag = LSL_Rotation.Mag(rotBetween); 835 {
760 // We shouldn't have to worry about a divide by zero here. The qs value will be 836 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
761 // non-zero because we already know if we're here, then the dotProduct is not -1 so 837 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
762 // qs will not be zero. Also, we've already handled the input vectors being zero so the 838 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
763 // crossProduct vector should also not be zero. 839 }
764 rotBetween.x = rotBetween.x / mag; 840 else // other rotation
765 rotBetween.y = rotBetween.y / mag; 841 {
766 rotBetween.z = rotBetween.z / mag; 842 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
767 rotBetween.s = rotBetween.s / mag; 843 axis = llVecNorm(axis);
768 // Check for undefined values and set zero rotation if any found. This code might not actually be required 844 double x, y, z, s, t;
769 // any longer since zero vectors are checked for at the top. 845 s = Math.Cos(theta);
770 if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s)) 846 t = Math.Sin(theta);
771 { 847 x = axis.x * t;
772 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 848 y = axis.y * t;
773 } 849 z = axis.z * t;
774 } 850 return new LSL_Rotation(x,y,z,s);
775 } 851 }
776 return rotBetween; 852 }
777 } 853
778
779 public void llWhisper(int channelID, string text) 854 public void llWhisper(int channelID, string text)
780 { 855 {
781 m_host.AddScriptLPS(1); 856 m_host.AddScriptLPS(1);
@@ -1099,10 +1174,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1099 return detectedParams.TouchUV; 1174 return detectedParams.TouchUV;
1100 } 1175 }
1101 1176
1177 [DebuggerNonUserCode]
1102 public virtual void llDie() 1178 public virtual void llDie()
1103 { 1179 {
1104 m_host.AddScriptLPS(1); 1180 m_host.AddScriptLPS(1);
1105 throw new SelfDeleteException(); 1181 if (!m_host.IsAttachment) throw new SelfDeleteException();
1106 } 1182 }
1107 1183
1108 public LSL_Float llGround(LSL_Vector offset) 1184 public LSL_Float llGround(LSL_Vector offset)
@@ -1175,6 +1251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1175 1251
1176 public void llSetStatus(int status, int value) 1252 public void llSetStatus(int status, int value)
1177 { 1253 {
1254 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1255 return;
1178 m_host.AddScriptLPS(1); 1256 m_host.AddScriptLPS(1);
1179 1257
1180 int statusrotationaxis = 0; 1258 int statusrotationaxis = 0;
@@ -1404,6 +1482,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1404 { 1482 {
1405 m_host.AddScriptLPS(1); 1483 m_host.AddScriptLPS(1);
1406 1484
1485 SetColor(m_host, color, face);
1486 }
1487
1488 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1489 {
1490 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1491 return;
1492
1493 Primitive.TextureEntry tex = part.Shape.Textures;
1494 Color4 texcolor;
1495 if (face >= 0 && face < GetNumberOfSides(part))
1496 {
1497 texcolor = tex.CreateFace((uint)face).RGBA;
1498 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1499 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1500 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1501 tex.FaceTextures[face].RGBA = texcolor;
1502 part.UpdateTexture(tex);
1503 return;
1504 }
1505 else if (face == ScriptBaseClass.ALL_SIDES)
1506 {
1507 for (uint i = 0; i < GetNumberOfSides(part); i++)
1508 {
1509 if (tex.FaceTextures[i] != null)
1510 {
1511 texcolor = tex.FaceTextures[i].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[i].RGBA = texcolor;
1516 }
1517 texcolor = tex.DefaultTexture.RGBA;
1518 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1519 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1520 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1521 tex.DefaultTexture.RGBA = texcolor;
1522 }
1523 part.UpdateTexture(tex);
1524 return;
1525 }
1526
1407 if (face == ScriptBaseClass.ALL_SIDES) 1527 if (face == ScriptBaseClass.ALL_SIDES)
1408 face = SceneObjectPart.ALL_SIDES; 1528 face = SceneObjectPart.ALL_SIDES;
1409 1529
@@ -1412,6 +1532,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1412 1532
1413 public void SetTexGen(SceneObjectPart part, int face,int style) 1533 public void SetTexGen(SceneObjectPart part, int face,int style)
1414 { 1534 {
1535 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1536 return;
1537
1415 Primitive.TextureEntry tex = part.Shape.Textures; 1538 Primitive.TextureEntry tex = part.Shape.Textures;
1416 MappingType textype; 1539 MappingType textype;
1417 textype = MappingType.Default; 1540 textype = MappingType.Default;
@@ -1442,6 +1565,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1442 1565
1443 public void SetGlow(SceneObjectPart part, int face, float glow) 1566 public void SetGlow(SceneObjectPart part, int face, float glow)
1444 { 1567 {
1568 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1569 return;
1570
1445 Primitive.TextureEntry tex = part.Shape.Textures; 1571 Primitive.TextureEntry tex = part.Shape.Textures;
1446 if (face >= 0 && face < GetNumberOfSides(part)) 1572 if (face >= 0 && face < GetNumberOfSides(part))
1447 { 1573 {
@@ -1467,6 +1593,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1467 1593
1468 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1594 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1469 { 1595 {
1596 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1597 return;
1470 1598
1471 Shininess sval = new Shininess(); 1599 Shininess sval = new Shininess();
1472 1600
@@ -1517,6 +1645,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1517 1645
1518 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1646 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1519 { 1647 {
1648 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1649 return;
1650
1520 Primitive.TextureEntry tex = part.Shape.Textures; 1651 Primitive.TextureEntry tex = part.Shape.Textures;
1521 if (face >= 0 && face < GetNumberOfSides(part)) 1652 if (face >= 0 && face < GetNumberOfSides(part))
1522 { 1653 {
@@ -1577,13 +1708,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1577 m_host.AddScriptLPS(1); 1708 m_host.AddScriptLPS(1);
1578 1709
1579 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1710 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1580 1711 if (parts.Count > 0)
1581 foreach (SceneObjectPart part in parts) 1712 {
1582 SetAlpha(part, alpha, face); 1713 try
1714 {
1715 parts[0].ParentGroup.areUpdatesSuspended = true;
1716 foreach (SceneObjectPart part in parts)
1717 SetAlpha(part, alpha, face);
1718 }
1719 finally
1720 {
1721 parts[0].ParentGroup.areUpdatesSuspended = false;
1722 }
1723 }
1583 } 1724 }
1584 1725
1585 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1726 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1586 { 1727 {
1728 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1729 return;
1730
1587 Primitive.TextureEntry tex = part.Shape.Textures; 1731 Primitive.TextureEntry tex = part.Shape.Textures;
1588 Color4 texcolor; 1732 Color4 texcolor;
1589 if (face >= 0 && face < GetNumberOfSides(part)) 1733 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1629,7 +1773,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1629 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1773 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1630 float wind, float tension, LSL_Vector Force) 1774 float wind, float tension, LSL_Vector Force)
1631 { 1775 {
1632 if (part == null) 1776 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1633 return; 1777 return;
1634 1778
1635 if (flexi) 1779 if (flexi)
@@ -1664,7 +1808,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1664 /// <param name="falloff"></param> 1808 /// <param name="falloff"></param>
1665 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1809 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1666 { 1810 {
1667 if (part == null) 1811 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1668 return; 1812 return;
1669 1813
1670 if (light) 1814 if (light)
@@ -1741,15 +1885,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1741 m_host.AddScriptLPS(1); 1885 m_host.AddScriptLPS(1);
1742 1886
1743 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1887 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1744 1888 if (parts.Count > 0)
1745 foreach (SceneObjectPart part in parts) 1889 {
1746 SetTexture(part, texture, face); 1890 try
1747 1891 {
1892 parts[0].ParentGroup.areUpdatesSuspended = true;
1893 foreach (SceneObjectPart part in parts)
1894 SetTexture(part, texture, face);
1895 }
1896 finally
1897 {
1898 parts[0].ParentGroup.areUpdatesSuspended = false;
1899 }
1900 }
1748 ScriptSleep(200); 1901 ScriptSleep(200);
1749 } 1902 }
1750 1903
1751 protected void SetTexture(SceneObjectPart part, string texture, int face) 1904 protected void SetTexture(SceneObjectPart part, string texture, int face)
1752 { 1905 {
1906 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1907 return;
1908
1753 UUID textureID=new UUID(); 1909 UUID textureID=new UUID();
1754 1910
1755 if (!UUID.TryParse(texture, out textureID)) 1911 if (!UUID.TryParse(texture, out textureID))
@@ -1795,6 +1951,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1795 1951
1796 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1952 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1797 { 1953 {
1954 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1955 return;
1956
1798 Primitive.TextureEntry tex = part.Shape.Textures; 1957 Primitive.TextureEntry tex = part.Shape.Textures;
1799 if (face >= 0 && face < GetNumberOfSides(part)) 1958 if (face >= 0 && face < GetNumberOfSides(part))
1800 { 1959 {
@@ -1831,6 +1990,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1831 1990
1832 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 1991 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1833 { 1992 {
1993 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1994 return;
1995
1834 Primitive.TextureEntry tex = part.Shape.Textures; 1996 Primitive.TextureEntry tex = part.Shape.Textures;
1835 if (face >= 0 && face < GetNumberOfSides(part)) 1997 if (face >= 0 && face < GetNumberOfSides(part))
1836 { 1998 {
@@ -1867,6 +2029,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1867 2029
1868 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 2030 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1869 { 2031 {
2032 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2033 return;
2034
1870 Primitive.TextureEntry tex = part.Shape.Textures; 2035 Primitive.TextureEntry tex = part.Shape.Textures;
1871 if (face >= 0 && face < GetNumberOfSides(part)) 2036 if (face >= 0 && face < GetNumberOfSides(part))
1872 { 2037 {
@@ -1937,6 +2102,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1937 2102
1938 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 2103 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
1939 { 2104 {
2105 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2106 return;
2107
1940 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2108 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1941 LSL_Vector currentPos = llGetLocalPos(); 2109 LSL_Vector currentPos = llGetLocalPos();
1942 2110
@@ -2023,6 +2191,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2023 2191
2024 protected void SetRot(SceneObjectPart part, Quaternion rot) 2192 protected void SetRot(SceneObjectPart part, Quaternion rot)
2025 { 2193 {
2194 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2195 return;
2196
2026 part.UpdateRotation(rot); 2197 part.UpdateRotation(rot);
2027 // Update rotation does not move the object in the physics scene if it's a linkset. 2198 // Update rotation does not move the object in the physics scene if it's a linkset.
2028 2199
@@ -2642,12 +2813,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2642 2813
2643 m_host.AddScriptLPS(1); 2814 m_host.AddScriptLPS(1);
2644 2815
2816 m_host.TaskInventory.LockItemsForRead(true);
2645 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2817 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2646 2818 m_host.TaskInventory.LockItemsForRead(false);
2647 lock (m_host.TaskInventory)
2648 {
2649 item = m_host.TaskInventory[invItemID];
2650 }
2651 2819
2652 if (item.PermsGranter == UUID.Zero) 2820 if (item.PermsGranter == UUID.Zero)
2653 return 0; 2821 return 0;
@@ -2722,6 +2890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2722 if (dist > m_ScriptDistanceFactor * 10.0f) 2890 if (dist > m_ScriptDistanceFactor * 10.0f)
2723 return; 2891 return;
2724 2892
2893 //Clone is thread-safe
2725 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2894 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2726 2895
2727 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2896 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2784,6 +2953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2784 2953
2785 public void llLookAt(LSL_Vector target, double strength, double damping) 2954 public void llLookAt(LSL_Vector target, double strength, double damping)
2786 { 2955 {
2956 /*
2787 m_host.AddScriptLPS(1); 2957 m_host.AddScriptLPS(1);
2788 // Determine where we are looking from 2958 // Determine where we are looking from
2789 LSL_Vector from = llGetPos(); 2959 LSL_Vector from = llGetPos();
@@ -2803,10 +2973,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2803 // the angles of rotation in radians into rotation value 2973 // the angles of rotation in radians into rotation value
2804 2974
2805 LSL_Types.Quaternion rot = llEuler2Rot(angle); 2975 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2806 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 2976
2807 m_host.startLookAt(rotation, (float)damping, (float)strength); 2977 // This would only work if your physics system contains an APID controller:
2978 // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
2979 // m_host.startLookAt(rotation, (float)damping, (float)strength);
2980
2808 // Orient the object to the angle calculated 2981 // Orient the object to the angle calculated
2809 //llSetRot(rot); 2982 llSetRot(rot);
2983 */
2984
2985 //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object.
2986 //There's probably a smarter way of doing this, my rotation math-fu is weak.
2987 // http://bugs.meta7.com/view.php?id=28
2988 // - Tom
2989
2990 LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d));
2991 llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos()));
2992
2993 }
2994
2995 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
2996 {
2997 m_host.AddScriptLPS(1);
2998// NotImplemented("llRotLookAt");
2999 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
3000
2810 } 3001 }
2811 3002
2812 public void llStopLookAt() 3003 public void llStopLookAt()
@@ -2855,13 +3046,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2855 { 3046 {
2856 TaskInventoryItem item; 3047 TaskInventoryItem item;
2857 3048
2858 lock (m_host.TaskInventory) 3049 m_host.TaskInventory.LockItemsForRead(true);
3050 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2859 { 3051 {
2860 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3052 m_host.TaskInventory.LockItemsForRead(false);
2861 return; 3053 return;
2862 else 3054 }
2863 item = m_host.TaskInventory[InventorySelf()]; 3055 else
3056 {
3057 item = m_host.TaskInventory[InventorySelf()];
2864 } 3058 }
3059 m_host.TaskInventory.LockItemsForRead(false);
2865 3060
2866 if (item.PermsGranter != UUID.Zero) 3061 if (item.PermsGranter != UUID.Zero)
2867 { 3062 {
@@ -2883,13 +3078,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2883 { 3078 {
2884 TaskInventoryItem item; 3079 TaskInventoryItem item;
2885 3080
3081 m_host.TaskInventory.LockItemsForRead(true);
2886 lock (m_host.TaskInventory) 3082 lock (m_host.TaskInventory)
2887 { 3083 {
3084
2888 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3085 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3086 {
3087 m_host.TaskInventory.LockItemsForRead(false);
2889 return; 3088 return;
3089 }
2890 else 3090 else
3091 {
2891 item = m_host.TaskInventory[InventorySelf()]; 3092 item = m_host.TaskInventory[InventorySelf()];
3093 }
2892 } 3094 }
3095 m_host.TaskInventory.LockItemsForRead(false);
2893 3096
2894 m_host.AddScriptLPS(1); 3097 m_host.AddScriptLPS(1);
2895 3098
@@ -2921,18 +3124,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2921 { 3124 {
2922 m_host.AddScriptLPS(1); 3125 m_host.AddScriptLPS(1);
2923 3126
2924 if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
2925 return;
2926
2927 TaskInventoryItem item; 3127 TaskInventoryItem item;
2928 3128
2929 lock (m_host.TaskInventory) 3129 m_host.TaskInventory.LockItemsForRead(true);
3130
3131 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2930 { 3132 {
2931 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3133 m_host.TaskInventory.LockItemsForRead(false);
2932 return; 3134 return;
2933 else
2934 item = m_host.TaskInventory[InventorySelf()];
2935 } 3135 }
3136 else
3137 {
3138 item = m_host.TaskInventory[InventorySelf()];
3139 }
3140
3141 m_host.TaskInventory.LockItemsForRead(false);
2936 3142
2937 if (item.PermsGranter != m_host.OwnerID) 3143 if (item.PermsGranter != m_host.OwnerID)
2938 return; 3144 return;
@@ -2943,11 +3149,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2943 3149
2944 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3150 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
2945 3151
3152 /*
2946 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3153 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
2947 if (attachmentsModule != null) 3154 if (attachmentsModule != null)
3155 {
2948 attachmentsModule.AttachObject( 3156 attachmentsModule.AttachObject(
2949 presence.ControllingClient, grp.LocalId, 3157 presence.ControllingClient, grp.LocalId,
2950 (uint)attachment, Quaternion.Identity, Vector3.Zero, false); 3158 (uint)attachment, Quaternion.Identity, Vector3.Zero, false);
3159 }
3160 */
3161 grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false);
2951 } 3162 }
2952 } 3163 }
2953 3164
@@ -2960,13 +3171,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2960 3171
2961 TaskInventoryItem item; 3172 TaskInventoryItem item;
2962 3173
2963 lock (m_host.TaskInventory) 3174 m_host.TaskInventory.LockItemsForRead(true);
3175
3176 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2964 { 3177 {
2965 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3178 m_host.TaskInventory.LockItemsForRead(false);
2966 return; 3179 return;
2967 else
2968 item = m_host.TaskInventory[InventorySelf()];
2969 } 3180 }
3181 else
3182 {
3183 item = m_host.TaskInventory[InventorySelf()];
3184 }
3185 m_host.TaskInventory.LockItemsForRead(false);
3186
2970 3187
2971 if (item.PermsGranter != m_host.OwnerID) 3188 if (item.PermsGranter != m_host.OwnerID)
2972 return; 3189 return;
@@ -3003,8 +3220,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3003 return m_host.OwnerID.ToString(); 3220 return m_host.OwnerID.ToString();
3004 } 3221 }
3005 3222
3223 [DebuggerNonUserCode]
3006 public void llInstantMessage(string user, string message) 3224 public void llInstantMessage(string user, string message)
3007 { 3225 {
3226 UUID result;
3227 if (!UUID.TryParse(user, out result))
3228 {
3229 throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user));
3230 return;
3231 }
3232
3233
3008 m_host.AddScriptLPS(1); 3234 m_host.AddScriptLPS(1);
3009 3235
3010 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3236 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -3019,14 +3245,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3019 UUID friendTransactionID = UUID.Random(); 3245 UUID friendTransactionID = UUID.Random();
3020 3246
3021 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3247 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
3022 3248
3023 GridInstantMessage msg = new GridInstantMessage(); 3249 GridInstantMessage msg = new GridInstantMessage();
3024 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3250 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
3025 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3251 msg.toAgentID = new Guid(user); // toAgentID.Guid;
3026 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 3252 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
3027// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 3253// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
3028// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 3254// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
3029 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 3255 DateTime dt = DateTime.UtcNow;
3256
3257 // Ticks from UtcNow, but make it look like local. Evil, huh?
3258 dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
3259
3260 try
3261 {
3262 // Convert that to the PST timezone
3263 TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
3264 dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
3265 }
3266 catch
3267 {
3268 // No logging here, as it could be VERY spammy
3269 }
3270
3271 // And make it look local again to fool the unix time util
3272 dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
3273
3274 msg.timestamp = (uint)Util.ToUnixTime(dt);
3275
3030 //if (client != null) 3276 //if (client != null)
3031 //{ 3277 //{
3032 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; 3278 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
@@ -3040,13 +3286,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3040 msg.message = message.Substring(0, 1024); 3286 msg.message = message.Substring(0, 1024);
3041 else 3287 else
3042 msg.message = message; 3288 msg.message = message;
3043 msg.dialog = (byte)19; // messgage from script ??? // dialog; 3289 msg.dialog = (byte)19; // MessageFromObject
3044 msg.fromGroup = false;// fromGroup; 3290 msg.fromGroup = false;// fromGroup;
3045 msg.offline = (byte)0; //offline; 3291 msg.offline = (byte)0; //offline;
3046 msg.ParentEstateID = 0; //ParentEstateID; 3292 msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
3047 msg.Position = Vector3.Zero;// new Vector3(m_host.AbsolutePosition); 3293 msg.Position = new Vector3(m_host.AbsolutePosition);
3048 msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid; 3294 msg.RegionID = World.RegionInfo.RegionID.Guid;
3049 msg.binaryBucket = new byte[0];// binaryBucket; 3295 msg.binaryBucket = Util.StringToBytes256(m_host.OwnerID.ToString());
3050 3296
3051 if (m_TransferModule != null) 3297 if (m_TransferModule != null)
3052 { 3298 {
@@ -3168,13 +3414,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3168 m_host.AddScriptLPS(1); 3414 m_host.AddScriptLPS(1);
3169 } 3415 }
3170 3416
3171 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3172 {
3173 m_host.AddScriptLPS(1);
3174 Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
3175 m_host.RotLookAt(rot, (float)strength, (float)damping);
3176 }
3177
3178 public LSL_Integer llStringLength(string str) 3417 public LSL_Integer llStringLength(string str)
3179 { 3418 {
3180 m_host.AddScriptLPS(1); 3419 m_host.AddScriptLPS(1);
@@ -3198,14 +3437,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3198 3437
3199 TaskInventoryItem item; 3438 TaskInventoryItem item;
3200 3439
3201 lock (m_host.TaskInventory) 3440 m_host.TaskInventory.LockItemsForRead(true);
3441 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3202 { 3442 {
3203 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3443 m_host.TaskInventory.LockItemsForRead(false);
3204 return; 3444 return;
3205 else
3206 item = m_host.TaskInventory[InventorySelf()];
3207 } 3445 }
3208 3446 else
3447 {
3448 item = m_host.TaskInventory[InventorySelf()];
3449 }
3450 m_host.TaskInventory.LockItemsForRead(false);
3209 if (item.PermsGranter == UUID.Zero) 3451 if (item.PermsGranter == UUID.Zero)
3210 return; 3452 return;
3211 3453
@@ -3235,13 +3477,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3235 3477
3236 TaskInventoryItem item; 3478 TaskInventoryItem item;
3237 3479
3238 lock (m_host.TaskInventory) 3480 m_host.TaskInventory.LockItemsForRead(true);
3481 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3239 { 3482 {
3240 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3483 m_host.TaskInventory.LockItemsForRead(false);
3241 return; 3484 return;
3242 else
3243 item = m_host.TaskInventory[InventorySelf()];
3244 } 3485 }
3486 else
3487 {
3488 item = m_host.TaskInventory[InventorySelf()];
3489 }
3490 m_host.TaskInventory.LockItemsForRead(false);
3491
3245 3492
3246 if (item.PermsGranter == UUID.Zero) 3493 if (item.PermsGranter == UUID.Zero)
3247 return; 3494 return;
@@ -3318,10 +3565,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3318 3565
3319 TaskInventoryItem item; 3566 TaskInventoryItem item;
3320 3567
3321 lock (m_host.TaskInventory) 3568
3569 m_host.TaskInventory.LockItemsForRead(true);
3570 if (!m_host.TaskInventory.ContainsKey(invItemID))
3571 {
3572 m_host.TaskInventory.LockItemsForRead(false);
3573 return;
3574 }
3575 else
3322 { 3576 {
3323 item = m_host.TaskInventory[invItemID]; 3577 item = m_host.TaskInventory[invItemID];
3324 } 3578 }
3579 m_host.TaskInventory.LockItemsForRead(false);
3325 3580
3326 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3581 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3327 { 3582 {
@@ -3353,11 +3608,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3353 3608
3354 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3609 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3355 { 3610 {
3356 lock (m_host.TaskInventory) 3611 m_host.TaskInventory.LockItemsForWrite(true);
3357 { 3612 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3358 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3613 m_host.TaskInventory[invItemID].PermsMask = perm;
3359 m_host.TaskInventory[invItemID].PermsMask = perm; 3614 m_host.TaskInventory.LockItemsForWrite(false);
3360 }
3361 3615
3362 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3616 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3363 "run_time_permissions", new Object[] { 3617 "run_time_permissions", new Object[] {
@@ -3377,11 +3631,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3377 3631
3378 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3632 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3379 { 3633 {
3380 lock (m_host.TaskInventory) 3634 m_host.TaskInventory.LockItemsForWrite(true);
3381 { 3635 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3382 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3636 m_host.TaskInventory[invItemID].PermsMask = perm;
3383 m_host.TaskInventory[invItemID].PermsMask = perm; 3637 m_host.TaskInventory.LockItemsForWrite(false);
3384 }
3385 3638
3386 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3639 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3387 "run_time_permissions", new Object[] { 3640 "run_time_permissions", new Object[] {
@@ -3402,11 +3655,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3402 3655
3403 if (!m_waitingForScriptAnswer) 3656 if (!m_waitingForScriptAnswer)
3404 { 3657 {
3405 lock (m_host.TaskInventory) 3658 m_host.TaskInventory.LockItemsForWrite(true);
3406 { 3659 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3407 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3660 m_host.TaskInventory[invItemID].PermsMask = 0;
3408 m_host.TaskInventory[invItemID].PermsMask = 0; 3661 m_host.TaskInventory.LockItemsForWrite(false);
3409 }
3410 3662
3411 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3663 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3412 m_waitingForScriptAnswer=true; 3664 m_waitingForScriptAnswer=true;
@@ -3441,10 +3693,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3441 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3693 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3442 llReleaseControls(); 3694 llReleaseControls();
3443 3695
3444 lock (m_host.TaskInventory) 3696
3445 { 3697 m_host.TaskInventory.LockItemsForWrite(true);
3446 m_host.TaskInventory[invItemID].PermsMask = answer; 3698 m_host.TaskInventory[invItemID].PermsMask = answer;
3447 } 3699 m_host.TaskInventory.LockItemsForWrite(false);
3700
3448 3701
3449 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3702 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3450 "run_time_permissions", new Object[] { 3703 "run_time_permissions", new Object[] {
@@ -3456,16 +3709,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3456 { 3709 {
3457 m_host.AddScriptLPS(1); 3710 m_host.AddScriptLPS(1);
3458 3711
3459 lock (m_host.TaskInventory) 3712 m_host.TaskInventory.LockItemsForRead(true);
3713
3714 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3460 { 3715 {
3461 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3716 if (item.Type == 10 && item.ItemID == m_itemID)
3462 { 3717 {
3463 if (item.Type == 10 && item.ItemID == m_itemID) 3718 m_host.TaskInventory.LockItemsForRead(false);
3464 { 3719 return item.PermsGranter.ToString();
3465 return item.PermsGranter.ToString();
3466 }
3467 } 3720 }
3468 } 3721 }
3722 m_host.TaskInventory.LockItemsForRead(false);
3469 3723
3470 return UUID.Zero.ToString(); 3724 return UUID.Zero.ToString();
3471 } 3725 }
@@ -3474,19 +3728,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3474 { 3728 {
3475 m_host.AddScriptLPS(1); 3729 m_host.AddScriptLPS(1);
3476 3730
3477 lock (m_host.TaskInventory) 3731 m_host.TaskInventory.LockItemsForRead(true);
3732
3733 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3478 { 3734 {
3479 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3735 if (item.Type == 10 && item.ItemID == m_itemID)
3480 { 3736 {
3481 if (item.Type == 10 && item.ItemID == m_itemID) 3737 int perms = item.PermsMask;
3482 { 3738 if (m_automaticLinkPermission)
3483 int perms = item.PermsMask; 3739 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3484 if (m_automaticLinkPermission) 3740 m_host.TaskInventory.LockItemsForRead(false);
3485 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3741 return perms;
3486 return perms;
3487 }
3488 } 3742 }
3489 } 3743 }
3744 m_host.TaskInventory.LockItemsForRead(false);
3490 3745
3491 return 0; 3746 return 0;
3492 } 3747 }
@@ -3508,9 +3763,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3508 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3763 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3509 { 3764 {
3510 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3765 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3511 3766 if (parts.Count > 0)
3512 foreach (SceneObjectPart part in parts) 3767 {
3513 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3768 try
3769 {
3770 parts[0].ParentGroup.areUpdatesSuspended = true;
3771 foreach (SceneObjectPart part in parts)
3772 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
3773 }
3774 finally
3775 {
3776 parts[0].ParentGroup.areUpdatesSuspended = false;
3777 }
3778 }
3514 } 3779 }
3515 3780
3516 public void llCreateLink(string target, int parent) 3781 public void llCreateLink(string target, int parent)
@@ -3519,11 +3784,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3519 UUID invItemID = InventorySelf(); 3784 UUID invItemID = InventorySelf();
3520 3785
3521 TaskInventoryItem item; 3786 TaskInventoryItem item;
3522 lock (m_host.TaskInventory) 3787 m_host.TaskInventory.LockItemsForRead(true);
3523 { 3788 item = m_host.TaskInventory[invItemID];
3524 item = m_host.TaskInventory[invItemID]; 3789 m_host.TaskInventory.LockItemsForRead(false);
3525 } 3790
3526
3527 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3791 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3528 && !m_automaticLinkPermission) 3792 && !m_automaticLinkPermission)
3529 { 3793 {
@@ -3576,16 +3840,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3576 m_host.AddScriptLPS(1); 3840 m_host.AddScriptLPS(1);
3577 UUID invItemID = InventorySelf(); 3841 UUID invItemID = InventorySelf();
3578 3842
3579 lock (m_host.TaskInventory) 3843 m_host.TaskInventory.LockItemsForRead(true);
3580 {
3581 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3844 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3582 && !m_automaticLinkPermission) 3845 && !m_automaticLinkPermission)
3583 { 3846 {
3584 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3847 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3848 m_host.TaskInventory.LockItemsForRead(false);
3585 return; 3849 return;
3586 } 3850 }
3587 } 3851 m_host.TaskInventory.LockItemsForRead(false);
3588 3852
3589 if (linknum < ScriptBaseClass.LINK_THIS) 3853 if (linknum < ScriptBaseClass.LINK_THIS)
3590 return; 3854 return;
3591 3855
@@ -3624,10 +3888,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3624 // Restructuring Multiple Prims. 3888 // Restructuring Multiple Prims.
3625 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3889 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3626 parts.Remove(parentPrim.RootPart); 3890 parts.Remove(parentPrim.RootPart);
3627 foreach (SceneObjectPart part in parts) 3891 if (parts.Count > 0)
3628 { 3892 {
3629 parentPrim.DelinkFromGroup(part.LocalId, true); 3893 try
3894 {
3895 parts[0].ParentGroup.areUpdatesSuspended = true;
3896 foreach (SceneObjectPart part in parts)
3897 {
3898 parentPrim.DelinkFromGroup(part.LocalId, true);
3899 }
3900 }
3901 finally
3902 {
3903 parts[0].ParentGroup.areUpdatesSuspended = false;
3904 }
3630 } 3905 }
3906
3631 parentPrim.HasGroupChanged = true; 3907 parentPrim.HasGroupChanged = true;
3632 parentPrim.ScheduleGroupForFullUpdate(); 3908 parentPrim.ScheduleGroupForFullUpdate();
3633 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3909 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3636,11 +3912,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3636 { 3912 {
3637 SceneObjectPart newRoot = parts[0]; 3913 SceneObjectPart newRoot = parts[0];
3638 parts.Remove(newRoot); 3914 parts.Remove(newRoot);
3639 foreach (SceneObjectPart part in parts) 3915
3916 try
3640 { 3917 {
3641 part.UpdateFlag = 0; 3918 parts[0].ParentGroup.areUpdatesSuspended = true;
3642 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 3919 foreach (SceneObjectPart part in parts)
3920 {
3921 part.UpdateFlag = 0;
3922 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
3923 }
3643 } 3924 }
3925 finally
3926 {
3927 parts[0].ParentGroup.areUpdatesSuspended = false;
3928 }
3929
3930
3644 newRoot.ParentGroup.HasGroupChanged = true; 3931 newRoot.ParentGroup.HasGroupChanged = true;
3645 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 3932 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3646 } 3933 }
@@ -3666,11 +3953,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3666 3953
3667 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3954 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3668 parts.Remove(parentPrim.RootPart); 3955 parts.Remove(parentPrim.RootPart);
3669 3956 if (parts.Count > 0)
3670 foreach (SceneObjectPart part in parts)
3671 { 3957 {
3672 parentPrim.DelinkFromGroup(part.LocalId, true); 3958 try
3673 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3959 {
3960 parts[0].ParentGroup.areUpdatesSuspended = true;
3961 foreach (SceneObjectPart part in parts)
3962 {
3963 parentPrim.DelinkFromGroup(part.LocalId, true);
3964 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3965 }
3966 }
3967 finally
3968 {
3969 parts[0].ParentGroup.areUpdatesSuspended = false;
3970 }
3674 } 3971 }
3675 parentPrim.HasGroupChanged = true; 3972 parentPrim.HasGroupChanged = true;
3676 parentPrim.ScheduleGroupForFullUpdate(); 3973 parentPrim.ScheduleGroupForFullUpdate();
@@ -3762,17 +4059,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3762 m_host.AddScriptLPS(1); 4059 m_host.AddScriptLPS(1);
3763 int count = 0; 4060 int count = 0;
3764 4061
3765 lock (m_host.TaskInventory) 4062 m_host.TaskInventory.LockItemsForRead(true);
4063 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3766 { 4064 {
3767 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4065 if (inv.Value.Type == type || type == -1)
3768 { 4066 {
3769 if (inv.Value.Type == type || type == -1) 4067 count = count + 1;
3770 {
3771 count = count + 1;
3772 }
3773 } 4068 }
3774 } 4069 }
3775 4070
4071 m_host.TaskInventory.LockItemsForRead(false);
3776 return count; 4072 return count;
3777 } 4073 }
3778 4074
@@ -3781,16 +4077,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3781 m_host.AddScriptLPS(1); 4077 m_host.AddScriptLPS(1);
3782 ArrayList keys = new ArrayList(); 4078 ArrayList keys = new ArrayList();
3783 4079
3784 lock (m_host.TaskInventory) 4080 m_host.TaskInventory.LockItemsForRead(true);
4081 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3785 { 4082 {
3786 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4083 if (inv.Value.Type == type || type == -1)
3787 { 4084 {
3788 if (inv.Value.Type == type || type == -1) 4085 keys.Add(inv.Value.Name);
3789 {
3790 keys.Add(inv.Value.Name);
3791 }
3792 } 4086 }
3793 } 4087 }
4088 m_host.TaskInventory.LockItemsForRead(false);
3794 4089
3795 if (keys.Count == 0) 4090 if (keys.Count == 0)
3796 { 4091 {
@@ -3827,20 +4122,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3827 } 4122 }
3828 4123
3829 // move the first object found with this inventory name 4124 // move the first object found with this inventory name
3830 lock (m_host.TaskInventory) 4125 m_host.TaskInventory.LockItemsForRead(true);
4126 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3831 { 4127 {
3832 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4128 if (inv.Value.Name == inventory)
3833 { 4129 {
3834 if (inv.Value.Name == inventory) 4130 found = true;
3835 { 4131 objId = inv.Key;
3836 found = true; 4132 assetType = inv.Value.Type;
3837 objId = inv.Key; 4133 objName = inv.Value.Name;
3838 assetType = inv.Value.Type; 4134 break;
3839 objName = inv.Value.Name;
3840 break;
3841 }
3842 } 4135 }
3843 } 4136 }
4137 m_host.TaskInventory.LockItemsForRead(false);
3844 4138
3845 if (!found) 4139 if (!found)
3846 { 4140 {
@@ -3848,9 +4142,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3848 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4142 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
3849 } 4143 }
3850 4144
3851 // check if destination is an avatar 4145 // check if destination is an object
3852 if (World.GetScenePresence(destId) != null) 4146 if (World.GetSceneObjectPart(destId) != null)
4147 {
4148 // destination is an object
4149 World.MoveTaskInventoryItem(destId, m_host, objId);
4150 }
4151 else
3853 { 4152 {
4153 ScenePresence presence = World.GetScenePresence(destId);
4154
4155 if (presence == null)
4156 {
4157 UserAccount account =
4158 World.UserAccountService.GetUserAccount(
4159 World.RegionInfo.ScopeID,
4160 destId);
4161
4162 if (account == null)
4163 {
4164 llSay(0, "Can't find destination "+destId.ToString());
4165 return;
4166 }
4167 }
4168
3854 // destination is an avatar 4169 // destination is an avatar
3855 InventoryItemBase agentItem = 4170 InventoryItemBase agentItem =
3856 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4171 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
@@ -3876,33 +4191,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3876 4191
3877 if (m_TransferModule != null) 4192 if (m_TransferModule != null)
3878 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 4193 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
4194
4195 //This delay should only occur when giving inventory to avatars.
4196 ScriptSleep(3000);
3879 } 4197 }
3880 else
3881 {
3882 // destination is an object
3883 World.MoveTaskInventoryItem(destId, m_host, objId);
3884 }
3885 ScriptSleep(3000);
3886 } 4198 }
3887 4199
4200 [DebuggerNonUserCode]
3888 public void llRemoveInventory(string name) 4201 public void llRemoveInventory(string name)
3889 { 4202 {
3890 m_host.AddScriptLPS(1); 4203 m_host.AddScriptLPS(1);
3891 4204
3892 lock (m_host.TaskInventory) 4205 m_host.TaskInventory.LockItemsForRead(true);
4206 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3893 { 4207 {
3894 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4208 if (item.Name == name)
3895 { 4209 {
3896 if (item.Name == name) 4210 if (item.ItemID == m_itemID)
3897 { 4211 throw new ScriptDeleteException();
3898 if (item.ItemID == m_itemID) 4212 else
3899 throw new ScriptDeleteException(); 4213 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3900 else 4214
3901 m_host.Inventory.RemoveInventoryItem(item.ItemID); 4215 m_host.TaskInventory.LockItemsForRead(false);
3902 return; 4216 return;
3903 }
3904 } 4217 }
3905 } 4218 }
4219 m_host.TaskInventory.LockItemsForRead(false);
3906 } 4220 }
3907 4221
3908 public void llSetText(string text, LSL_Vector color, double alpha) 4222 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -3938,22 +4252,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3938 UUID uuid = (UUID)id; 4252 UUID uuid = (UUID)id;
3939 4253
3940 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 4254 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
4255 if (account == null)
4256 return UUID.Zero.ToString();
4257
3941 4258
3942 PresenceInfo pinfo = null; 4259 PresenceInfo pinfo = null;
3943 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); 4260 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3944 if (pinfos != null && pinfos.Length > 0) 4261 if (pinfos != null && pinfos.Length > 0)
3945 pinfo = pinfos[0]; 4262 pinfo = pinfos[0];
3946 4263
3947 if (pinfo == null)
3948 return UUID.Zero.ToString();
3949
3950 string reply = String.Empty; 4264 string reply = String.Empty;
3951 4265
3952 switch (data) 4266 switch (data)
3953 { 4267 {
3954 case 1: // DATA_ONLINE (0|1) 4268 case 1: // DATA_ONLINE (0|1)
3955 // TODO: implement fetching of this information 4269 if (pinfo != null && pinfo.RegionID != UUID.Zero)
3956 if (pinfo != null)
3957 reply = "1"; 4270 reply = "1";
3958 else 4271 else
3959 reply = "0"; 4272 reply = "0";
@@ -3993,6 +4306,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3993 { 4306 {
3994 m_host.AddScriptLPS(1); 4307 m_host.AddScriptLPS(1);
3995 4308
4309 //Clone is thread safe
3996 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 4310 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3997 4311
3998 foreach (TaskInventoryItem item in itemDictionary.Values) 4312 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -4046,6 +4360,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4046 ScenePresence presence = World.GetScenePresence(agentId); 4360 ScenePresence presence = World.GetScenePresence(agentId);
4047 if (presence != null) 4361 if (presence != null)
4048 { 4362 {
4363 // agent must not be a god
4364 if (presence.GodLevel >= 200) return;
4365
4049 // agent must be over the owners land 4366 // agent must be over the owners land
4050 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4367 if (m_host.OwnerID == World.LandChannel.GetLandObject(
4051 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 4368 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
@@ -4106,17 +4423,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4106 UUID soundId = UUID.Zero; 4423 UUID soundId = UUID.Zero;
4107 if (!UUID.TryParse(impact_sound, out soundId)) 4424 if (!UUID.TryParse(impact_sound, out soundId))
4108 { 4425 {
4109 lock (m_host.TaskInventory) 4426 m_host.TaskInventory.LockItemsForRead(true);
4427 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4110 { 4428 {
4111 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4429 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
4112 { 4430 {
4113 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4431 soundId = item.AssetID;
4114 { 4432 break;
4115 soundId = item.AssetID;
4116 break;
4117 }
4118 } 4433 }
4119 } 4434 }
4435 m_host.TaskInventory.LockItemsForRead(false);
4120 } 4436 }
4121 m_host.CollisionSound = soundId; 4437 m_host.CollisionSound = soundId;
4122 m_host.CollisionSoundVolume = (float)impact_volume; 4438 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4162,6 +4478,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4162 UUID partItemID; 4478 UUID partItemID;
4163 foreach (SceneObjectPart part in parts) 4479 foreach (SceneObjectPart part in parts)
4164 { 4480 {
4481 //Clone is thread safe
4165 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4482 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4166 4483
4167 foreach (TaskInventoryItem item in itemsDictionary.Values) 4484 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4376,17 +4693,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4376 4693
4377 m_host.AddScriptLPS(1); 4694 m_host.AddScriptLPS(1);
4378 4695
4379 lock (m_host.TaskInventory) 4696 m_host.TaskInventory.LockItemsForRead(true);
4697 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4380 { 4698 {
4381 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4699 if (item.Type == 10 && item.ItemID == m_itemID)
4382 { 4700 {
4383 if (item.Type == 10 && item.ItemID == m_itemID) 4701 result = item.Name!=null?item.Name:String.Empty;
4384 { 4702 break;
4385 result = item.Name != null ? item.Name : String.Empty;
4386 break;
4387 }
4388 } 4703 }
4389 } 4704 }
4705 m_host.TaskInventory.LockItemsForRead(false);
4390 4706
4391 return result; 4707 return result;
4392 } 4708 }
@@ -4539,23 +4855,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4539 { 4855 {
4540 m_host.AddScriptLPS(1); 4856 m_host.AddScriptLPS(1);
4541 4857
4542 lock (m_host.TaskInventory) 4858 m_host.TaskInventory.LockItemsForRead(true);
4859 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4543 { 4860 {
4544 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4861 if (inv.Value.Name == name)
4545 { 4862 {
4546 if (inv.Value.Name == name) 4863 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4547 { 4864 {
4548 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 4865 m_host.TaskInventory.LockItemsForRead(false);
4549 { 4866 return inv.Value.AssetID.ToString();
4550 return inv.Value.AssetID.ToString(); 4867 }
4551 } 4868 else
4552 else 4869 {
4553 { 4870 m_host.TaskInventory.LockItemsForRead(false);
4554 return UUID.Zero.ToString(); 4871 return UUID.Zero.ToString();
4555 }
4556 } 4872 }
4557 } 4873 }
4558 } 4874 }
4875 m_host.TaskInventory.LockItemsForRead(false);
4559 4876
4560 return UUID.Zero.ToString(); 4877 return UUID.Zero.ToString();
4561 } 4878 }
@@ -5491,10 +5808,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5491 m_host.AddScriptLPS(1); 5808 m_host.AddScriptLPS(1);
5492 5809
5493 List<SceneObjectPart> parts = GetLinkParts(linknumber); 5810 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5494 5811 if (parts.Count > 0)
5495 foreach (var part in parts)
5496 { 5812 {
5497 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 5813 try
5814 {
5815 parts[0].ParentGroup.areUpdatesSuspended = true;
5816 foreach (var part in parts)
5817 {
5818 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
5819 }
5820 }
5821 finally
5822 {
5823 parts[0].ParentGroup.areUpdatesSuspended = false;
5824 }
5498 } 5825 }
5499 } 5826 }
5500 5827
@@ -6073,6 +6400,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6073 tempf = (float)rules.GetLSLFloatItem(i + 1); 6400 tempf = (float)rules.GetLSLFloatItem(i + 1);
6074 prules.OuterAngle = (float)tempf; 6401 prules.OuterAngle = (float)tempf;
6075 break; 6402 break;
6403
6404 case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE:
6405 tempf = (float)rules.GetLSLFloatItem(i + 1);
6406 prules.InnerAngle = (float)tempf;
6407 break;
6408
6409 case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE:
6410 tempf = (float)rules.GetLSLFloatItem(i + 1);
6411 prules.OuterAngle = (float)tempf;
6412 break;
6076 } 6413 }
6077 6414
6078 } 6415 }
@@ -6111,14 +6448,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6111 6448
6112 protected UUID GetTaskInventoryItem(string name) 6449 protected UUID GetTaskInventoryItem(string name)
6113 { 6450 {
6114 lock (m_host.TaskInventory) 6451 m_host.TaskInventory.LockItemsForRead(true);
6452 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6115 { 6453 {
6116 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6454 if (inv.Value.Name == name)
6117 { 6455 {
6118 if (inv.Value.Name == name) 6456 m_host.TaskInventory.LockItemsForRead(false);
6119 return inv.Key; 6457 return inv.Key;
6120 } 6458 }
6121 } 6459 }
6460 m_host.TaskInventory.LockItemsForRead(false);
6122 6461
6123 return UUID.Zero; 6462 return UUID.Zero;
6124 } 6463 }
@@ -6446,22 +6785,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6446 } 6785 }
6447 6786
6448 // copy the first script found with this inventory name 6787 // copy the first script found with this inventory name
6449 lock (m_host.TaskInventory) 6788 m_host.TaskInventory.LockItemsForRead(true);
6789 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6450 { 6790 {
6451 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6791 if (inv.Value.Name == name)
6452 { 6792 {
6453 if (inv.Value.Name == name) 6793 // make sure the object is a script
6794 if (10 == inv.Value.Type)
6454 { 6795 {
6455 // make sure the object is a script 6796 found = true;
6456 if (10 == inv.Value.Type) 6797 srcId = inv.Key;
6457 { 6798 break;
6458 found = true;
6459 srcId = inv.Key;
6460 break;
6461 }
6462 } 6799 }
6463 } 6800 }
6464 } 6801 }
6802 m_host.TaskInventory.LockItemsForRead(false);
6465 6803
6466 if (!found) 6804 if (!found)
6467 { 6805 {
@@ -6545,6 +6883,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6545 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6883 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
6546 { 6884 {
6547 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6885 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6886 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6887 return shapeBlock;
6548 6888
6549 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 6889 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6550 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 6890 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6620,6 +6960,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6620 6960
6621 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) 6961 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
6622 { 6962 {
6963 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6964 return;
6965
6623 ObjectShapePacket.ObjectDataBlock shapeBlock; 6966 ObjectShapePacket.ObjectDataBlock shapeBlock;
6624 6967
6625 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6968 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6669,6 +7012,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6669 7012
6670 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) 7013 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
6671 { 7014 {
7015 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7016 return;
7017
6672 ObjectShapePacket.ObjectDataBlock shapeBlock; 7018 ObjectShapePacket.ObjectDataBlock shapeBlock;
6673 7019
6674 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7020 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6711,6 +7057,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6711 7057
6712 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) 7058 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)
6713 { 7059 {
7060 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7061 return;
7062
6714 ObjectShapePacket.ObjectDataBlock shapeBlock; 7063 ObjectShapePacket.ObjectDataBlock shapeBlock;
6715 7064
6716 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7065 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6837,6 +7186,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6837 7186
6838 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) 7187 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
6839 { 7188 {
7189 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7190 return;
7191
6840 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7192 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6841 UUID sculptId; 7193 UUID sculptId;
6842 7194
@@ -6852,13 +7204,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6852 shapeBlock.PathScaleX = 100; 7204 shapeBlock.PathScaleX = 100;
6853 shapeBlock.PathScaleY = 150; 7205 shapeBlock.PathScaleY = 150;
6854 7206
6855 if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && 7207 if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 &&
6856 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && 7208 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 &&
6857 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && 7209 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 &&
6858 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) 7210 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0)
6859 { 7211 {
6860 // default 7212 // default
6861 type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; 7213 type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE;
6862 } 7214 }
6863 7215
6864 // retain pathcurve 7216 // retain pathcurve
@@ -6877,12 +7229,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6877 7229
6878 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7230 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6879 { 7231 {
6880 m_host.AddScriptLPS(1); 7232 m_host.AddScriptLPS(1);
6881 7233
6882 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7234 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6883 7235 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
6884 foreach (SceneObjectPart part in parts) 7236 if (parts.Count>0)
6885 SetPrimParams(part, rules); 7237 {
7238 try
7239 {
7240 parts[0].ParentGroup.areUpdatesSuspended = true;
7241 foreach (SceneObjectPart part in parts)
7242 SetPrimParams(part, rules);
7243 }
7244 finally
7245 {
7246 parts[0].ParentGroup.areUpdatesSuspended = false;
7247 }
7248 }
7249 if (avatars.Count > 0)
7250 {
7251 foreach (ScenePresence avatar in avatars)
7252 SetPrimParams(avatar, rules);
7253 }
6886 } 7254 }
6887 7255
6888 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7256 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
@@ -6890,8 +7258,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6890 llSetLinkPrimitiveParams(linknumber, rules); 7258 llSetLinkPrimitiveParams(linknumber, rules);
6891 } 7259 }
6892 7260
7261 protected void SetPrimParams(ScenePresence av, LSL_List rules)
7262 {
7263 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7264 //We only support PRIM_POSITION and PRIM_ROTATION
7265
7266 int idx = 0;
7267
7268 while (idx < rules.Length)
7269 {
7270 int code = rules.GetLSLIntegerItem(idx++);
7271
7272 int remain = rules.Length - idx;
7273
7274
7275
7276 switch (code)
7277 {
7278 case (int)ScriptBaseClass.PRIM_POSITION:
7279 if (remain < 1)
7280 return;
7281 LSL_Vector v;
7282 v = rules.GetVector3Item(idx++);
7283 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7284 av.SendFullUpdateToAllClients();
7285
7286 break;
7287
7288 case (int)ScriptBaseClass.PRIM_ROTATION:
7289 if (remain < 1)
7290 return;
7291 LSL_Rotation r;
7292 r = rules.GetQuaternionItem(idx++);
7293 av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7294 av.SendFullUpdateToAllClients();
7295 break;
7296 }
7297 }
7298
7299 }
7300
6893 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 7301 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6894 { 7302 {
7303 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7304 return;
7305
6895 int idx = 0; 7306 int idx = 0;
6896 7307
6897 while (idx < rules.Length) 7308 while (idx < rules.Length)
@@ -7723,24 +8134,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7723 break; 8134 break;
7724 8135
7725 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8136 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7726 // TODO--------------
7727 if (remain < 1) 8137 if (remain < 1)
7728 return res; 8138 return res;
8139 face = (int)rules.GetLSLIntegerItem(idx++);
7729 8140
7730 face=(int)rules.GetLSLIntegerItem(idx++); 8141 tex = part.Shape.Textures;
7731 8142 int shiny;
7732 res.Add(new LSL_Integer(0)); 8143 if (face == ScriptBaseClass.ALL_SIDES)
7733 res.Add(new LSL_Integer(0)); 8144 {
8145 for (face = 0; face < GetNumberOfSides(part); face++)
8146 {
8147 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8148 if (shinyness == Shininess.High)
8149 {
8150 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8151 }
8152 else if (shinyness == Shininess.Medium)
8153 {
8154 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8155 }
8156 else if (shinyness == Shininess.Low)
8157 {
8158 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8159 }
8160 else
8161 {
8162 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8163 }
8164 res.Add(new LSL_Integer(shiny));
8165 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8166 }
8167 }
8168 else
8169 {
8170 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8171 if (shinyness == Shininess.High)
8172 {
8173 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8174 }
8175 else if (shinyness == Shininess.Medium)
8176 {
8177 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8178 }
8179 else if (shinyness == Shininess.Low)
8180 {
8181 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8182 }
8183 else
8184 {
8185 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8186 }
8187 res.Add(new LSL_Integer(shiny));
8188 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8189 }
7734 break; 8190 break;
7735 8191
7736 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8192 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7737 // TODO--------------
7738 if (remain < 1) 8193 if (remain < 1)
7739 return res; 8194 return res;
8195 face = (int)rules.GetLSLIntegerItem(idx++);
7740 8196
7741 face=(int)rules.GetLSLIntegerItem(idx++); 8197 tex = part.Shape.Textures;
7742 8198 int fullbright;
7743 res.Add(new LSL_Integer(0)); 8199 if (face == ScriptBaseClass.ALL_SIDES)
8200 {
8201 for (face = 0; face < GetNumberOfSides(part); face++)
8202 {
8203 if (tex.GetFace((uint)face).Fullbright == true)
8204 {
8205 fullbright = ScriptBaseClass.TRUE;
8206 }
8207 else
8208 {
8209 fullbright = ScriptBaseClass.FALSE;
8210 }
8211 res.Add(new LSL_Integer(fullbright));
8212 }
8213 }
8214 else
8215 {
8216 if (tex.GetFace((uint)face).Fullbright == true)
8217 {
8218 fullbright = ScriptBaseClass.TRUE;
8219 }
8220 else
8221 {
8222 fullbright = ScriptBaseClass.FALSE;
8223 }
8224 res.Add(new LSL_Integer(fullbright));
8225 }
7744 break; 8226 break;
7745 8227
7746 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 8228 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
@@ -7761,14 +8243,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7761 break; 8243 break;
7762 8244
7763 case (int)ScriptBaseClass.PRIM_TEXGEN: 8245 case (int)ScriptBaseClass.PRIM_TEXGEN:
7764 // TODO--------------
7765 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) 8246 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7766 if (remain < 1) 8247 if (remain < 1)
7767 return res; 8248 return res;
8249 face = (int)rules.GetLSLIntegerItem(idx++);
7768 8250
7769 face=(int)rules.GetLSLIntegerItem(idx++); 8251 tex = part.Shape.Textures;
7770 8252 if (face == ScriptBaseClass.ALL_SIDES)
7771 res.Add(new LSL_Integer(0)); 8253 {
8254 for (face = 0; face < GetNumberOfSides(part); face++)
8255 {
8256 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8257 {
8258 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8259 }
8260 else
8261 {
8262 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8263 }
8264 }
8265 }
8266 else
8267 {
8268 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8269 {
8270 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8271 }
8272 else
8273 {
8274 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8275 }
8276 }
7772 break; 8277 break;
7773 8278
7774 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 8279 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
@@ -7787,13 +8292,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7787 break; 8292 break;
7788 8293
7789 case (int)ScriptBaseClass.PRIM_GLOW: 8294 case (int)ScriptBaseClass.PRIM_GLOW:
7790 // TODO--------------
7791 if (remain < 1) 8295 if (remain < 1)
7792 return res; 8296 return res;
8297 face = (int)rules.GetLSLIntegerItem(idx++);
7793 8298
7794 face=(int)rules.GetLSLIntegerItem(idx++); 8299 tex = part.Shape.Textures;
7795 8300 float primglow;
7796 res.Add(new LSL_Float(0)); 8301 if (face == ScriptBaseClass.ALL_SIDES)
8302 {
8303 for (face = 0; face < GetNumberOfSides(part); face++)
8304 {
8305 primglow = tex.GetFace((uint)face).Glow;
8306 res.Add(new LSL_Float(primglow));
8307 }
8308 }
8309 else
8310 {
8311 primglow = tex.GetFace((uint)face).Glow;
8312 res.Add(new LSL_Float(primglow));
8313 }
7797 break; 8314 break;
7798 case (int)ScriptBaseClass.PRIM_TEXT: 8315 case (int)ScriptBaseClass.PRIM_TEXT:
7799 Color4 textColor = part.GetTextColor(); 8316 Color4 textColor = part.GetTextColor();
@@ -8330,28 +8847,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8330 { 8847 {
8331 m_host.AddScriptLPS(1); 8848 m_host.AddScriptLPS(1);
8332 8849
8333 lock (m_host.TaskInventory) 8850 m_host.TaskInventory.LockItemsForRead(true);
8851 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8334 { 8852 {
8335 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8853 if (inv.Value.Name == item)
8336 { 8854 {
8337 if (inv.Value.Name == item) 8855 m_host.TaskInventory.LockItemsForRead(false);
8856 switch (mask)
8338 { 8857 {
8339 switch (mask) 8858 case 0:
8340 { 8859 return (int)inv.Value.BasePermissions;
8341 case 0: 8860 case 1:
8342 return (int)inv.Value.BasePermissions; 8861 return (int)inv.Value.CurrentPermissions;
8343 case 1: 8862 case 2:
8344 return (int)inv.Value.CurrentPermissions; 8863 return (int)inv.Value.GroupPermissions;
8345 case 2: 8864 case 3:
8346 return (int)inv.Value.GroupPermissions; 8865 return (int)inv.Value.EveryonePermissions;
8347 case 3: 8866 case 4:
8348 return (int)inv.Value.EveryonePermissions; 8867 return (int)inv.Value.NextPermissions;
8349 case 4:
8350 return (int)inv.Value.NextPermissions;
8351 }
8352 } 8868 }
8353 } 8869 }
8354 } 8870 }
8871 m_host.TaskInventory.LockItemsForRead(false);
8355 8872
8356 return -1; 8873 return -1;
8357 } 8874 }
@@ -8398,16 +8915,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8398 { 8915 {
8399 m_host.AddScriptLPS(1); 8916 m_host.AddScriptLPS(1);
8400 8917
8401 lock (m_host.TaskInventory) 8918 m_host.TaskInventory.LockItemsForRead(true);
8919 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8402 { 8920 {
8403 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8921 if (inv.Value.Name == item)
8404 { 8922 {
8405 if (inv.Value.Name == item) 8923 m_host.TaskInventory.LockItemsForRead(false);
8406 { 8924 return inv.Value.CreatorID.ToString();
8407 return inv.Value.CreatorID.ToString();
8408 }
8409 } 8925 }
8410 } 8926 }
8927 m_host.TaskInventory.LockItemsForRead(false);
8411 8928
8412 llSay(0, "No item name '" + item + "'"); 8929 llSay(0, "No item name '" + item + "'");
8413 8930
@@ -8667,17 +9184,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8667 int width = 0; 9184 int width = 0;
8668 int height = 0; 9185 int height = 0;
8669 9186
8670 ParcelMediaCommandEnum? commandToSend = null; 9187 uint commandToSend = 0;
8671 float time = 0.0f; // default is from start 9188 float time = 0.0f; // default is from start
8672 9189
8673 ScenePresence presence = null; 9190 ScenePresence presence = null;
8674 9191
8675 for (int i = 0; i < commandList.Data.Length; i++) 9192 for (int i = 0; i < commandList.Data.Length; i++)
8676 { 9193 {
8677 ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; 9194 uint command = (uint)(commandList.GetLSLIntegerItem(i));
8678 switch (command) 9195 switch (command)
8679 { 9196 {
8680 case ParcelMediaCommandEnum.Agent: 9197 case (uint)ParcelMediaCommandEnum.Agent:
8681 // we send only to one agent 9198 // we send only to one agent
8682 if ((i + 1) < commandList.Length) 9199 if ((i + 1) < commandList.Length)
8683 { 9200 {
@@ -8694,25 +9211,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8694 } 9211 }
8695 break; 9212 break;
8696 9213
8697 case ParcelMediaCommandEnum.Loop: 9214 case (uint)ParcelMediaCommandEnum.Loop:
8698 loop = 1; 9215 loop = 1;
8699 commandToSend = command; 9216 commandToSend = command;
8700 update = true; //need to send the media update packet to set looping 9217 update = true; //need to send the media update packet to set looping
8701 break; 9218 break;
8702 9219
8703 case ParcelMediaCommandEnum.Play: 9220 case (uint)ParcelMediaCommandEnum.Play:
8704 loop = 0; 9221 loop = 0;
8705 commandToSend = command; 9222 commandToSend = command;
8706 update = true; //need to send the media update packet to make sure it doesn't loop 9223 update = true; //need to send the media update packet to make sure it doesn't loop
8707 break; 9224 break;
8708 9225
8709 case ParcelMediaCommandEnum.Pause: 9226 case (uint)ParcelMediaCommandEnum.Pause:
8710 case ParcelMediaCommandEnum.Stop: 9227 case (uint)ParcelMediaCommandEnum.Stop:
8711 case ParcelMediaCommandEnum.Unload: 9228 case (uint)ParcelMediaCommandEnum.Unload:
8712 commandToSend = command; 9229 commandToSend = command;
8713 break; 9230 break;
8714 9231
8715 case ParcelMediaCommandEnum.Url: 9232 case (uint)ParcelMediaCommandEnum.Url:
8716 if ((i + 1) < commandList.Length) 9233 if ((i + 1) < commandList.Length)
8717 { 9234 {
8718 if (commandList.Data[i + 1] is LSL_String) 9235 if (commandList.Data[i + 1] is LSL_String)
@@ -8725,7 +9242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8725 } 9242 }
8726 break; 9243 break;
8727 9244
8728 case ParcelMediaCommandEnum.Texture: 9245 case (uint)ParcelMediaCommandEnum.Texture:
8729 if ((i + 1) < commandList.Length) 9246 if ((i + 1) < commandList.Length)
8730 { 9247 {
8731 if (commandList.Data[i + 1] is LSL_String) 9248 if (commandList.Data[i + 1] is LSL_String)
@@ -8738,7 +9255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8738 } 9255 }
8739 break; 9256 break;
8740 9257
8741 case ParcelMediaCommandEnum.Time: 9258 case (uint)ParcelMediaCommandEnum.Time:
8742 if ((i + 1) < commandList.Length) 9259 if ((i + 1) < commandList.Length)
8743 { 9260 {
8744 if (commandList.Data[i + 1] is LSL_Float) 9261 if (commandList.Data[i + 1] is LSL_Float)
@@ -8750,7 +9267,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8750 } 9267 }
8751 break; 9268 break;
8752 9269
8753 case ParcelMediaCommandEnum.AutoAlign: 9270 case (uint)ParcelMediaCommandEnum.AutoAlign:
8754 if ((i + 1) < commandList.Length) 9271 if ((i + 1) < commandList.Length)
8755 { 9272 {
8756 if (commandList.Data[i + 1] is LSL_Integer) 9273 if (commandList.Data[i + 1] is LSL_Integer)
@@ -8764,7 +9281,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8764 } 9281 }
8765 break; 9282 break;
8766 9283
8767 case ParcelMediaCommandEnum.Type: 9284 case (uint)ParcelMediaCommandEnum.Type:
8768 if ((i + 1) < commandList.Length) 9285 if ((i + 1) < commandList.Length)
8769 { 9286 {
8770 if (commandList.Data[i + 1] is LSL_String) 9287 if (commandList.Data[i + 1] is LSL_String)
@@ -8777,7 +9294,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8777 } 9294 }
8778 break; 9295 break;
8779 9296
8780 case ParcelMediaCommandEnum.Desc: 9297 case (uint)ParcelMediaCommandEnum.Desc:
8781 if ((i + 1) < commandList.Length) 9298 if ((i + 1) < commandList.Length)
8782 { 9299 {
8783 if (commandList.Data[i + 1] is LSL_String) 9300 if (commandList.Data[i + 1] is LSL_String)
@@ -8790,7 +9307,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8790 } 9307 }
8791 break; 9308 break;
8792 9309
8793 case ParcelMediaCommandEnum.Size: 9310 case (uint)ParcelMediaCommandEnum.Size:
8794 if ((i + 2) < commandList.Length) 9311 if ((i + 2) < commandList.Length)
8795 { 9312 {
8796 if (commandList.Data[i + 1] is LSL_Integer) 9313 if (commandList.Data[i + 1] is LSL_Integer)
@@ -8860,7 +9377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8860 } 9377 }
8861 } 9378 }
8862 9379
8863 if (commandToSend != null) 9380 if (commandToSend != 0)
8864 { 9381 {
8865 // the commandList contained a start/stop/... command, too 9382 // the commandList contained a start/stop/... command, too
8866 if (presence == null) 9383 if (presence == null)
@@ -8897,7 +9414,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8897 9414
8898 if (aList.Data[i] != null) 9415 if (aList.Data[i] != null)
8899 { 9416 {
8900 switch ((ParcelMediaCommandEnum) aList.Data[i]) 9417 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
8901 { 9418 {
8902 case ParcelMediaCommandEnum.Url: 9419 case ParcelMediaCommandEnum.Url:
8903 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); 9420 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL));
@@ -8940,16 +9457,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8940 { 9457 {
8941 m_host.AddScriptLPS(1); 9458 m_host.AddScriptLPS(1);
8942 9459
8943 lock (m_host.TaskInventory) 9460 m_host.TaskInventory.LockItemsForRead(true);
9461 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8944 { 9462 {
8945 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9463 if (inv.Value.Name == name)
8946 { 9464 {
8947 if (inv.Value.Name == name) 9465 m_host.TaskInventory.LockItemsForRead(false);
8948 { 9466 return inv.Value.Type;
8949 return inv.Value.Type;
8950 }
8951 } 9467 }
8952 } 9468 }
9469 m_host.TaskInventory.LockItemsForRead(false);
8953 9470
8954 return -1; 9471 return -1;
8955 } 9472 }
@@ -8960,15 +9477,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8960 9477
8961 if (quick_pay_buttons.Data.Length < 4) 9478 if (quick_pay_buttons.Data.Length < 4)
8962 { 9479 {
8963 LSLError("List must have at least 4 elements"); 9480 int x;
8964 return; 9481 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
9482 {
9483 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
9484 }
8965 } 9485 }
8966 m_host.ParentGroup.RootPart.PayPrice[0]=price; 9486 int[] nPrice = new int[5];
8967 9487 nPrice[0]=price;
8968 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 9488 nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0];
8969 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 9489 nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1];
8970 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 9490 nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2];
8971 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 9491 nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3];
9492 m_host.ParentGroup.RootPart.PayPrice = nPrice;
8972 m_host.ParentGroup.HasGroupChanged = true; 9493 m_host.ParentGroup.HasGroupChanged = true;
8973 } 9494 }
8974 9495
@@ -8980,17 +9501,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8980 if (invItemID == UUID.Zero) 9501 if (invItemID == UUID.Zero)
8981 return new LSL_Vector(); 9502 return new LSL_Vector();
8982 9503
8983 lock (m_host.TaskInventory) 9504 m_host.TaskInventory.LockItemsForRead(true);
9505 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8984 { 9506 {
8985 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9507 m_host.TaskInventory.LockItemsForRead(false);
8986 return new LSL_Vector(); 9508 return new LSL_Vector();
9509 }
8987 9510
8988 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9511 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8989 { 9512 {
8990 ShoutError("No permissions to track the camera"); 9513 ShoutError("No permissions to track the camera");
8991 return new LSL_Vector(); 9514 m_host.TaskInventory.LockItemsForRead(false);
8992 } 9515 return new LSL_Vector();
8993 } 9516 }
9517 m_host.TaskInventory.LockItemsForRead(false);
8994 9518
8995 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9519 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8996 if (presence != null) 9520 if (presence != null)
@@ -9008,17 +9532,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9008 if (invItemID == UUID.Zero) 9532 if (invItemID == UUID.Zero)
9009 return new LSL_Rotation(); 9533 return new LSL_Rotation();
9010 9534
9011 lock (m_host.TaskInventory) 9535 m_host.TaskInventory.LockItemsForRead(true);
9536 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9012 { 9537 {
9013 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9538 m_host.TaskInventory.LockItemsForRead(false);
9014 return new LSL_Rotation(); 9539 return new LSL_Rotation();
9015 9540 }
9016 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9541 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9017 { 9542 {
9018 ShoutError("No permissions to track the camera"); 9543 ShoutError("No permissions to track the camera");
9019 return new LSL_Rotation(); 9544 m_host.TaskInventory.LockItemsForRead(false);
9020 } 9545 return new LSL_Rotation();
9021 } 9546 }
9547 m_host.TaskInventory.LockItemsForRead(false);
9022 9548
9023 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9549 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
9024 if (presence != null) 9550 if (presence != null)
@@ -9080,8 +9606,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9080 { 9606 {
9081 m_host.AddScriptLPS(1); 9607 m_host.AddScriptLPS(1);
9082 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 9608 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0);
9083 if (detectedParams == null) return; // only works on the first detected avatar 9609 if (detectedParams == null)
9084 9610 {
9611 if (m_host.IsAttachment == true)
9612 {
9613 detectedParams = new DetectParams();
9614 detectedParams.Key = m_host.OwnerID;
9615 }
9616 else
9617 {
9618 return;
9619 }
9620 }
9621
9085 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 9622 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
9086 if (avatar != null) 9623 if (avatar != null)
9087 { 9624 {
@@ -9089,6 +9626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9089 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 9626 new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
9090 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); 9627 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
9091 } 9628 }
9629
9092 ScriptSleep(1000); 9630 ScriptSleep(1000);
9093 } 9631 }
9094 9632
@@ -9168,14 +9706,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9168 if (objectID == UUID.Zero) return; 9706 if (objectID == UUID.Zero) return;
9169 9707
9170 UUID agentID; 9708 UUID agentID;
9171 lock (m_host.TaskInventory) 9709 m_host.TaskInventory.LockItemsForRead(true);
9172 { 9710 // we need the permission first, to know which avatar we want to set the camera for
9173 // we need the permission first, to know which avatar we want to set the camera for 9711 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9174 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9175 9712
9176 if (agentID == UUID.Zero) return; 9713 if (agentID == UUID.Zero)
9177 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9714 {
9715 m_host.TaskInventory.LockItemsForRead(false);
9716 return;
9178 } 9717 }
9718 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9719 {
9720 m_host.TaskInventory.LockItemsForRead(false);
9721 return;
9722 }
9723 m_host.TaskInventory.LockItemsForRead(false);
9179 9724
9180 ScenePresence presence = World.GetScenePresence(agentID); 9725 ScenePresence presence = World.GetScenePresence(agentID);
9181 9726
@@ -9225,12 +9770,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9225 9770
9226 // we need the permission first, to know which avatar we want to clear the camera for 9771 // we need the permission first, to know which avatar we want to clear the camera for
9227 UUID agentID; 9772 UUID agentID;
9228 lock (m_host.TaskInventory) 9773 m_host.TaskInventory.LockItemsForRead(true);
9774 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9775 if (agentID == UUID.Zero)
9776 {
9777 m_host.TaskInventory.LockItemsForRead(false);
9778 return;
9779 }
9780 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9229 { 9781 {
9230 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9782 m_host.TaskInventory.LockItemsForRead(false);
9231 if (agentID == UUID.Zero) return; 9783 return;
9232 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
9233 } 9784 }
9785 m_host.TaskInventory.LockItemsForRead(false);
9234 9786
9235 ScenePresence presence = World.GetScenePresence(agentID); 9787 ScenePresence presence = World.GetScenePresence(agentID);
9236 9788
@@ -9297,19 +9849,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9297 public LSL_String llXorBase64StringsCorrect(string str1, string str2) 9849 public LSL_String llXorBase64StringsCorrect(string str1, string str2)
9298 { 9850 {
9299 m_host.AddScriptLPS(1); 9851 m_host.AddScriptLPS(1);
9300 string ret = String.Empty; 9852
9301 string src1 = llBase64ToString(str1); 9853 if (str1 == String.Empty)
9302 string src2 = llBase64ToString(str2); 9854 return String.Empty;
9303 int c = 0; 9855 if (str2 == String.Empty)
9304 for (int i = 0; i < src1.Length; i++) 9856 return str1;
9857
9858 byte[] data1 = Convert.FromBase64String(str1);
9859 byte[] data2 = Convert.FromBase64String(str2);
9860
9861 byte[] d2 = new Byte[data1.Length];
9862 int pos = 0;
9863
9864 if (data1.Length <= data2.Length)
9865 {
9866 Array.Copy(data2, 0, d2, 0, data1.Length);
9867 }
9868 else
9305 { 9869 {
9306 ret += (char) (src1[i] ^ src2[c]); 9870 while (pos < data1.Length)
9871 {
9872 int len = data1.Length - pos;
9873 if (len > data2.Length)
9874 len = data2.Length;
9307 9875
9308 c++; 9876 Array.Copy(data2, 0, d2, pos, len);
9309 if (c >= src2.Length) 9877 pos += len;
9310 c = 0; 9878 }
9311 } 9879 }
9312 return llStringToBase64(ret); 9880
9881 for (pos = 0 ; pos < data1.Length ; pos++ )
9882 data1[pos] ^= d2[pos];
9883
9884 return Convert.ToBase64String(data1);
9313 } 9885 }
9314 9886
9315 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body) 9887 public LSL_String llHTTPRequest(string url, LSL_List parameters, string body)
@@ -9687,15 +10259,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9687 10259
9688 internal UUID ScriptByName(string name) 10260 internal UUID ScriptByName(string name)
9689 { 10261 {
9690 lock (m_host.TaskInventory) 10262 m_host.TaskInventory.LockItemsForRead(true);
10263
10264 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
9691 { 10265 {
9692 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 10266 if (item.Type == 10 && item.Name == name)
9693 { 10267 {
9694 if (item.Type == 10 && item.Name == name) 10268 m_host.TaskInventory.LockItemsForRead(false);
9695 return item.ItemID; 10269 return item.ItemID;
9696 } 10270 }
9697 } 10271 }
9698 10272
10273 m_host.TaskInventory.LockItemsForRead(false);
10274
9699 return UUID.Zero; 10275 return UUID.Zero;
9700 } 10276 }
9701 10277
@@ -9736,6 +10312,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9736 { 10312 {
9737 m_host.AddScriptLPS(1); 10313 m_host.AddScriptLPS(1);
9738 10314
10315 //Clone is thread safe
9739 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10316 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9740 10317
9741 UUID assetID = UUID.Zero; 10318 UUID assetID = UUID.Zero;
@@ -9798,6 +10375,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9798 { 10375 {
9799 m_host.AddScriptLPS(1); 10376 m_host.AddScriptLPS(1);
9800 10377
10378 //Clone is thread safe
9801 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10379 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9802 10380
9803 UUID assetID = UUID.Zero; 10381 UUID assetID = UUID.Zero;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index fe71ed5..1fa8c30 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -73,6 +73,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
74 m_LSFunctionsEnabled = true; 74 m_LSFunctionsEnabled = true;
75 75
76 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
77 m_LSFunctionsEnabled = true;
78
76 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); 79 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
77 if (m_comms == null) 80 if (m_comms == null)
78 m_LSFunctionsEnabled = false; 81 m_LSFunctionsEnabled = false;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 01b64eb..db43902 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -769,18 +769,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
769 if (target != null) 769 if (target != null)
770 { 770 {
771 UUID animID=UUID.Zero; 771 UUID animID=UUID.Zero;
772 lock (m_host.TaskInventory) 772 m_host.TaskInventory.LockItemsForRead(true);
773 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
773 { 774 {
774 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 775 if (inv.Value.Name == animation)
775 { 776 {
776 if (inv.Value.Name == animation) 777 if (inv.Value.Type == (int)AssetType.Animation)
777 { 778 animID = inv.Value.AssetID;
778 if (inv.Value.Type == (int)AssetType.Animation) 779 continue;
779 animID = inv.Value.AssetID;
780 continue;
781 }
782 } 780 }
783 } 781 }
782 m_host.TaskInventory.LockItemsForRead(false);
784 if (animID == UUID.Zero) 783 if (animID == UUID.Zero)
785 target.Animator.AddAnimation(animation, m_host.UUID); 784 target.Animator.AddAnimation(animation, m_host.UUID);
786 else 785 else
@@ -802,18 +801,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
802 if (target != null) 801 if (target != null)
803 { 802 {
804 UUID animID=UUID.Zero; 803 UUID animID=UUID.Zero;
805 lock (m_host.TaskInventory) 804 m_host.TaskInventory.LockItemsForRead(true);
805 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
806 { 806 {
807 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 807 if (inv.Value.Name == animation)
808 { 808 {
809 if (inv.Value.Name == animation) 809 if (inv.Value.Type == (int)AssetType.Animation)
810 { 810 animID = inv.Value.AssetID;
811 if (inv.Value.Type == (int)AssetType.Animation) 811 continue;
812 animID = inv.Value.AssetID;
813 continue;
814 }
815 } 812 }
816 } 813 }
814 m_host.TaskInventory.LockItemsForRead(false);
817 815
818 if (animID == UUID.Zero) 816 if (animID == UUID.Zero)
819 target.Animator.RemoveAnimation(animation); 817 target.Animator.RemoveAnimation(animation);
@@ -1664,6 +1662,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1664 1662
1665 if (!UUID.TryParse(name, out assetID)) 1663 if (!UUID.TryParse(name, out assetID))
1666 { 1664 {
1665 m_host.TaskInventory.LockItemsForRead(true);
1667 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1666 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1668 { 1667 {
1669 if (item.Type == 7 && item.Name == name) 1668 if (item.Type == 7 && item.Name == name)
@@ -1671,6 +1670,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1671 assetID = item.AssetID; 1670 assetID = item.AssetID;
1672 } 1671 }
1673 } 1672 }
1673 m_host.TaskInventory.LockItemsForRead(false);
1674 } 1674 }
1675 1675
1676 if (assetID == UUID.Zero) 1676 if (assetID == UUID.Zero)
@@ -1717,6 +1717,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1717 1717
1718 if (!UUID.TryParse(name, out assetID)) 1718 if (!UUID.TryParse(name, out assetID))
1719 { 1719 {
1720 m_host.TaskInventory.LockItemsForRead(true);
1720 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1721 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1721 { 1722 {
1722 if (item.Type == 7 && item.Name == name) 1723 if (item.Type == 7 && item.Name == name)
@@ -1724,6 +1725,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1724 assetID = item.AssetID; 1725 assetID = item.AssetID;
1725 } 1726 }
1726 } 1727 }
1728 m_host.TaskInventory.LockItemsForRead(false);
1727 } 1729 }
1728 1730
1729 if (assetID == UUID.Zero) 1731 if (assetID == UUID.Zero)
@@ -1774,6 +1776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1774 1776
1775 if (!UUID.TryParse(name, out assetID)) 1777 if (!UUID.TryParse(name, out assetID))
1776 { 1778 {
1779 m_host.TaskInventory.LockItemsForRead(true);
1777 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1780 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1778 { 1781 {
1779 if (item.Type == 7 && item.Name == name) 1782 if (item.Type == 7 && item.Name == name)
@@ -1781,6 +1784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1781 assetID = item.AssetID; 1784 assetID = item.AssetID;
1782 } 1785 }
1783 } 1786 }
1787 m_host.TaskInventory.LockItemsForRead(false);
1784 } 1788 }
1785 1789
1786 if (assetID == UUID.Zero) 1790 if (assetID == UUID.Zero)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 5c2abd5..a5b1124 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
204 // Is the sensor type is AGENT and not SCRIPTED then include agents 204 // Is the sensor type is AGENT and not SCRIPTED then include agents
205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) 205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0)
206 { 206 {
207 sensedEntities.AddRange(doAgentSensor(ts)); 207 sensedEntities.AddRange(doAgentSensor(ts));
208 } 208 }
209 209
210 // If SCRIPTED or PASSIVE or ACTIVE check objects 210 // If SCRIPTED or PASSIVE or ACTIVE check objects
@@ -309,6 +309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
309 // in mouselook. 309 // in mouselook.
310 310
311 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); 311 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar);
312 fromRegionPos = avatar.AbsolutePosition;
312 q = avatar.Rotation; 313 q = avatar.Rotation;
313 } 314 }
314 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 315 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
@@ -422,6 +423,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
422 SceneObjectPart SensePoint = ts.host; 423 SceneObjectPart SensePoint = ts.host;
423 Vector3 fromRegionPos = SensePoint.AbsolutePosition; 424 Vector3 fromRegionPos = SensePoint.AbsolutePosition;
424 Quaternion q = SensePoint.RotationOffset; 425 Quaternion q = SensePoint.RotationOffset;
426 if (SensePoint.ParentGroup.RootPart.IsAttachment)
427 {
428 // In attachments, the sensor cone always orients with the
429 // avatar rotation. This may include a nonzero elevation if
430 // in mouselook.
431
432 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar);
433 fromRegionPos = avatar.AbsolutePosition;
434 q = avatar.Rotation;
435 }
425 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 436 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
426 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 437 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
427 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 438 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index eeb59d9..2fd33fe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
109 if (Timers.Count == 0) 109 if (Timers.Count == 0)
110 return; 110 return;
111 111
112 Dictionary<string, TimerClass>.ValueCollection tvals;
112 lock (TimerListLock) 113 lock (TimerListLock)
113 { 114 {
114 // Go through all timers 115 // Go through all timers
115 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 116 tvals = Timers.Values;
116 foreach (TimerClass ts in tvals) 117 }
118
119 foreach (TimerClass ts in tvals)
120 {
121 // Time has passed?
122 if (ts.next < DateTime.Now.Ticks)
117 { 123 {
118 // Time has passed? 124 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
119 if (ts.next < DateTime.Now.Ticks) 125 // Add it to queue
120 { 126 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
121 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 127 new EventParams("timer", new Object[0],
122 // Add it to queue 128 new DetectParams[0]));
123 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 129 // set next interval
124 new EventParams("timer", new Object[0], 130
125 new DetectParams[0])); 131 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
126 // set next interval 132 ts.next = DateTime.Now.Ticks + ts.interval;
127
128 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
129 ts.next = DateTime.Now.Ticks + ts.interval;
130 }
131 } 133 }
132 } 134 }
133 } 135 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 78ee43c..c8f3623 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
81 // Avatar Info Commands 81 // Avatar Info Commands
82 string osGetAgentIP(string agent); 82 string osGetAgentIP(string agent);
83 LSL_List osGetAgents(); 83 LSL_List osGetAgents();
84 84
85 // Teleport commands 85 // Teleport commands
86 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 86 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
87 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 87 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 9615315..943d7a2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Reflection; 31using System.Reflection;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using OpenSim.Region.ScriptEngine.Shared; 33using OpenSim.Region.ScriptEngine.Shared;
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
132 return (eventFlags); 133 return (eventFlags);
133 } 134 }
134 135
136 [DebuggerNonUserCode]
135 public void ExecuteEvent(string state, string FunctionName, object[] args) 137 public void ExecuteEvent(string state, string FunctionName, object[] args)
136 { 138 {
137 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 139 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index dba6502..96f6486 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -274,6 +274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
274 public const int CHANGED_ALLOWED_DROP = 64; 274 public const int CHANGED_ALLOWED_DROP = 64;
275 public const int CHANGED_OWNER = 128; 275 public const int CHANGED_OWNER = 128;
276 public const int CHANGED_REGION_RESTART = 256; 276 public const int CHANGED_REGION_RESTART = 256;
277 public const int CHANGED_REGION_START = 256; //LL Changed the constant from CHANGED_REGION_RESTART
277 public const int CHANGED_REGION = 512; 278 public const int CHANGED_REGION = 512;
278 public const int CHANGED_TELEPORT = 1024; 279 public const int CHANGED_TELEPORT = 1024;
279 public const int CHANGED_ANIMATION = 16384; 280 public const int CHANGED_ANIMATION = 16384;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 3339995..e86d08c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Diagnostics; //for [DebuggerNonUserCode]
29using System.Runtime.Remoting.Lifetime; 30using System.Runtime.Remoting.Lifetime;
30using System.Threading; 31using System.Threading;
31using System.Reflection; 32using System.Reflection;
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
309 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); 310 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
310 } 311 }
311 312
313 [DebuggerNonUserCode]
312 public void llDie() 314 public void llDie()
313 { 315 {
314 m_LSL_Functions.llDie(); 316 m_LSL_Functions.llDie();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
index f8dbe03..8280ca5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LS_Stub.cs
@@ -72,5 +72,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
72 { 72 {
73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target); 73 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
74 } 74 }
75
76 public LSL_List cmGetWindlightScene(LSL_List rules)
77 {
78 return m_LS_Functions.lsGetWindlightScene(rules);
79 }
80
81 public int cmSetWindlightScene(LSL_List rules)
82 {
83 return m_LS_Functions.lsSetWindlightScene(rules);
84 }
85
86 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
87 {
88 return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
89 }
75 } 90 }
76} 91}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index edbbc2a..b138da3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
33using System.Reflection; 33using System.Reflection;
34using System.Collections; 34using System.Collections;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.Diagnostics; //for [DebuggerNonUserCode]
36using OpenSim.Region.ScriptEngine.Interfaces; 37using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared; 38using OpenSim.Region.ScriptEngine.Shared;
38using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; 39using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
90 return (int)m_Executor.GetStateEventFlags(state); 91 return (int)m_Executor.GetStateEventFlags(state);
91 } 92 }
92 93
94 [DebuggerNonUserCode]
93 public void ExecuteEvent(string state, string FunctionName, object[] args) 95 public void ExecuteEvent(string state, string FunctionName, object[] args)
94 { 96 {
95 m_Executor.ExecuteEvent(state, FunctionName, args); 97 m_Executor.ExecuteEvent(state, FunctionName, args);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 3dd381d..b348403 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Runtime.Remoting; 31using System.Runtime.Remoting;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Threading; 33using System.Threading;
@@ -238,13 +239,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
238 239
239 if (part != null) 240 if (part != null)
240 { 241 {
241 lock (part.TaskInventory) 242 part.TaskInventory.LockItemsForRead(true);
243 if (part.TaskInventory.ContainsKey(m_ItemID))
242 { 244 {
243 if (part.TaskInventory.ContainsKey(m_ItemID)) 245 m_thisScriptTask = part.TaskInventory[m_ItemID];
244 {
245 m_thisScriptTask = part.TaskInventory[m_ItemID];
246 }
247 } 246 }
247 part.TaskInventory.LockItemsForRead(false);
248 } 248 }
249 249
250 ApiManager am = new ApiManager(); 250 ApiManager am = new ApiManager();
@@ -429,14 +429,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
429 { 429 {
430 int permsMask; 430 int permsMask;
431 UUID permsGranter; 431 UUID permsGranter;
432 lock (part.TaskInventory) 432 part.TaskInventory.LockItemsForRead(true);
433 if (!part.TaskInventory.ContainsKey(m_ItemID))
433 { 434 {
434 if (!part.TaskInventory.ContainsKey(m_ItemID)) 435 part.TaskInventory.LockItemsForRead(false);
435 return; 436 return;
436
437 permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
438 permsMask = part.TaskInventory[m_ItemID].PermsMask;
439 } 437 }
438 permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
439 permsMask = part.TaskInventory[m_ItemID].PermsMask;
440 part.TaskInventory.LockItemsForRead(false);
440 441
441 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 442 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
442 { 443 {
@@ -545,6 +546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
545 return true; 546 return true;
546 } 547 }
547 548
549 [DebuggerNonUserCode] //Prevents the debugger from farting in this function
548 public void SetState(string state) 550 public void SetState(string state)
549 { 551 {
550 if (state == State) 552 if (state == State)
@@ -556,7 +558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
556 new DetectParams[0])); 558 new DetectParams[0]));
557 PostEvent(new EventParams("state_entry", new Object[0], 559 PostEvent(new EventParams("state_entry", new Object[0],
558 new DetectParams[0])); 560 new DetectParams[0]));
559 561
560 throw new EventAbortException(); 562 throw new EventAbortException();
561 } 563 }
562 564
@@ -639,14 +641,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
639 /// <returns></returns> 641 /// <returns></returns>
640 public object EventProcessor() 642 public object EventProcessor()
641 { 643 {
642 if (m_Suspended) 644 EventParams data = null;
643 return 0;
644 645
645 lock (m_Script) 646 lock (m_EventQueue)
646 { 647 {
647 EventParams data = null; 648 if (m_Suspended)
649 return 0;
648 650
649 lock (m_EventQueue) 651 lock (m_Script)
650 { 652 {
651 data = (EventParams) m_EventQueue.Dequeue(); 653 data = (EventParams) m_EventQueue.Dequeue();
652 if (data == null) // Shouldn't happen 654 if (data == null) // Shouldn't happen
@@ -672,6 +674,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
672 if (data.EventName == "collision") 674 if (data.EventName == "collision")
673 m_CollisionInQueue = false; 675 m_CollisionInQueue = false;
674 } 676 }
677 }
678 lock(m_Script)
679 {
675 680
676 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); 681 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
677 682
@@ -828,6 +833,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
828 new Object[0], new DetectParams[0])); 833 new Object[0], new DetectParams[0]));
829 } 834 }
830 835
836 [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
831 public void ApiResetScript() 837 public void ApiResetScript()
832 { 838 {
833 // bool running = Running; 839 // bool running = Running;
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 941c761..5927973 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
@@ -337,19 +337,19 @@ namespace OpenSim.Region.ScriptEngine.Shared
337 337
338 public override string ToString() 338 public override string ToString()
339 { 339 {
340 string st=String.Format(Culture.FormatProvider, "<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s); 340 string st=String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", x, y, z, s);
341 return st; 341 return st;
342 } 342 }
343 343
344 public static explicit operator string(Quaternion r) 344 public static explicit operator string(Quaternion r)
345 { 345 {
346 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s); 346 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s);
347 return s; 347 return s;
348 } 348 }
349 349
350 public static explicit operator LSLString(Quaternion r) 350 public static explicit operator LSLString(Quaternion r)
351 { 351 {
352 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 string s=String.Format("<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", r.x, r.y, r.z, r.s);
353 return new LSLString(s); 353 return new LSLString(s);
354 } 354 }
355 355