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 b2eb585..6ab3c62 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) |
@@ -3936,6 +4160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3936 | { | 4160 | { |
3937 | m_host.AddScriptLPS(1); | 4161 | m_host.AddScriptLPS(1); |
3938 | 4162 | ||
4163 | //Clone is thread safe | ||
3939 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4164 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3940 | 4165 | ||
3941 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4166 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3989,6 +4214,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3989 | ScenePresence presence = World.GetScenePresence(agentId); | 4214 | ScenePresence presence = World.GetScenePresence(agentId); |
3990 | if (presence != null) | 4215 | if (presence != null) |
3991 | { | 4216 | { |
4217 | // agent must not be a god | ||
4218 | if (presence.GodLevel >= 200) return; | ||
4219 | |||
3992 | // agent must be over the owners land | 4220 | // agent must be over the owners land |
3993 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4221 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
3994 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4222 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4049,17 +4277,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4049 | UUID soundId = UUID.Zero; | 4277 | UUID soundId = UUID.Zero; |
4050 | if (!UUID.TryParse(impact_sound, out soundId)) | 4278 | if (!UUID.TryParse(impact_sound, out soundId)) |
4051 | { | 4279 | { |
4052 | lock (m_host.TaskInventory) | 4280 | m_host.TaskInventory.LockItemsForRead(true); |
4281 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4053 | { | 4282 | { |
4054 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4283 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4055 | { | 4284 | { |
4056 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4285 | soundId = item.AssetID; |
4057 | { | 4286 | break; |
4058 | soundId = item.AssetID; | ||
4059 | break; | ||
4060 | } | ||
4061 | } | 4287 | } |
4062 | } | 4288 | } |
4289 | m_host.TaskInventory.LockItemsForRead(false); | ||
4063 | } | 4290 | } |
4064 | m_host.CollisionSound = soundId; | 4291 | m_host.CollisionSound = soundId; |
4065 | m_host.CollisionSoundVolume = (float)impact_volume; | 4292 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4105,6 +4332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4105 | UUID partItemID; | 4332 | UUID partItemID; |
4106 | foreach (SceneObjectPart part in parts) | 4333 | foreach (SceneObjectPart part in parts) |
4107 | { | 4334 | { |
4335 | //Clone is thread safe | ||
4108 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4336 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4109 | 4337 | ||
4110 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4338 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4319,17 +4547,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4319 | 4547 | ||
4320 | m_host.AddScriptLPS(1); | 4548 | m_host.AddScriptLPS(1); |
4321 | 4549 | ||
4322 | lock (m_host.TaskInventory) | 4550 | m_host.TaskInventory.LockItemsForRead(true); |
4551 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4323 | { | 4552 | { |
4324 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4553 | if (item.Type == 10 && item.ItemID == m_itemID) |
4325 | { | 4554 | { |
4326 | if (item.Type == 10 && item.ItemID == m_itemID) | 4555 | result = item.Name!=null?item.Name:String.Empty; |
4327 | { | 4556 | break; |
4328 | result = item.Name != null ? item.Name : String.Empty; | ||
4329 | break; | ||
4330 | } | ||
4331 | } | 4557 | } |
4332 | } | 4558 | } |
4559 | m_host.TaskInventory.LockItemsForRead(false); | ||
4333 | 4560 | ||
4334 | return result; | 4561 | return result; |
4335 | } | 4562 | } |
@@ -4482,23 +4709,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4482 | { | 4709 | { |
4483 | m_host.AddScriptLPS(1); | 4710 | m_host.AddScriptLPS(1); |
4484 | 4711 | ||
4485 | lock (m_host.TaskInventory) | 4712 | m_host.TaskInventory.LockItemsForRead(true); |
4713 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4486 | { | 4714 | { |
4487 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4715 | if (inv.Value.Name == name) |
4488 | { | 4716 | { |
4489 | if (inv.Value.Name == name) | 4717 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4490 | { | 4718 | { |
4491 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4719 | m_host.TaskInventory.LockItemsForRead(false); |
4492 | { | 4720 | return inv.Value.AssetID.ToString(); |
4493 | return inv.Value.AssetID.ToString(); | 4721 | } |
4494 | } | 4722 | else |
4495 | else | 4723 | { |
4496 | { | 4724 | m_host.TaskInventory.LockItemsForRead(false); |
4497 | return UUID.Zero.ToString(); | 4725 | return UUID.Zero.ToString(); |
4498 | } | ||
4499 | } | 4726 | } |
4500 | } | 4727 | } |
4501 | } | 4728 | } |
4729 | m_host.TaskInventory.LockItemsForRead(false); | ||
4502 | 4730 | ||
4503 | return UUID.Zero.ToString(); | 4731 | return UUID.Zero.ToString(); |
4504 | } | 4732 | } |
@@ -6013,6 +6241,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6013 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6241 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6014 | prules.OuterAngle = (float)tempf; | 6242 | prules.OuterAngle = (float)tempf; |
6015 | break; | 6243 | break; |
6244 | |||
6245 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6246 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6247 | prules.InnerAngle = (float)tempf; | ||
6248 | break; | ||
6249 | |||
6250 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6251 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6252 | prules.OuterAngle = (float)tempf; | ||
6253 | break; | ||
6016 | } | 6254 | } |
6017 | 6255 | ||
6018 | } | 6256 | } |
@@ -6051,14 +6289,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6051 | 6289 | ||
6052 | protected UUID GetTaskInventoryItem(string name) | 6290 | protected UUID GetTaskInventoryItem(string name) |
6053 | { | 6291 | { |
6054 | lock (m_host.TaskInventory) | 6292 | m_host.TaskInventory.LockItemsForRead(true); |
6293 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6055 | { | 6294 | { |
6056 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6295 | if (inv.Value.Name == name) |
6057 | { | 6296 | { |
6058 | if (inv.Value.Name == name) | 6297 | m_host.TaskInventory.LockItemsForRead(false); |
6059 | return inv.Key; | 6298 | return inv.Key; |
6060 | } | 6299 | } |
6061 | } | 6300 | } |
6301 | m_host.TaskInventory.LockItemsForRead(false); | ||
6062 | 6302 | ||
6063 | return UUID.Zero; | 6303 | return UUID.Zero; |
6064 | } | 6304 | } |
@@ -6386,22 +6626,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6386 | } | 6626 | } |
6387 | 6627 | ||
6388 | // copy the first script found with this inventory name | 6628 | // copy the first script found with this inventory name |
6389 | lock (m_host.TaskInventory) | 6629 | m_host.TaskInventory.LockItemsForRead(true); |
6630 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6390 | { | 6631 | { |
6391 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6632 | if (inv.Value.Name == name) |
6392 | { | 6633 | { |
6393 | if (inv.Value.Name == name) | 6634 | // make sure the object is a script |
6635 | if (10 == inv.Value.Type) | ||
6394 | { | 6636 | { |
6395 | // make sure the object is a script | 6637 | found = true; |
6396 | if (10 == inv.Value.Type) | 6638 | srcId = inv.Key; |
6397 | { | 6639 | break; |
6398 | found = true; | ||
6399 | srcId = inv.Key; | ||
6400 | break; | ||
6401 | } | ||
6402 | } | 6640 | } |
6403 | } | 6641 | } |
6404 | } | 6642 | } |
6643 | m_host.TaskInventory.LockItemsForRead(false); | ||
6405 | 6644 | ||
6406 | if (!found) | 6645 | if (!found) |
6407 | { | 6646 | { |
@@ -6485,6 +6724,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6485 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6724 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6486 | { | 6725 | { |
6487 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6726 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6727 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6728 | return shapeBlock; | ||
6488 | 6729 | ||
6489 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6730 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6490 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6731 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6555,6 +6796,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6555 | 6796 | ||
6556 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6797 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6557 | { | 6798 | { |
6799 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6800 | return; | ||
6801 | |||
6558 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6802 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6559 | 6803 | ||
6560 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6804 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6604,6 +6848,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6604 | 6848 | ||
6605 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6849 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6606 | { | 6850 | { |
6851 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6852 | return; | ||
6853 | |||
6607 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6854 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6608 | 6855 | ||
6609 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6856 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6646,6 +6893,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6646 | 6893 | ||
6647 | 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) | 6894 | 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) |
6648 | { | 6895 | { |
6896 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6897 | return; | ||
6898 | |||
6649 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6899 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6650 | 6900 | ||
6651 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6901 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6767,6 +7017,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6767 | 7017 | ||
6768 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7018 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6769 | { | 7019 | { |
7020 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7021 | return; | ||
7022 | |||
6770 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7023 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6771 | UUID sculptId; | 7024 | UUID sculptId; |
6772 | 7025 | ||
@@ -6807,7 +7060,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6807 | 7060 | ||
6808 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7061 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6809 | { | 7062 | { |
6810 | m_host.AddScriptLPS(1); | 7063 | m_host.AddScriptLPS(1); |
6811 | 7064 | ||
6812 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7065 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6813 | 7066 | ||
@@ -6822,6 +7075,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6822 | 7075 | ||
6823 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7076 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6824 | { | 7077 | { |
7078 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7079 | return; | ||
7080 | |||
6825 | int idx = 0; | 7081 | int idx = 0; |
6826 | 7082 | ||
6827 | while (idx < rules.Length) | 7083 | while (idx < rules.Length) |
@@ -7653,24 +7909,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7653 | break; | 7909 | break; |
7654 | 7910 | ||
7655 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7911 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7656 | // TODO-------------- | ||
7657 | if (remain < 1) | 7912 | if (remain < 1) |
7658 | return res; | 7913 | return res; |
7914 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7659 | 7915 | ||
7660 | face=(int)rules.GetLSLIntegerItem(idx++); | 7916 | tex = part.Shape.Textures; |
7661 | 7917 | int shiny; | |
7662 | res.Add(new LSL_Integer(0)); | 7918 | if (face == ScriptBaseClass.ALL_SIDES) |
7663 | res.Add(new LSL_Integer(0)); | 7919 | { |
7920 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7921 | { | ||
7922 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7923 | if (shinyness == Shininess.High) | ||
7924 | { | ||
7925 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7926 | } | ||
7927 | else if (shinyness == Shininess.Medium) | ||
7928 | { | ||
7929 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7930 | } | ||
7931 | else if (shinyness == Shininess.Low) | ||
7932 | { | ||
7933 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7934 | } | ||
7935 | else | ||
7936 | { | ||
7937 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7938 | } | ||
7939 | res.Add(new LSL_Integer(shiny)); | ||
7940 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7941 | } | ||
7942 | } | ||
7943 | else | ||
7944 | { | ||
7945 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7946 | if (shinyness == Shininess.High) | ||
7947 | { | ||
7948 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7949 | } | ||
7950 | else if (shinyness == Shininess.Medium) | ||
7951 | { | ||
7952 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7953 | } | ||
7954 | else if (shinyness == Shininess.Low) | ||
7955 | { | ||
7956 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7957 | } | ||
7958 | else | ||
7959 | { | ||
7960 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7961 | } | ||
7962 | res.Add(new LSL_Integer(shiny)); | ||
7963 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7964 | } | ||
7664 | break; | 7965 | break; |
7665 | 7966 | ||
7666 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7967 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7667 | // TODO-------------- | ||
7668 | if (remain < 1) | 7968 | if (remain < 1) |
7669 | return res; | 7969 | return res; |
7970 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7670 | 7971 | ||
7671 | face=(int)rules.GetLSLIntegerItem(idx++); | 7972 | tex = part.Shape.Textures; |
7672 | 7973 | int fullbright; | |
7673 | res.Add(new LSL_Integer(0)); | 7974 | if (face == ScriptBaseClass.ALL_SIDES) |
7975 | { | ||
7976 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7977 | { | ||
7978 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7979 | { | ||
7980 | fullbright = ScriptBaseClass.TRUE; | ||
7981 | } | ||
7982 | else | ||
7983 | { | ||
7984 | fullbright = ScriptBaseClass.FALSE; | ||
7985 | } | ||
7986 | res.Add(new LSL_Integer(fullbright)); | ||
7987 | } | ||
7988 | } | ||
7989 | else | ||
7990 | { | ||
7991 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7992 | { | ||
7993 | fullbright = ScriptBaseClass.TRUE; | ||
7994 | } | ||
7995 | else | ||
7996 | { | ||
7997 | fullbright = ScriptBaseClass.FALSE; | ||
7998 | } | ||
7999 | res.Add(new LSL_Integer(fullbright)); | ||
8000 | } | ||
7674 | break; | 8001 | break; |
7675 | 8002 | ||
7676 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8003 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7691,14 +8018,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7691 | break; | 8018 | break; |
7692 | 8019 | ||
7693 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8020 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7694 | // TODO-------------- | ||
7695 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8021 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7696 | if (remain < 1) | 8022 | if (remain < 1) |
7697 | return res; | 8023 | return res; |
8024 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7698 | 8025 | ||
7699 | face=(int)rules.GetLSLIntegerItem(idx++); | 8026 | tex = part.Shape.Textures; |
7700 | 8027 | if (face == ScriptBaseClass.ALL_SIDES) | |
7701 | res.Add(new LSL_Integer(0)); | 8028 | { |
8029 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8030 | { | ||
8031 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8032 | { | ||
8033 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8034 | } | ||
8035 | else | ||
8036 | { | ||
8037 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8038 | } | ||
8039 | } | ||
8040 | } | ||
8041 | else | ||
8042 | { | ||
8043 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8044 | { | ||
8045 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8046 | } | ||
8047 | else | ||
8048 | { | ||
8049 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8050 | } | ||
8051 | } | ||
7702 | break; | 8052 | break; |
7703 | 8053 | ||
7704 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8054 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7717,13 +8067,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7717 | break; | 8067 | break; |
7718 | 8068 | ||
7719 | case (int)ScriptBaseClass.PRIM_GLOW: | 8069 | case (int)ScriptBaseClass.PRIM_GLOW: |
7720 | // TODO-------------- | ||
7721 | if (remain < 1) | 8070 | if (remain < 1) |
7722 | return res; | 8071 | return res; |
8072 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7723 | 8073 | ||
7724 | face=(int)rules.GetLSLIntegerItem(idx++); | 8074 | tex = part.Shape.Textures; |
7725 | 8075 | float primglow; | |
7726 | res.Add(new LSL_Float(0)); | 8076 | if (face == ScriptBaseClass.ALL_SIDES) |
8077 | { | ||
8078 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8079 | { | ||
8080 | primglow = tex.GetFace((uint)face).Glow; | ||
8081 | res.Add(new LSL_Float(primglow)); | ||
8082 | } | ||
8083 | } | ||
8084 | else | ||
8085 | { | ||
8086 | primglow = tex.GetFace((uint)face).Glow; | ||
8087 | res.Add(new LSL_Float(primglow)); | ||
8088 | } | ||
7727 | break; | 8089 | break; |
7728 | case (int)ScriptBaseClass.PRIM_TEXT: | 8090 | case (int)ScriptBaseClass.PRIM_TEXT: |
7729 | Color4 textColor = part.GetTextColor(); | 8091 | Color4 textColor = part.GetTextColor(); |
@@ -8260,28 +8622,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8260 | { | 8622 | { |
8261 | m_host.AddScriptLPS(1); | 8623 | m_host.AddScriptLPS(1); |
8262 | 8624 | ||
8263 | lock (m_host.TaskInventory) | 8625 | m_host.TaskInventory.LockItemsForRead(true); |
8626 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8264 | { | 8627 | { |
8265 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8628 | if (inv.Value.Name == item) |
8266 | { | 8629 | { |
8267 | if (inv.Value.Name == item) | 8630 | m_host.TaskInventory.LockItemsForRead(false); |
8631 | switch (mask) | ||
8268 | { | 8632 | { |
8269 | switch (mask) | 8633 | case 0: |
8270 | { | 8634 | return (int)inv.Value.BasePermissions; |
8271 | case 0: | 8635 | case 1: |
8272 | return (int)inv.Value.BasePermissions; | 8636 | return (int)inv.Value.CurrentPermissions; |
8273 | case 1: | 8637 | case 2: |
8274 | return (int)inv.Value.CurrentPermissions; | 8638 | return (int)inv.Value.GroupPermissions; |
8275 | case 2: | 8639 | case 3: |
8276 | return (int)inv.Value.GroupPermissions; | 8640 | return (int)inv.Value.EveryonePermissions; |
8277 | case 3: | 8641 | case 4: |
8278 | return (int)inv.Value.EveryonePermissions; | 8642 | return (int)inv.Value.NextPermissions; |
8279 | case 4: | ||
8280 | return (int)inv.Value.NextPermissions; | ||
8281 | } | ||
8282 | } | 8643 | } |
8283 | } | 8644 | } |
8284 | } | 8645 | } |
8646 | m_host.TaskInventory.LockItemsForRead(false); | ||
8285 | 8647 | ||
8286 | return -1; | 8648 | return -1; |
8287 | } | 8649 | } |
@@ -8328,16 +8690,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8328 | { | 8690 | { |
8329 | m_host.AddScriptLPS(1); | 8691 | m_host.AddScriptLPS(1); |
8330 | 8692 | ||
8331 | lock (m_host.TaskInventory) | 8693 | m_host.TaskInventory.LockItemsForRead(true); |
8694 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8332 | { | 8695 | { |
8333 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8696 | if (inv.Value.Name == item) |
8334 | { | 8697 | { |
8335 | if (inv.Value.Name == item) | 8698 | m_host.TaskInventory.LockItemsForRead(false); |
8336 | { | 8699 | return inv.Value.CreatorID.ToString(); |
8337 | return inv.Value.CreatorID.ToString(); | ||
8338 | } | ||
8339 | } | 8700 | } |
8340 | } | 8701 | } |
8702 | m_host.TaskInventory.LockItemsForRead(false); | ||
8341 | 8703 | ||
8342 | llSay(0, "No item name '" + item + "'"); | 8704 | llSay(0, "No item name '" + item + "'"); |
8343 | 8705 | ||
@@ -8870,16 +9232,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8870 | { | 9232 | { |
8871 | m_host.AddScriptLPS(1); | 9233 | m_host.AddScriptLPS(1); |
8872 | 9234 | ||
8873 | lock (m_host.TaskInventory) | 9235 | m_host.TaskInventory.LockItemsForRead(true); |
9236 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8874 | { | 9237 | { |
8875 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9238 | if (inv.Value.Name == name) |
8876 | { | 9239 | { |
8877 | if (inv.Value.Name == name) | 9240 | m_host.TaskInventory.LockItemsForRead(false); |
8878 | { | 9241 | return inv.Value.Type; |
8879 | return inv.Value.Type; | ||
8880 | } | ||
8881 | } | 9242 | } |
8882 | } | 9243 | } |
9244 | m_host.TaskInventory.LockItemsForRead(false); | ||
8883 | 9245 | ||
8884 | return -1; | 9246 | return -1; |
8885 | } | 9247 | } |
@@ -8890,15 +9252,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8890 | 9252 | ||
8891 | if (quick_pay_buttons.Data.Length < 4) | 9253 | if (quick_pay_buttons.Data.Length < 4) |
8892 | { | 9254 | { |
8893 | LSLError("List must have at least 4 elements"); | 9255 | int x; |
8894 | return; | 9256 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9257 | { | ||
9258 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9259 | } | ||
8895 | } | 9260 | } |
8896 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9261 | int[] nPrice = new int[5]; |
8897 | 9262 | nPrice[0]=price; | |
8898 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9263 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8899 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9264 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8900 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9265 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8901 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9266 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9267 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8902 | m_host.ParentGroup.HasGroupChanged = true; | 9268 | m_host.ParentGroup.HasGroupChanged = true; |
8903 | } | 9269 | } |
8904 | 9270 | ||
@@ -8910,17 +9276,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8910 | if (invItemID == UUID.Zero) | 9276 | if (invItemID == UUID.Zero) |
8911 | return new LSL_Vector(); | 9277 | return new LSL_Vector(); |
8912 | 9278 | ||
8913 | lock (m_host.TaskInventory) | 9279 | m_host.TaskInventory.LockItemsForRead(true); |
9280 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8914 | { | 9281 | { |
8915 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9282 | m_host.TaskInventory.LockItemsForRead(false); |
8916 | return new LSL_Vector(); | 9283 | return new LSL_Vector(); |
9284 | } | ||
8917 | 9285 | ||
8918 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9286 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8919 | { | 9287 | { |
8920 | ShoutError("No permissions to track the camera"); | 9288 | ShoutError("No permissions to track the camera"); |
8921 | return new LSL_Vector(); | 9289 | m_host.TaskInventory.LockItemsForRead(false); |
8922 | } | 9290 | return new LSL_Vector(); |
8923 | } | 9291 | } |
9292 | m_host.TaskInventory.LockItemsForRead(false); | ||
8924 | 9293 | ||
8925 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9294 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8926 | if (presence != null) | 9295 | if (presence != null) |
@@ -8938,17 +9307,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8938 | if (invItemID == UUID.Zero) | 9307 | if (invItemID == UUID.Zero) |
8939 | return new LSL_Rotation(); | 9308 | return new LSL_Rotation(); |
8940 | 9309 | ||
8941 | lock (m_host.TaskInventory) | 9310 | m_host.TaskInventory.LockItemsForRead(true); |
9311 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8942 | { | 9312 | { |
8943 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9313 | m_host.TaskInventory.LockItemsForRead(false); |
8944 | return new LSL_Rotation(); | 9314 | return new LSL_Rotation(); |
8945 | 9315 | } | |
8946 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9316 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8947 | { | 9317 | { |
8948 | ShoutError("No permissions to track the camera"); | 9318 | ShoutError("No permissions to track the camera"); |
8949 | return new LSL_Rotation(); | 9319 | m_host.TaskInventory.LockItemsForRead(false); |
8950 | } | 9320 | return new LSL_Rotation(); |
8951 | } | 9321 | } |
9322 | m_host.TaskInventory.LockItemsForRead(false); | ||
8952 | 9323 | ||
8953 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9324 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8954 | if (presence != null) | 9325 | if (presence != null) |
@@ -9098,14 +9469,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9098 | if (objectID == UUID.Zero) return; | 9469 | if (objectID == UUID.Zero) return; |
9099 | 9470 | ||
9100 | UUID agentID; | 9471 | UUID agentID; |
9101 | lock (m_host.TaskInventory) | 9472 | m_host.TaskInventory.LockItemsForRead(true); |
9102 | { | 9473 | // we need the permission first, to know which avatar we want to set the camera for |
9103 | // we need the permission first, to know which avatar we want to set the camera for | 9474 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9104 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9105 | 9475 | ||
9106 | if (agentID == UUID.Zero) return; | 9476 | if (agentID == UUID.Zero) |
9107 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9477 | { |
9478 | m_host.TaskInventory.LockItemsForRead(false); | ||
9479 | return; | ||
9480 | } | ||
9481 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9482 | { | ||
9483 | m_host.TaskInventory.LockItemsForRead(false); | ||
9484 | return; | ||
9108 | } | 9485 | } |
9486 | m_host.TaskInventory.LockItemsForRead(false); | ||
9109 | 9487 | ||
9110 | ScenePresence presence = World.GetScenePresence(agentID); | 9488 | ScenePresence presence = World.GetScenePresence(agentID); |
9111 | 9489 | ||
@@ -9155,12 +9533,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9155 | 9533 | ||
9156 | // we need the permission first, to know which avatar we want to clear the camera for | 9534 | // we need the permission first, to know which avatar we want to clear the camera for |
9157 | UUID agentID; | 9535 | UUID agentID; |
9158 | lock (m_host.TaskInventory) | 9536 | m_host.TaskInventory.LockItemsForRead(true); |
9537 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9538 | if (agentID == UUID.Zero) | ||
9159 | { | 9539 | { |
9160 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9540 | m_host.TaskInventory.LockItemsForRead(false); |
9161 | if (agentID == UUID.Zero) return; | 9541 | return; |
9162 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9163 | } | 9542 | } |
9543 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9544 | { | ||
9545 | m_host.TaskInventory.LockItemsForRead(false); | ||
9546 | return; | ||
9547 | } | ||
9548 | m_host.TaskInventory.LockItemsForRead(false); | ||
9164 | 9549 | ||
9165 | ScenePresence presence = World.GetScenePresence(agentID); | 9550 | ScenePresence presence = World.GetScenePresence(agentID); |
9166 | 9551 | ||
@@ -9617,15 +10002,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9617 | 10002 | ||
9618 | internal UUID ScriptByName(string name) | 10003 | internal UUID ScriptByName(string name) |
9619 | { | 10004 | { |
9620 | lock (m_host.TaskInventory) | 10005 | m_host.TaskInventory.LockItemsForRead(true); |
10006 | |||
10007 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9621 | { | 10008 | { |
9622 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10009 | if (item.Type == 10 && item.Name == name) |
9623 | { | 10010 | { |
9624 | if (item.Type == 10 && item.Name == name) | 10011 | m_host.TaskInventory.LockItemsForRead(false); |
9625 | return item.ItemID; | 10012 | return item.ItemID; |
9626 | } | 10013 | } |
9627 | } | 10014 | } |
9628 | 10015 | ||
10016 | m_host.TaskInventory.LockItemsForRead(false); | ||
10017 | |||
9629 | return UUID.Zero; | 10018 | return UUID.Zero; |
9630 | } | 10019 | } |
9631 | 10020 | ||
@@ -9666,6 +10055,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9666 | { | 10055 | { |
9667 | m_host.AddScriptLPS(1); | 10056 | m_host.AddScriptLPS(1); |
9668 | 10057 | ||
10058 | //Clone is thread safe | ||
9669 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10059 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9670 | 10060 | ||
9671 | UUID assetID = UUID.Zero; | 10061 | UUID assetID = UUID.Zero; |
@@ -9728,6 +10118,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9728 | { | 10118 | { |
9729 | m_host.AddScriptLPS(1); | 10119 | m_host.AddScriptLPS(1); |
9730 | 10120 | ||
10121 | //Clone is thread safe | ||
9731 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10122 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9732 | 10123 | ||
9733 | UUID assetID = UUID.Zero; | 10124 | 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; |