diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
11 files changed, 893 insertions, 375 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..9f3e354 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 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using 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); |
@@ -219,6 +222,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
219 | public List<SceneObjectPart> GetLinkParts(int linkType) | 222 | public List<SceneObjectPart> GetLinkParts(int linkType) |
220 | { | 223 | { |
221 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 224 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
225 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
226 | return ret; | ||
222 | ret.Add(m_host); | 227 | ret.Add(m_host); |
223 | 228 | ||
224 | switch (linkType) | 229 | switch (linkType) |
@@ -272,40 +277,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 277 | protected UUID InventorySelf() |
273 | { | 278 | { |
274 | UUID invItemID = new UUID(); | 279 | UUID invItemID = new UUID(); |
275 | 280 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 281 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
282 | { | ||
283 | m_host.TaskInventory.LockItemsForRead(true); | ||
284 | unlock = true; | ||
285 | } | ||
286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 287 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 288 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 289 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 290 | invItemID = inv.Key; |
281 | { | 291 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 292 | } |
286 | } | 293 | } |
287 | 294 | if (unlock) | |
295 | { | ||
296 | m_host.TaskInventory.LockItemsForRead(false); | ||
297 | } | ||
288 | return invItemID; | 298 | return invItemID; |
289 | } | 299 | } |
290 | 300 | ||
291 | protected UUID InventoryKey(string name, int type) | 301 | protected UUID InventoryKey(string name, int type) |
292 | { | 302 | { |
293 | m_host.AddScriptLPS(1); | 303 | m_host.AddScriptLPS(1); |
294 | 304 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 305 | |
306 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 307 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 308 | if (inv.Value.Name == name) |
298 | { | 309 | { |
299 | if (inv.Value.Name == name) | 310 | m_host.TaskInventory.LockItemsForRead(false); |
311 | |||
312 | if (inv.Value.Type != type) | ||
300 | { | 313 | { |
301 | if (inv.Value.Type != type) | 314 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 315 | } |
316 | |||
317 | return inv.Value.AssetID; | ||
306 | } | 318 | } |
307 | } | 319 | } |
308 | 320 | ||
321 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 322 | return UUID.Zero; |
310 | } | 323 | } |
311 | 324 | ||
@@ -313,17 +326,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 326 | { |
314 | m_host.AddScriptLPS(1); | 327 | m_host.AddScriptLPS(1); |
315 | 328 | ||
316 | lock (m_host.TaskInventory) | 329 | |
330 | m_host.TaskInventory.LockItemsForRead(true); | ||
331 | |||
332 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 333 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 334 | if (inv.Value.Name == name) |
319 | { | 335 | { |
320 | if (inv.Value.Name == name) | 336 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 337 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 338 | } |
325 | } | 339 | } |
326 | 340 | ||
341 | m_host.TaskInventory.LockItemsForRead(false); | ||
342 | |||
343 | |||
327 | return UUID.Zero; | 344 | return UUID.Zero; |
328 | } | 345 | } |
329 | 346 | ||
@@ -705,6 +722,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
705 | { | 722 | { |
706 | //A and B should both be normalized | 723 | //A and B should both be normalized |
707 | m_host.AddScriptLPS(1); | 724 | m_host.AddScriptLPS(1); |
725 | /* This method is more accurate than the SL one, and thus causes problems | ||
726 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. | ||
727 | |||
708 | double dotProduct = LSL_Vector.Dot(a, b); | 728 | double dotProduct = LSL_Vector.Dot(a, b); |
709 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 729 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
710 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | 730 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
@@ -721,8 +741,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
721 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 741 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
722 | 742 | ||
723 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | 743 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
724 | } | 744 | */ |
725 | 745 | ||
746 | // This method mimics the 180 errors found in SL | ||
747 | // See www.euclideanspace.com... angleBetween | ||
748 | LSL_Vector vec_a = a; | ||
749 | LSL_Vector vec_b = b; | ||
750 | |||
751 | // Eliminate zero length | ||
752 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
753 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
754 | if (vec_a_mag < 0.00001 || | ||
755 | vec_b_mag < 0.00001) | ||
756 | { | ||
757 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
758 | } | ||
759 | |||
760 | // Normalize | ||
761 | vec_a = llVecNorm(vec_a); | ||
762 | vec_b = llVecNorm(vec_b); | ||
763 | |||
764 | // Calculate axis and rotation angle | ||
765 | LSL_Vector axis = vec_a % vec_b; | ||
766 | LSL_Float cos_theta = vec_a * vec_b; | ||
767 | |||
768 | // Check if parallel | ||
769 | if (cos_theta > 0.99999) | ||
770 | { | ||
771 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
772 | } | ||
773 | |||
774 | // Check if anti-parallel | ||
775 | else if (cos_theta < -0.99999) | ||
776 | { | ||
777 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); | ||
778 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); | ||
779 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); | ||
780 | } | ||
781 | else // other rotation | ||
782 | { | ||
783 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; | ||
784 | axis = llVecNorm(axis); | ||
785 | double x, y, z, s, t; | ||
786 | s = Math.Cos(theta); | ||
787 | t = Math.Sin(theta); | ||
788 | x = axis.x * t; | ||
789 | y = axis.y * t; | ||
790 | z = axis.z * t; | ||
791 | return new LSL_Rotation(x,y,z,s); | ||
792 | } | ||
793 | } | ||
794 | |||
726 | public void llWhisper(int channelID, string text) | 795 | public void llWhisper(int channelID, string text) |
727 | { | 796 | { |
728 | m_host.AddScriptLPS(1); | 797 | m_host.AddScriptLPS(1); |
@@ -1046,10 +1115,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1046 | return detectedParams.TouchUV; | 1115 | return detectedParams.TouchUV; |
1047 | } | 1116 | } |
1048 | 1117 | ||
1118 | [DebuggerNonUserCode] | ||
1049 | public virtual void llDie() | 1119 | public virtual void llDie() |
1050 | { | 1120 | { |
1051 | m_host.AddScriptLPS(1); | 1121 | m_host.AddScriptLPS(1); |
1052 | throw new SelfDeleteException(); | 1122 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1053 | } | 1123 | } |
1054 | 1124 | ||
1055 | public LSL_Float llGround(LSL_Vector offset) | 1125 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1122,6 +1192,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1122 | 1192 | ||
1123 | public void llSetStatus(int status, int value) | 1193 | public void llSetStatus(int status, int value) |
1124 | { | 1194 | { |
1195 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1196 | return; | ||
1125 | m_host.AddScriptLPS(1); | 1197 | m_host.AddScriptLPS(1); |
1126 | 1198 | ||
1127 | int statusrotationaxis = 0; | 1199 | int statusrotationaxis = 0; |
@@ -1351,6 +1423,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1351 | { | 1423 | { |
1352 | m_host.AddScriptLPS(1); | 1424 | m_host.AddScriptLPS(1); |
1353 | 1425 | ||
1426 | SetColor(m_host, color, face); | ||
1427 | } | ||
1428 | |||
1429 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1430 | { | ||
1431 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1432 | return; | ||
1433 | |||
1434 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1435 | Color4 texcolor; | ||
1436 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1437 | { | ||
1438 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1439 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1440 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1441 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1442 | tex.FaceTextures[face].RGBA = texcolor; | ||
1443 | part.UpdateTexture(tex); | ||
1444 | return; | ||
1445 | } | ||
1446 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1447 | { | ||
1448 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1449 | { | ||
1450 | if (tex.FaceTextures[i] != null) | ||
1451 | { | ||
1452 | texcolor = tex.FaceTextures[i].RGBA; | ||
1453 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1454 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1455 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1456 | tex.FaceTextures[i].RGBA = texcolor; | ||
1457 | } | ||
1458 | texcolor = tex.DefaultTexture.RGBA; | ||
1459 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1460 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1461 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1462 | tex.DefaultTexture.RGBA = texcolor; | ||
1463 | } | ||
1464 | part.UpdateTexture(tex); | ||
1465 | return; | ||
1466 | } | ||
1467 | |||
1354 | if (face == ScriptBaseClass.ALL_SIDES) | 1468 | if (face == ScriptBaseClass.ALL_SIDES) |
1355 | face = SceneObjectPart.ALL_SIDES; | 1469 | face = SceneObjectPart.ALL_SIDES; |
1356 | 1470 | ||
@@ -1359,6 +1473,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1359 | 1473 | ||
1360 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1474 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1361 | { | 1475 | { |
1476 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1477 | return; | ||
1478 | |||
1362 | Primitive.TextureEntry tex = part.Shape.Textures; | 1479 | Primitive.TextureEntry tex = part.Shape.Textures; |
1363 | MappingType textype; | 1480 | MappingType textype; |
1364 | textype = MappingType.Default; | 1481 | textype = MappingType.Default; |
@@ -1389,6 +1506,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1389 | 1506 | ||
1390 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1507 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1391 | { | 1508 | { |
1509 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1510 | return; | ||
1511 | |||
1392 | Primitive.TextureEntry tex = part.Shape.Textures; | 1512 | Primitive.TextureEntry tex = part.Shape.Textures; |
1393 | if (face >= 0 && face < GetNumberOfSides(part)) | 1513 | if (face >= 0 && face < GetNumberOfSides(part)) |
1394 | { | 1514 | { |
@@ -1414,6 +1534,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1414 | 1534 | ||
1415 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1535 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1416 | { | 1536 | { |
1537 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1538 | return; | ||
1417 | 1539 | ||
1418 | Shininess sval = new Shininess(); | 1540 | Shininess sval = new Shininess(); |
1419 | 1541 | ||
@@ -1464,6 +1586,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1464 | 1586 | ||
1465 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1587 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1466 | { | 1588 | { |
1589 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1590 | return; | ||
1591 | |||
1467 | Primitive.TextureEntry tex = part.Shape.Textures; | 1592 | Primitive.TextureEntry tex = part.Shape.Textures; |
1468 | if (face >= 0 && face < GetNumberOfSides(part)) | 1593 | if (face >= 0 && face < GetNumberOfSides(part)) |
1469 | { | 1594 | { |
@@ -1524,13 +1649,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1524 | m_host.AddScriptLPS(1); | 1649 | m_host.AddScriptLPS(1); |
1525 | 1650 | ||
1526 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1651 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1527 | 1652 | if (parts.Count > 0) | |
1528 | foreach (SceneObjectPart part in parts) | 1653 | { |
1529 | SetAlpha(part, alpha, face); | 1654 | try |
1655 | { | ||
1656 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1657 | foreach (SceneObjectPart part in parts) | ||
1658 | SetAlpha(part, alpha, face); | ||
1659 | } | ||
1660 | finally | ||
1661 | { | ||
1662 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1663 | } | ||
1664 | } | ||
1530 | } | 1665 | } |
1531 | 1666 | ||
1532 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1667 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1533 | { | 1668 | { |
1669 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1670 | return; | ||
1671 | |||
1534 | Primitive.TextureEntry tex = part.Shape.Textures; | 1672 | Primitive.TextureEntry tex = part.Shape.Textures; |
1535 | Color4 texcolor; | 1673 | Color4 texcolor; |
1536 | if (face >= 0 && face < GetNumberOfSides(part)) | 1674 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1576,7 +1714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1576 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1714 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1577 | float wind, float tension, LSL_Vector Force) | 1715 | float wind, float tension, LSL_Vector Force) |
1578 | { | 1716 | { |
1579 | if (part == null) | 1717 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1580 | return; | 1718 | return; |
1581 | 1719 | ||
1582 | if (flexi) | 1720 | if (flexi) |
@@ -1611,7 +1749,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1611 | /// <param name="falloff"></param> | 1749 | /// <param name="falloff"></param> |
1612 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1750 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1613 | { | 1751 | { |
1614 | if (part == null) | 1752 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1615 | return; | 1753 | return; |
1616 | 1754 | ||
1617 | if (light) | 1755 | if (light) |
@@ -1688,15 +1826,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1688 | m_host.AddScriptLPS(1); | 1826 | m_host.AddScriptLPS(1); |
1689 | 1827 | ||
1690 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1828 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1691 | 1829 | if (parts.Count > 0) | |
1692 | foreach (SceneObjectPart part in parts) | 1830 | { |
1693 | SetTexture(part, texture, face); | 1831 | try |
1694 | 1832 | { | |
1833 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1834 | foreach (SceneObjectPart part in parts) | ||
1835 | SetTexture(part, texture, face); | ||
1836 | } | ||
1837 | finally | ||
1838 | { | ||
1839 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1840 | } | ||
1841 | } | ||
1695 | ScriptSleep(200); | 1842 | ScriptSleep(200); |
1696 | } | 1843 | } |
1697 | 1844 | ||
1698 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1845 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1699 | { | 1846 | { |
1847 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1848 | return; | ||
1849 | |||
1700 | UUID textureID=new UUID(); | 1850 | UUID textureID=new UUID(); |
1701 | 1851 | ||
1702 | if (!UUID.TryParse(texture, out textureID)) | 1852 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1742,6 +1892,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1742 | 1892 | ||
1743 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1893 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1744 | { | 1894 | { |
1895 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1896 | return; | ||
1897 | |||
1745 | Primitive.TextureEntry tex = part.Shape.Textures; | 1898 | Primitive.TextureEntry tex = part.Shape.Textures; |
1746 | if (face >= 0 && face < GetNumberOfSides(part)) | 1899 | if (face >= 0 && face < GetNumberOfSides(part)) |
1747 | { | 1900 | { |
@@ -1778,6 +1931,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1778 | 1931 | ||
1779 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1932 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1780 | { | 1933 | { |
1934 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1935 | return; | ||
1936 | |||
1781 | Primitive.TextureEntry tex = part.Shape.Textures; | 1937 | Primitive.TextureEntry tex = part.Shape.Textures; |
1782 | if (face >= 0 && face < GetNumberOfSides(part)) | 1938 | if (face >= 0 && face < GetNumberOfSides(part)) |
1783 | { | 1939 | { |
@@ -1814,6 +1970,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1814 | 1970 | ||
1815 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1971 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1816 | { | 1972 | { |
1973 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1974 | return; | ||
1975 | |||
1817 | Primitive.TextureEntry tex = part.Shape.Textures; | 1976 | Primitive.TextureEntry tex = part.Shape.Textures; |
1818 | if (face >= 0 && face < GetNumberOfSides(part)) | 1977 | if (face >= 0 && face < GetNumberOfSides(part)) |
1819 | { | 1978 | { |
@@ -1884,6 +2043,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1884 | 2043 | ||
1885 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2044 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1886 | { | 2045 | { |
2046 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2047 | return; | ||
2048 | |||
1887 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2049 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1888 | LSL_Vector currentPos = llGetLocalPos(); | 2050 | LSL_Vector currentPos = llGetLocalPos(); |
1889 | 2051 | ||
@@ -1970,6 +2132,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1970 | 2132 | ||
1971 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2133 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1972 | { | 2134 | { |
2135 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2136 | return; | ||
2137 | |||
1973 | part.UpdateRotation(rot); | 2138 | part.UpdateRotation(rot); |
1974 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2139 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1975 | 2140 | ||
@@ -2589,12 +2754,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2589 | 2754 | ||
2590 | m_host.AddScriptLPS(1); | 2755 | m_host.AddScriptLPS(1); |
2591 | 2756 | ||
2757 | m_host.TaskInventory.LockItemsForRead(true); | ||
2592 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2758 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2593 | 2759 | m_host.TaskInventory.LockItemsForRead(false); | |
2594 | lock (m_host.TaskInventory) | ||
2595 | { | ||
2596 | item = m_host.TaskInventory[invItemID]; | ||
2597 | } | ||
2598 | 2760 | ||
2599 | if (item.PermsGranter == UUID.Zero) | 2761 | if (item.PermsGranter == UUID.Zero) |
2600 | return 0; | 2762 | return 0; |
@@ -2669,6 +2831,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2669 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2831 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2670 | return; | 2832 | return; |
2671 | 2833 | ||
2834 | //Clone is thread-safe | ||
2672 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2835 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2673 | 2836 | ||
2674 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2837 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2731,6 +2894,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2731 | 2894 | ||
2732 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2895 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2733 | { | 2896 | { |
2897 | /* | ||
2734 | m_host.AddScriptLPS(1); | 2898 | m_host.AddScriptLPS(1); |
2735 | // Determine where we are looking from | 2899 | // Determine where we are looking from |
2736 | LSL_Vector from = llGetPos(); | 2900 | LSL_Vector from = llGetPos(); |
@@ -2750,10 +2914,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2750 | // the angles of rotation in radians into rotation value | 2914 | // the angles of rotation in radians into rotation value |
2751 | 2915 | ||
2752 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2916 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2753 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2917 | |
2754 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2918 | // This would only work if your physics system contains an APID controller: |
2919 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2920 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2921 | |||
2755 | // Orient the object to the angle calculated | 2922 | // Orient the object to the angle calculated |
2756 | //llSetRot(rot); | 2923 | llSetRot(rot); |
2924 | */ | ||
2925 | |||
2926 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2927 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2928 | // http://bugs.meta7.com/view.php?id=28 | ||
2929 | // - Tom | ||
2930 | |||
2931 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2932 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2933 | |||
2934 | } | ||
2935 | |||
2936 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2937 | { | ||
2938 | m_host.AddScriptLPS(1); | ||
2939 | // NotImplemented("llRotLookAt"); | ||
2940 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2941 | |||
2757 | } | 2942 | } |
2758 | 2943 | ||
2759 | public void llStopLookAt() | 2944 | public void llStopLookAt() |
@@ -2802,13 +2987,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2802 | { | 2987 | { |
2803 | TaskInventoryItem item; | 2988 | TaskInventoryItem item; |
2804 | 2989 | ||
2805 | lock (m_host.TaskInventory) | 2990 | m_host.TaskInventory.LockItemsForRead(true); |
2991 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2806 | { | 2992 | { |
2807 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2993 | m_host.TaskInventory.LockItemsForRead(false); |
2808 | return; | 2994 | return; |
2809 | else | ||
2810 | item = m_host.TaskInventory[InventorySelf()]; | ||
2811 | } | 2995 | } |
2996 | else | ||
2997 | { | ||
2998 | item = m_host.TaskInventory[InventorySelf()]; | ||
2999 | } | ||
3000 | m_host.TaskInventory.LockItemsForRead(false); | ||
2812 | 3001 | ||
2813 | if (item.PermsGranter != UUID.Zero) | 3002 | if (item.PermsGranter != UUID.Zero) |
2814 | { | 3003 | { |
@@ -2830,13 +3019,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2830 | { | 3019 | { |
2831 | TaskInventoryItem item; | 3020 | TaskInventoryItem item; |
2832 | 3021 | ||
3022 | m_host.TaskInventory.LockItemsForRead(true); | ||
2833 | lock (m_host.TaskInventory) | 3023 | lock (m_host.TaskInventory) |
2834 | { | 3024 | { |
3025 | |||
2835 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3026 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3027 | { | ||
3028 | m_host.TaskInventory.LockItemsForRead(false); | ||
2836 | return; | 3029 | return; |
3030 | } | ||
2837 | else | 3031 | else |
3032 | { | ||
2838 | item = m_host.TaskInventory[InventorySelf()]; | 3033 | item = m_host.TaskInventory[InventorySelf()]; |
3034 | } | ||
2839 | } | 3035 | } |
3036 | m_host.TaskInventory.LockItemsForRead(false); | ||
2840 | 3037 | ||
2841 | m_host.AddScriptLPS(1); | 3038 | m_host.AddScriptLPS(1); |
2842 | 3039 | ||
@@ -2873,14 +3070,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2873 | 3070 | ||
2874 | TaskInventoryItem item; | 3071 | TaskInventoryItem item; |
2875 | 3072 | ||
2876 | lock (m_host.TaskInventory) | 3073 | m_host.TaskInventory.LockItemsForRead(true); |
3074 | |||
3075 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2877 | { | 3076 | { |
2878 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3077 | m_host.TaskInventory.LockItemsForRead(false); |
2879 | return; | 3078 | return; |
2880 | else | 3079 | } |
2881 | item = m_host.TaskInventory[InventorySelf()]; | 3080 | else |
3081 | { | ||
3082 | item = m_host.TaskInventory[InventorySelf()]; | ||
2882 | } | 3083 | } |
2883 | 3084 | ||
3085 | m_host.TaskInventory.LockItemsForRead(false); | ||
3086 | |||
2884 | if (item.PermsGranter != m_host.OwnerID) | 3087 | if (item.PermsGranter != m_host.OwnerID) |
2885 | return; | 3088 | return; |
2886 | 3089 | ||
@@ -2907,13 +3110,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2907 | 3110 | ||
2908 | TaskInventoryItem item; | 3111 | TaskInventoryItem item; |
2909 | 3112 | ||
2910 | lock (m_host.TaskInventory) | 3113 | m_host.TaskInventory.LockItemsForRead(true); |
3114 | |||
3115 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2911 | { | 3116 | { |
2912 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3117 | m_host.TaskInventory.LockItemsForRead(false); |
2913 | return; | 3118 | return; |
2914 | else | ||
2915 | item = m_host.TaskInventory[InventorySelf()]; | ||
2916 | } | 3119 | } |
3120 | else | ||
3121 | { | ||
3122 | item = m_host.TaskInventory[InventorySelf()]; | ||
3123 | } | ||
3124 | m_host.TaskInventory.LockItemsForRead(false); | ||
3125 | |||
2917 | 3126 | ||
2918 | if (item.PermsGranter != m_host.OwnerID) | 3127 | if (item.PermsGranter != m_host.OwnerID) |
2919 | return; | 3128 | return; |
@@ -2950,8 +3159,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2950 | return m_host.OwnerID.ToString(); | 3159 | return m_host.OwnerID.ToString(); |
2951 | } | 3160 | } |
2952 | 3161 | ||
3162 | [DebuggerNonUserCode] | ||
2953 | public void llInstantMessage(string user, string message) | 3163 | public void llInstantMessage(string user, string message) |
2954 | { | 3164 | { |
3165 | UUID result; | ||
3166 | if (!UUID.TryParse(user, out result)) | ||
3167 | { | ||
3168 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3169 | return; | ||
3170 | } | ||
3171 | |||
3172 | |||
2955 | m_host.AddScriptLPS(1); | 3173 | m_host.AddScriptLPS(1); |
2956 | 3174 | ||
2957 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3175 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2966,7 +3184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2966 | UUID friendTransactionID = UUID.Random(); | 3184 | UUID friendTransactionID = UUID.Random(); |
2967 | 3185 | ||
2968 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3186 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2969 | 3187 | ||
2970 | GridInstantMessage msg = new GridInstantMessage(); | 3188 | GridInstantMessage msg = new GridInstantMessage(); |
2971 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3189 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2972 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3190 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3115,13 +3333,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3115 | m_host.AddScriptLPS(1); | 3333 | m_host.AddScriptLPS(1); |
3116 | } | 3334 | } |
3117 | 3335 | ||
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) | 3336 | public LSL_Integer llStringLength(string str) |
3126 | { | 3337 | { |
3127 | m_host.AddScriptLPS(1); | 3338 | m_host.AddScriptLPS(1); |
@@ -3145,14 +3356,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3145 | 3356 | ||
3146 | TaskInventoryItem item; | 3357 | TaskInventoryItem item; |
3147 | 3358 | ||
3148 | lock (m_host.TaskInventory) | 3359 | m_host.TaskInventory.LockItemsForRead(true); |
3360 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3149 | { | 3361 | { |
3150 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3362 | m_host.TaskInventory.LockItemsForRead(false); |
3151 | return; | 3363 | return; |
3152 | else | ||
3153 | item = m_host.TaskInventory[InventorySelf()]; | ||
3154 | } | 3364 | } |
3155 | 3365 | else | |
3366 | { | ||
3367 | item = m_host.TaskInventory[InventorySelf()]; | ||
3368 | } | ||
3369 | m_host.TaskInventory.LockItemsForRead(false); | ||
3156 | if (item.PermsGranter == UUID.Zero) | 3370 | if (item.PermsGranter == UUID.Zero) |
3157 | return; | 3371 | return; |
3158 | 3372 | ||
@@ -3182,13 +3396,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3182 | 3396 | ||
3183 | TaskInventoryItem item; | 3397 | TaskInventoryItem item; |
3184 | 3398 | ||
3185 | lock (m_host.TaskInventory) | 3399 | m_host.TaskInventory.LockItemsForRead(true); |
3400 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3186 | { | 3401 | { |
3187 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3402 | m_host.TaskInventory.LockItemsForRead(false); |
3188 | return; | 3403 | return; |
3189 | else | ||
3190 | item = m_host.TaskInventory[InventorySelf()]; | ||
3191 | } | 3404 | } |
3405 | else | ||
3406 | { | ||
3407 | item = m_host.TaskInventory[InventorySelf()]; | ||
3408 | } | ||
3409 | m_host.TaskInventory.LockItemsForRead(false); | ||
3410 | |||
3192 | 3411 | ||
3193 | if (item.PermsGranter == UUID.Zero) | 3412 | if (item.PermsGranter == UUID.Zero) |
3194 | return; | 3413 | return; |
@@ -3265,10 +3484,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3265 | 3484 | ||
3266 | TaskInventoryItem item; | 3485 | TaskInventoryItem item; |
3267 | 3486 | ||
3268 | lock (m_host.TaskInventory) | 3487 | |
3488 | m_host.TaskInventory.LockItemsForRead(true); | ||
3489 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3490 | { | ||
3491 | m_host.TaskInventory.LockItemsForRead(false); | ||
3492 | return; | ||
3493 | } | ||
3494 | else | ||
3269 | { | 3495 | { |
3270 | item = m_host.TaskInventory[invItemID]; | 3496 | item = m_host.TaskInventory[invItemID]; |
3271 | } | 3497 | } |
3498 | m_host.TaskInventory.LockItemsForRead(false); | ||
3272 | 3499 | ||
3273 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3500 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3274 | { | 3501 | { |
@@ -3300,11 +3527,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3300 | 3527 | ||
3301 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3528 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3302 | { | 3529 | { |
3303 | lock (m_host.TaskInventory) | 3530 | m_host.TaskInventory.LockItemsForWrite(true); |
3304 | { | 3531 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3305 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3532 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3306 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3533 | m_host.TaskInventory.LockItemsForWrite(false); |
3307 | } | ||
3308 | 3534 | ||
3309 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3535 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3310 | "run_time_permissions", new Object[] { | 3536 | "run_time_permissions", new Object[] { |
@@ -3324,11 +3550,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3324 | 3550 | ||
3325 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3551 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3326 | { | 3552 | { |
3327 | lock (m_host.TaskInventory) | 3553 | m_host.TaskInventory.LockItemsForWrite(true); |
3328 | { | 3554 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3329 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3555 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3330 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3556 | m_host.TaskInventory.LockItemsForWrite(false); |
3331 | } | ||
3332 | 3557 | ||
3333 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3558 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3334 | "run_time_permissions", new Object[] { | 3559 | "run_time_permissions", new Object[] { |
@@ -3349,11 +3574,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3349 | 3574 | ||
3350 | if (!m_waitingForScriptAnswer) | 3575 | if (!m_waitingForScriptAnswer) |
3351 | { | 3576 | { |
3352 | lock (m_host.TaskInventory) | 3577 | m_host.TaskInventory.LockItemsForWrite(true); |
3353 | { | 3578 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3354 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3579 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3355 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3580 | m_host.TaskInventory.LockItemsForWrite(false); |
3356 | } | ||
3357 | 3581 | ||
3358 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3582 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3359 | m_waitingForScriptAnswer=true; | 3583 | m_waitingForScriptAnswer=true; |
@@ -3388,10 +3612,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3388 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3612 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3389 | llReleaseControls(); | 3613 | llReleaseControls(); |
3390 | 3614 | ||
3391 | lock (m_host.TaskInventory) | 3615 | |
3392 | { | 3616 | m_host.TaskInventory.LockItemsForWrite(true); |
3393 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3617 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3394 | } | 3618 | m_host.TaskInventory.LockItemsForWrite(false); |
3619 | |||
3395 | 3620 | ||
3396 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3621 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3397 | "run_time_permissions", new Object[] { | 3622 | "run_time_permissions", new Object[] { |
@@ -3403,16 +3628,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3403 | { | 3628 | { |
3404 | m_host.AddScriptLPS(1); | 3629 | m_host.AddScriptLPS(1); |
3405 | 3630 | ||
3406 | lock (m_host.TaskInventory) | 3631 | m_host.TaskInventory.LockItemsForRead(true); |
3632 | |||
3633 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3407 | { | 3634 | { |
3408 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3635 | if (item.Type == 10 && item.ItemID == m_itemID) |
3409 | { | 3636 | { |
3410 | if (item.Type == 10 && item.ItemID == m_itemID) | 3637 | m_host.TaskInventory.LockItemsForRead(false); |
3411 | { | 3638 | return item.PermsGranter.ToString(); |
3412 | return item.PermsGranter.ToString(); | ||
3413 | } | ||
3414 | } | 3639 | } |
3415 | } | 3640 | } |
3641 | m_host.TaskInventory.LockItemsForRead(false); | ||
3416 | 3642 | ||
3417 | return UUID.Zero.ToString(); | 3643 | return UUID.Zero.ToString(); |
3418 | } | 3644 | } |
@@ -3421,19 +3647,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3421 | { | 3647 | { |
3422 | m_host.AddScriptLPS(1); | 3648 | m_host.AddScriptLPS(1); |
3423 | 3649 | ||
3424 | lock (m_host.TaskInventory) | 3650 | m_host.TaskInventory.LockItemsForRead(true); |
3651 | |||
3652 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3425 | { | 3653 | { |
3426 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3654 | if (item.Type == 10 && item.ItemID == m_itemID) |
3427 | { | 3655 | { |
3428 | if (item.Type == 10 && item.ItemID == m_itemID) | 3656 | int perms = item.PermsMask; |
3429 | { | 3657 | if (m_automaticLinkPermission) |
3430 | int perms = item.PermsMask; | 3658 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3431 | if (m_automaticLinkPermission) | 3659 | m_host.TaskInventory.LockItemsForRead(false); |
3432 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3660 | return perms; |
3433 | return perms; | ||
3434 | } | ||
3435 | } | 3661 | } |
3436 | } | 3662 | } |
3663 | m_host.TaskInventory.LockItemsForRead(false); | ||
3437 | 3664 | ||
3438 | return 0; | 3665 | return 0; |
3439 | } | 3666 | } |
@@ -3455,9 +3682,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3455 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3682 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3456 | { | 3683 | { |
3457 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3684 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3458 | 3685 | if (parts.Count > 0) | |
3459 | foreach (SceneObjectPart part in parts) | 3686 | { |
3460 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3687 | try |
3688 | { | ||
3689 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3690 | foreach (SceneObjectPart part in parts) | ||
3691 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3692 | } | ||
3693 | finally | ||
3694 | { | ||
3695 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3696 | } | ||
3697 | } | ||
3461 | } | 3698 | } |
3462 | 3699 | ||
3463 | public void llCreateLink(string target, int parent) | 3700 | public void llCreateLink(string target, int parent) |
@@ -3466,11 +3703,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3466 | UUID invItemID = InventorySelf(); | 3703 | UUID invItemID = InventorySelf(); |
3467 | 3704 | ||
3468 | TaskInventoryItem item; | 3705 | TaskInventoryItem item; |
3469 | lock (m_host.TaskInventory) | 3706 | m_host.TaskInventory.LockItemsForRead(true); |
3470 | { | 3707 | item = m_host.TaskInventory[invItemID]; |
3471 | item = m_host.TaskInventory[invItemID]; | 3708 | m_host.TaskInventory.LockItemsForRead(false); |
3472 | } | 3709 | |
3473 | |||
3474 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3710 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3475 | && !m_automaticLinkPermission) | 3711 | && !m_automaticLinkPermission) |
3476 | { | 3712 | { |
@@ -3523,16 +3759,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3523 | m_host.AddScriptLPS(1); | 3759 | m_host.AddScriptLPS(1); |
3524 | UUID invItemID = InventorySelf(); | 3760 | UUID invItemID = InventorySelf(); |
3525 | 3761 | ||
3526 | lock (m_host.TaskInventory) | 3762 | m_host.TaskInventory.LockItemsForRead(true); |
3527 | { | ||
3528 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3763 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3529 | && !m_automaticLinkPermission) | 3764 | && !m_automaticLinkPermission) |
3530 | { | 3765 | { |
3531 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3766 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3767 | m_host.TaskInventory.LockItemsForRead(false); | ||
3532 | return; | 3768 | return; |
3533 | } | 3769 | } |
3534 | } | 3770 | m_host.TaskInventory.LockItemsForRead(false); |
3535 | 3771 | ||
3536 | if (linknum < ScriptBaseClass.LINK_THIS) | 3772 | if (linknum < ScriptBaseClass.LINK_THIS) |
3537 | return; | 3773 | return; |
3538 | 3774 | ||
@@ -3571,10 +3807,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3571 | // Restructuring Multiple Prims. | 3807 | // Restructuring Multiple Prims. |
3572 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3808 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3573 | parts.Remove(parentPrim.RootPart); | 3809 | parts.Remove(parentPrim.RootPart); |
3574 | foreach (SceneObjectPart part in parts) | 3810 | if (parts.Count > 0) |
3575 | { | 3811 | { |
3576 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3812 | try |
3813 | { | ||
3814 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3815 | foreach (SceneObjectPart part in parts) | ||
3816 | { | ||
3817 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3818 | } | ||
3819 | } | ||
3820 | finally | ||
3821 | { | ||
3822 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3823 | } | ||
3577 | } | 3824 | } |
3825 | |||
3578 | parentPrim.HasGroupChanged = true; | 3826 | parentPrim.HasGroupChanged = true; |
3579 | parentPrim.ScheduleGroupForFullUpdate(); | 3827 | parentPrim.ScheduleGroupForFullUpdate(); |
3580 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3828 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3583,11 +3831,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3583 | { | 3831 | { |
3584 | SceneObjectPart newRoot = parts[0]; | 3832 | SceneObjectPart newRoot = parts[0]; |
3585 | parts.Remove(newRoot); | 3833 | parts.Remove(newRoot); |
3586 | foreach (SceneObjectPart part in parts) | 3834 | |
3835 | try | ||
3587 | { | 3836 | { |
3588 | part.UpdateFlag = 0; | 3837 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3589 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3838 | foreach (SceneObjectPart part in parts) |
3839 | { | ||
3840 | part.UpdateFlag = 0; | ||
3841 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3842 | } | ||
3590 | } | 3843 | } |
3844 | finally | ||
3845 | { | ||
3846 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3847 | } | ||
3848 | |||
3849 | |||
3591 | newRoot.ParentGroup.HasGroupChanged = true; | 3850 | newRoot.ParentGroup.HasGroupChanged = true; |
3592 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3851 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3593 | } | 3852 | } |
@@ -3613,11 +3872,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3613 | 3872 | ||
3614 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3873 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3615 | parts.Remove(parentPrim.RootPart); | 3874 | parts.Remove(parentPrim.RootPart); |
3616 | 3875 | if (parts.Count > 0) | |
3617 | foreach (SceneObjectPart part in parts) | ||
3618 | { | 3876 | { |
3619 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3877 | try |
3620 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3878 | { |
3879 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3880 | foreach (SceneObjectPart part in parts) | ||
3881 | { | ||
3882 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3883 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | ||
3884 | } | ||
3885 | } | ||
3886 | finally | ||
3887 | { | ||
3888 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3889 | } | ||
3621 | } | 3890 | } |
3622 | parentPrim.HasGroupChanged = true; | 3891 | parentPrim.HasGroupChanged = true; |
3623 | parentPrim.ScheduleGroupForFullUpdate(); | 3892 | parentPrim.ScheduleGroupForFullUpdate(); |
@@ -3709,17 +3978,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3709 | m_host.AddScriptLPS(1); | 3978 | m_host.AddScriptLPS(1); |
3710 | int count = 0; | 3979 | int count = 0; |
3711 | 3980 | ||
3712 | lock (m_host.TaskInventory) | 3981 | m_host.TaskInventory.LockItemsForRead(true); |
3982 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3713 | { | 3983 | { |
3714 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3984 | if (inv.Value.Type == type || type == -1) |
3715 | { | 3985 | { |
3716 | if (inv.Value.Type == type || type == -1) | 3986 | count = count + 1; |
3717 | { | ||
3718 | count = count + 1; | ||
3719 | } | ||
3720 | } | 3987 | } |
3721 | } | 3988 | } |
3722 | 3989 | ||
3990 | m_host.TaskInventory.LockItemsForRead(false); | ||
3723 | return count; | 3991 | return count; |
3724 | } | 3992 | } |
3725 | 3993 | ||
@@ -3728,16 +3996,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3728 | m_host.AddScriptLPS(1); | 3996 | m_host.AddScriptLPS(1); |
3729 | ArrayList keys = new ArrayList(); | 3997 | ArrayList keys = new ArrayList(); |
3730 | 3998 | ||
3731 | lock (m_host.TaskInventory) | 3999 | m_host.TaskInventory.LockItemsForRead(true); |
4000 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3732 | { | 4001 | { |
3733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4002 | if (inv.Value.Type == type || type == -1) |
3734 | { | 4003 | { |
3735 | if (inv.Value.Type == type || type == -1) | 4004 | keys.Add(inv.Value.Name); |
3736 | { | ||
3737 | keys.Add(inv.Value.Name); | ||
3738 | } | ||
3739 | } | 4005 | } |
3740 | } | 4006 | } |
4007 | m_host.TaskInventory.LockItemsForRead(false); | ||
3741 | 4008 | ||
3742 | if (keys.Count == 0) | 4009 | if (keys.Count == 0) |
3743 | { | 4010 | { |
@@ -3774,20 +4041,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3774 | } | 4041 | } |
3775 | 4042 | ||
3776 | // move the first object found with this inventory name | 4043 | // move the first object found with this inventory name |
3777 | lock (m_host.TaskInventory) | 4044 | m_host.TaskInventory.LockItemsForRead(true); |
4045 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3778 | { | 4046 | { |
3779 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4047 | if (inv.Value.Name == inventory) |
3780 | { | 4048 | { |
3781 | if (inv.Value.Name == inventory) | 4049 | found = true; |
3782 | { | 4050 | objId = inv.Key; |
3783 | found = true; | 4051 | assetType = inv.Value.Type; |
3784 | objId = inv.Key; | 4052 | objName = inv.Value.Name; |
3785 | assetType = inv.Value.Type; | 4053 | break; |
3786 | objName = inv.Value.Name; | ||
3787 | break; | ||
3788 | } | ||
3789 | } | 4054 | } |
3790 | } | 4055 | } |
4056 | m_host.TaskInventory.LockItemsForRead(false); | ||
3791 | 4057 | ||
3792 | if (!found) | 4058 | if (!found) |
3793 | { | 4059 | { |
@@ -3795,9 +4061,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3795 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4061 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3796 | } | 4062 | } |
3797 | 4063 | ||
3798 | // check if destination is an avatar | 4064 | // check if destination is an object |
3799 | if (World.GetScenePresence(destId) != null) | 4065 | if (World.GetSceneObjectPart(destId) != null) |
4066 | { | ||
4067 | // destination is an object | ||
4068 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4069 | } | ||
4070 | else | ||
3800 | { | 4071 | { |
4072 | ScenePresence presence = World.GetScenePresence(destId); | ||
4073 | |||
4074 | if (presence == null) | ||
4075 | { | ||
4076 | UserAccount account = | ||
4077 | World.UserAccountService.GetUserAccount( | ||
4078 | World.RegionInfo.ScopeID, | ||
4079 | destId); | ||
4080 | |||
4081 | if (account == null) | ||
4082 | { | ||
4083 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4084 | return; | ||
4085 | } | ||
4086 | } | ||
4087 | |||
3801 | // destination is an avatar | 4088 | // destination is an avatar |
3802 | InventoryItemBase agentItem = | 4089 | InventoryItemBase agentItem = |
3803 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4090 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
@@ -3823,33 +4110,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3823 | 4110 | ||
3824 | if (m_TransferModule != null) | 4111 | if (m_TransferModule != null) |
3825 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4112 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4113 | |||
4114 | //This delay should only occur when giving inventory to avatars. | ||
4115 | ScriptSleep(3000); | ||
3826 | } | 4116 | } |
3827 | else | ||
3828 | { | ||
3829 | // destination is an object | ||
3830 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3831 | } | ||
3832 | ScriptSleep(3000); | ||
3833 | } | 4117 | } |
3834 | 4118 | ||
4119 | [DebuggerNonUserCode] | ||
3835 | public void llRemoveInventory(string name) | 4120 | public void llRemoveInventory(string name) |
3836 | { | 4121 | { |
3837 | m_host.AddScriptLPS(1); | 4122 | m_host.AddScriptLPS(1); |
3838 | 4123 | ||
3839 | lock (m_host.TaskInventory) | 4124 | m_host.TaskInventory.LockItemsForRead(true); |
4125 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3840 | { | 4126 | { |
3841 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4127 | if (item.Name == name) |
3842 | { | 4128 | { |
3843 | if (item.Name == name) | 4129 | if (item.ItemID == m_itemID) |
3844 | { | 4130 | throw new ScriptDeleteException(); |
3845 | if (item.ItemID == m_itemID) | 4131 | else |
3846 | throw new ScriptDeleteException(); | 4132 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3847 | else | 4133 | |
3848 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4134 | m_host.TaskInventory.LockItemsForRead(false); |
3849 | return; | 4135 | return; |
3850 | } | ||
3851 | } | 4136 | } |
3852 | } | 4137 | } |
4138 | m_host.TaskInventory.LockItemsForRead(false); | ||
3853 | } | 4139 | } |
3854 | 4140 | ||
3855 | public void llSetText(string text, LSL_Vector color, double alpha) | 4141 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3940,6 +4226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3940 | { | 4226 | { |
3941 | m_host.AddScriptLPS(1); | 4227 | m_host.AddScriptLPS(1); |
3942 | 4228 | ||
4229 | //Clone is thread safe | ||
3943 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4230 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3944 | 4231 | ||
3945 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4232 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3993,6 +4280,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3993 | ScenePresence presence = World.GetScenePresence(agentId); | 4280 | ScenePresence presence = World.GetScenePresence(agentId); |
3994 | if (presence != null) | 4281 | if (presence != null) |
3995 | { | 4282 | { |
4283 | // agent must not be a god | ||
4284 | if (presence.GodLevel >= 200) return; | ||
4285 | |||
3996 | // agent must be over the owners land | 4286 | // agent must be over the owners land |
3997 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4287 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
3998 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4288 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4053,17 +4343,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4053 | UUID soundId = UUID.Zero; | 4343 | UUID soundId = UUID.Zero; |
4054 | if (!UUID.TryParse(impact_sound, out soundId)) | 4344 | if (!UUID.TryParse(impact_sound, out soundId)) |
4055 | { | 4345 | { |
4056 | lock (m_host.TaskInventory) | 4346 | m_host.TaskInventory.LockItemsForRead(true); |
4347 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4057 | { | 4348 | { |
4058 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4349 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4059 | { | 4350 | { |
4060 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4351 | soundId = item.AssetID; |
4061 | { | 4352 | break; |
4062 | soundId = item.AssetID; | ||
4063 | break; | ||
4064 | } | ||
4065 | } | 4353 | } |
4066 | } | 4354 | } |
4355 | m_host.TaskInventory.LockItemsForRead(false); | ||
4067 | } | 4356 | } |
4068 | m_host.CollisionSound = soundId; | 4357 | m_host.CollisionSound = soundId; |
4069 | m_host.CollisionSoundVolume = (float)impact_volume; | 4358 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4109,6 +4398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4109 | UUID partItemID; | 4398 | UUID partItemID; |
4110 | foreach (SceneObjectPart part in parts) | 4399 | foreach (SceneObjectPart part in parts) |
4111 | { | 4400 | { |
4401 | //Clone is thread safe | ||
4112 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4402 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4113 | 4403 | ||
4114 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4404 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4323,17 +4613,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4323 | 4613 | ||
4324 | m_host.AddScriptLPS(1); | 4614 | m_host.AddScriptLPS(1); |
4325 | 4615 | ||
4326 | lock (m_host.TaskInventory) | 4616 | m_host.TaskInventory.LockItemsForRead(true); |
4617 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4327 | { | 4618 | { |
4328 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4619 | if (item.Type == 10 && item.ItemID == m_itemID) |
4329 | { | 4620 | { |
4330 | if (item.Type == 10 && item.ItemID == m_itemID) | 4621 | result = item.Name!=null?item.Name:String.Empty; |
4331 | { | 4622 | break; |
4332 | result = item.Name != null ? item.Name : String.Empty; | ||
4333 | break; | ||
4334 | } | ||
4335 | } | 4623 | } |
4336 | } | 4624 | } |
4625 | m_host.TaskInventory.LockItemsForRead(false); | ||
4337 | 4626 | ||
4338 | return result; | 4627 | return result; |
4339 | } | 4628 | } |
@@ -4486,23 +4775,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4486 | { | 4775 | { |
4487 | m_host.AddScriptLPS(1); | 4776 | m_host.AddScriptLPS(1); |
4488 | 4777 | ||
4489 | lock (m_host.TaskInventory) | 4778 | m_host.TaskInventory.LockItemsForRead(true); |
4779 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4490 | { | 4780 | { |
4491 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4781 | if (inv.Value.Name == name) |
4492 | { | 4782 | { |
4493 | if (inv.Value.Name == name) | 4783 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4494 | { | 4784 | { |
4495 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4785 | m_host.TaskInventory.LockItemsForRead(false); |
4496 | { | 4786 | return inv.Value.AssetID.ToString(); |
4497 | return inv.Value.AssetID.ToString(); | 4787 | } |
4498 | } | 4788 | else |
4499 | else | 4789 | { |
4500 | { | 4790 | m_host.TaskInventory.LockItemsForRead(false); |
4501 | return UUID.Zero.ToString(); | 4791 | return UUID.Zero.ToString(); |
4502 | } | ||
4503 | } | 4792 | } |
4504 | } | 4793 | } |
4505 | } | 4794 | } |
4795 | m_host.TaskInventory.LockItemsForRead(false); | ||
4506 | 4796 | ||
4507 | return UUID.Zero.ToString(); | 4797 | return UUID.Zero.ToString(); |
4508 | } | 4798 | } |
@@ -5438,10 +5728,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5438 | m_host.AddScriptLPS(1); | 5728 | m_host.AddScriptLPS(1); |
5439 | 5729 | ||
5440 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5730 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5441 | 5731 | if (parts.Count > 0) | |
5442 | foreach (var part in parts) | ||
5443 | { | 5732 | { |
5444 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5733 | try |
5734 | { | ||
5735 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5736 | foreach (var part in parts) | ||
5737 | { | ||
5738 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5739 | } | ||
5740 | } | ||
5741 | finally | ||
5742 | { | ||
5743 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5744 | } | ||
5445 | } | 5745 | } |
5446 | } | 5746 | } |
5447 | 5747 | ||
@@ -6020,6 +6320,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6020 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6320 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6021 | prules.OuterAngle = (float)tempf; | 6321 | prules.OuterAngle = (float)tempf; |
6022 | break; | 6322 | break; |
6323 | |||
6324 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6325 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6326 | prules.InnerAngle = (float)tempf; | ||
6327 | break; | ||
6328 | |||
6329 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6330 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6331 | prules.OuterAngle = (float)tempf; | ||
6332 | break; | ||
6023 | } | 6333 | } |
6024 | 6334 | ||
6025 | } | 6335 | } |
@@ -6058,14 +6368,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6058 | 6368 | ||
6059 | protected UUID GetTaskInventoryItem(string name) | 6369 | protected UUID GetTaskInventoryItem(string name) |
6060 | { | 6370 | { |
6061 | lock (m_host.TaskInventory) | 6371 | m_host.TaskInventory.LockItemsForRead(true); |
6372 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6062 | { | 6373 | { |
6063 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6374 | if (inv.Value.Name == name) |
6064 | { | 6375 | { |
6065 | if (inv.Value.Name == name) | 6376 | m_host.TaskInventory.LockItemsForRead(false); |
6066 | return inv.Key; | 6377 | return inv.Key; |
6067 | } | 6378 | } |
6068 | } | 6379 | } |
6380 | m_host.TaskInventory.LockItemsForRead(false); | ||
6069 | 6381 | ||
6070 | return UUID.Zero; | 6382 | return UUID.Zero; |
6071 | } | 6383 | } |
@@ -6393,22 +6705,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6393 | } | 6705 | } |
6394 | 6706 | ||
6395 | // copy the first script found with this inventory name | 6707 | // copy the first script found with this inventory name |
6396 | lock (m_host.TaskInventory) | 6708 | m_host.TaskInventory.LockItemsForRead(true); |
6709 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6397 | { | 6710 | { |
6398 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6711 | if (inv.Value.Name == name) |
6399 | { | 6712 | { |
6400 | if (inv.Value.Name == name) | 6713 | // make sure the object is a script |
6714 | if (10 == inv.Value.Type) | ||
6401 | { | 6715 | { |
6402 | // make sure the object is a script | 6716 | found = true; |
6403 | if (10 == inv.Value.Type) | 6717 | srcId = inv.Key; |
6404 | { | 6718 | break; |
6405 | found = true; | ||
6406 | srcId = inv.Key; | ||
6407 | break; | ||
6408 | } | ||
6409 | } | 6719 | } |
6410 | } | 6720 | } |
6411 | } | 6721 | } |
6722 | m_host.TaskInventory.LockItemsForRead(false); | ||
6412 | 6723 | ||
6413 | if (!found) | 6724 | if (!found) |
6414 | { | 6725 | { |
@@ -6492,6 +6803,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6492 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6803 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6493 | { | 6804 | { |
6494 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6805 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6806 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6807 | return shapeBlock; | ||
6495 | 6808 | ||
6496 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6809 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6497 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6810 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6562,6 +6875,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6562 | 6875 | ||
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) | 6876 | 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 | { | 6877 | { |
6878 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6879 | return; | ||
6880 | |||
6565 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6881 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6566 | 6882 | ||
6567 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6883 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6611,6 +6927,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6611 | 6927 | ||
6612 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6928 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6613 | { | 6929 | { |
6930 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6931 | return; | ||
6932 | |||
6614 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6933 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6615 | 6934 | ||
6616 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6935 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6653,6 +6972,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6653 | 6972 | ||
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) | 6973 | 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 | { | 6974 | { |
6975 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6976 | return; | ||
6977 | |||
6656 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6978 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6657 | 6979 | ||
6658 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6980 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6774,6 +7096,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6774 | 7096 | ||
6775 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7097 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6776 | { | 7098 | { |
7099 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7100 | return; | ||
7101 | |||
6777 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7102 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6778 | UUID sculptId; | 7103 | UUID sculptId; |
6779 | 7104 | ||
@@ -6789,13 +7114,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6789 | shapeBlock.PathScaleX = 100; | 7114 | shapeBlock.PathScaleX = 100; |
6790 | shapeBlock.PathScaleY = 150; | 7115 | shapeBlock.PathScaleY = 150; |
6791 | 7116 | ||
6792 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7117 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6793 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7118 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6794 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7119 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6795 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7120 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6796 | { | 7121 | { |
6797 | // default | 7122 | // default |
6798 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7123 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6799 | } | 7124 | } |
6800 | 7125 | ||
6801 | // retain pathcurve | 7126 | // retain pathcurve |
@@ -6814,12 +7139,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6814 | 7139 | ||
6815 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7140 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6816 | { | 7141 | { |
6817 | m_host.AddScriptLPS(1); | 7142 | m_host.AddScriptLPS(1); |
6818 | 7143 | ||
6819 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7144 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6820 | 7145 | if (parts.Count>0) | |
6821 | foreach (SceneObjectPart part in parts) | 7146 | { |
6822 | SetPrimParams(part, rules); | 7147 | try |
7148 | { | ||
7149 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7150 | foreach (SceneObjectPart part in parts) | ||
7151 | SetPrimParams(part, rules); | ||
7152 | } | ||
7153 | finally | ||
7154 | { | ||
7155 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7156 | } | ||
7157 | } | ||
6823 | } | 7158 | } |
6824 | 7159 | ||
6825 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7160 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
@@ -6829,6 +7164,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6829 | 7164 | ||
6830 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7165 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6831 | { | 7166 | { |
7167 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7168 | return; | ||
7169 | |||
6832 | int idx = 0; | 7170 | int idx = 0; |
6833 | 7171 | ||
6834 | while (idx < rules.Length) | 7172 | while (idx < rules.Length) |
@@ -7660,24 +7998,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7660 | break; | 7998 | break; |
7661 | 7999 | ||
7662 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8000 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7663 | // TODO-------------- | ||
7664 | if (remain < 1) | 8001 | if (remain < 1) |
7665 | return res; | 8002 | return res; |
8003 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7666 | 8004 | ||
7667 | face=(int)rules.GetLSLIntegerItem(idx++); | 8005 | tex = part.Shape.Textures; |
7668 | 8006 | int shiny; | |
7669 | res.Add(new LSL_Integer(0)); | 8007 | if (face == ScriptBaseClass.ALL_SIDES) |
7670 | res.Add(new LSL_Integer(0)); | 8008 | { |
8009 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8010 | { | ||
8011 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8012 | if (shinyness == Shininess.High) | ||
8013 | { | ||
8014 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8015 | } | ||
8016 | else if (shinyness == Shininess.Medium) | ||
8017 | { | ||
8018 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8019 | } | ||
8020 | else if (shinyness == Shininess.Low) | ||
8021 | { | ||
8022 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8023 | } | ||
8024 | else | ||
8025 | { | ||
8026 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8027 | } | ||
8028 | res.Add(new LSL_Integer(shiny)); | ||
8029 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8030 | } | ||
8031 | } | ||
8032 | else | ||
8033 | { | ||
8034 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8035 | if (shinyness == Shininess.High) | ||
8036 | { | ||
8037 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8038 | } | ||
8039 | else if (shinyness == Shininess.Medium) | ||
8040 | { | ||
8041 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8042 | } | ||
8043 | else if (shinyness == Shininess.Low) | ||
8044 | { | ||
8045 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8046 | } | ||
8047 | else | ||
8048 | { | ||
8049 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8050 | } | ||
8051 | res.Add(new LSL_Integer(shiny)); | ||
8052 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8053 | } | ||
7671 | break; | 8054 | break; |
7672 | 8055 | ||
7673 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8056 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7674 | // TODO-------------- | ||
7675 | if (remain < 1) | 8057 | if (remain < 1) |
7676 | return res; | 8058 | return res; |
8059 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7677 | 8060 | ||
7678 | face=(int)rules.GetLSLIntegerItem(idx++); | 8061 | tex = part.Shape.Textures; |
7679 | 8062 | int fullbright; | |
7680 | res.Add(new LSL_Integer(0)); | 8063 | if (face == ScriptBaseClass.ALL_SIDES) |
8064 | { | ||
8065 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8066 | { | ||
8067 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8068 | { | ||
8069 | fullbright = ScriptBaseClass.TRUE; | ||
8070 | } | ||
8071 | else | ||
8072 | { | ||
8073 | fullbright = ScriptBaseClass.FALSE; | ||
8074 | } | ||
8075 | res.Add(new LSL_Integer(fullbright)); | ||
8076 | } | ||
8077 | } | ||
8078 | else | ||
8079 | { | ||
8080 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8081 | { | ||
8082 | fullbright = ScriptBaseClass.TRUE; | ||
8083 | } | ||
8084 | else | ||
8085 | { | ||
8086 | fullbright = ScriptBaseClass.FALSE; | ||
8087 | } | ||
8088 | res.Add(new LSL_Integer(fullbright)); | ||
8089 | } | ||
7681 | break; | 8090 | break; |
7682 | 8091 | ||
7683 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8092 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7698,14 +8107,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7698 | break; | 8107 | break; |
7699 | 8108 | ||
7700 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8109 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7701 | // TODO-------------- | ||
7702 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8110 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7703 | if (remain < 1) | 8111 | if (remain < 1) |
7704 | return res; | 8112 | return res; |
8113 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7705 | 8114 | ||
7706 | face=(int)rules.GetLSLIntegerItem(idx++); | 8115 | tex = part.Shape.Textures; |
7707 | 8116 | if (face == ScriptBaseClass.ALL_SIDES) | |
7708 | res.Add(new LSL_Integer(0)); | 8117 | { |
8118 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8119 | { | ||
8120 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8121 | { | ||
8122 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8123 | } | ||
8124 | else | ||
8125 | { | ||
8126 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8127 | } | ||
8128 | } | ||
8129 | } | ||
8130 | else | ||
8131 | { | ||
8132 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8133 | { | ||
8134 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8135 | } | ||
8136 | else | ||
8137 | { | ||
8138 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8139 | } | ||
8140 | } | ||
7709 | break; | 8141 | break; |
7710 | 8142 | ||
7711 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8143 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7724,13 +8156,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7724 | break; | 8156 | break; |
7725 | 8157 | ||
7726 | case (int)ScriptBaseClass.PRIM_GLOW: | 8158 | case (int)ScriptBaseClass.PRIM_GLOW: |
7727 | // TODO-------------- | ||
7728 | if (remain < 1) | 8159 | if (remain < 1) |
7729 | return res; | 8160 | return res; |
8161 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7730 | 8162 | ||
7731 | face=(int)rules.GetLSLIntegerItem(idx++); | 8163 | tex = part.Shape.Textures; |
7732 | 8164 | float primglow; | |
7733 | res.Add(new LSL_Float(0)); | 8165 | if (face == ScriptBaseClass.ALL_SIDES) |
8166 | { | ||
8167 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8168 | { | ||
8169 | primglow = tex.GetFace((uint)face).Glow; | ||
8170 | res.Add(new LSL_Float(primglow)); | ||
8171 | } | ||
8172 | } | ||
8173 | else | ||
8174 | { | ||
8175 | primglow = tex.GetFace((uint)face).Glow; | ||
8176 | res.Add(new LSL_Float(primglow)); | ||
8177 | } | ||
7734 | break; | 8178 | break; |
7735 | case (int)ScriptBaseClass.PRIM_TEXT: | 8179 | case (int)ScriptBaseClass.PRIM_TEXT: |
7736 | Color4 textColor = part.GetTextColor(); | 8180 | Color4 textColor = part.GetTextColor(); |
@@ -8267,28 +8711,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8267 | { | 8711 | { |
8268 | m_host.AddScriptLPS(1); | 8712 | m_host.AddScriptLPS(1); |
8269 | 8713 | ||
8270 | lock (m_host.TaskInventory) | 8714 | m_host.TaskInventory.LockItemsForRead(true); |
8715 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8271 | { | 8716 | { |
8272 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8717 | if (inv.Value.Name == item) |
8273 | { | 8718 | { |
8274 | if (inv.Value.Name == item) | 8719 | m_host.TaskInventory.LockItemsForRead(false); |
8720 | switch (mask) | ||
8275 | { | 8721 | { |
8276 | switch (mask) | 8722 | case 0: |
8277 | { | 8723 | return (int)inv.Value.BasePermissions; |
8278 | case 0: | 8724 | case 1: |
8279 | return (int)inv.Value.BasePermissions; | 8725 | return (int)inv.Value.CurrentPermissions; |
8280 | case 1: | 8726 | case 2: |
8281 | return (int)inv.Value.CurrentPermissions; | 8727 | return (int)inv.Value.GroupPermissions; |
8282 | case 2: | 8728 | case 3: |
8283 | return (int)inv.Value.GroupPermissions; | 8729 | return (int)inv.Value.EveryonePermissions; |
8284 | case 3: | 8730 | case 4: |
8285 | return (int)inv.Value.EveryonePermissions; | 8731 | return (int)inv.Value.NextPermissions; |
8286 | case 4: | ||
8287 | return (int)inv.Value.NextPermissions; | ||
8288 | } | ||
8289 | } | 8732 | } |
8290 | } | 8733 | } |
8291 | } | 8734 | } |
8735 | m_host.TaskInventory.LockItemsForRead(false); | ||
8292 | 8736 | ||
8293 | return -1; | 8737 | return -1; |
8294 | } | 8738 | } |
@@ -8335,16 +8779,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8335 | { | 8779 | { |
8336 | m_host.AddScriptLPS(1); | 8780 | m_host.AddScriptLPS(1); |
8337 | 8781 | ||
8338 | lock (m_host.TaskInventory) | 8782 | m_host.TaskInventory.LockItemsForRead(true); |
8783 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8339 | { | 8784 | { |
8340 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8785 | if (inv.Value.Name == item) |
8341 | { | 8786 | { |
8342 | if (inv.Value.Name == item) | 8787 | m_host.TaskInventory.LockItemsForRead(false); |
8343 | { | 8788 | return inv.Value.CreatorID.ToString(); |
8344 | return inv.Value.CreatorID.ToString(); | ||
8345 | } | ||
8346 | } | 8789 | } |
8347 | } | 8790 | } |
8791 | m_host.TaskInventory.LockItemsForRead(false); | ||
8348 | 8792 | ||
8349 | llSay(0, "No item name '" + item + "'"); | 8793 | llSay(0, "No item name '" + item + "'"); |
8350 | 8794 | ||
@@ -8604,17 +9048,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8604 | int width = 0; | 9048 | int width = 0; |
8605 | int height = 0; | 9049 | int height = 0; |
8606 | 9050 | ||
8607 | ParcelMediaCommandEnum? commandToSend = null; | 9051 | uint commandToSend = 0; |
8608 | float time = 0.0f; // default is from start | 9052 | float time = 0.0f; // default is from start |
8609 | 9053 | ||
8610 | ScenePresence presence = null; | 9054 | ScenePresence presence = null; |
8611 | 9055 | ||
8612 | for (int i = 0; i < commandList.Data.Length; i++) | 9056 | for (int i = 0; i < commandList.Data.Length; i++) |
8613 | { | 9057 | { |
8614 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9058 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8615 | switch (command) | 9059 | switch (command) |
8616 | { | 9060 | { |
8617 | case ParcelMediaCommandEnum.Agent: | 9061 | case (uint)ParcelMediaCommandEnum.Agent: |
8618 | // we send only to one agent | 9062 | // we send only to one agent |
8619 | if ((i + 1) < commandList.Length) | 9063 | if ((i + 1) < commandList.Length) |
8620 | { | 9064 | { |
@@ -8631,25 +9075,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8631 | } | 9075 | } |
8632 | break; | 9076 | break; |
8633 | 9077 | ||
8634 | case ParcelMediaCommandEnum.Loop: | 9078 | case (uint)ParcelMediaCommandEnum.Loop: |
8635 | loop = 1; | 9079 | loop = 1; |
8636 | commandToSend = command; | 9080 | commandToSend = command; |
8637 | update = true; //need to send the media update packet to set looping | 9081 | update = true; //need to send the media update packet to set looping |
8638 | break; | 9082 | break; |
8639 | 9083 | ||
8640 | case ParcelMediaCommandEnum.Play: | 9084 | case (uint)ParcelMediaCommandEnum.Play: |
8641 | loop = 0; | 9085 | loop = 0; |
8642 | commandToSend = command; | 9086 | commandToSend = command; |
8643 | update = true; //need to send the media update packet to make sure it doesn't loop | 9087 | update = true; //need to send the media update packet to make sure it doesn't loop |
8644 | break; | 9088 | break; |
8645 | 9089 | ||
8646 | case ParcelMediaCommandEnum.Pause: | 9090 | case (uint)ParcelMediaCommandEnum.Pause: |
8647 | case ParcelMediaCommandEnum.Stop: | 9091 | case (uint)ParcelMediaCommandEnum.Stop: |
8648 | case ParcelMediaCommandEnum.Unload: | 9092 | case (uint)ParcelMediaCommandEnum.Unload: |
8649 | commandToSend = command; | 9093 | commandToSend = command; |
8650 | break; | 9094 | break; |
8651 | 9095 | ||
8652 | case ParcelMediaCommandEnum.Url: | 9096 | case (uint)ParcelMediaCommandEnum.Url: |
8653 | if ((i + 1) < commandList.Length) | 9097 | if ((i + 1) < commandList.Length) |
8654 | { | 9098 | { |
8655 | if (commandList.Data[i + 1] is LSL_String) | 9099 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8662,7 +9106,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8662 | } | 9106 | } |
8663 | break; | 9107 | break; |
8664 | 9108 | ||
8665 | case ParcelMediaCommandEnum.Texture: | 9109 | case (uint)ParcelMediaCommandEnum.Texture: |
8666 | if ((i + 1) < commandList.Length) | 9110 | if ((i + 1) < commandList.Length) |
8667 | { | 9111 | { |
8668 | if (commandList.Data[i + 1] is LSL_String) | 9112 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8675,7 +9119,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8675 | } | 9119 | } |
8676 | break; | 9120 | break; |
8677 | 9121 | ||
8678 | case ParcelMediaCommandEnum.Time: | 9122 | case (uint)ParcelMediaCommandEnum.Time: |
8679 | if ((i + 1) < commandList.Length) | 9123 | if ((i + 1) < commandList.Length) |
8680 | { | 9124 | { |
8681 | if (commandList.Data[i + 1] is LSL_Float) | 9125 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -8687,7 +9131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8687 | } | 9131 | } |
8688 | break; | 9132 | break; |
8689 | 9133 | ||
8690 | case ParcelMediaCommandEnum.AutoAlign: | 9134 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
8691 | if ((i + 1) < commandList.Length) | 9135 | if ((i + 1) < commandList.Length) |
8692 | { | 9136 | { |
8693 | if (commandList.Data[i + 1] is LSL_Integer) | 9137 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8701,7 +9145,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8701 | } | 9145 | } |
8702 | break; | 9146 | break; |
8703 | 9147 | ||
8704 | case ParcelMediaCommandEnum.Type: | 9148 | case (uint)ParcelMediaCommandEnum.Type: |
8705 | if ((i + 1) < commandList.Length) | 9149 | if ((i + 1) < commandList.Length) |
8706 | { | 9150 | { |
8707 | if (commandList.Data[i + 1] is LSL_String) | 9151 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8714,7 +9158,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8714 | } | 9158 | } |
8715 | break; | 9159 | break; |
8716 | 9160 | ||
8717 | case ParcelMediaCommandEnum.Desc: | 9161 | case (uint)ParcelMediaCommandEnum.Desc: |
8718 | if ((i + 1) < commandList.Length) | 9162 | if ((i + 1) < commandList.Length) |
8719 | { | 9163 | { |
8720 | if (commandList.Data[i + 1] is LSL_String) | 9164 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8727,7 +9171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8727 | } | 9171 | } |
8728 | break; | 9172 | break; |
8729 | 9173 | ||
8730 | case ParcelMediaCommandEnum.Size: | 9174 | case (uint)ParcelMediaCommandEnum.Size: |
8731 | if ((i + 2) < commandList.Length) | 9175 | if ((i + 2) < commandList.Length) |
8732 | { | 9176 | { |
8733 | if (commandList.Data[i + 1] is LSL_Integer) | 9177 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8797,7 +9241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8797 | } | 9241 | } |
8798 | } | 9242 | } |
8799 | 9243 | ||
8800 | if (commandToSend != null) | 9244 | if (commandToSend != 0) |
8801 | { | 9245 | { |
8802 | // the commandList contained a start/stop/... command, too | 9246 | // the commandList contained a start/stop/... command, too |
8803 | if (presence == null) | 9247 | if (presence == null) |
@@ -8877,16 +9321,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8877 | { | 9321 | { |
8878 | m_host.AddScriptLPS(1); | 9322 | m_host.AddScriptLPS(1); |
8879 | 9323 | ||
8880 | lock (m_host.TaskInventory) | 9324 | m_host.TaskInventory.LockItemsForRead(true); |
9325 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8881 | { | 9326 | { |
8882 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9327 | if (inv.Value.Name == name) |
8883 | { | 9328 | { |
8884 | if (inv.Value.Name == name) | 9329 | m_host.TaskInventory.LockItemsForRead(false); |
8885 | { | 9330 | return inv.Value.Type; |
8886 | return inv.Value.Type; | ||
8887 | } | ||
8888 | } | 9331 | } |
8889 | } | 9332 | } |
9333 | m_host.TaskInventory.LockItemsForRead(false); | ||
8890 | 9334 | ||
8891 | return -1; | 9335 | return -1; |
8892 | } | 9336 | } |
@@ -8897,15 +9341,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8897 | 9341 | ||
8898 | if (quick_pay_buttons.Data.Length < 4) | 9342 | if (quick_pay_buttons.Data.Length < 4) |
8899 | { | 9343 | { |
8900 | LSLError("List must have at least 4 elements"); | 9344 | int x; |
8901 | return; | 9345 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9346 | { | ||
9347 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9348 | } | ||
8902 | } | 9349 | } |
8903 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9350 | int[] nPrice = new int[5]; |
8904 | 9351 | nPrice[0]=price; | |
8905 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9352 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8906 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9353 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8907 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9354 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8908 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9355 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9356 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8909 | m_host.ParentGroup.HasGroupChanged = true; | 9357 | m_host.ParentGroup.HasGroupChanged = true; |
8910 | } | 9358 | } |
8911 | 9359 | ||
@@ -8917,17 +9365,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8917 | if (invItemID == UUID.Zero) | 9365 | if (invItemID == UUID.Zero) |
8918 | return new LSL_Vector(); | 9366 | return new LSL_Vector(); |
8919 | 9367 | ||
8920 | lock (m_host.TaskInventory) | 9368 | m_host.TaskInventory.LockItemsForRead(true); |
9369 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8921 | { | 9370 | { |
8922 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9371 | m_host.TaskInventory.LockItemsForRead(false); |
8923 | return new LSL_Vector(); | 9372 | return new LSL_Vector(); |
9373 | } | ||
8924 | 9374 | ||
8925 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9375 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8926 | { | 9376 | { |
8927 | ShoutError("No permissions to track the camera"); | 9377 | ShoutError("No permissions to track the camera"); |
8928 | return new LSL_Vector(); | 9378 | m_host.TaskInventory.LockItemsForRead(false); |
8929 | } | 9379 | return new LSL_Vector(); |
8930 | } | 9380 | } |
9381 | m_host.TaskInventory.LockItemsForRead(false); | ||
8931 | 9382 | ||
8932 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9383 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8933 | if (presence != null) | 9384 | if (presence != null) |
@@ -8945,17 +9396,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8945 | if (invItemID == UUID.Zero) | 9396 | if (invItemID == UUID.Zero) |
8946 | return new LSL_Rotation(); | 9397 | return new LSL_Rotation(); |
8947 | 9398 | ||
8948 | lock (m_host.TaskInventory) | 9399 | m_host.TaskInventory.LockItemsForRead(true); |
9400 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8949 | { | 9401 | { |
8950 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9402 | m_host.TaskInventory.LockItemsForRead(false); |
8951 | return new LSL_Rotation(); | 9403 | return new LSL_Rotation(); |
8952 | 9404 | } | |
8953 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9405 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8954 | { | 9406 | { |
8955 | ShoutError("No permissions to track the camera"); | 9407 | ShoutError("No permissions to track the camera"); |
8956 | return new LSL_Rotation(); | 9408 | m_host.TaskInventory.LockItemsForRead(false); |
8957 | } | 9409 | return new LSL_Rotation(); |
8958 | } | 9410 | } |
9411 | m_host.TaskInventory.LockItemsForRead(false); | ||
8959 | 9412 | ||
8960 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9413 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8961 | if (presence != null) | 9414 | if (presence != null) |
@@ -9105,14 +9558,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9105 | if (objectID == UUID.Zero) return; | 9558 | if (objectID == UUID.Zero) return; |
9106 | 9559 | ||
9107 | UUID agentID; | 9560 | UUID agentID; |
9108 | lock (m_host.TaskInventory) | 9561 | m_host.TaskInventory.LockItemsForRead(true); |
9109 | { | 9562 | // 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 | 9563 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9111 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9112 | 9564 | ||
9113 | if (agentID == UUID.Zero) return; | 9565 | if (agentID == UUID.Zero) |
9114 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9566 | { |
9567 | m_host.TaskInventory.LockItemsForRead(false); | ||
9568 | return; | ||
9115 | } | 9569 | } |
9570 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9571 | { | ||
9572 | m_host.TaskInventory.LockItemsForRead(false); | ||
9573 | return; | ||
9574 | } | ||
9575 | m_host.TaskInventory.LockItemsForRead(false); | ||
9116 | 9576 | ||
9117 | ScenePresence presence = World.GetScenePresence(agentID); | 9577 | ScenePresence presence = World.GetScenePresence(agentID); |
9118 | 9578 | ||
@@ -9162,12 +9622,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9162 | 9622 | ||
9163 | // we need the permission first, to know which avatar we want to clear the camera for | 9623 | // we need the permission first, to know which avatar we want to clear the camera for |
9164 | UUID agentID; | 9624 | UUID agentID; |
9165 | lock (m_host.TaskInventory) | 9625 | m_host.TaskInventory.LockItemsForRead(true); |
9626 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9627 | if (agentID == UUID.Zero) | ||
9166 | { | 9628 | { |
9167 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9629 | m_host.TaskInventory.LockItemsForRead(false); |
9168 | if (agentID == UUID.Zero) return; | 9630 | return; |
9169 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9631 | } |
9632 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9633 | { | ||
9634 | m_host.TaskInventory.LockItemsForRead(false); | ||
9635 | return; | ||
9170 | } | 9636 | } |
9637 | m_host.TaskInventory.LockItemsForRead(false); | ||
9171 | 9638 | ||
9172 | ScenePresence presence = World.GetScenePresence(agentID); | 9639 | ScenePresence presence = World.GetScenePresence(agentID); |
9173 | 9640 | ||
@@ -9624,15 +10091,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9624 | 10091 | ||
9625 | internal UUID ScriptByName(string name) | 10092 | internal UUID ScriptByName(string name) |
9626 | { | 10093 | { |
9627 | lock (m_host.TaskInventory) | 10094 | m_host.TaskInventory.LockItemsForRead(true); |
10095 | |||
10096 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9628 | { | 10097 | { |
9629 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10098 | if (item.Type == 10 && item.Name == name) |
9630 | { | 10099 | { |
9631 | if (item.Type == 10 && item.Name == name) | 10100 | m_host.TaskInventory.LockItemsForRead(false); |
9632 | return item.ItemID; | 10101 | return item.ItemID; |
9633 | } | 10102 | } |
9634 | } | 10103 | } |
9635 | 10104 | ||
10105 | m_host.TaskInventory.LockItemsForRead(false); | ||
10106 | |||
9636 | return UUID.Zero; | 10107 | return UUID.Zero; |
9637 | } | 10108 | } |
9638 | 10109 | ||
@@ -9673,6 +10144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9673 | { | 10144 | { |
9674 | m_host.AddScriptLPS(1); | 10145 | m_host.AddScriptLPS(1); |
9675 | 10146 | ||
10147 | //Clone is thread safe | ||
9676 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10148 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9677 | 10149 | ||
9678 | UUID assetID = UUID.Zero; | 10150 | UUID assetID = UUID.Zero; |
@@ -9735,6 +10207,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9735 | { | 10207 | { |
9736 | m_host.AddScriptLPS(1); | 10208 | m_host.AddScriptLPS(1); |
9737 | 10209 | ||
10210 | //Clone is thread safe | ||
9738 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10211 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9739 | 10212 | ||
9740 | UUID assetID = UUID.Zero; | 10213 | 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 cd6d3a3..0e86c86 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using 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; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 3dd381d..b348403 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -238,13 +239,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
238 | 239 | ||
239 | if (part != null) | 240 | if (part != null) |
240 | { | 241 | { |
241 | lock (part.TaskInventory) | 242 | part.TaskInventory.LockItemsForRead(true); |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
242 | { | 244 | { |
243 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
244 | { | ||
245 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
246 | } | ||
247 | } | 246 | } |
247 | part.TaskInventory.LockItemsForRead(false); | ||
248 | } | 248 | } |
249 | 249 | ||
250 | ApiManager am = new ApiManager(); | 250 | ApiManager am = new ApiManager(); |
@@ -429,14 +429,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
429 | { | 429 | { |
430 | int permsMask; | 430 | int permsMask; |
431 | UUID permsGranter; | 431 | UUID permsGranter; |
432 | lock (part.TaskInventory) | 432 | part.TaskInventory.LockItemsForRead(true); |
433 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
433 | { | 434 | { |
434 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 435 | part.TaskInventory.LockItemsForRead(false); |
435 | return; | 436 | return; |
436 | |||
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | } | 437 | } |
438 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
439 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
440 | part.TaskInventory.LockItemsForRead(false); | ||
440 | 441 | ||
441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 442 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
442 | { | 443 | { |
@@ -545,6 +546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
545 | return true; | 546 | return true; |
546 | } | 547 | } |
547 | 548 | ||
549 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
548 | public void SetState(string state) | 550 | public void SetState(string state) |
549 | { | 551 | { |
550 | if (state == State) | 552 | if (state == State) |
@@ -556,7 +558,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
556 | new DetectParams[0])); | 558 | new DetectParams[0])); |
557 | PostEvent(new EventParams("state_entry", new Object[0], | 559 | PostEvent(new EventParams("state_entry", new Object[0], |
558 | new DetectParams[0])); | 560 | new DetectParams[0])); |
559 | 561 | ||
560 | throw new EventAbortException(); | 562 | throw new EventAbortException(); |
561 | } | 563 | } |
562 | 564 | ||
@@ -639,14 +641,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
639 | /// <returns></returns> | 641 | /// <returns></returns> |
640 | public object EventProcessor() | 642 | public object EventProcessor() |
641 | { | 643 | { |
642 | if (m_Suspended) | 644 | EventParams data = null; |
643 | return 0; | ||
644 | 645 | ||
645 | lock (m_Script) | 646 | lock (m_EventQueue) |
646 | { | 647 | { |
647 | EventParams data = null; | 648 | if (m_Suspended) |
649 | return 0; | ||
648 | 650 | ||
649 | lock (m_EventQueue) | 651 | lock (m_Script) |
650 | { | 652 | { |
651 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | data = (EventParams) m_EventQueue.Dequeue(); |
652 | if (data == null) // Shouldn't happen | 654 | if (data == null) // Shouldn't happen |
@@ -672,6 +674,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
672 | if (data.EventName == "collision") | 674 | if (data.EventName == "collision") |
673 | m_CollisionInQueue = false; | 675 | m_CollisionInQueue = false; |
674 | } | 676 | } |
677 | } | ||
678 | lock(m_Script) | ||
679 | { | ||
675 | 680 | ||
676 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | 681 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); |
677 | 682 | ||
@@ -828,6 +833,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
828 | new Object[0], new DetectParams[0])); | 833 | new Object[0], new DetectParams[0])); |
829 | } | 834 | } |
830 | 835 | ||
836 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
831 | public void ApiResetScript() | 837 | public void ApiResetScript() |
832 | { | 838 | { |
833 | // bool running = Running; | 839 | // bool running = Running; |