diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
13 files changed, 782 insertions, 329 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs index 880ca1b..07cba60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -113,6 +113,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
113 | } | 113 | } |
114 | 114 | ||
115 | /// <summary> | 115 | /// <summary> |
116 | /// Like osGetAgents but returns enough info for a radar | ||
117 | /// </summary> | ||
118 | /// <returns>Strided list of the UUID, position and name of each avatar in the region</returns> | ||
119 | public LSL_List cmGetAvatarList() | ||
120 | { | ||
121 | LSL_List result = new LSL_List(); | ||
122 | World.ForEachScenePresence(delegate (ScenePresence avatar) | ||
123 | { | ||
124 | if (avatar.UUID != m_host.OwnerID) | ||
125 | { | ||
126 | if (avatar.IsChildAgent == false) | ||
127 | { | ||
128 | result.Add(avatar.UUID); | ||
129 | result.Add(avatar.PhysicsActor.Position); | ||
130 | result.Add(avatar.Name); | ||
131 | } | ||
132 | } | ||
133 | }); | ||
134 | return result; | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
116 | /// Get the current Windlight scene | 138 | /// Get the current Windlight scene |
117 | /// </summary> | 139 | /// </summary> |
118 | /// <returns>List of windlight parameters</returns> | 140 | /// <returns>List of windlight parameters</returns> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 79b6be3..ca0feed 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()) |
277 | { | 282 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 283 | m_host.TaskInventory.LockItemsForRead(true); |
284 | unlock = true; | ||
285 | } | ||
286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
287 | { | ||
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 | { |
@@ -1531,6 +1656,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1531 | 1656 | ||
1532 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1657 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1533 | { | 1658 | { |
1659 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1660 | return; | ||
1661 | |||
1534 | Primitive.TextureEntry tex = part.Shape.Textures; | 1662 | Primitive.TextureEntry tex = part.Shape.Textures; |
1535 | Color4 texcolor; | 1663 | Color4 texcolor; |
1536 | if (face >= 0 && face < GetNumberOfSides(part)) | 1664 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1576,7 +1704,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1576 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1704 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1577 | float wind, float tension, LSL_Vector Force) | 1705 | float wind, float tension, LSL_Vector Force) |
1578 | { | 1706 | { |
1579 | if (part == null) | 1707 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1580 | return; | 1708 | return; |
1581 | 1709 | ||
1582 | if (flexi) | 1710 | if (flexi) |
@@ -1611,7 +1739,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1611 | /// <param name="falloff"></param> | 1739 | /// <param name="falloff"></param> |
1612 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1740 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1613 | { | 1741 | { |
1614 | if (part == null) | 1742 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1615 | return; | 1743 | return; |
1616 | 1744 | ||
1617 | if (light) | 1745 | if (light) |
@@ -1697,6 +1825,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1697 | 1825 | ||
1698 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1826 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1699 | { | 1827 | { |
1828 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1829 | return; | ||
1830 | |||
1700 | UUID textureID=new UUID(); | 1831 | UUID textureID=new UUID(); |
1701 | 1832 | ||
1702 | if (!UUID.TryParse(texture, out textureID)) | 1833 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1742,6 +1873,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1742 | 1873 | ||
1743 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1874 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1744 | { | 1875 | { |
1876 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1877 | return; | ||
1878 | |||
1745 | Primitive.TextureEntry tex = part.Shape.Textures; | 1879 | Primitive.TextureEntry tex = part.Shape.Textures; |
1746 | if (face >= 0 && face < GetNumberOfSides(part)) | 1880 | if (face >= 0 && face < GetNumberOfSides(part)) |
1747 | { | 1881 | { |
@@ -1778,6 +1912,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1778 | 1912 | ||
1779 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1913 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1780 | { | 1914 | { |
1915 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1916 | return; | ||
1917 | |||
1781 | Primitive.TextureEntry tex = part.Shape.Textures; | 1918 | Primitive.TextureEntry tex = part.Shape.Textures; |
1782 | if (face >= 0 && face < GetNumberOfSides(part)) | 1919 | if (face >= 0 && face < GetNumberOfSides(part)) |
1783 | { | 1920 | { |
@@ -1814,6 +1951,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1814 | 1951 | ||
1815 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1952 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1816 | { | 1953 | { |
1954 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1955 | return; | ||
1956 | |||
1817 | Primitive.TextureEntry tex = part.Shape.Textures; | 1957 | Primitive.TextureEntry tex = part.Shape.Textures; |
1818 | if (face >= 0 && face < GetNumberOfSides(part)) | 1958 | if (face >= 0 && face < GetNumberOfSides(part)) |
1819 | { | 1959 | { |
@@ -1884,6 +2024,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1884 | 2024 | ||
1885 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2025 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1886 | { | 2026 | { |
2027 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2028 | return; | ||
2029 | |||
1887 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2030 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1888 | LSL_Vector currentPos = llGetLocalPos(); | 2031 | LSL_Vector currentPos = llGetLocalPos(); |
1889 | 2032 | ||
@@ -1970,6 +2113,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1970 | 2113 | ||
1971 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2114 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1972 | { | 2115 | { |
2116 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2117 | return; | ||
2118 | |||
1973 | part.UpdateRotation(rot); | 2119 | part.UpdateRotation(rot); |
1974 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2120 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1975 | 2121 | ||
@@ -2589,12 +2735,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2589 | 2735 | ||
2590 | m_host.AddScriptLPS(1); | 2736 | m_host.AddScriptLPS(1); |
2591 | 2737 | ||
2738 | m_host.TaskInventory.LockItemsForRead(true); | ||
2592 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2739 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2593 | 2740 | m_host.TaskInventory.LockItemsForRead(false); | |
2594 | lock (m_host.TaskInventory) | ||
2595 | { | ||
2596 | item = m_host.TaskInventory[invItemID]; | ||
2597 | } | ||
2598 | 2741 | ||
2599 | if (item.PermsGranter == UUID.Zero) | 2742 | if (item.PermsGranter == UUID.Zero) |
2600 | return 0; | 2743 | return 0; |
@@ -2669,6 +2812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2669 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2812 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2670 | return; | 2813 | return; |
2671 | 2814 | ||
2815 | //Clone is thread-safe | ||
2672 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2816 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2673 | 2817 | ||
2674 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2818 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2729,6 +2873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2729 | 2873 | ||
2730 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2874 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2731 | { | 2875 | { |
2876 | /* | ||
2732 | m_host.AddScriptLPS(1); | 2877 | m_host.AddScriptLPS(1); |
2733 | // Determine where we are looking from | 2878 | // Determine where we are looking from |
2734 | LSL_Vector from = llGetPos(); | 2879 | LSL_Vector from = llGetPos(); |
@@ -2748,10 +2893,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2748 | // the angles of rotation in radians into rotation value | 2893 | // the angles of rotation in radians into rotation value |
2749 | 2894 | ||
2750 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2895 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2751 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2896 | |
2752 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2897 | // This would only work if your physics system contains an APID controller: |
2898 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2899 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2900 | |||
2753 | // Orient the object to the angle calculated | 2901 | // Orient the object to the angle calculated |
2754 | //llSetRot(rot); | 2902 | llSetRot(rot); |
2903 | */ | ||
2904 | |||
2905 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2906 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2907 | // http://bugs.meta7.com/view.php?id=28 | ||
2908 | // - Tom | ||
2909 | |||
2910 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2911 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2912 | |||
2913 | } | ||
2914 | |||
2915 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2916 | { | ||
2917 | m_host.AddScriptLPS(1); | ||
2918 | // NotImplemented("llRotLookAt"); | ||
2919 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2920 | |||
2755 | } | 2921 | } |
2756 | 2922 | ||
2757 | public void llStopLookAt() | 2923 | public void llStopLookAt() |
@@ -2800,13 +2966,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2800 | { | 2966 | { |
2801 | TaskInventoryItem item; | 2967 | TaskInventoryItem item; |
2802 | 2968 | ||
2803 | lock (m_host.TaskInventory) | 2969 | m_host.TaskInventory.LockItemsForRead(true); |
2970 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2804 | { | 2971 | { |
2805 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2972 | m_host.TaskInventory.LockItemsForRead(false); |
2806 | return; | 2973 | return; |
2807 | else | 2974 | } |
2808 | item = m_host.TaskInventory[InventorySelf()]; | 2975 | else |
2976 | { | ||
2977 | item = m_host.TaskInventory[InventorySelf()]; | ||
2809 | } | 2978 | } |
2979 | m_host.TaskInventory.LockItemsForRead(false); | ||
2810 | 2980 | ||
2811 | if (item.PermsGranter != UUID.Zero) | 2981 | if (item.PermsGranter != UUID.Zero) |
2812 | { | 2982 | { |
@@ -2828,13 +2998,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2828 | { | 2998 | { |
2829 | TaskInventoryItem item; | 2999 | TaskInventoryItem item; |
2830 | 3000 | ||
3001 | m_host.TaskInventory.LockItemsForRead(true); | ||
2831 | lock (m_host.TaskInventory) | 3002 | lock (m_host.TaskInventory) |
2832 | { | 3003 | { |
3004 | |||
2833 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3005 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3006 | { | ||
3007 | m_host.TaskInventory.LockItemsForRead(false); | ||
2834 | return; | 3008 | return; |
3009 | } | ||
2835 | else | 3010 | else |
3011 | { | ||
2836 | item = m_host.TaskInventory[InventorySelf()]; | 3012 | item = m_host.TaskInventory[InventorySelf()]; |
3013 | } | ||
2837 | } | 3014 | } |
3015 | m_host.TaskInventory.LockItemsForRead(false); | ||
2838 | 3016 | ||
2839 | m_host.AddScriptLPS(1); | 3017 | m_host.AddScriptLPS(1); |
2840 | 3018 | ||
@@ -2871,14 +3049,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2871 | 3049 | ||
2872 | TaskInventoryItem item; | 3050 | TaskInventoryItem item; |
2873 | 3051 | ||
2874 | lock (m_host.TaskInventory) | 3052 | m_host.TaskInventory.LockItemsForRead(true); |
3053 | |||
3054 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2875 | { | 3055 | { |
2876 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3056 | m_host.TaskInventory.LockItemsForRead(false); |
2877 | return; | 3057 | return; |
2878 | else | 3058 | } |
2879 | item = m_host.TaskInventory[InventorySelf()]; | 3059 | else |
3060 | { | ||
3061 | item = m_host.TaskInventory[InventorySelf()]; | ||
2880 | } | 3062 | } |
2881 | 3063 | ||
3064 | m_host.TaskInventory.LockItemsForRead(false); | ||
3065 | |||
2882 | if (item.PermsGranter != m_host.OwnerID) | 3066 | if (item.PermsGranter != m_host.OwnerID) |
2883 | return; | 3067 | return; |
2884 | 3068 | ||
@@ -2905,13 +3089,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2905 | 3089 | ||
2906 | TaskInventoryItem item; | 3090 | TaskInventoryItem item; |
2907 | 3091 | ||
2908 | lock (m_host.TaskInventory) | 3092 | m_host.TaskInventory.LockItemsForRead(true); |
3093 | |||
3094 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2909 | { | 3095 | { |
2910 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3096 | m_host.TaskInventory.LockItemsForRead(false); |
2911 | return; | 3097 | return; |
2912 | else | ||
2913 | item = m_host.TaskInventory[InventorySelf()]; | ||
2914 | } | 3098 | } |
3099 | else | ||
3100 | { | ||
3101 | item = m_host.TaskInventory[InventorySelf()]; | ||
3102 | } | ||
3103 | m_host.TaskInventory.LockItemsForRead(false); | ||
3104 | |||
2915 | 3105 | ||
2916 | if (item.PermsGranter != m_host.OwnerID) | 3106 | if (item.PermsGranter != m_host.OwnerID) |
2917 | return; | 3107 | return; |
@@ -2948,8 +3138,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2948 | return m_host.OwnerID.ToString(); | 3138 | return m_host.OwnerID.ToString(); |
2949 | } | 3139 | } |
2950 | 3140 | ||
3141 | [DebuggerNonUserCode] | ||
2951 | public void llInstantMessage(string user, string message) | 3142 | public void llInstantMessage(string user, string message) |
2952 | { | 3143 | { |
3144 | UUID result; | ||
3145 | if (!UUID.TryParse(user, out result)) | ||
3146 | { | ||
3147 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3148 | return; | ||
3149 | } | ||
3150 | |||
3151 | |||
2953 | m_host.AddScriptLPS(1); | 3152 | m_host.AddScriptLPS(1); |
2954 | 3153 | ||
2955 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3154 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2964,7 +3163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2964 | UUID friendTransactionID = UUID.Random(); | 3163 | UUID friendTransactionID = UUID.Random(); |
2965 | 3164 | ||
2966 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3165 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2967 | 3166 | ||
2968 | GridInstantMessage msg = new GridInstantMessage(); | 3167 | GridInstantMessage msg = new GridInstantMessage(); |
2969 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3168 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2970 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3169 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3113,13 +3312,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3113 | m_host.AddScriptLPS(1); | 3312 | m_host.AddScriptLPS(1); |
3114 | } | 3313 | } |
3115 | 3314 | ||
3116 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3117 | { | ||
3118 | m_host.AddScriptLPS(1); | ||
3119 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3120 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3121 | } | ||
3122 | |||
3123 | public LSL_Integer llStringLength(string str) | 3315 | public LSL_Integer llStringLength(string str) |
3124 | { | 3316 | { |
3125 | m_host.AddScriptLPS(1); | 3317 | m_host.AddScriptLPS(1); |
@@ -3143,14 +3335,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3143 | 3335 | ||
3144 | TaskInventoryItem item; | 3336 | TaskInventoryItem item; |
3145 | 3337 | ||
3146 | lock (m_host.TaskInventory) | 3338 | m_host.TaskInventory.LockItemsForRead(true); |
3339 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3147 | { | 3340 | { |
3148 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3341 | m_host.TaskInventory.LockItemsForRead(false); |
3149 | return; | 3342 | return; |
3150 | else | ||
3151 | item = m_host.TaskInventory[InventorySelf()]; | ||
3152 | } | 3343 | } |
3153 | 3344 | else | |
3345 | { | ||
3346 | item = m_host.TaskInventory[InventorySelf()]; | ||
3347 | } | ||
3348 | m_host.TaskInventory.LockItemsForRead(false); | ||
3154 | if (item.PermsGranter == UUID.Zero) | 3349 | if (item.PermsGranter == UUID.Zero) |
3155 | return; | 3350 | return; |
3156 | 3351 | ||
@@ -3180,13 +3375,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3180 | 3375 | ||
3181 | TaskInventoryItem item; | 3376 | TaskInventoryItem item; |
3182 | 3377 | ||
3183 | lock (m_host.TaskInventory) | 3378 | m_host.TaskInventory.LockItemsForRead(true); |
3379 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3184 | { | 3380 | { |
3185 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3381 | m_host.TaskInventory.LockItemsForRead(false); |
3186 | return; | 3382 | return; |
3187 | else | ||
3188 | item = m_host.TaskInventory[InventorySelf()]; | ||
3189 | } | 3383 | } |
3384 | else | ||
3385 | { | ||
3386 | item = m_host.TaskInventory[InventorySelf()]; | ||
3387 | } | ||
3388 | m_host.TaskInventory.LockItemsForRead(false); | ||
3389 | |||
3190 | 3390 | ||
3191 | if (item.PermsGranter == UUID.Zero) | 3391 | if (item.PermsGranter == UUID.Zero) |
3192 | return; | 3392 | return; |
@@ -3263,10 +3463,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3263 | 3463 | ||
3264 | TaskInventoryItem item; | 3464 | TaskInventoryItem item; |
3265 | 3465 | ||
3266 | lock (m_host.TaskInventory) | 3466 | |
3467 | m_host.TaskInventory.LockItemsForRead(true); | ||
3468 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3469 | { | ||
3470 | m_host.TaskInventory.LockItemsForRead(false); | ||
3471 | return; | ||
3472 | } | ||
3473 | else | ||
3267 | { | 3474 | { |
3268 | item = m_host.TaskInventory[invItemID]; | 3475 | item = m_host.TaskInventory[invItemID]; |
3269 | } | 3476 | } |
3477 | m_host.TaskInventory.LockItemsForRead(false); | ||
3270 | 3478 | ||
3271 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3479 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3272 | { | 3480 | { |
@@ -3298,11 +3506,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3298 | 3506 | ||
3299 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3507 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3300 | { | 3508 | { |
3301 | lock (m_host.TaskInventory) | 3509 | m_host.TaskInventory.LockItemsForWrite(true); |
3302 | { | 3510 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3303 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3511 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3304 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3512 | m_host.TaskInventory.LockItemsForWrite(false); |
3305 | } | ||
3306 | 3513 | ||
3307 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3514 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3308 | "run_time_permissions", new Object[] { | 3515 | "run_time_permissions", new Object[] { |
@@ -3322,11 +3529,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3322 | 3529 | ||
3323 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3530 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3324 | { | 3531 | { |
3325 | lock (m_host.TaskInventory) | 3532 | m_host.TaskInventory.LockItemsForWrite(true); |
3326 | { | 3533 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3327 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3534 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3328 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3535 | m_host.TaskInventory.LockItemsForWrite(false); |
3329 | } | ||
3330 | 3536 | ||
3331 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3537 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3332 | "run_time_permissions", new Object[] { | 3538 | "run_time_permissions", new Object[] { |
@@ -3347,11 +3553,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3347 | 3553 | ||
3348 | if (!m_waitingForScriptAnswer) | 3554 | if (!m_waitingForScriptAnswer) |
3349 | { | 3555 | { |
3350 | lock (m_host.TaskInventory) | 3556 | m_host.TaskInventory.LockItemsForWrite(true); |
3351 | { | 3557 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3352 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3558 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3353 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3559 | m_host.TaskInventory.LockItemsForWrite(false); |
3354 | } | ||
3355 | 3560 | ||
3356 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3561 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3357 | m_waitingForScriptAnswer=true; | 3562 | m_waitingForScriptAnswer=true; |
@@ -3386,10 +3591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3386 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3591 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3387 | llReleaseControls(); | 3592 | llReleaseControls(); |
3388 | 3593 | ||
3389 | lock (m_host.TaskInventory) | 3594 | |
3390 | { | 3595 | m_host.TaskInventory.LockItemsForWrite(true); |
3391 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3596 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3392 | } | 3597 | m_host.TaskInventory.LockItemsForWrite(false); |
3598 | |||
3393 | 3599 | ||
3394 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3600 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3395 | "run_time_permissions", new Object[] { | 3601 | "run_time_permissions", new Object[] { |
@@ -3401,16 +3607,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3401 | { | 3607 | { |
3402 | m_host.AddScriptLPS(1); | 3608 | m_host.AddScriptLPS(1); |
3403 | 3609 | ||
3404 | lock (m_host.TaskInventory) | 3610 | m_host.TaskInventory.LockItemsForRead(true); |
3611 | |||
3612 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3405 | { | 3613 | { |
3406 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3614 | if (item.Type == 10 && item.ItemID == m_itemID) |
3407 | { | 3615 | { |
3408 | if (item.Type == 10 && item.ItemID == m_itemID) | 3616 | m_host.TaskInventory.LockItemsForRead(false); |
3409 | { | 3617 | return item.PermsGranter.ToString(); |
3410 | return item.PermsGranter.ToString(); | ||
3411 | } | ||
3412 | } | 3618 | } |
3413 | } | 3619 | } |
3620 | m_host.TaskInventory.LockItemsForRead(false); | ||
3414 | 3621 | ||
3415 | return UUID.Zero.ToString(); | 3622 | return UUID.Zero.ToString(); |
3416 | } | 3623 | } |
@@ -3419,19 +3626,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3419 | { | 3626 | { |
3420 | m_host.AddScriptLPS(1); | 3627 | m_host.AddScriptLPS(1); |
3421 | 3628 | ||
3422 | lock (m_host.TaskInventory) | 3629 | m_host.TaskInventory.LockItemsForRead(true); |
3630 | |||
3631 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3423 | { | 3632 | { |
3424 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3633 | if (item.Type == 10 && item.ItemID == m_itemID) |
3425 | { | 3634 | { |
3426 | if (item.Type == 10 && item.ItemID == m_itemID) | 3635 | int perms = item.PermsMask; |
3427 | { | 3636 | if (m_automaticLinkPermission) |
3428 | int perms = item.PermsMask; | 3637 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3429 | if (m_automaticLinkPermission) | 3638 | m_host.TaskInventory.LockItemsForRead(false); |
3430 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3639 | return perms; |
3431 | return perms; | ||
3432 | } | ||
3433 | } | 3640 | } |
3434 | } | 3641 | } |
3642 | m_host.TaskInventory.LockItemsForRead(false); | ||
3435 | 3643 | ||
3436 | return 0; | 3644 | return 0; |
3437 | } | 3645 | } |
@@ -3464,11 +3672,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3464 | UUID invItemID = InventorySelf(); | 3672 | UUID invItemID = InventorySelf(); |
3465 | 3673 | ||
3466 | TaskInventoryItem item; | 3674 | TaskInventoryItem item; |
3467 | lock (m_host.TaskInventory) | 3675 | m_host.TaskInventory.LockItemsForRead(true); |
3468 | { | 3676 | item = m_host.TaskInventory[invItemID]; |
3469 | item = m_host.TaskInventory[invItemID]; | 3677 | m_host.TaskInventory.LockItemsForRead(false); |
3470 | } | 3678 | |
3471 | |||
3472 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3679 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3473 | && !m_automaticLinkPermission) | 3680 | && !m_automaticLinkPermission) |
3474 | { | 3681 | { |
@@ -3521,16 +3728,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3521 | m_host.AddScriptLPS(1); | 3728 | m_host.AddScriptLPS(1); |
3522 | UUID invItemID = InventorySelf(); | 3729 | UUID invItemID = InventorySelf(); |
3523 | 3730 | ||
3524 | lock (m_host.TaskInventory) | 3731 | m_host.TaskInventory.LockItemsForRead(true); |
3525 | { | ||
3526 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3732 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3527 | && !m_automaticLinkPermission) | 3733 | && !m_automaticLinkPermission) |
3528 | { | 3734 | { |
3529 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3735 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3736 | m_host.TaskInventory.LockItemsForRead(false); | ||
3530 | return; | 3737 | return; |
3531 | } | 3738 | } |
3532 | } | 3739 | m_host.TaskInventory.LockItemsForRead(false); |
3533 | 3740 | ||
3534 | if (linknum < ScriptBaseClass.LINK_THIS) | 3741 | if (linknum < ScriptBaseClass.LINK_THIS) |
3535 | return; | 3742 | return; |
3536 | 3743 | ||
@@ -3707,17 +3914,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3707 | m_host.AddScriptLPS(1); | 3914 | m_host.AddScriptLPS(1); |
3708 | int count = 0; | 3915 | int count = 0; |
3709 | 3916 | ||
3710 | lock (m_host.TaskInventory) | 3917 | m_host.TaskInventory.LockItemsForRead(true); |
3918 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3711 | { | 3919 | { |
3712 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3920 | if (inv.Value.Type == type || type == -1) |
3713 | { | 3921 | { |
3714 | if (inv.Value.Type == type || type == -1) | 3922 | count = count + 1; |
3715 | { | ||
3716 | count = count + 1; | ||
3717 | } | ||
3718 | } | 3923 | } |
3719 | } | 3924 | } |
3720 | 3925 | ||
3926 | m_host.TaskInventory.LockItemsForRead(false); | ||
3721 | return count; | 3927 | return count; |
3722 | } | 3928 | } |
3723 | 3929 | ||
@@ -3726,16 +3932,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3726 | m_host.AddScriptLPS(1); | 3932 | m_host.AddScriptLPS(1); |
3727 | ArrayList keys = new ArrayList(); | 3933 | ArrayList keys = new ArrayList(); |
3728 | 3934 | ||
3729 | lock (m_host.TaskInventory) | 3935 | m_host.TaskInventory.LockItemsForRead(true); |
3936 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3730 | { | 3937 | { |
3731 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3938 | if (inv.Value.Type == type || type == -1) |
3732 | { | 3939 | { |
3733 | if (inv.Value.Type == type || type == -1) | 3940 | keys.Add(inv.Value.Name); |
3734 | { | ||
3735 | keys.Add(inv.Value.Name); | ||
3736 | } | ||
3737 | } | 3941 | } |
3738 | } | 3942 | } |
3943 | m_host.TaskInventory.LockItemsForRead(false); | ||
3739 | 3944 | ||
3740 | if (keys.Count == 0) | 3945 | if (keys.Count == 0) |
3741 | { | 3946 | { |
@@ -3772,20 +3977,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3772 | } | 3977 | } |
3773 | 3978 | ||
3774 | // move the first object found with this inventory name | 3979 | // move the first object found with this inventory name |
3775 | lock (m_host.TaskInventory) | 3980 | m_host.TaskInventory.LockItemsForRead(true); |
3981 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3776 | { | 3982 | { |
3777 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3983 | if (inv.Value.Name == inventory) |
3778 | { | 3984 | { |
3779 | if (inv.Value.Name == inventory) | 3985 | found = true; |
3780 | { | 3986 | objId = inv.Key; |
3781 | found = true; | 3987 | assetType = inv.Value.Type; |
3782 | objId = inv.Key; | 3988 | objName = inv.Value.Name; |
3783 | assetType = inv.Value.Type; | 3989 | break; |
3784 | objName = inv.Value.Name; | ||
3785 | break; | ||
3786 | } | ||
3787 | } | 3990 | } |
3788 | } | 3991 | } |
3992 | m_host.TaskInventory.LockItemsForRead(false); | ||
3789 | 3993 | ||
3790 | if (!found) | 3994 | if (!found) |
3791 | { | 3995 | { |
@@ -3793,9 +3997,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3793 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 3997 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3794 | } | 3998 | } |
3795 | 3999 | ||
3796 | // check if destination is an avatar | 4000 | // check if destination is an object |
3797 | if (World.GetScenePresence(destId) != null) | 4001 | if (World.GetSceneObjectPart(destId) != null) |
4002 | { | ||
4003 | // destination is an object | ||
4004 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4005 | } | ||
4006 | else | ||
3798 | { | 4007 | { |
4008 | ScenePresence presence = World.GetScenePresence(destId); | ||
4009 | |||
4010 | if (presence == null) | ||
4011 | { | ||
4012 | UserAccount account = | ||
4013 | World.UserAccountService.GetUserAccount( | ||
4014 | World.RegionInfo.ScopeID, | ||
4015 | destId); | ||
4016 | |||
4017 | if (account == null) | ||
4018 | { | ||
4019 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4020 | return; | ||
4021 | } | ||
4022 | } | ||
4023 | |||
3799 | // destination is an avatar | 4024 | // destination is an avatar |
3800 | InventoryItemBase agentItem = | 4025 | InventoryItemBase agentItem = |
3801 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4026 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
@@ -3821,33 +4046,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3821 | 4046 | ||
3822 | if (m_TransferModule != null) | 4047 | if (m_TransferModule != null) |
3823 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4048 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4049 | |||
4050 | //This delay should only occur when giving inventory to avatars. | ||
4051 | ScriptSleep(3000); | ||
3824 | } | 4052 | } |
3825 | else | ||
3826 | { | ||
3827 | // destination is an object | ||
3828 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3829 | } | ||
3830 | ScriptSleep(3000); | ||
3831 | } | 4053 | } |
3832 | 4054 | ||
4055 | [DebuggerNonUserCode] | ||
3833 | public void llRemoveInventory(string name) | 4056 | public void llRemoveInventory(string name) |
3834 | { | 4057 | { |
3835 | m_host.AddScriptLPS(1); | 4058 | m_host.AddScriptLPS(1); |
3836 | 4059 | ||
3837 | lock (m_host.TaskInventory) | 4060 | m_host.TaskInventory.LockItemsForRead(true); |
4061 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3838 | { | 4062 | { |
3839 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4063 | if (item.Name == name) |
3840 | { | 4064 | { |
3841 | if (item.Name == name) | 4065 | if (item.ItemID == m_itemID) |
3842 | { | 4066 | throw new ScriptDeleteException(); |
3843 | if (item.ItemID == m_itemID) | 4067 | else |
3844 | throw new ScriptDeleteException(); | 4068 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3845 | else | 4069 | |
3846 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4070 | m_host.TaskInventory.LockItemsForRead(false); |
3847 | return; | 4071 | return; |
3848 | } | ||
3849 | } | 4072 | } |
3850 | } | 4073 | } |
4074 | m_host.TaskInventory.LockItemsForRead(false); | ||
3851 | } | 4075 | } |
3852 | 4076 | ||
3853 | public void llSetText(string text, LSL_Vector color, double alpha) | 4077 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3938,6 +4162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3938 | { | 4162 | { |
3939 | m_host.AddScriptLPS(1); | 4163 | m_host.AddScriptLPS(1); |
3940 | 4164 | ||
4165 | //Clone is thread safe | ||
3941 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4166 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3942 | 4167 | ||
3943 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4168 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3991,6 +4216,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3991 | ScenePresence presence = World.GetScenePresence(agentId); | 4216 | ScenePresence presence = World.GetScenePresence(agentId); |
3992 | if (presence != null) | 4217 | if (presence != null) |
3993 | { | 4218 | { |
4219 | // agent must not be a god | ||
4220 | if (presence.GodLevel >= 200) return; | ||
4221 | |||
3994 | // agent must be over the owners land | 4222 | // agent must be over the owners land |
3995 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4223 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
3996 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4224 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4051,17 +4279,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4051 | UUID soundId = UUID.Zero; | 4279 | UUID soundId = UUID.Zero; |
4052 | if (!UUID.TryParse(impact_sound, out soundId)) | 4280 | if (!UUID.TryParse(impact_sound, out soundId)) |
4053 | { | 4281 | { |
4054 | lock (m_host.TaskInventory) | 4282 | m_host.TaskInventory.LockItemsForRead(true); |
4283 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4055 | { | 4284 | { |
4056 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4285 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4057 | { | 4286 | { |
4058 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4287 | soundId = item.AssetID; |
4059 | { | 4288 | break; |
4060 | soundId = item.AssetID; | ||
4061 | break; | ||
4062 | } | ||
4063 | } | 4289 | } |
4064 | } | 4290 | } |
4291 | m_host.TaskInventory.LockItemsForRead(false); | ||
4065 | } | 4292 | } |
4066 | m_host.CollisionSound = soundId; | 4293 | m_host.CollisionSound = soundId; |
4067 | m_host.CollisionSoundVolume = (float)impact_volume; | 4294 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4107,6 +4334,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4107 | UUID partItemID; | 4334 | UUID partItemID; |
4108 | foreach (SceneObjectPart part in parts) | 4335 | foreach (SceneObjectPart part in parts) |
4109 | { | 4336 | { |
4337 | //Clone is thread safe | ||
4110 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4338 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4111 | 4339 | ||
4112 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4340 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4321,17 +4549,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4321 | 4549 | ||
4322 | m_host.AddScriptLPS(1); | 4550 | m_host.AddScriptLPS(1); |
4323 | 4551 | ||
4324 | lock (m_host.TaskInventory) | 4552 | m_host.TaskInventory.LockItemsForRead(true); |
4553 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4325 | { | 4554 | { |
4326 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4555 | if (item.Type == 10 && item.ItemID == m_itemID) |
4327 | { | 4556 | { |
4328 | if (item.Type == 10 && item.ItemID == m_itemID) | 4557 | result = item.Name!=null?item.Name:String.Empty; |
4329 | { | 4558 | break; |
4330 | result = item.Name != null ? item.Name : String.Empty; | ||
4331 | break; | ||
4332 | } | ||
4333 | } | 4559 | } |
4334 | } | 4560 | } |
4561 | m_host.TaskInventory.LockItemsForRead(false); | ||
4335 | 4562 | ||
4336 | return result; | 4563 | return result; |
4337 | } | 4564 | } |
@@ -4484,23 +4711,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4484 | { | 4711 | { |
4485 | m_host.AddScriptLPS(1); | 4712 | m_host.AddScriptLPS(1); |
4486 | 4713 | ||
4487 | lock (m_host.TaskInventory) | 4714 | m_host.TaskInventory.LockItemsForRead(true); |
4715 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4488 | { | 4716 | { |
4489 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4717 | if (inv.Value.Name == name) |
4490 | { | 4718 | { |
4491 | if (inv.Value.Name == name) | 4719 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4492 | { | 4720 | { |
4493 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4721 | m_host.TaskInventory.LockItemsForRead(false); |
4494 | { | 4722 | return inv.Value.AssetID.ToString(); |
4495 | return inv.Value.AssetID.ToString(); | 4723 | } |
4496 | } | 4724 | else |
4497 | else | 4725 | { |
4498 | { | 4726 | m_host.TaskInventory.LockItemsForRead(false); |
4499 | return UUID.Zero.ToString(); | 4727 | return UUID.Zero.ToString(); |
4500 | } | ||
4501 | } | 4728 | } |
4502 | } | 4729 | } |
4503 | } | 4730 | } |
4731 | m_host.TaskInventory.LockItemsForRead(false); | ||
4504 | 4732 | ||
4505 | return UUID.Zero.ToString(); | 4733 | return UUID.Zero.ToString(); |
4506 | } | 4734 | } |
@@ -6015,6 +6243,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6015 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6243 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6016 | prules.OuterAngle = (float)tempf; | 6244 | prules.OuterAngle = (float)tempf; |
6017 | break; | 6245 | break; |
6246 | |||
6247 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6248 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6249 | prules.InnerAngle = (float)tempf; | ||
6250 | break; | ||
6251 | |||
6252 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6253 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6254 | prules.OuterAngle = (float)tempf; | ||
6255 | break; | ||
6018 | } | 6256 | } |
6019 | 6257 | ||
6020 | } | 6258 | } |
@@ -6053,14 +6291,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6053 | 6291 | ||
6054 | protected UUID GetTaskInventoryItem(string name) | 6292 | protected UUID GetTaskInventoryItem(string name) |
6055 | { | 6293 | { |
6056 | lock (m_host.TaskInventory) | 6294 | m_host.TaskInventory.LockItemsForRead(true); |
6295 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6057 | { | 6296 | { |
6058 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6297 | if (inv.Value.Name == name) |
6059 | { | 6298 | { |
6060 | if (inv.Value.Name == name) | 6299 | m_host.TaskInventory.LockItemsForRead(false); |
6061 | return inv.Key; | 6300 | return inv.Key; |
6062 | } | 6301 | } |
6063 | } | 6302 | } |
6303 | m_host.TaskInventory.LockItemsForRead(false); | ||
6064 | 6304 | ||
6065 | return UUID.Zero; | 6305 | return UUID.Zero; |
6066 | } | 6306 | } |
@@ -6388,22 +6628,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6388 | } | 6628 | } |
6389 | 6629 | ||
6390 | // copy the first script found with this inventory name | 6630 | // copy the first script found with this inventory name |
6391 | lock (m_host.TaskInventory) | 6631 | m_host.TaskInventory.LockItemsForRead(true); |
6632 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6392 | { | 6633 | { |
6393 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6634 | if (inv.Value.Name == name) |
6394 | { | 6635 | { |
6395 | if (inv.Value.Name == name) | 6636 | // make sure the object is a script |
6637 | if (10 == inv.Value.Type) | ||
6396 | { | 6638 | { |
6397 | // make sure the object is a script | 6639 | found = true; |
6398 | if (10 == inv.Value.Type) | 6640 | srcId = inv.Key; |
6399 | { | 6641 | break; |
6400 | found = true; | ||
6401 | srcId = inv.Key; | ||
6402 | break; | ||
6403 | } | ||
6404 | } | 6642 | } |
6405 | } | 6643 | } |
6406 | } | 6644 | } |
6645 | m_host.TaskInventory.LockItemsForRead(false); | ||
6407 | 6646 | ||
6408 | if (!found) | 6647 | if (!found) |
6409 | { | 6648 | { |
@@ -6487,6 +6726,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6487 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6726 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6488 | { | 6727 | { |
6489 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6728 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6729 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6730 | return shapeBlock; | ||
6490 | 6731 | ||
6491 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6732 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6492 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6733 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6557,6 +6798,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6557 | 6798 | ||
6558 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6799 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6559 | { | 6800 | { |
6801 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6802 | return; | ||
6803 | |||
6560 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6804 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6561 | 6805 | ||
6562 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6806 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6606,6 +6850,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6606 | 6850 | ||
6607 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6851 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6608 | { | 6852 | { |
6853 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6854 | return; | ||
6855 | |||
6609 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6856 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6610 | 6857 | ||
6611 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6858 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6648,6 +6895,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6648 | 6895 | ||
6649 | 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) | 6896 | 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) |
6650 | { | 6897 | { |
6898 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6899 | return; | ||
6900 | |||
6651 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6901 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6652 | 6902 | ||
6653 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6903 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6769,6 +7019,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6769 | 7019 | ||
6770 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7020 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6771 | { | 7021 | { |
7022 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7023 | return; | ||
7024 | |||
6772 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7025 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6773 | UUID sculptId; | 7026 | UUID sculptId; |
6774 | 7027 | ||
@@ -6809,7 +7062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6809 | 7062 | ||
6810 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7063 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6811 | { | 7064 | { |
6812 | m_host.AddScriptLPS(1); | 7065 | m_host.AddScriptLPS(1); |
6813 | 7066 | ||
6814 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7067 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6815 | 7068 | ||
@@ -6824,6 +7077,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6824 | 7077 | ||
6825 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7078 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6826 | { | 7079 | { |
7080 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7081 | return; | ||
7082 | |||
6827 | int idx = 0; | 7083 | int idx = 0; |
6828 | 7084 | ||
6829 | while (idx < rules.Length) | 7085 | while (idx < rules.Length) |
@@ -7655,24 +7911,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7655 | break; | 7911 | break; |
7656 | 7912 | ||
7657 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7913 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7658 | // TODO-------------- | ||
7659 | if (remain < 1) | 7914 | if (remain < 1) |
7660 | return res; | 7915 | return res; |
7916 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7661 | 7917 | ||
7662 | face=(int)rules.GetLSLIntegerItem(idx++); | 7918 | tex = part.Shape.Textures; |
7663 | 7919 | int shiny; | |
7664 | res.Add(new LSL_Integer(0)); | 7920 | if (face == ScriptBaseClass.ALL_SIDES) |
7665 | res.Add(new LSL_Integer(0)); | 7921 | { |
7922 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7923 | { | ||
7924 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7925 | if (shinyness == Shininess.High) | ||
7926 | { | ||
7927 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7928 | } | ||
7929 | else if (shinyness == Shininess.Medium) | ||
7930 | { | ||
7931 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7932 | } | ||
7933 | else if (shinyness == Shininess.Low) | ||
7934 | { | ||
7935 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7936 | } | ||
7937 | else | ||
7938 | { | ||
7939 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7940 | } | ||
7941 | res.Add(new LSL_Integer(shiny)); | ||
7942 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7943 | } | ||
7944 | } | ||
7945 | else | ||
7946 | { | ||
7947 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7948 | if (shinyness == Shininess.High) | ||
7949 | { | ||
7950 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7951 | } | ||
7952 | else if (shinyness == Shininess.Medium) | ||
7953 | { | ||
7954 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7955 | } | ||
7956 | else if (shinyness == Shininess.Low) | ||
7957 | { | ||
7958 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7959 | } | ||
7960 | else | ||
7961 | { | ||
7962 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7963 | } | ||
7964 | res.Add(new LSL_Integer(shiny)); | ||
7965 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7966 | } | ||
7666 | break; | 7967 | break; |
7667 | 7968 | ||
7668 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7969 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7669 | // TODO-------------- | ||
7670 | if (remain < 1) | 7970 | if (remain < 1) |
7671 | return res; | 7971 | return res; |
7972 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7672 | 7973 | ||
7673 | face=(int)rules.GetLSLIntegerItem(idx++); | 7974 | tex = part.Shape.Textures; |
7674 | 7975 | int fullbright; | |
7675 | res.Add(new LSL_Integer(0)); | 7976 | if (face == ScriptBaseClass.ALL_SIDES) |
7977 | { | ||
7978 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7979 | { | ||
7980 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7981 | { | ||
7982 | fullbright = ScriptBaseClass.TRUE; | ||
7983 | } | ||
7984 | else | ||
7985 | { | ||
7986 | fullbright = ScriptBaseClass.FALSE; | ||
7987 | } | ||
7988 | res.Add(new LSL_Integer(fullbright)); | ||
7989 | } | ||
7990 | } | ||
7991 | else | ||
7992 | { | ||
7993 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7994 | { | ||
7995 | fullbright = ScriptBaseClass.TRUE; | ||
7996 | } | ||
7997 | else | ||
7998 | { | ||
7999 | fullbright = ScriptBaseClass.FALSE; | ||
8000 | } | ||
8001 | res.Add(new LSL_Integer(fullbright)); | ||
8002 | } | ||
7676 | break; | 8003 | break; |
7677 | 8004 | ||
7678 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8005 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7693,14 +8020,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7693 | break; | 8020 | break; |
7694 | 8021 | ||
7695 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8022 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7696 | // TODO-------------- | ||
7697 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8023 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7698 | if (remain < 1) | 8024 | if (remain < 1) |
7699 | return res; | 8025 | return res; |
8026 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7700 | 8027 | ||
7701 | face=(int)rules.GetLSLIntegerItem(idx++); | 8028 | tex = part.Shape.Textures; |
7702 | 8029 | if (face == ScriptBaseClass.ALL_SIDES) | |
7703 | res.Add(new LSL_Integer(0)); | 8030 | { |
8031 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8032 | { | ||
8033 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8034 | { | ||
8035 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8036 | } | ||
8037 | else | ||
8038 | { | ||
8039 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8040 | } | ||
8041 | } | ||
8042 | } | ||
8043 | else | ||
8044 | { | ||
8045 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8046 | { | ||
8047 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8048 | } | ||
8049 | else | ||
8050 | { | ||
8051 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8052 | } | ||
8053 | } | ||
7704 | break; | 8054 | break; |
7705 | 8055 | ||
7706 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8056 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7719,13 +8069,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7719 | break; | 8069 | break; |
7720 | 8070 | ||
7721 | case (int)ScriptBaseClass.PRIM_GLOW: | 8071 | case (int)ScriptBaseClass.PRIM_GLOW: |
7722 | // TODO-------------- | ||
7723 | if (remain < 1) | 8072 | if (remain < 1) |
7724 | return res; | 8073 | return res; |
8074 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7725 | 8075 | ||
7726 | face=(int)rules.GetLSLIntegerItem(idx++); | 8076 | tex = part.Shape.Textures; |
7727 | 8077 | float primglow; | |
7728 | res.Add(new LSL_Float(0)); | 8078 | if (face == ScriptBaseClass.ALL_SIDES) |
8079 | { | ||
8080 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8081 | { | ||
8082 | primglow = tex.GetFace((uint)face).Glow; | ||
8083 | res.Add(new LSL_Float(primglow)); | ||
8084 | } | ||
8085 | } | ||
8086 | else | ||
8087 | { | ||
8088 | primglow = tex.GetFace((uint)face).Glow; | ||
8089 | res.Add(new LSL_Float(primglow)); | ||
8090 | } | ||
7729 | break; | 8091 | break; |
7730 | case (int)ScriptBaseClass.PRIM_TEXT: | 8092 | case (int)ScriptBaseClass.PRIM_TEXT: |
7731 | Color4 textColor = part.GetTextColor(); | 8093 | Color4 textColor = part.GetTextColor(); |
@@ -8262,28 +8624,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8262 | { | 8624 | { |
8263 | m_host.AddScriptLPS(1); | 8625 | m_host.AddScriptLPS(1); |
8264 | 8626 | ||
8265 | lock (m_host.TaskInventory) | 8627 | m_host.TaskInventory.LockItemsForRead(true); |
8628 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8266 | { | 8629 | { |
8267 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8630 | if (inv.Value.Name == item) |
8268 | { | 8631 | { |
8269 | if (inv.Value.Name == item) | 8632 | m_host.TaskInventory.LockItemsForRead(false); |
8633 | switch (mask) | ||
8270 | { | 8634 | { |
8271 | switch (mask) | 8635 | case 0: |
8272 | { | 8636 | return (int)inv.Value.BasePermissions; |
8273 | case 0: | 8637 | case 1: |
8274 | return (int)inv.Value.BasePermissions; | 8638 | return (int)inv.Value.CurrentPermissions; |
8275 | case 1: | 8639 | case 2: |
8276 | return (int)inv.Value.CurrentPermissions; | 8640 | return (int)inv.Value.GroupPermissions; |
8277 | case 2: | 8641 | case 3: |
8278 | return (int)inv.Value.GroupPermissions; | 8642 | return (int)inv.Value.EveryonePermissions; |
8279 | case 3: | 8643 | case 4: |
8280 | return (int)inv.Value.EveryonePermissions; | 8644 | return (int)inv.Value.NextPermissions; |
8281 | case 4: | ||
8282 | return (int)inv.Value.NextPermissions; | ||
8283 | } | ||
8284 | } | 8645 | } |
8285 | } | 8646 | } |
8286 | } | 8647 | } |
8648 | m_host.TaskInventory.LockItemsForRead(false); | ||
8287 | 8649 | ||
8288 | return -1; | 8650 | return -1; |
8289 | } | 8651 | } |
@@ -8330,16 +8692,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8330 | { | 8692 | { |
8331 | m_host.AddScriptLPS(1); | 8693 | m_host.AddScriptLPS(1); |
8332 | 8694 | ||
8333 | lock (m_host.TaskInventory) | 8695 | m_host.TaskInventory.LockItemsForRead(true); |
8696 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8334 | { | 8697 | { |
8335 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8698 | if (inv.Value.Name == item) |
8336 | { | 8699 | { |
8337 | if (inv.Value.Name == item) | 8700 | m_host.TaskInventory.LockItemsForRead(false); |
8338 | { | 8701 | return inv.Value.CreatorID.ToString(); |
8339 | return inv.Value.CreatorID.ToString(); | ||
8340 | } | ||
8341 | } | 8702 | } |
8342 | } | 8703 | } |
8704 | m_host.TaskInventory.LockItemsForRead(false); | ||
8343 | 8705 | ||
8344 | llSay(0, "No item name '" + item + "'"); | 8706 | llSay(0, "No item name '" + item + "'"); |
8345 | 8707 | ||
@@ -8872,16 +9234,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8872 | { | 9234 | { |
8873 | m_host.AddScriptLPS(1); | 9235 | m_host.AddScriptLPS(1); |
8874 | 9236 | ||
8875 | lock (m_host.TaskInventory) | 9237 | m_host.TaskInventory.LockItemsForRead(true); |
9238 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8876 | { | 9239 | { |
8877 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9240 | if (inv.Value.Name == name) |
8878 | { | 9241 | { |
8879 | if (inv.Value.Name == name) | 9242 | m_host.TaskInventory.LockItemsForRead(false); |
8880 | { | 9243 | return inv.Value.Type; |
8881 | return inv.Value.Type; | ||
8882 | } | ||
8883 | } | 9244 | } |
8884 | } | 9245 | } |
9246 | m_host.TaskInventory.LockItemsForRead(false); | ||
8885 | 9247 | ||
8886 | return -1; | 9248 | return -1; |
8887 | } | 9249 | } |
@@ -8892,15 +9254,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8892 | 9254 | ||
8893 | if (quick_pay_buttons.Data.Length < 4) | 9255 | if (quick_pay_buttons.Data.Length < 4) |
8894 | { | 9256 | { |
8895 | LSLError("List must have at least 4 elements"); | 9257 | int x; |
8896 | return; | 9258 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9259 | { | ||
9260 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9261 | } | ||
8897 | } | 9262 | } |
8898 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9263 | int[] nPrice = new int[5]; |
8899 | 9264 | nPrice[0]=price; | |
8900 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9265 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8901 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9266 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8902 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9267 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8903 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9268 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9269 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8904 | m_host.ParentGroup.HasGroupChanged = true; | 9270 | m_host.ParentGroup.HasGroupChanged = true; |
8905 | } | 9271 | } |
8906 | 9272 | ||
@@ -8912,17 +9278,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8912 | if (invItemID == UUID.Zero) | 9278 | if (invItemID == UUID.Zero) |
8913 | return new LSL_Vector(); | 9279 | return new LSL_Vector(); |
8914 | 9280 | ||
8915 | lock (m_host.TaskInventory) | 9281 | m_host.TaskInventory.LockItemsForRead(true); |
9282 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8916 | { | 9283 | { |
8917 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9284 | m_host.TaskInventory.LockItemsForRead(false); |
8918 | return new LSL_Vector(); | 9285 | return new LSL_Vector(); |
9286 | } | ||
8919 | 9287 | ||
8920 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9288 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8921 | { | 9289 | { |
8922 | ShoutError("No permissions to track the camera"); | 9290 | ShoutError("No permissions to track the camera"); |
8923 | return new LSL_Vector(); | 9291 | m_host.TaskInventory.LockItemsForRead(false); |
8924 | } | 9292 | return new LSL_Vector(); |
8925 | } | 9293 | } |
9294 | m_host.TaskInventory.LockItemsForRead(false); | ||
8926 | 9295 | ||
8927 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9296 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8928 | if (presence != null) | 9297 | if (presence != null) |
@@ -8940,17 +9309,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8940 | if (invItemID == UUID.Zero) | 9309 | if (invItemID == UUID.Zero) |
8941 | return new LSL_Rotation(); | 9310 | return new LSL_Rotation(); |
8942 | 9311 | ||
8943 | lock (m_host.TaskInventory) | 9312 | m_host.TaskInventory.LockItemsForRead(true); |
9313 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8944 | { | 9314 | { |
8945 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9315 | m_host.TaskInventory.LockItemsForRead(false); |
8946 | return new LSL_Rotation(); | 9316 | return new LSL_Rotation(); |
8947 | 9317 | } | |
8948 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9318 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8949 | { | 9319 | { |
8950 | ShoutError("No permissions to track the camera"); | 9320 | ShoutError("No permissions to track the camera"); |
8951 | return new LSL_Rotation(); | 9321 | m_host.TaskInventory.LockItemsForRead(false); |
8952 | } | 9322 | return new LSL_Rotation(); |
8953 | } | 9323 | } |
9324 | m_host.TaskInventory.LockItemsForRead(false); | ||
8954 | 9325 | ||
8955 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9326 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8956 | if (presence != null) | 9327 | if (presence != null) |
@@ -9100,14 +9471,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9100 | if (objectID == UUID.Zero) return; | 9471 | if (objectID == UUID.Zero) return; |
9101 | 9472 | ||
9102 | UUID agentID; | 9473 | UUID agentID; |
9103 | lock (m_host.TaskInventory) | 9474 | m_host.TaskInventory.LockItemsForRead(true); |
9104 | { | 9475 | // we need the permission first, to know which avatar we want to set the camera for |
9105 | // we need the permission first, to know which avatar we want to set the camera for | 9476 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9106 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9107 | 9477 | ||
9108 | if (agentID == UUID.Zero) return; | 9478 | if (agentID == UUID.Zero) |
9109 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9479 | { |
9480 | m_host.TaskInventory.LockItemsForRead(false); | ||
9481 | return; | ||
9482 | } | ||
9483 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9484 | { | ||
9485 | m_host.TaskInventory.LockItemsForRead(false); | ||
9486 | return; | ||
9110 | } | 9487 | } |
9488 | m_host.TaskInventory.LockItemsForRead(false); | ||
9111 | 9489 | ||
9112 | ScenePresence presence = World.GetScenePresence(agentID); | 9490 | ScenePresence presence = World.GetScenePresence(agentID); |
9113 | 9491 | ||
@@ -9157,12 +9535,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9157 | 9535 | ||
9158 | // we need the permission first, to know which avatar we want to clear the camera for | 9536 | // we need the permission first, to know which avatar we want to clear the camera for |
9159 | UUID agentID; | 9537 | UUID agentID; |
9160 | lock (m_host.TaskInventory) | 9538 | m_host.TaskInventory.LockItemsForRead(true); |
9539 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9540 | if (agentID == UUID.Zero) | ||
9161 | { | 9541 | { |
9162 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9542 | m_host.TaskInventory.LockItemsForRead(false); |
9163 | if (agentID == UUID.Zero) return; | 9543 | return; |
9164 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9165 | } | 9544 | } |
9545 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9546 | { | ||
9547 | m_host.TaskInventory.LockItemsForRead(false); | ||
9548 | return; | ||
9549 | } | ||
9550 | m_host.TaskInventory.LockItemsForRead(false); | ||
9166 | 9551 | ||
9167 | ScenePresence presence = World.GetScenePresence(agentID); | 9552 | ScenePresence presence = World.GetScenePresence(agentID); |
9168 | 9553 | ||
@@ -9619,15 +10004,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9619 | 10004 | ||
9620 | internal UUID ScriptByName(string name) | 10005 | internal UUID ScriptByName(string name) |
9621 | { | 10006 | { |
9622 | lock (m_host.TaskInventory) | 10007 | m_host.TaskInventory.LockItemsForRead(true); |
10008 | |||
10009 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9623 | { | 10010 | { |
9624 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10011 | if (item.Type == 10 && item.Name == name) |
9625 | { | 10012 | { |
9626 | if (item.Type == 10 && item.Name == name) | 10013 | m_host.TaskInventory.LockItemsForRead(false); |
9627 | return item.ItemID; | 10014 | return item.ItemID; |
9628 | } | 10015 | } |
9629 | } | 10016 | } |
9630 | 10017 | ||
10018 | m_host.TaskInventory.LockItemsForRead(false); | ||
10019 | |||
9631 | return UUID.Zero; | 10020 | return UUID.Zero; |
9632 | } | 10021 | } |
9633 | 10022 | ||
@@ -9668,6 +10057,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9668 | { | 10057 | { |
9669 | m_host.AddScriptLPS(1); | 10058 | m_host.AddScriptLPS(1); |
9670 | 10059 | ||
10060 | //Clone is thread safe | ||
9671 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10061 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9672 | 10062 | ||
9673 | UUID assetID = UUID.Zero; | 10063 | UUID assetID = UUID.Zero; |
@@ -9730,6 +10120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9730 | { | 10120 | { |
9731 | m_host.AddScriptLPS(1); | 10121 | m_host.AddScriptLPS(1); |
9732 | 10122 | ||
10123 | //Clone is thread safe | ||
9733 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10124 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9734 | 10125 | ||
9735 | UUID assetID = UUID.Zero; | 10126 | 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 7e68cc7..9474bab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -719,18 +719,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
719 | if (target != null) | 719 | if (target != null) |
720 | { | 720 | { |
721 | UUID animID=UUID.Zero; | 721 | UUID animID=UUID.Zero; |
722 | lock (m_host.TaskInventory) | 722 | m_host.TaskInventory.LockItemsForRead(true); |
723 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
723 | { | 724 | { |
724 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 725 | if (inv.Value.Name == animation) |
725 | { | 726 | { |
726 | if (inv.Value.Name == animation) | 727 | if (inv.Value.Type == (int)AssetType.Animation) |
727 | { | 728 | animID = inv.Value.AssetID; |
728 | if (inv.Value.Type == (int)AssetType.Animation) | 729 | continue; |
729 | animID = inv.Value.AssetID; | ||
730 | continue; | ||
731 | } | ||
732 | } | 730 | } |
733 | } | 731 | } |
732 | m_host.TaskInventory.LockItemsForRead(false); | ||
734 | if (animID == UUID.Zero) | 733 | if (animID == UUID.Zero) |
735 | target.Animator.AddAnimation(animation, m_host.UUID); | 734 | target.Animator.AddAnimation(animation, m_host.UUID); |
736 | else | 735 | else |
@@ -752,18 +751,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
752 | if (target != null) | 751 | if (target != null) |
753 | { | 752 | { |
754 | UUID animID=UUID.Zero; | 753 | UUID animID=UUID.Zero; |
755 | lock (m_host.TaskInventory) | 754 | m_host.TaskInventory.LockItemsForRead(true); |
755 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
756 | { | 756 | { |
757 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 757 | if (inv.Value.Name == animation) |
758 | { | 758 | { |
759 | if (inv.Value.Name == animation) | 759 | if (inv.Value.Type == (int)AssetType.Animation) |
760 | { | 760 | animID = inv.Value.AssetID; |
761 | if (inv.Value.Type == (int)AssetType.Animation) | 761 | continue; |
762 | animID = inv.Value.AssetID; | ||
763 | continue; | ||
764 | } | ||
765 | } | 762 | } |
766 | } | 763 | } |
764 | m_host.TaskInventory.LockItemsForRead(false); | ||
767 | 765 | ||
768 | if (animID == UUID.Zero) | 766 | if (animID == UUID.Zero) |
769 | target.Animator.RemoveAnimation(animation); | 767 | target.Animator.RemoveAnimation(animation); |
@@ -1532,6 +1530,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1532 | 1530 | ||
1533 | if (!UUID.TryParse(name, out assetID)) | 1531 | if (!UUID.TryParse(name, out assetID)) |
1534 | { | 1532 | { |
1533 | m_host.TaskInventory.LockItemsForRead(true); | ||
1535 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1534 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1536 | { | 1535 | { |
1537 | if (item.Type == 7 && item.Name == name) | 1536 | if (item.Type == 7 && item.Name == name) |
@@ -1539,6 +1538,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1539 | assetID = item.AssetID; | 1538 | assetID = item.AssetID; |
1540 | } | 1539 | } |
1541 | } | 1540 | } |
1541 | m_host.TaskInventory.LockItemsForRead(false); | ||
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | if (assetID == UUID.Zero) | 1544 | if (assetID == UUID.Zero) |
@@ -1585,6 +1585,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1585 | 1585 | ||
1586 | if (!UUID.TryParse(name, out assetID)) | 1586 | if (!UUID.TryParse(name, out assetID)) |
1587 | { | 1587 | { |
1588 | m_host.TaskInventory.LockItemsForRead(true); | ||
1588 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1589 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1589 | { | 1590 | { |
1590 | if (item.Type == 7 && item.Name == name) | 1591 | if (item.Type == 7 && item.Name == name) |
@@ -1592,6 +1593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1592 | assetID = item.AssetID; | 1593 | assetID = item.AssetID; |
1593 | } | 1594 | } |
1594 | } | 1595 | } |
1596 | m_host.TaskInventory.LockItemsForRead(false); | ||
1595 | } | 1597 | } |
1596 | 1598 | ||
1597 | if (assetID == UUID.Zero) | 1599 | if (assetID == UUID.Zero) |
@@ -1642,6 +1644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1642 | 1644 | ||
1643 | if (!UUID.TryParse(name, out assetID)) | 1645 | if (!UUID.TryParse(name, out assetID)) |
1644 | { | 1646 | { |
1647 | m_host.TaskInventory.LockItemsForRead(true); | ||
1645 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1648 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1646 | { | 1649 | { |
1647 | if (item.Type == 7 && item.Name == name) | 1650 | if (item.Type == 7 && item.Name == name) |
@@ -1649,6 +1652,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1649 | assetID = item.AssetID; | 1652 | assetID = item.AssetID; |
1650 | } | 1653 | } |
1651 | } | 1654 | } |
1655 | m_host.TaskInventory.LockItemsForRead(false); | ||
1652 | } | 1656 | } |
1653 | 1657 | ||
1654 | if (assetID == UUID.Zero) | 1658 | 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 4d7ead6..d354fde 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); |
@@ -472,6 +483,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
472 | sensedEntities.Add(new SensedEntity(dis, presence.UUID)); | 483 | sensedEntities.Add(new SensedEntity(dis, presence.UUID)); |
473 | } | 484 | } |
474 | } | 485 | } |
486 | else | ||
487 | { | ||
488 | // If full circle is asked for, just add it | ||
489 | sensedEntities.Add(new SensedEntity(dis, presence.UUID)); | ||
490 | } | ||
475 | } | 491 | } |
476 | }); | 492 | }); |
477 | 493 | ||
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/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs index f13b6e5..fba27f9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -44,5 +44,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
44 | LSL_List cmGetWindlightScene(LSL_List rules); | 44 | LSL_List cmGetWindlightScene(LSL_List rules); |
45 | int cmSetWindlightScene(LSL_List rules); | 45 | int cmSetWindlightScene(LSL_List rules); |
46 | int cmSetWindlightSceneTargeted(LSL_List rules, key target); | 46 | int cmSetWindlightSceneTargeted(LSL_List rules, key target); |
47 | LSL_List cmGetAvatarList(); | ||
47 | } | 48 | } |
48 | } | 49 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 60b8050..f5921e1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
80 | // Avatar Info Commands | 80 | // Avatar Info Commands |
81 | string osGetAgentIP(string agent); | 81 | string osGetAgentIP(string agent); |
82 | LSL_List osGetAgents(); | 82 | LSL_List osGetAgents(); |
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | 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/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs index c0edaae..aaffbe4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -72,5 +72,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
72 | { | 72 | { |
73 | return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); | 73 | return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); |
74 | } | 74 | } |
75 | public LSL_List cmGetAvatarList() | ||
76 | { | ||
77 | return m_CM_Functions.cmGetAvatarList(); | ||
78 | } | ||
75 | } | 79 | } |
76 | } | 80 | } |
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/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; |