aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1288
-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
10 files changed, 1012 insertions, 381 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 59ab26b..61c5add 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,6 +781,9 @@ 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);
784 /* This method is more accurate than the SL one, and thus causes problems
785 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
786
708 double dotProduct = LSL_Vector.Dot(a, b); 787 double dotProduct = LSL_Vector.Dot(a, b);
709 LSL_Vector crossProduct = LSL_Vector.Cross(a, b); 788 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
710 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); 789 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
@@ -721,8 +800,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
721 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 800 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
722 801
723 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); 802 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
724 } 803 */
725 804
805 // This method mimics the 180 errors found in SL
806 // See www.euclideanspace.com... angleBetween
807 LSL_Vector vec_a = a;
808 LSL_Vector vec_b = b;
809
810 // Eliminate zero length
811 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
812 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
813 if (vec_a_mag < 0.00001 ||
814 vec_b_mag < 0.00001)
815 {
816 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
817 }
818
819 // Normalize
820 vec_a = llVecNorm(vec_a);
821 vec_b = llVecNorm(vec_b);
822
823 // Calculate axis and rotation angle
824 LSL_Vector axis = vec_a % vec_b;
825 LSL_Float cos_theta = vec_a * vec_b;
826
827 // Check if parallel
828 if (cos_theta > 0.99999)
829 {
830 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
831 }
832
833 // Check if anti-parallel
834 else if (cos_theta < -0.99999)
835 {
836 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
837 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
838 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
839 }
840 else // other rotation
841 {
842 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
843 axis = llVecNorm(axis);
844 double x, y, z, s, t;
845 s = Math.Cos(theta);
846 t = Math.Sin(theta);
847 x = axis.x * t;
848 y = axis.y * t;
849 z = axis.z * t;
850 return new LSL_Rotation(x,y,z,s);
851 }
852 }
853
726 public void llWhisper(int channelID, string text) 854 public void llWhisper(int channelID, string text)
727 { 855 {
728 m_host.AddScriptLPS(1); 856 m_host.AddScriptLPS(1);
@@ -1046,10 +1174,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1046 return detectedParams.TouchUV; 1174 return detectedParams.TouchUV;
1047 } 1175 }
1048 1176
1177 [DebuggerNonUserCode]
1049 public virtual void llDie() 1178 public virtual void llDie()
1050 { 1179 {
1051 m_host.AddScriptLPS(1); 1180 m_host.AddScriptLPS(1);
1052 throw new SelfDeleteException(); 1181 if (!m_host.IsAttachment) throw new SelfDeleteException();
1053 } 1182 }
1054 1183
1055 public LSL_Float llGround(LSL_Vector offset) 1184 public LSL_Float llGround(LSL_Vector offset)
@@ -1122,6 +1251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1122 1251
1123 public void llSetStatus(int status, int value) 1252 public void llSetStatus(int status, int value)
1124 { 1253 {
1254 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1255 return;
1125 m_host.AddScriptLPS(1); 1256 m_host.AddScriptLPS(1);
1126 1257
1127 int statusrotationaxis = 0; 1258 int statusrotationaxis = 0;
@@ -1351,6 +1482,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1351 { 1482 {
1352 m_host.AddScriptLPS(1); 1483 m_host.AddScriptLPS(1);
1353 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
1354 if (face == ScriptBaseClass.ALL_SIDES) 1527 if (face == ScriptBaseClass.ALL_SIDES)
1355 face = SceneObjectPart.ALL_SIDES; 1528 face = SceneObjectPart.ALL_SIDES;
1356 1529
@@ -1359,6 +1532,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1359 1532
1360 public void SetTexGen(SceneObjectPart part, int face,int style) 1533 public void SetTexGen(SceneObjectPart part, int face,int style)
1361 { 1534 {
1535 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1536 return;
1537
1362 Primitive.TextureEntry tex = part.Shape.Textures; 1538 Primitive.TextureEntry tex = part.Shape.Textures;
1363 MappingType textype; 1539 MappingType textype;
1364 textype = MappingType.Default; 1540 textype = MappingType.Default;
@@ -1389,6 +1565,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1389 1565
1390 public void SetGlow(SceneObjectPart part, int face, float glow) 1566 public void SetGlow(SceneObjectPart part, int face, float glow)
1391 { 1567 {
1568 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1569 return;
1570
1392 Primitive.TextureEntry tex = part.Shape.Textures; 1571 Primitive.TextureEntry tex = part.Shape.Textures;
1393 if (face >= 0 && face < GetNumberOfSides(part)) 1572 if (face >= 0 && face < GetNumberOfSides(part))
1394 { 1573 {
@@ -1414,6 +1593,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1414 1593
1415 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1594 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1416 { 1595 {
1596 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1597 return;
1417 1598
1418 Shininess sval = new Shininess(); 1599 Shininess sval = new Shininess();
1419 1600
@@ -1464,6 +1645,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1464 1645
1465 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1646 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1466 { 1647 {
1648 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1649 return;
1650
1467 Primitive.TextureEntry tex = part.Shape.Textures; 1651 Primitive.TextureEntry tex = part.Shape.Textures;
1468 if (face >= 0 && face < GetNumberOfSides(part)) 1652 if (face >= 0 && face < GetNumberOfSides(part))
1469 { 1653 {
@@ -1524,13 +1708,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1524 m_host.AddScriptLPS(1); 1708 m_host.AddScriptLPS(1);
1525 1709
1526 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1710 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1527 1711 if (parts.Count > 0)
1528 foreach (SceneObjectPart part in parts) 1712 {
1529 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 }
1530 } 1724 }
1531 1725
1532 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1726 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1533 { 1727 {
1728 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1729 return;
1730
1534 Primitive.TextureEntry tex = part.Shape.Textures; 1731 Primitive.TextureEntry tex = part.Shape.Textures;
1535 Color4 texcolor; 1732 Color4 texcolor;
1536 if (face >= 0 && face < GetNumberOfSides(part)) 1733 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1576,7 +1773,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1576 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,
1577 float wind, float tension, LSL_Vector Force) 1774 float wind, float tension, LSL_Vector Force)
1578 { 1775 {
1579 if (part == null) 1776 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1580 return; 1777 return;
1581 1778
1582 if (flexi) 1779 if (flexi)
@@ -1611,7 +1808,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1611 /// <param name="falloff"></param> 1808 /// <param name="falloff"></param>
1612 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)
1613 { 1810 {
1614 if (part == null) 1811 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1615 return; 1812 return;
1616 1813
1617 if (light) 1814 if (light)
@@ -1688,15 +1885,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1688 m_host.AddScriptLPS(1); 1885 m_host.AddScriptLPS(1);
1689 1886
1690 List<SceneObjectPart> parts = GetLinkParts(linknumber); 1887 List<SceneObjectPart> parts = GetLinkParts(linknumber);
1691 1888 if (parts.Count > 0)
1692 foreach (SceneObjectPart part in parts) 1889 {
1693 SetTexture(part, texture, face); 1890 try
1694 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 }
1695 ScriptSleep(200); 1901 ScriptSleep(200);
1696 } 1902 }
1697 1903
1698 protected void SetTexture(SceneObjectPart part, string texture, int face) 1904 protected void SetTexture(SceneObjectPart part, string texture, int face)
1699 { 1905 {
1906 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1907 return;
1908
1700 UUID textureID=new UUID(); 1909 UUID textureID=new UUID();
1701 1910
1702 if (!UUID.TryParse(texture, out textureID)) 1911 if (!UUID.TryParse(texture, out textureID))
@@ -1742,6 +1951,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1742 1951
1743 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1952 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1744 { 1953 {
1954 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1955 return;
1956
1745 Primitive.TextureEntry tex = part.Shape.Textures; 1957 Primitive.TextureEntry tex = part.Shape.Textures;
1746 if (face >= 0 && face < GetNumberOfSides(part)) 1958 if (face >= 0 && face < GetNumberOfSides(part))
1747 { 1959 {
@@ -1778,6 +1990,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1778 1990
1779 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 1991 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1780 { 1992 {
1993 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1994 return;
1995
1781 Primitive.TextureEntry tex = part.Shape.Textures; 1996 Primitive.TextureEntry tex = part.Shape.Textures;
1782 if (face >= 0 && face < GetNumberOfSides(part)) 1997 if (face >= 0 && face < GetNumberOfSides(part))
1783 { 1998 {
@@ -1814,6 +2029,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1814 2029
1815 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 2030 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1816 { 2031 {
2032 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2033 return;
2034
1817 Primitive.TextureEntry tex = part.Shape.Textures; 2035 Primitive.TextureEntry tex = part.Shape.Textures;
1818 if (face >= 0 && face < GetNumberOfSides(part)) 2036 if (face >= 0 && face < GetNumberOfSides(part))
1819 { 2037 {
@@ -1884,6 +2102,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1884 2102
1885 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 2103 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
1886 { 2104 {
2105 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2106 return;
2107
1887 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2108 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1888 LSL_Vector currentPos = llGetLocalPos(); 2109 LSL_Vector currentPos = llGetLocalPos();
1889 2110
@@ -1970,6 +2191,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1970 2191
1971 protected void SetRot(SceneObjectPart part, Quaternion rot) 2192 protected void SetRot(SceneObjectPart part, Quaternion rot)
1972 { 2193 {
2194 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2195 return;
2196
1973 part.UpdateRotation(rot); 2197 part.UpdateRotation(rot);
1974 // 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.
1975 2199
@@ -2589,12 +2813,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2589 2813
2590 m_host.AddScriptLPS(1); 2814 m_host.AddScriptLPS(1);
2591 2815
2816 m_host.TaskInventory.LockItemsForRead(true);
2592 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2817 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2593 2818 m_host.TaskInventory.LockItemsForRead(false);
2594 lock (m_host.TaskInventory)
2595 {
2596 item = m_host.TaskInventory[invItemID];
2597 }
2598 2819
2599 if (item.PermsGranter == UUID.Zero) 2820 if (item.PermsGranter == UUID.Zero)
2600 return 0; 2821 return 0;
@@ -2669,6 +2890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2669 if (dist > m_ScriptDistanceFactor * 10.0f) 2890 if (dist > m_ScriptDistanceFactor * 10.0f)
2670 return; 2891 return;
2671 2892
2893 //Clone is thread-safe
2672 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2894 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2673 2895
2674 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2896 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2731,6 +2953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2731 2953
2732 public void llLookAt(LSL_Vector target, double strength, double damping) 2954 public void llLookAt(LSL_Vector target, double strength, double damping)
2733 { 2955 {
2956 /*
2734 m_host.AddScriptLPS(1); 2957 m_host.AddScriptLPS(1);
2735 // Determine where we are looking from 2958 // Determine where we are looking from
2736 LSL_Vector from = llGetPos(); 2959 LSL_Vector from = llGetPos();
@@ -2750,10 +2973,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2750 // the angles of rotation in radians into rotation value 2973 // the angles of rotation in radians into rotation value
2751 2974
2752 LSL_Types.Quaternion rot = llEuler2Rot(angle); 2975 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2753 Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 2976
2754 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
2755 // Orient the object to the angle calculated 2981 // Orient the object to the angle calculated
2756 //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
2757 } 3001 }
2758 3002
2759 public void llStopLookAt() 3003 public void llStopLookAt()
@@ -2802,13 +3046,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2802 { 3046 {
2803 TaskInventoryItem item; 3047 TaskInventoryItem item;
2804 3048
2805 lock (m_host.TaskInventory) 3049 m_host.TaskInventory.LockItemsForRead(true);
3050 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2806 { 3051 {
2807 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3052 m_host.TaskInventory.LockItemsForRead(false);
2808 return; 3053 return;
2809 else
2810 item = m_host.TaskInventory[InventorySelf()];
2811 } 3054 }
3055 else
3056 {
3057 item = m_host.TaskInventory[InventorySelf()];
3058 }
3059 m_host.TaskInventory.LockItemsForRead(false);
2812 3060
2813 if (item.PermsGranter != UUID.Zero) 3061 if (item.PermsGranter != UUID.Zero)
2814 { 3062 {
@@ -2830,13 +3078,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2830 { 3078 {
2831 TaskInventoryItem item; 3079 TaskInventoryItem item;
2832 3080
3081 m_host.TaskInventory.LockItemsForRead(true);
2833 lock (m_host.TaskInventory) 3082 lock (m_host.TaskInventory)
2834 { 3083 {
3084
2835 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3085 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3086 {
3087 m_host.TaskInventory.LockItemsForRead(false);
2836 return; 3088 return;
3089 }
2837 else 3090 else
3091 {
2838 item = m_host.TaskInventory[InventorySelf()]; 3092 item = m_host.TaskInventory[InventorySelf()];
3093 }
2839 } 3094 }
3095 m_host.TaskInventory.LockItemsForRead(false);
2840 3096
2841 m_host.AddScriptLPS(1); 3097 m_host.AddScriptLPS(1);
2842 3098
@@ -2868,19 +3124,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2868 { 3124 {
2869 m_host.AddScriptLPS(1); 3125 m_host.AddScriptLPS(1);
2870 3126
2871 if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
2872 return;
2873
2874 TaskInventoryItem item; 3127 TaskInventoryItem item;
2875 3128
2876 lock (m_host.TaskInventory) 3129 m_host.TaskInventory.LockItemsForRead(true);
3130
3131 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2877 { 3132 {
2878 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3133 m_host.TaskInventory.LockItemsForRead(false);
2879 return; 3134 return;
2880 else 3135 }
2881 item = m_host.TaskInventory[InventorySelf()]; 3136 else
3137 {
3138 item = m_host.TaskInventory[InventorySelf()];
2882 } 3139 }
2883 3140
3141 m_host.TaskInventory.LockItemsForRead(false);
3142
2884 if (item.PermsGranter != m_host.OwnerID) 3143 if (item.PermsGranter != m_host.OwnerID)
2885 return; 3144 return;
2886 3145
@@ -2890,11 +3149,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2890 3149
2891 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3150 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
2892 3151
3152 /*
2893 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3153 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
2894 if (attachmentsModule != null) 3154 if (attachmentsModule != null)
3155 {
2895 attachmentsModule.AttachObject( 3156 attachmentsModule.AttachObject(
2896 presence.ControllingClient, grp.LocalId, 3157 presence.ControllingClient, grp.LocalId,
2897 (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);
2898 } 3162 }
2899 } 3163 }
2900 3164
@@ -2907,13 +3171,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2907 3171
2908 TaskInventoryItem item; 3172 TaskInventoryItem item;
2909 3173
2910 lock (m_host.TaskInventory) 3174 m_host.TaskInventory.LockItemsForRead(true);
3175
3176 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2911 { 3177 {
2912 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3178 m_host.TaskInventory.LockItemsForRead(false);
2913 return; 3179 return;
2914 else 3180 }
2915 item = m_host.TaskInventory[InventorySelf()]; 3181 else
3182 {
3183 item = m_host.TaskInventory[InventorySelf()];
2916 } 3184 }
3185 m_host.TaskInventory.LockItemsForRead(false);
3186
2917 3187
2918 if (item.PermsGranter != m_host.OwnerID) 3188 if (item.PermsGranter != m_host.OwnerID)
2919 return; 3189 return;
@@ -2950,8 +3220,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2950 return m_host.OwnerID.ToString(); 3220 return m_host.OwnerID.ToString();
2951 } 3221 }
2952 3222
3223 [DebuggerNonUserCode]
2953 public void llInstantMessage(string user, string message) 3224 public void llInstantMessage(string user, string message)
2954 { 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
2955 m_host.AddScriptLPS(1); 3234 m_host.AddScriptLPS(1);
2956 3235
2957 // 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.
@@ -2966,7 +3245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2966 UUID friendTransactionID = UUID.Random(); 3245 UUID friendTransactionID = UUID.Random();
2967 3246
2968 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3247 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
2969 3248
2970 GridInstantMessage msg = new GridInstantMessage(); 3249 GridInstantMessage msg = new GridInstantMessage();
2971 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3250 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
2972 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3251 msg.toAgentID = new Guid(user); // toAgentID.Guid;
@@ -3115,13 +3394,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3115 m_host.AddScriptLPS(1); 3394 m_host.AddScriptLPS(1);
3116 } 3395 }
3117 3396
3118 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3119 {
3120 m_host.AddScriptLPS(1);
3121 Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
3122 m_host.RotLookAt(rot, (float)strength, (float)damping);
3123 }
3124
3125 public LSL_Integer llStringLength(string str) 3397 public LSL_Integer llStringLength(string str)
3126 { 3398 {
3127 m_host.AddScriptLPS(1); 3399 m_host.AddScriptLPS(1);
@@ -3145,14 +3417,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3145 3417
3146 TaskInventoryItem item; 3418 TaskInventoryItem item;
3147 3419
3148 lock (m_host.TaskInventory) 3420 m_host.TaskInventory.LockItemsForRead(true);
3421 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3149 { 3422 {
3150 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3423 m_host.TaskInventory.LockItemsForRead(false);
3151 return; 3424 return;
3152 else
3153 item = m_host.TaskInventory[InventorySelf()];
3154 } 3425 }
3155 3426 else
3427 {
3428 item = m_host.TaskInventory[InventorySelf()];
3429 }
3430 m_host.TaskInventory.LockItemsForRead(false);
3156 if (item.PermsGranter == UUID.Zero) 3431 if (item.PermsGranter == UUID.Zero)
3157 return; 3432 return;
3158 3433
@@ -3182,13 +3457,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3182 3457
3183 TaskInventoryItem item; 3458 TaskInventoryItem item;
3184 3459
3185 lock (m_host.TaskInventory) 3460 m_host.TaskInventory.LockItemsForRead(true);
3461 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3186 { 3462 {
3187 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3463 m_host.TaskInventory.LockItemsForRead(false);
3188 return; 3464 return;
3189 else
3190 item = m_host.TaskInventory[InventorySelf()];
3191 } 3465 }
3466 else
3467 {
3468 item = m_host.TaskInventory[InventorySelf()];
3469 }
3470 m_host.TaskInventory.LockItemsForRead(false);
3471
3192 3472
3193 if (item.PermsGranter == UUID.Zero) 3473 if (item.PermsGranter == UUID.Zero)
3194 return; 3474 return;
@@ -3265,10 +3545,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3265 3545
3266 TaskInventoryItem item; 3546 TaskInventoryItem item;
3267 3547
3268 lock (m_host.TaskInventory) 3548
3549 m_host.TaskInventory.LockItemsForRead(true);
3550 if (!m_host.TaskInventory.ContainsKey(invItemID))
3551 {
3552 m_host.TaskInventory.LockItemsForRead(false);
3553 return;
3554 }
3555 else
3269 { 3556 {
3270 item = m_host.TaskInventory[invItemID]; 3557 item = m_host.TaskInventory[invItemID];
3271 } 3558 }
3559 m_host.TaskInventory.LockItemsForRead(false);
3272 3560
3273 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3561 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3274 { 3562 {
@@ -3300,11 +3588,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3300 3588
3301 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3589 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3302 { 3590 {
3303 lock (m_host.TaskInventory) 3591 m_host.TaskInventory.LockItemsForWrite(true);
3304 { 3592 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3305 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3593 m_host.TaskInventory[invItemID].PermsMask = perm;
3306 m_host.TaskInventory[invItemID].PermsMask = perm; 3594 m_host.TaskInventory.LockItemsForWrite(false);
3307 }
3308 3595
3309 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3596 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3310 "run_time_permissions", new Object[] { 3597 "run_time_permissions", new Object[] {
@@ -3324,11 +3611,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3324 3611
3325 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3612 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3326 { 3613 {
3327 lock (m_host.TaskInventory) 3614 m_host.TaskInventory.LockItemsForWrite(true);
3328 { 3615 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3329 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3616 m_host.TaskInventory[invItemID].PermsMask = perm;
3330 m_host.TaskInventory[invItemID].PermsMask = perm; 3617 m_host.TaskInventory.LockItemsForWrite(false);
3331 }
3332 3618
3333 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3619 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3334 "run_time_permissions", new Object[] { 3620 "run_time_permissions", new Object[] {
@@ -3349,11 +3635,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3349 3635
3350 if (!m_waitingForScriptAnswer) 3636 if (!m_waitingForScriptAnswer)
3351 { 3637 {
3352 lock (m_host.TaskInventory) 3638 m_host.TaskInventory.LockItemsForWrite(true);
3353 { 3639 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3354 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3640 m_host.TaskInventory[invItemID].PermsMask = 0;
3355 m_host.TaskInventory[invItemID].PermsMask = 0; 3641 m_host.TaskInventory.LockItemsForWrite(false);
3356 }
3357 3642
3358 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3643 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3359 m_waitingForScriptAnswer=true; 3644 m_waitingForScriptAnswer=true;
@@ -3388,10 +3673,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3388 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3673 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3389 llReleaseControls(); 3674 llReleaseControls();
3390 3675
3391 lock (m_host.TaskInventory) 3676
3392 { 3677 m_host.TaskInventory.LockItemsForWrite(true);
3393 m_host.TaskInventory[invItemID].PermsMask = answer; 3678 m_host.TaskInventory[invItemID].PermsMask = answer;
3394 } 3679 m_host.TaskInventory.LockItemsForWrite(false);
3680
3395 3681
3396 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3682 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3397 "run_time_permissions", new Object[] { 3683 "run_time_permissions", new Object[] {
@@ -3403,16 +3689,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3403 { 3689 {
3404 m_host.AddScriptLPS(1); 3690 m_host.AddScriptLPS(1);
3405 3691
3406 lock (m_host.TaskInventory) 3692 m_host.TaskInventory.LockItemsForRead(true);
3693
3694 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3407 { 3695 {
3408 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3696 if (item.Type == 10 && item.ItemID == m_itemID)
3409 { 3697 {
3410 if (item.Type == 10 && item.ItemID == m_itemID) 3698 m_host.TaskInventory.LockItemsForRead(false);
3411 { 3699 return item.PermsGranter.ToString();
3412 return item.PermsGranter.ToString();
3413 }
3414 } 3700 }
3415 } 3701 }
3702 m_host.TaskInventory.LockItemsForRead(false);
3416 3703
3417 return UUID.Zero.ToString(); 3704 return UUID.Zero.ToString();
3418 } 3705 }
@@ -3421,19 +3708,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3421 { 3708 {
3422 m_host.AddScriptLPS(1); 3709 m_host.AddScriptLPS(1);
3423 3710
3424 lock (m_host.TaskInventory) 3711 m_host.TaskInventory.LockItemsForRead(true);
3712
3713 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3425 { 3714 {
3426 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3715 if (item.Type == 10 && item.ItemID == m_itemID)
3427 { 3716 {
3428 if (item.Type == 10 && item.ItemID == m_itemID) 3717 int perms = item.PermsMask;
3429 { 3718 if (m_automaticLinkPermission)
3430 int perms = item.PermsMask; 3719 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3431 if (m_automaticLinkPermission) 3720 m_host.TaskInventory.LockItemsForRead(false);
3432 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3721 return perms;
3433 return perms;
3434 }
3435 } 3722 }
3436 } 3723 }
3724 m_host.TaskInventory.LockItemsForRead(false);
3437 3725
3438 return 0; 3726 return 0;
3439 } 3727 }
@@ -3455,9 +3743,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3455 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3743 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3456 { 3744 {
3457 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3745 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3458 3746 if (parts.Count > 0)
3459 foreach (SceneObjectPart part in parts) 3747 {
3460 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3748 try
3749 {
3750 parts[0].ParentGroup.areUpdatesSuspended = true;
3751 foreach (SceneObjectPart part in parts)
3752 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
3753 }
3754 finally
3755 {
3756 parts[0].ParentGroup.areUpdatesSuspended = false;
3757 }
3758 }
3461 } 3759 }
3462 3760
3463 public void llCreateLink(string target, int parent) 3761 public void llCreateLink(string target, int parent)
@@ -3466,11 +3764,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3466 UUID invItemID = InventorySelf(); 3764 UUID invItemID = InventorySelf();
3467 3765
3468 TaskInventoryItem item; 3766 TaskInventoryItem item;
3469 lock (m_host.TaskInventory) 3767 m_host.TaskInventory.LockItemsForRead(true);
3470 { 3768 item = m_host.TaskInventory[invItemID];
3471 item = m_host.TaskInventory[invItemID]; 3769 m_host.TaskInventory.LockItemsForRead(false);
3472 } 3770
3473
3474 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3771 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3475 && !m_automaticLinkPermission) 3772 && !m_automaticLinkPermission)
3476 { 3773 {
@@ -3523,16 +3820,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3523 m_host.AddScriptLPS(1); 3820 m_host.AddScriptLPS(1);
3524 UUID invItemID = InventorySelf(); 3821 UUID invItemID = InventorySelf();
3525 3822
3526 lock (m_host.TaskInventory) 3823 m_host.TaskInventory.LockItemsForRead(true);
3527 {
3528 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3824 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3529 && !m_automaticLinkPermission) 3825 && !m_automaticLinkPermission)
3530 { 3826 {
3531 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3827 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3828 m_host.TaskInventory.LockItemsForRead(false);
3532 return; 3829 return;
3533 } 3830 }
3534 } 3831 m_host.TaskInventory.LockItemsForRead(false);
3535 3832
3536 if (linknum < ScriptBaseClass.LINK_THIS) 3833 if (linknum < ScriptBaseClass.LINK_THIS)
3537 return; 3834 return;
3538 3835
@@ -3571,10 +3868,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3571 // Restructuring Multiple Prims. 3868 // Restructuring Multiple Prims.
3572 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3869 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3573 parts.Remove(parentPrim.RootPart); 3870 parts.Remove(parentPrim.RootPart);
3574 foreach (SceneObjectPart part in parts) 3871 if (parts.Count > 0)
3575 { 3872 {
3576 parentPrim.DelinkFromGroup(part.LocalId, true); 3873 try
3874 {
3875 parts[0].ParentGroup.areUpdatesSuspended = true;
3876 foreach (SceneObjectPart part in parts)
3877 {
3878 parentPrim.DelinkFromGroup(part.LocalId, true);
3879 }
3880 }
3881 finally
3882 {
3883 parts[0].ParentGroup.areUpdatesSuspended = false;
3884 }
3577 } 3885 }
3886
3578 parentPrim.HasGroupChanged = true; 3887 parentPrim.HasGroupChanged = true;
3579 parentPrim.ScheduleGroupForFullUpdate(); 3888 parentPrim.ScheduleGroupForFullUpdate();
3580 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3889 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
@@ -3583,11 +3892,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3583 { 3892 {
3584 SceneObjectPart newRoot = parts[0]; 3893 SceneObjectPart newRoot = parts[0];
3585 parts.Remove(newRoot); 3894 parts.Remove(newRoot);
3586 foreach (SceneObjectPart part in parts) 3895
3896 try
3587 { 3897 {
3588 part.UpdateFlag = 0; 3898 parts[0].ParentGroup.areUpdatesSuspended = true;
3589 newRoot.ParentGroup.LinkToGroup(part.ParentGroup); 3899 foreach (SceneObjectPart part in parts)
3900 {
3901 part.UpdateFlag = 0;
3902 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
3903 }
3590 } 3904 }
3905 finally
3906 {
3907 parts[0].ParentGroup.areUpdatesSuspended = false;
3908 }
3909
3910
3591 newRoot.ParentGroup.HasGroupChanged = true; 3911 newRoot.ParentGroup.HasGroupChanged = true;
3592 newRoot.ParentGroup.ScheduleGroupForFullUpdate(); 3912 newRoot.ParentGroup.ScheduleGroupForFullUpdate();
3593 } 3913 }
@@ -3613,11 +3933,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3613 3933
3614 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); 3934 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3615 parts.Remove(parentPrim.RootPart); 3935 parts.Remove(parentPrim.RootPart);
3616 3936 if (parts.Count > 0)
3617 foreach (SceneObjectPart part in parts)
3618 { 3937 {
3619 parentPrim.DelinkFromGroup(part.LocalId, true); 3938 try
3620 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3939 {
3940 parts[0].ParentGroup.areUpdatesSuspended = true;
3941 foreach (SceneObjectPart part in parts)
3942 {
3943 parentPrim.DelinkFromGroup(part.LocalId, true);
3944 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3945 }
3946 }
3947 finally
3948 {
3949 parts[0].ParentGroup.areUpdatesSuspended = false;
3950 }
3621 } 3951 }
3622 parentPrim.HasGroupChanged = true; 3952 parentPrim.HasGroupChanged = true;
3623 parentPrim.ScheduleGroupForFullUpdate(); 3953 parentPrim.ScheduleGroupForFullUpdate();
@@ -3709,17 +4039,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3709 m_host.AddScriptLPS(1); 4039 m_host.AddScriptLPS(1);
3710 int count = 0; 4040 int count = 0;
3711 4041
3712 lock (m_host.TaskInventory) 4042 m_host.TaskInventory.LockItemsForRead(true);
4043 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3713 { 4044 {
3714 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4045 if (inv.Value.Type == type || type == -1)
3715 { 4046 {
3716 if (inv.Value.Type == type || type == -1) 4047 count = count + 1;
3717 {
3718 count = count + 1;
3719 }
3720 } 4048 }
3721 } 4049 }
3722 4050
4051 m_host.TaskInventory.LockItemsForRead(false);
3723 return count; 4052 return count;
3724 } 4053 }
3725 4054
@@ -3728,16 +4057,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3728 m_host.AddScriptLPS(1); 4057 m_host.AddScriptLPS(1);
3729 ArrayList keys = new ArrayList(); 4058 ArrayList keys = new ArrayList();
3730 4059
3731 lock (m_host.TaskInventory) 4060 m_host.TaskInventory.LockItemsForRead(true);
4061 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3732 { 4062 {
3733 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4063 if (inv.Value.Type == type || type == -1)
3734 { 4064 {
3735 if (inv.Value.Type == type || type == -1) 4065 keys.Add(inv.Value.Name);
3736 {
3737 keys.Add(inv.Value.Name);
3738 }
3739 } 4066 }
3740 } 4067 }
4068 m_host.TaskInventory.LockItemsForRead(false);
3741 4069
3742 if (keys.Count == 0) 4070 if (keys.Count == 0)
3743 { 4071 {
@@ -3774,20 +4102,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3774 } 4102 }
3775 4103
3776 // move the first object found with this inventory name 4104 // move the first object found with this inventory name
3777 lock (m_host.TaskInventory) 4105 m_host.TaskInventory.LockItemsForRead(true);
4106 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3778 { 4107 {
3779 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4108 if (inv.Value.Name == inventory)
3780 { 4109 {
3781 if (inv.Value.Name == inventory) 4110 found = true;
3782 { 4111 objId = inv.Key;
3783 found = true; 4112 assetType = inv.Value.Type;
3784 objId = inv.Key; 4113 objName = inv.Value.Name;
3785 assetType = inv.Value.Type; 4114 break;
3786 objName = inv.Value.Name;
3787 break;
3788 }
3789 } 4115 }
3790 } 4116 }
4117 m_host.TaskInventory.LockItemsForRead(false);
3791 4118
3792 if (!found) 4119 if (!found)
3793 { 4120 {
@@ -3795,9 +4122,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3795 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4122 throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
3796 } 4123 }
3797 4124
3798 // check if destination is an avatar 4125 // check if destination is an object
3799 if (World.GetScenePresence(destId) != null) 4126 if (World.GetSceneObjectPart(destId) != null)
3800 { 4127 {
4128 // destination is an object
4129 World.MoveTaskInventoryItem(destId, m_host, objId);
4130 }
4131 else
4132 {
4133 ScenePresence presence = World.GetScenePresence(destId);
4134
4135 if (presence == null)
4136 {
4137 UserAccount account =
4138 World.UserAccountService.GetUserAccount(
4139 World.RegionInfo.ScopeID,
4140 destId);
4141
4142 if (account == null)
4143 {
4144 llSay(0, "Can't find destination "+destId.ToString());
4145 return;
4146 }
4147 }
4148
3801 // destination is an avatar 4149 // destination is an avatar
3802 InventoryItemBase agentItem = 4150 InventoryItemBase agentItem =
3803 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); 4151 World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId);
@@ -3823,33 +4171,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3823 4171
3824 if (m_TransferModule != null) 4172 if (m_TransferModule != null)
3825 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 4173 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
4174
4175 //This delay should only occur when giving inventory to avatars.
4176 ScriptSleep(3000);
3826 } 4177 }
3827 else
3828 {
3829 // destination is an object
3830 World.MoveTaskInventoryItem(destId, m_host, objId);
3831 }
3832 ScriptSleep(3000);
3833 } 4178 }
3834 4179
4180 [DebuggerNonUserCode]
3835 public void llRemoveInventory(string name) 4181 public void llRemoveInventory(string name)
3836 { 4182 {
3837 m_host.AddScriptLPS(1); 4183 m_host.AddScriptLPS(1);
3838 4184
3839 lock (m_host.TaskInventory) 4185 m_host.TaskInventory.LockItemsForRead(true);
4186 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3840 { 4187 {
3841 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4188 if (item.Name == name)
3842 { 4189 {
3843 if (item.Name == name) 4190 if (item.ItemID == m_itemID)
3844 { 4191 throw new ScriptDeleteException();
3845 if (item.ItemID == m_itemID) 4192 else
3846 throw new ScriptDeleteException(); 4193 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3847 else 4194
3848 m_host.Inventory.RemoveInventoryItem(item.ItemID); 4195 m_host.TaskInventory.LockItemsForRead(false);
3849 return; 4196 return;
3850 }
3851 } 4197 }
3852 } 4198 }
4199 m_host.TaskInventory.LockItemsForRead(false);
3853 } 4200 }
3854 4201
3855 public void llSetText(string text, LSL_Vector color, double alpha) 4202 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -3940,6 +4287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3940 { 4287 {
3941 m_host.AddScriptLPS(1); 4288 m_host.AddScriptLPS(1);
3942 4289
4290 //Clone is thread safe
3943 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 4291 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3944 4292
3945 foreach (TaskInventoryItem item in itemDictionary.Values) 4293 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -3993,6 +4341,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3993 ScenePresence presence = World.GetScenePresence(agentId); 4341 ScenePresence presence = World.GetScenePresence(agentId);
3994 if (presence != null) 4342 if (presence != null)
3995 { 4343 {
4344 // agent must not be a god
4345 if (presence.GodLevel >= 200) return;
4346
3996 // agent must be over the owners land 4347 // agent must be over the owners land
3997 if (m_host.OwnerID == World.LandChannel.GetLandObject( 4348 if (m_host.OwnerID == World.LandChannel.GetLandObject(
3998 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) 4349 presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
@@ -4053,17 +4404,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4053 UUID soundId = UUID.Zero; 4404 UUID soundId = UUID.Zero;
4054 if (!UUID.TryParse(impact_sound, out soundId)) 4405 if (!UUID.TryParse(impact_sound, out soundId))
4055 { 4406 {
4056 lock (m_host.TaskInventory) 4407 m_host.TaskInventory.LockItemsForRead(true);
4408 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4057 { 4409 {
4058 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4410 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
4059 { 4411 {
4060 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4412 soundId = item.AssetID;
4061 { 4413 break;
4062 soundId = item.AssetID;
4063 break;
4064 }
4065 } 4414 }
4066 } 4415 }
4416 m_host.TaskInventory.LockItemsForRead(false);
4067 } 4417 }
4068 m_host.CollisionSound = soundId; 4418 m_host.CollisionSound = soundId;
4069 m_host.CollisionSoundVolume = (float)impact_volume; 4419 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4109,6 +4459,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4109 UUID partItemID; 4459 UUID partItemID;
4110 foreach (SceneObjectPart part in parts) 4460 foreach (SceneObjectPart part in parts)
4111 { 4461 {
4462 //Clone is thread safe
4112 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4463 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4113 4464
4114 foreach (TaskInventoryItem item in itemsDictionary.Values) 4465 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4323,17 +4674,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4323 4674
4324 m_host.AddScriptLPS(1); 4675 m_host.AddScriptLPS(1);
4325 4676
4326 lock (m_host.TaskInventory) 4677 m_host.TaskInventory.LockItemsForRead(true);
4678 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4327 { 4679 {
4328 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4680 if (item.Type == 10 && item.ItemID == m_itemID)
4329 { 4681 {
4330 if (item.Type == 10 && item.ItemID == m_itemID) 4682 result = item.Name!=null?item.Name:String.Empty;
4331 { 4683 break;
4332 result = item.Name != null ? item.Name : String.Empty;
4333 break;
4334 }
4335 } 4684 }
4336 } 4685 }
4686 m_host.TaskInventory.LockItemsForRead(false);
4337 4687
4338 return result; 4688 return result;
4339 } 4689 }
@@ -4486,23 +4836,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4486 { 4836 {
4487 m_host.AddScriptLPS(1); 4837 m_host.AddScriptLPS(1);
4488 4838
4489 lock (m_host.TaskInventory) 4839 m_host.TaskInventory.LockItemsForRead(true);
4840 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4490 { 4841 {
4491 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4842 if (inv.Value.Name == name)
4492 { 4843 {
4493 if (inv.Value.Name == name) 4844 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4494 { 4845 {
4495 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 4846 m_host.TaskInventory.LockItemsForRead(false);
4496 { 4847 return inv.Value.AssetID.ToString();
4497 return inv.Value.AssetID.ToString(); 4848 }
4498 } 4849 else
4499 else 4850 {
4500 { 4851 m_host.TaskInventory.LockItemsForRead(false);
4501 return UUID.Zero.ToString(); 4852 return UUID.Zero.ToString();
4502 }
4503 } 4853 }
4504 } 4854 }
4505 } 4855 }
4856 m_host.TaskInventory.LockItemsForRead(false);
4506 4857
4507 return UUID.Zero.ToString(); 4858 return UUID.Zero.ToString();
4508 } 4859 }
@@ -5438,10 +5789,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5438 m_host.AddScriptLPS(1); 5789 m_host.AddScriptLPS(1);
5439 5790
5440 List<SceneObjectPart> parts = GetLinkParts(linknumber); 5791 List<SceneObjectPart> parts = GetLinkParts(linknumber);
5441 5792 if (parts.Count > 0)
5442 foreach (var part in parts)
5443 { 5793 {
5444 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); 5794 try
5795 {
5796 parts[0].ParentGroup.areUpdatesSuspended = true;
5797 foreach (var part in parts)
5798 {
5799 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
5800 }
5801 }
5802 finally
5803 {
5804 parts[0].ParentGroup.areUpdatesSuspended = false;
5805 }
5445 } 5806 }
5446 } 5807 }
5447 5808
@@ -6020,6 +6381,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6020 tempf = (float)rules.GetLSLFloatItem(i + 1); 6381 tempf = (float)rules.GetLSLFloatItem(i + 1);
6021 prules.OuterAngle = (float)tempf; 6382 prules.OuterAngle = (float)tempf;
6022 break; 6383 break;
6384
6385 case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE:
6386 tempf = (float)rules.GetLSLFloatItem(i + 1);
6387 prules.InnerAngle = (float)tempf;
6388 break;
6389
6390 case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE:
6391 tempf = (float)rules.GetLSLFloatItem(i + 1);
6392 prules.OuterAngle = (float)tempf;
6393 break;
6023 } 6394 }
6024 6395
6025 } 6396 }
@@ -6058,14 +6429,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6058 6429
6059 protected UUID GetTaskInventoryItem(string name) 6430 protected UUID GetTaskInventoryItem(string name)
6060 { 6431 {
6061 lock (m_host.TaskInventory) 6432 m_host.TaskInventory.LockItemsForRead(true);
6433 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6062 { 6434 {
6063 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6435 if (inv.Value.Name == name)
6064 { 6436 {
6065 if (inv.Value.Name == name) 6437 m_host.TaskInventory.LockItemsForRead(false);
6066 return inv.Key; 6438 return inv.Key;
6067 } 6439 }
6068 } 6440 }
6441 m_host.TaskInventory.LockItemsForRead(false);
6069 6442
6070 return UUID.Zero; 6443 return UUID.Zero;
6071 } 6444 }
@@ -6393,22 +6766,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6393 } 6766 }
6394 6767
6395 // copy the first script found with this inventory name 6768 // copy the first script found with this inventory name
6396 lock (m_host.TaskInventory) 6769 m_host.TaskInventory.LockItemsForRead(true);
6770 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6397 { 6771 {
6398 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6772 if (inv.Value.Name == name)
6399 { 6773 {
6400 if (inv.Value.Name == name) 6774 // make sure the object is a script
6775 if (10 == inv.Value.Type)
6401 { 6776 {
6402 // make sure the object is a script 6777 found = true;
6403 if (10 == inv.Value.Type) 6778 srcId = inv.Key;
6404 { 6779 break;
6405 found = true;
6406 srcId = inv.Key;
6407 break;
6408 }
6409 } 6780 }
6410 } 6781 }
6411 } 6782 }
6783 m_host.TaskInventory.LockItemsForRead(false);
6412 6784
6413 if (!found) 6785 if (!found)
6414 { 6786 {
@@ -6492,6 +6864,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6492 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6864 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
6493 { 6865 {
6494 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6866 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6867 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6868 return shapeBlock;
6495 6869
6496 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 6870 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6497 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 6871 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6562,6 +6936,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6562 6936
6563 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) 6937 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
6564 { 6938 {
6939 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6940 return;
6941
6565 ObjectShapePacket.ObjectDataBlock shapeBlock; 6942 ObjectShapePacket.ObjectDataBlock shapeBlock;
6566 6943
6567 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6944 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6611,6 +6988,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6611 6988
6612 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) 6989 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
6613 { 6990 {
6991 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6992 return;
6993
6614 ObjectShapePacket.ObjectDataBlock shapeBlock; 6994 ObjectShapePacket.ObjectDataBlock shapeBlock;
6615 6995
6616 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6996 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6653,6 +7033,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6653 7033
6654 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) 7034 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)
6655 { 7035 {
7036 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7037 return;
7038
6656 ObjectShapePacket.ObjectDataBlock shapeBlock; 7039 ObjectShapePacket.ObjectDataBlock shapeBlock;
6657 7040
6658 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 7041 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6774,6 +7157,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6774 7157
6775 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) 7158 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
6776 { 7159 {
7160 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7161 return;
7162
6777 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 7163 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6778 UUID sculptId; 7164 UUID sculptId;
6779 7165
@@ -6789,13 +7175,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6789 shapeBlock.PathScaleX = 100; 7175 shapeBlock.PathScaleX = 100;
6790 shapeBlock.PathScaleY = 150; 7176 shapeBlock.PathScaleY = 150;
6791 7177
6792 if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && 7178 if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 &&
6793 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && 7179 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 &&
6794 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && 7180 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 &&
6795 type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) 7181 (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0)
6796 { 7182 {
6797 // default 7183 // default
6798 type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; 7184 type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE;
6799 } 7185 }
6800 7186
6801 // retain pathcurve 7187 // retain pathcurve
@@ -6814,12 +7200,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6814 7200
6815 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7201 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6816 { 7202 {
6817 m_host.AddScriptLPS(1); 7203 m_host.AddScriptLPS(1);
6818 7204
6819 List<SceneObjectPart> parts = GetLinkParts(linknumber); 7205 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6820 7206 List<ScenePresence> avatars = GetLinkAvatars(linknumber);
6821 foreach (SceneObjectPart part in parts) 7207 if (parts.Count>0)
6822 SetPrimParams(part, rules); 7208 {
7209 try
7210 {
7211 parts[0].ParentGroup.areUpdatesSuspended = true;
7212 foreach (SceneObjectPart part in parts)
7213 SetPrimParams(part, rules);
7214 }
7215 finally
7216 {
7217 parts[0].ParentGroup.areUpdatesSuspended = false;
7218 }
7219 }
7220 if (avatars.Count > 0)
7221 {
7222 foreach (ScenePresence avatar in avatars)
7223 SetPrimParams(avatar, rules);
7224 }
6823 } 7225 }
6824 7226
6825 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) 7227 public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules)
@@ -6827,8 +7229,51 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6827 llSetLinkPrimitiveParams(linknumber, rules); 7229 llSetLinkPrimitiveParams(linknumber, rules);
6828 } 7230 }
6829 7231
7232 protected void SetPrimParams(ScenePresence av, LSL_List rules)
7233 {
7234 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7235 //We only support PRIM_POSITION and PRIM_ROTATION
7236
7237 int idx = 0;
7238
7239 while (idx < rules.Length)
7240 {
7241 int code = rules.GetLSLIntegerItem(idx++);
7242
7243 int remain = rules.Length - idx;
7244
7245
7246
7247 switch (code)
7248 {
7249 case (int)ScriptBaseClass.PRIM_POSITION:
7250 if (remain < 1)
7251 return;
7252 LSL_Vector v;
7253 v = rules.GetVector3Item(idx++);
7254 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7255 av.SendFullUpdateToAllClients();
7256
7257 break;
7258
7259 case (int)ScriptBaseClass.PRIM_ROTATION:
7260 if (remain < 1)
7261 return;
7262 LSL_Rotation r;
7263 r = rules.GetQuaternionItem(idx++);
7264 av.OffsetRotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7265 av.SendFullUpdateToAllClients();
7266 break;
7267 }
7268 }
7269
7270 }
7271
6830 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 7272 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6831 { 7273 {
7274 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
7275 return;
7276
6832 int idx = 0; 7277 int idx = 0;
6833 7278
6834 while (idx < rules.Length) 7279 while (idx < rules.Length)
@@ -7660,24 +8105,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7660 break; 8105 break;
7661 8106
7662 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8107 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7663 // TODO--------------
7664 if (remain < 1) 8108 if (remain < 1)
7665 return res; 8109 return res;
8110 face = (int)rules.GetLSLIntegerItem(idx++);
7666 8111
7667 face=(int)rules.GetLSLIntegerItem(idx++); 8112 tex = part.Shape.Textures;
7668 8113 int shiny;
7669 res.Add(new LSL_Integer(0)); 8114 if (face == ScriptBaseClass.ALL_SIDES)
7670 res.Add(new LSL_Integer(0)); 8115 {
8116 for (face = 0; face < GetNumberOfSides(part); face++)
8117 {
8118 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8119 if (shinyness == Shininess.High)
8120 {
8121 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8122 }
8123 else if (shinyness == Shininess.Medium)
8124 {
8125 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8126 }
8127 else if (shinyness == Shininess.Low)
8128 {
8129 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8130 }
8131 else
8132 {
8133 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8134 }
8135 res.Add(new LSL_Integer(shiny));
8136 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8137 }
8138 }
8139 else
8140 {
8141 Shininess shinyness = tex.GetFace((uint)face).Shiny;
8142 if (shinyness == Shininess.High)
8143 {
8144 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
8145 }
8146 else if (shinyness == Shininess.Medium)
8147 {
8148 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
8149 }
8150 else if (shinyness == Shininess.Low)
8151 {
8152 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
8153 }
8154 else
8155 {
8156 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
8157 }
8158 res.Add(new LSL_Integer(shiny));
8159 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
8160 }
7671 break; 8161 break;
7672 8162
7673 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8163 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7674 // TODO--------------
7675 if (remain < 1) 8164 if (remain < 1)
7676 return res; 8165 return res;
8166 face = (int)rules.GetLSLIntegerItem(idx++);
7677 8167
7678 face=(int)rules.GetLSLIntegerItem(idx++); 8168 tex = part.Shape.Textures;
7679 8169 int fullbright;
7680 res.Add(new LSL_Integer(0)); 8170 if (face == ScriptBaseClass.ALL_SIDES)
8171 {
8172 for (face = 0; face < GetNumberOfSides(part); face++)
8173 {
8174 if (tex.GetFace((uint)face).Fullbright == true)
8175 {
8176 fullbright = ScriptBaseClass.TRUE;
8177 }
8178 else
8179 {
8180 fullbright = ScriptBaseClass.FALSE;
8181 }
8182 res.Add(new LSL_Integer(fullbright));
8183 }
8184 }
8185 else
8186 {
8187 if (tex.GetFace((uint)face).Fullbright == true)
8188 {
8189 fullbright = ScriptBaseClass.TRUE;
8190 }
8191 else
8192 {
8193 fullbright = ScriptBaseClass.FALSE;
8194 }
8195 res.Add(new LSL_Integer(fullbright));
8196 }
7681 break; 8197 break;
7682 8198
7683 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 8199 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
@@ -7698,14 +8214,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7698 break; 8214 break;
7699 8215
7700 case (int)ScriptBaseClass.PRIM_TEXGEN: 8216 case (int)ScriptBaseClass.PRIM_TEXGEN:
7701 // TODO--------------
7702 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) 8217 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7703 if (remain < 1) 8218 if (remain < 1)
7704 return res; 8219 return res;
8220 face = (int)rules.GetLSLIntegerItem(idx++);
7705 8221
7706 face=(int)rules.GetLSLIntegerItem(idx++); 8222 tex = part.Shape.Textures;
7707 8223 if (face == ScriptBaseClass.ALL_SIDES)
7708 res.Add(new LSL_Integer(0)); 8224 {
8225 for (face = 0; face < GetNumberOfSides(part); face++)
8226 {
8227 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8228 {
8229 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8230 }
8231 else
8232 {
8233 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8234 }
8235 }
8236 }
8237 else
8238 {
8239 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
8240 {
8241 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
8242 }
8243 else
8244 {
8245 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
8246 }
8247 }
7709 break; 8248 break;
7710 8249
7711 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 8250 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
@@ -7724,13 +8263,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7724 break; 8263 break;
7725 8264
7726 case (int)ScriptBaseClass.PRIM_GLOW: 8265 case (int)ScriptBaseClass.PRIM_GLOW:
7727 // TODO--------------
7728 if (remain < 1) 8266 if (remain < 1)
7729 return res; 8267 return res;
8268 face = (int)rules.GetLSLIntegerItem(idx++);
7730 8269
7731 face=(int)rules.GetLSLIntegerItem(idx++); 8270 tex = part.Shape.Textures;
7732 8271 float primglow;
7733 res.Add(new LSL_Float(0)); 8272 if (face == ScriptBaseClass.ALL_SIDES)
8273 {
8274 for (face = 0; face < GetNumberOfSides(part); face++)
8275 {
8276 primglow = tex.GetFace((uint)face).Glow;
8277 res.Add(new LSL_Float(primglow));
8278 }
8279 }
8280 else
8281 {
8282 primglow = tex.GetFace((uint)face).Glow;
8283 res.Add(new LSL_Float(primglow));
8284 }
7734 break; 8285 break;
7735 case (int)ScriptBaseClass.PRIM_TEXT: 8286 case (int)ScriptBaseClass.PRIM_TEXT:
7736 Color4 textColor = part.GetTextColor(); 8287 Color4 textColor = part.GetTextColor();
@@ -8267,28 +8818,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8267 { 8818 {
8268 m_host.AddScriptLPS(1); 8819 m_host.AddScriptLPS(1);
8269 8820
8270 lock (m_host.TaskInventory) 8821 m_host.TaskInventory.LockItemsForRead(true);
8822 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8271 { 8823 {
8272 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8824 if (inv.Value.Name == item)
8273 { 8825 {
8274 if (inv.Value.Name == item) 8826 m_host.TaskInventory.LockItemsForRead(false);
8827 switch (mask)
8275 { 8828 {
8276 switch (mask) 8829 case 0:
8277 { 8830 return (int)inv.Value.BasePermissions;
8278 case 0: 8831 case 1:
8279 return (int)inv.Value.BasePermissions; 8832 return (int)inv.Value.CurrentPermissions;
8280 case 1: 8833 case 2:
8281 return (int)inv.Value.CurrentPermissions; 8834 return (int)inv.Value.GroupPermissions;
8282 case 2: 8835 case 3:
8283 return (int)inv.Value.GroupPermissions; 8836 return (int)inv.Value.EveryonePermissions;
8284 case 3: 8837 case 4:
8285 return (int)inv.Value.EveryonePermissions; 8838 return (int)inv.Value.NextPermissions;
8286 case 4:
8287 return (int)inv.Value.NextPermissions;
8288 }
8289 } 8839 }
8290 } 8840 }
8291 } 8841 }
8842 m_host.TaskInventory.LockItemsForRead(false);
8292 8843
8293 return -1; 8844 return -1;
8294 } 8845 }
@@ -8335,16 +8886,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8335 { 8886 {
8336 m_host.AddScriptLPS(1); 8887 m_host.AddScriptLPS(1);
8337 8888
8338 lock (m_host.TaskInventory) 8889 m_host.TaskInventory.LockItemsForRead(true);
8890 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8339 { 8891 {
8340 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8892 if (inv.Value.Name == item)
8341 { 8893 {
8342 if (inv.Value.Name == item) 8894 m_host.TaskInventory.LockItemsForRead(false);
8343 { 8895 return inv.Value.CreatorID.ToString();
8344 return inv.Value.CreatorID.ToString();
8345 }
8346 } 8896 }
8347 } 8897 }
8898 m_host.TaskInventory.LockItemsForRead(false);
8348 8899
8349 llSay(0, "No item name '" + item + "'"); 8900 llSay(0, "No item name '" + item + "'");
8350 8901
@@ -8604,17 +9155,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8604 int width = 0; 9155 int width = 0;
8605 int height = 0; 9156 int height = 0;
8606 9157
8607 ParcelMediaCommandEnum? commandToSend = null; 9158 uint commandToSend = 0;
8608 float time = 0.0f; // default is from start 9159 float time = 0.0f; // default is from start
8609 9160
8610 ScenePresence presence = null; 9161 ScenePresence presence = null;
8611 9162
8612 for (int i = 0; i < commandList.Data.Length; i++) 9163 for (int i = 0; i < commandList.Data.Length; i++)
8613 { 9164 {
8614 ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; 9165 uint command = (uint)(commandList.GetLSLIntegerItem(i));
8615 switch (command) 9166 switch (command)
8616 { 9167 {
8617 case ParcelMediaCommandEnum.Agent: 9168 case (uint)ParcelMediaCommandEnum.Agent:
8618 // we send only to one agent 9169 // we send only to one agent
8619 if ((i + 1) < commandList.Length) 9170 if ((i + 1) < commandList.Length)
8620 { 9171 {
@@ -8631,25 +9182,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8631 } 9182 }
8632 break; 9183 break;
8633 9184
8634 case ParcelMediaCommandEnum.Loop: 9185 case (uint)ParcelMediaCommandEnum.Loop:
8635 loop = 1; 9186 loop = 1;
8636 commandToSend = command; 9187 commandToSend = command;
8637 update = true; //need to send the media update packet to set looping 9188 update = true; //need to send the media update packet to set looping
8638 break; 9189 break;
8639 9190
8640 case ParcelMediaCommandEnum.Play: 9191 case (uint)ParcelMediaCommandEnum.Play:
8641 loop = 0; 9192 loop = 0;
8642 commandToSend = command; 9193 commandToSend = command;
8643 update = true; //need to send the media update packet to make sure it doesn't loop 9194 update = true; //need to send the media update packet to make sure it doesn't loop
8644 break; 9195 break;
8645 9196
8646 case ParcelMediaCommandEnum.Pause: 9197 case (uint)ParcelMediaCommandEnum.Pause:
8647 case ParcelMediaCommandEnum.Stop: 9198 case (uint)ParcelMediaCommandEnum.Stop:
8648 case ParcelMediaCommandEnum.Unload: 9199 case (uint)ParcelMediaCommandEnum.Unload:
8649 commandToSend = command; 9200 commandToSend = command;
8650 break; 9201 break;
8651 9202
8652 case ParcelMediaCommandEnum.Url: 9203 case (uint)ParcelMediaCommandEnum.Url:
8653 if ((i + 1) < commandList.Length) 9204 if ((i + 1) < commandList.Length)
8654 { 9205 {
8655 if (commandList.Data[i + 1] is LSL_String) 9206 if (commandList.Data[i + 1] is LSL_String)
@@ -8662,7 +9213,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8662 } 9213 }
8663 break; 9214 break;
8664 9215
8665 case ParcelMediaCommandEnum.Texture: 9216 case (uint)ParcelMediaCommandEnum.Texture:
8666 if ((i + 1) < commandList.Length) 9217 if ((i + 1) < commandList.Length)
8667 { 9218 {
8668 if (commandList.Data[i + 1] is LSL_String) 9219 if (commandList.Data[i + 1] is LSL_String)
@@ -8675,7 +9226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8675 } 9226 }
8676 break; 9227 break;
8677 9228
8678 case ParcelMediaCommandEnum.Time: 9229 case (uint)ParcelMediaCommandEnum.Time:
8679 if ((i + 1) < commandList.Length) 9230 if ((i + 1) < commandList.Length)
8680 { 9231 {
8681 if (commandList.Data[i + 1] is LSL_Float) 9232 if (commandList.Data[i + 1] is LSL_Float)
@@ -8687,7 +9238,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8687 } 9238 }
8688 break; 9239 break;
8689 9240
8690 case ParcelMediaCommandEnum.AutoAlign: 9241 case (uint)ParcelMediaCommandEnum.AutoAlign:
8691 if ((i + 1) < commandList.Length) 9242 if ((i + 1) < commandList.Length)
8692 { 9243 {
8693 if (commandList.Data[i + 1] is LSL_Integer) 9244 if (commandList.Data[i + 1] is LSL_Integer)
@@ -8701,7 +9252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8701 } 9252 }
8702 break; 9253 break;
8703 9254
8704 case ParcelMediaCommandEnum.Type: 9255 case (uint)ParcelMediaCommandEnum.Type:
8705 if ((i + 1) < commandList.Length) 9256 if ((i + 1) < commandList.Length)
8706 { 9257 {
8707 if (commandList.Data[i + 1] is LSL_String) 9258 if (commandList.Data[i + 1] is LSL_String)
@@ -8714,7 +9265,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8714 } 9265 }
8715 break; 9266 break;
8716 9267
8717 case ParcelMediaCommandEnum.Desc: 9268 case (uint)ParcelMediaCommandEnum.Desc:
8718 if ((i + 1) < commandList.Length) 9269 if ((i + 1) < commandList.Length)
8719 { 9270 {
8720 if (commandList.Data[i + 1] is LSL_String) 9271 if (commandList.Data[i + 1] is LSL_String)
@@ -8727,7 +9278,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8727 } 9278 }
8728 break; 9279 break;
8729 9280
8730 case ParcelMediaCommandEnum.Size: 9281 case (uint)ParcelMediaCommandEnum.Size:
8731 if ((i + 2) < commandList.Length) 9282 if ((i + 2) < commandList.Length)
8732 { 9283 {
8733 if (commandList.Data[i + 1] is LSL_Integer) 9284 if (commandList.Data[i + 1] is LSL_Integer)
@@ -8797,7 +9348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8797 } 9348 }
8798 } 9349 }
8799 9350
8800 if (commandToSend != null) 9351 if (commandToSend != 0)
8801 { 9352 {
8802 // the commandList contained a start/stop/... command, too 9353 // the commandList contained a start/stop/... command, too
8803 if (presence == null) 9354 if (presence == null)
@@ -8877,16 +9428,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8877 { 9428 {
8878 m_host.AddScriptLPS(1); 9429 m_host.AddScriptLPS(1);
8879 9430
8880 lock (m_host.TaskInventory) 9431 m_host.TaskInventory.LockItemsForRead(true);
9432 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8881 { 9433 {
8882 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9434 if (inv.Value.Name == name)
8883 { 9435 {
8884 if (inv.Value.Name == name) 9436 m_host.TaskInventory.LockItemsForRead(false);
8885 { 9437 return inv.Value.Type;
8886 return inv.Value.Type;
8887 }
8888 } 9438 }
8889 } 9439 }
9440 m_host.TaskInventory.LockItemsForRead(false);
8890 9441
8891 return -1; 9442 return -1;
8892 } 9443 }
@@ -8897,15 +9448,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8897 9448
8898 if (quick_pay_buttons.Data.Length < 4) 9449 if (quick_pay_buttons.Data.Length < 4)
8899 { 9450 {
8900 LSLError("List must have at least 4 elements"); 9451 int x;
8901 return; 9452 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
9453 {
9454 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
9455 }
8902 } 9456 }
8903 m_host.ParentGroup.RootPart.PayPrice[0]=price; 9457 int[] nPrice = new int[5];
8904 9458 nPrice[0]=price;
8905 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 9459 nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0];
8906 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 9460 nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1];
8907 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 9461 nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2];
8908 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 9462 nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3];
9463 m_host.ParentGroup.RootPart.PayPrice = nPrice;
8909 m_host.ParentGroup.HasGroupChanged = true; 9464 m_host.ParentGroup.HasGroupChanged = true;
8910 } 9465 }
8911 9466
@@ -8917,17 +9472,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8917 if (invItemID == UUID.Zero) 9472 if (invItemID == UUID.Zero)
8918 return new LSL_Vector(); 9473 return new LSL_Vector();
8919 9474
8920 lock (m_host.TaskInventory) 9475 m_host.TaskInventory.LockItemsForRead(true);
9476 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8921 { 9477 {
8922 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9478 m_host.TaskInventory.LockItemsForRead(false);
8923 return new LSL_Vector(); 9479 return new LSL_Vector();
9480 }
8924 9481
8925 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9482 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8926 { 9483 {
8927 ShoutError("No permissions to track the camera"); 9484 ShoutError("No permissions to track the camera");
8928 return new LSL_Vector(); 9485 m_host.TaskInventory.LockItemsForRead(false);
8929 } 9486 return new LSL_Vector();
8930 } 9487 }
9488 m_host.TaskInventory.LockItemsForRead(false);
8931 9489
8932 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9490 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8933 if (presence != null) 9491 if (presence != null)
@@ -8945,17 +9503,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8945 if (invItemID == UUID.Zero) 9503 if (invItemID == UUID.Zero)
8946 return new LSL_Rotation(); 9504 return new LSL_Rotation();
8947 9505
8948 lock (m_host.TaskInventory) 9506 m_host.TaskInventory.LockItemsForRead(true);
9507 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8949 { 9508 {
8950 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9509 m_host.TaskInventory.LockItemsForRead(false);
8951 return new LSL_Rotation(); 9510 return new LSL_Rotation();
8952
8953 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8954 {
8955 ShoutError("No permissions to track the camera");
8956 return new LSL_Rotation();
8957 }
8958 } 9511 }
9512 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9513 {
9514 ShoutError("No permissions to track the camera");
9515 m_host.TaskInventory.LockItemsForRead(false);
9516 return new LSL_Rotation();
9517 }
9518 m_host.TaskInventory.LockItemsForRead(false);
8959 9519
8960 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9520 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8961 if (presence != null) 9521 if (presence != null)
@@ -9017,8 +9577,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9017 { 9577 {
9018 m_host.AddScriptLPS(1); 9578 m_host.AddScriptLPS(1);
9019 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 9579 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0);
9020 if (detectedParams == null) return; // only works on the first detected avatar 9580 if (detectedParams == null)
9021 9581 {
9582 if (m_host.IsAttachment == true)
9583 {
9584 detectedParams = new DetectParams();
9585 detectedParams.Key = m_host.OwnerID;
9586 }
9587 else
9588 {
9589 return;
9590 }
9591 }
9592
9022 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 9593 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
9023 if (avatar != null) 9594 if (avatar != null)
9024 { 9595 {
@@ -9026,6 +9597,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9026 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 9597 new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
9027 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); 9598 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
9028 } 9599 }
9600
9029 ScriptSleep(1000); 9601 ScriptSleep(1000);
9030 } 9602 }
9031 9603
@@ -9105,14 +9677,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9105 if (objectID == UUID.Zero) return; 9677 if (objectID == UUID.Zero) return;
9106 9678
9107 UUID agentID; 9679 UUID agentID;
9108 lock (m_host.TaskInventory) 9680 m_host.TaskInventory.LockItemsForRead(true);
9109 { 9681 // we need the permission first, to know which avatar we want to set the camera for
9110 // we need the permission first, to know which avatar we want to set the camera for 9682 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9111 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9112 9683
9113 if (agentID == UUID.Zero) return; 9684 if (agentID == UUID.Zero)
9114 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9685 {
9686 m_host.TaskInventory.LockItemsForRead(false);
9687 return;
9688 }
9689 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9690 {
9691 m_host.TaskInventory.LockItemsForRead(false);
9692 return;
9115 } 9693 }
9694 m_host.TaskInventory.LockItemsForRead(false);
9116 9695
9117 ScenePresence presence = World.GetScenePresence(agentID); 9696 ScenePresence presence = World.GetScenePresence(agentID);
9118 9697
@@ -9162,12 +9741,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9162 9741
9163 // we need the permission first, to know which avatar we want to clear the camera for 9742 // we need the permission first, to know which avatar we want to clear the camera for
9164 UUID agentID; 9743 UUID agentID;
9165 lock (m_host.TaskInventory) 9744 m_host.TaskInventory.LockItemsForRead(true);
9745 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9746 if (agentID == UUID.Zero)
9166 { 9747 {
9167 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9748 m_host.TaskInventory.LockItemsForRead(false);
9168 if (agentID == UUID.Zero) return; 9749 return;
9169 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9750 }
9751 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9752 {
9753 m_host.TaskInventory.LockItemsForRead(false);
9754 return;
9170 } 9755 }
9756 m_host.TaskInventory.LockItemsForRead(false);
9171 9757
9172 ScenePresence presence = World.GetScenePresence(agentID); 9758 ScenePresence presence = World.GetScenePresence(agentID);
9173 9759
@@ -9624,15 +10210,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9624 10210
9625 internal UUID ScriptByName(string name) 10211 internal UUID ScriptByName(string name)
9626 { 10212 {
9627 lock (m_host.TaskInventory) 10213 m_host.TaskInventory.LockItemsForRead(true);
10214
10215 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
9628 { 10216 {
9629 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 10217 if (item.Type == 10 && item.Name == name)
9630 { 10218 {
9631 if (item.Type == 10 && item.Name == name) 10219 m_host.TaskInventory.LockItemsForRead(false);
9632 return item.ItemID; 10220 return item.ItemID;
9633 } 10221 }
9634 } 10222 }
9635 10223
10224 m_host.TaskInventory.LockItemsForRead(false);
10225
9636 return UUID.Zero; 10226 return UUID.Zero;
9637 } 10227 }
9638 10228
@@ -9673,6 +10263,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9673 { 10263 {
9674 m_host.AddScriptLPS(1); 10264 m_host.AddScriptLPS(1);
9675 10265
10266 //Clone is thread safe
9676 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10267 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9677 10268
9678 UUID assetID = UUID.Zero; 10269 UUID assetID = UUID.Zero;
@@ -9735,6 +10326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9735 { 10326 {
9736 m_host.AddScriptLPS(1); 10327 m_host.AddScriptLPS(1);
9737 10328
10329 //Clone is thread safe
9738 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 10330 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9739 10331
9740 UUID assetID = UUID.Zero; 10332 UUID assetID = UUID.Zero;
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);