diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
13 files changed, 995 insertions, 491 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 3ccbb3a..228e9b8 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 | ||
@@ -1978,6 +2121,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1978 | 2121 | ||
1979 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2122 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1980 | { | 2123 | { |
2124 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2125 | return; | ||
2126 | |||
1981 | part.UpdateRotation(rot); | 2127 | part.UpdateRotation(rot); |
1982 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2128 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1983 | 2129 | ||
@@ -2597,12 +2743,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2597 | 2743 | ||
2598 | m_host.AddScriptLPS(1); | 2744 | m_host.AddScriptLPS(1); |
2599 | 2745 | ||
2746 | m_host.TaskInventory.LockItemsForRead(true); | ||
2600 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2747 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2601 | 2748 | m_host.TaskInventory.LockItemsForRead(false); | |
2602 | lock (m_host.TaskInventory) | ||
2603 | { | ||
2604 | item = m_host.TaskInventory[invItemID]; | ||
2605 | } | ||
2606 | 2749 | ||
2607 | if (item.PermsGranter == UUID.Zero) | 2750 | if (item.PermsGranter == UUID.Zero) |
2608 | return 0; | 2751 | return 0; |
@@ -2677,6 +2820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2677 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2820 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2678 | return; | 2821 | return; |
2679 | 2822 | ||
2823 | //Clone is thread-safe | ||
2680 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2824 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2681 | 2825 | ||
2682 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2826 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2737,6 +2881,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2737 | 2881 | ||
2738 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2882 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2739 | { | 2883 | { |
2884 | /* | ||
2740 | m_host.AddScriptLPS(1); | 2885 | m_host.AddScriptLPS(1); |
2741 | // Determine where we are looking from | 2886 | // Determine where we are looking from |
2742 | LSL_Vector from = llGetPos(); | 2887 | LSL_Vector from = llGetPos(); |
@@ -2756,10 +2901,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2756 | // the angles of rotation in radians into rotation value | 2901 | // the angles of rotation in radians into rotation value |
2757 | 2902 | ||
2758 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2903 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2759 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2904 | |
2760 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2905 | // This would only work if your physics system contains an APID controller: |
2906 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2907 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2908 | |||
2761 | // Orient the object to the angle calculated | 2909 | // Orient the object to the angle calculated |
2762 | //llSetRot(rot); | 2910 | llSetRot(rot); |
2911 | */ | ||
2912 | |||
2913 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2914 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2915 | // http://bugs.meta7.com/view.php?id=28 | ||
2916 | // - Tom | ||
2917 | |||
2918 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2919 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2920 | |||
2921 | } | ||
2922 | |||
2923 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2924 | { | ||
2925 | m_host.AddScriptLPS(1); | ||
2926 | // NotImplemented("llRotLookAt"); | ||
2927 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2928 | |||
2763 | } | 2929 | } |
2764 | 2930 | ||
2765 | public void llStopLookAt() | 2931 | public void llStopLookAt() |
@@ -2808,13 +2974,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2808 | { | 2974 | { |
2809 | TaskInventoryItem item; | 2975 | TaskInventoryItem item; |
2810 | 2976 | ||
2811 | lock (m_host.TaskInventory) | 2977 | m_host.TaskInventory.LockItemsForRead(true); |
2978 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2812 | { | 2979 | { |
2813 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2980 | m_host.TaskInventory.LockItemsForRead(false); |
2814 | return; | 2981 | return; |
2815 | else | ||
2816 | item = m_host.TaskInventory[InventorySelf()]; | ||
2817 | } | 2982 | } |
2983 | else | ||
2984 | { | ||
2985 | item = m_host.TaskInventory[InventorySelf()]; | ||
2986 | } | ||
2987 | m_host.TaskInventory.LockItemsForRead(false); | ||
2818 | 2988 | ||
2819 | if (item.PermsGranter != UUID.Zero) | 2989 | if (item.PermsGranter != UUID.Zero) |
2820 | { | 2990 | { |
@@ -2836,13 +3006,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2836 | { | 3006 | { |
2837 | TaskInventoryItem item; | 3007 | TaskInventoryItem item; |
2838 | 3008 | ||
3009 | m_host.TaskInventory.LockItemsForRead(true); | ||
2839 | lock (m_host.TaskInventory) | 3010 | lock (m_host.TaskInventory) |
2840 | { | 3011 | { |
3012 | |||
2841 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3013 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3014 | { | ||
3015 | m_host.TaskInventory.LockItemsForRead(false); | ||
2842 | return; | 3016 | return; |
3017 | } | ||
2843 | else | 3018 | else |
3019 | { | ||
2844 | item = m_host.TaskInventory[InventorySelf()]; | 3020 | item = m_host.TaskInventory[InventorySelf()]; |
3021 | } | ||
2845 | } | 3022 | } |
3023 | m_host.TaskInventory.LockItemsForRead(false); | ||
2846 | 3024 | ||
2847 | m_host.AddScriptLPS(1); | 3025 | m_host.AddScriptLPS(1); |
2848 | 3026 | ||
@@ -2879,14 +3057,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2879 | 3057 | ||
2880 | TaskInventoryItem item; | 3058 | TaskInventoryItem item; |
2881 | 3059 | ||
2882 | lock (m_host.TaskInventory) | 3060 | m_host.TaskInventory.LockItemsForRead(true); |
3061 | |||
3062 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2883 | { | 3063 | { |
2884 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3064 | m_host.TaskInventory.LockItemsForRead(false); |
2885 | return; | 3065 | return; |
2886 | else | 3066 | } |
2887 | item = m_host.TaskInventory[InventorySelf()]; | 3067 | else |
3068 | { | ||
3069 | item = m_host.TaskInventory[InventorySelf()]; | ||
2888 | } | 3070 | } |
2889 | 3071 | ||
3072 | m_host.TaskInventory.LockItemsForRead(false); | ||
3073 | |||
2890 | if (item.PermsGranter != m_host.OwnerID) | 3074 | if (item.PermsGranter != m_host.OwnerID) |
2891 | return; | 3075 | return; |
2892 | 3076 | ||
@@ -2913,13 +3097,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2913 | 3097 | ||
2914 | TaskInventoryItem item; | 3098 | TaskInventoryItem item; |
2915 | 3099 | ||
2916 | lock (m_host.TaskInventory) | 3100 | m_host.TaskInventory.LockItemsForRead(true); |
3101 | |||
3102 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2917 | { | 3103 | { |
2918 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3104 | m_host.TaskInventory.LockItemsForRead(false); |
2919 | return; | 3105 | return; |
2920 | else | ||
2921 | item = m_host.TaskInventory[InventorySelf()]; | ||
2922 | } | 3106 | } |
3107 | else | ||
3108 | { | ||
3109 | item = m_host.TaskInventory[InventorySelf()]; | ||
3110 | } | ||
3111 | m_host.TaskInventory.LockItemsForRead(false); | ||
3112 | |||
2923 | 3113 | ||
2924 | if (item.PermsGranter != m_host.OwnerID) | 3114 | if (item.PermsGranter != m_host.OwnerID) |
2925 | return; | 3115 | return; |
@@ -2956,8 +3146,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2956 | return m_host.OwnerID.ToString(); | 3146 | return m_host.OwnerID.ToString(); |
2957 | } | 3147 | } |
2958 | 3148 | ||
3149 | [DebuggerNonUserCode] | ||
2959 | public void llInstantMessage(string user, string message) | 3150 | public void llInstantMessage(string user, string message) |
2960 | { | 3151 | { |
3152 | UUID result; | ||
3153 | if (!UUID.TryParse(user, out result)) | ||
3154 | { | ||
3155 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3156 | return; | ||
3157 | } | ||
3158 | |||
3159 | |||
2961 | m_host.AddScriptLPS(1); | 3160 | m_host.AddScriptLPS(1); |
2962 | 3161 | ||
2963 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3162 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2972,7 +3171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2972 | UUID friendTransactionID = UUID.Random(); | 3171 | UUID friendTransactionID = UUID.Random(); |
2973 | 3172 | ||
2974 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3173 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2975 | 3174 | ||
2976 | GridInstantMessage msg = new GridInstantMessage(); | 3175 | GridInstantMessage msg = new GridInstantMessage(); |
2977 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3176 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2978 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3177 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3121,13 +3320,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3121 | m_host.AddScriptLPS(1); | 3320 | m_host.AddScriptLPS(1); |
3122 | } | 3321 | } |
3123 | 3322 | ||
3124 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3125 | { | ||
3126 | m_host.AddScriptLPS(1); | ||
3127 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3128 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3129 | } | ||
3130 | |||
3131 | public LSL_Integer llStringLength(string str) | 3323 | public LSL_Integer llStringLength(string str) |
3132 | { | 3324 | { |
3133 | m_host.AddScriptLPS(1); | 3325 | m_host.AddScriptLPS(1); |
@@ -3151,14 +3343,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3151 | 3343 | ||
3152 | TaskInventoryItem item; | 3344 | TaskInventoryItem item; |
3153 | 3345 | ||
3154 | lock (m_host.TaskInventory) | 3346 | m_host.TaskInventory.LockItemsForRead(true); |
3347 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3155 | { | 3348 | { |
3156 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3349 | m_host.TaskInventory.LockItemsForRead(false); |
3157 | return; | 3350 | return; |
3158 | else | ||
3159 | item = m_host.TaskInventory[InventorySelf()]; | ||
3160 | } | 3351 | } |
3161 | 3352 | else | |
3353 | { | ||
3354 | item = m_host.TaskInventory[InventorySelf()]; | ||
3355 | } | ||
3356 | m_host.TaskInventory.LockItemsForRead(false); | ||
3162 | if (item.PermsGranter == UUID.Zero) | 3357 | if (item.PermsGranter == UUID.Zero) |
3163 | return; | 3358 | return; |
3164 | 3359 | ||
@@ -3188,13 +3383,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3188 | 3383 | ||
3189 | TaskInventoryItem item; | 3384 | TaskInventoryItem item; |
3190 | 3385 | ||
3191 | lock (m_host.TaskInventory) | 3386 | m_host.TaskInventory.LockItemsForRead(true); |
3387 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3192 | { | 3388 | { |
3193 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3389 | m_host.TaskInventory.LockItemsForRead(false); |
3194 | return; | 3390 | return; |
3195 | else | ||
3196 | item = m_host.TaskInventory[InventorySelf()]; | ||
3197 | } | 3391 | } |
3392 | else | ||
3393 | { | ||
3394 | item = m_host.TaskInventory[InventorySelf()]; | ||
3395 | } | ||
3396 | m_host.TaskInventory.LockItemsForRead(false); | ||
3397 | |||
3198 | 3398 | ||
3199 | if (item.PermsGranter == UUID.Zero) | 3399 | if (item.PermsGranter == UUID.Zero) |
3200 | return; | 3400 | return; |
@@ -3271,10 +3471,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3271 | 3471 | ||
3272 | TaskInventoryItem item; | 3472 | TaskInventoryItem item; |
3273 | 3473 | ||
3274 | lock (m_host.TaskInventory) | 3474 | |
3475 | m_host.TaskInventory.LockItemsForRead(true); | ||
3476 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3477 | { | ||
3478 | m_host.TaskInventory.LockItemsForRead(false); | ||
3479 | return; | ||
3480 | } | ||
3481 | else | ||
3275 | { | 3482 | { |
3276 | item = m_host.TaskInventory[invItemID]; | 3483 | item = m_host.TaskInventory[invItemID]; |
3277 | } | 3484 | } |
3485 | m_host.TaskInventory.LockItemsForRead(false); | ||
3278 | 3486 | ||
3279 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3487 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3280 | { | 3488 | { |
@@ -3306,11 +3514,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3306 | 3514 | ||
3307 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3515 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3308 | { | 3516 | { |
3309 | lock (m_host.TaskInventory) | 3517 | m_host.TaskInventory.LockItemsForWrite(true); |
3310 | { | 3518 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3311 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3519 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3312 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3520 | m_host.TaskInventory.LockItemsForWrite(false); |
3313 | } | ||
3314 | 3521 | ||
3315 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3522 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3316 | "run_time_permissions", new Object[] { | 3523 | "run_time_permissions", new Object[] { |
@@ -3330,11 +3537,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3330 | 3537 | ||
3331 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3538 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3332 | { | 3539 | { |
3333 | lock (m_host.TaskInventory) | 3540 | m_host.TaskInventory.LockItemsForWrite(true); |
3334 | { | 3541 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3335 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3542 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3336 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3543 | m_host.TaskInventory.LockItemsForWrite(false); |
3337 | } | ||
3338 | 3544 | ||
3339 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3545 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3340 | "run_time_permissions", new Object[] { | 3546 | "run_time_permissions", new Object[] { |
@@ -3355,11 +3561,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3355 | 3561 | ||
3356 | if (!m_waitingForScriptAnswer) | 3562 | if (!m_waitingForScriptAnswer) |
3357 | { | 3563 | { |
3358 | lock (m_host.TaskInventory) | 3564 | m_host.TaskInventory.LockItemsForWrite(true); |
3359 | { | 3565 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3360 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3566 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3361 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3567 | m_host.TaskInventory.LockItemsForWrite(false); |
3362 | } | ||
3363 | 3568 | ||
3364 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3569 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3365 | m_waitingForScriptAnswer=true; | 3570 | m_waitingForScriptAnswer=true; |
@@ -3394,10 +3599,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3394 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3599 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3395 | llReleaseControls(); | 3600 | llReleaseControls(); |
3396 | 3601 | ||
3397 | lock (m_host.TaskInventory) | 3602 | |
3398 | { | 3603 | m_host.TaskInventory.LockItemsForWrite(true); |
3399 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3604 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3400 | } | 3605 | m_host.TaskInventory.LockItemsForWrite(false); |
3606 | |||
3401 | 3607 | ||
3402 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3608 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3403 | "run_time_permissions", new Object[] { | 3609 | "run_time_permissions", new Object[] { |
@@ -3409,16 +3615,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3409 | { | 3615 | { |
3410 | m_host.AddScriptLPS(1); | 3616 | m_host.AddScriptLPS(1); |
3411 | 3617 | ||
3412 | lock (m_host.TaskInventory) | 3618 | m_host.TaskInventory.LockItemsForRead(true); |
3619 | |||
3620 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3413 | { | 3621 | { |
3414 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3622 | if (item.Type == 10 && item.ItemID == m_itemID) |
3415 | { | 3623 | { |
3416 | if (item.Type == 10 && item.ItemID == m_itemID) | 3624 | m_host.TaskInventory.LockItemsForRead(false); |
3417 | { | 3625 | return item.PermsGranter.ToString(); |
3418 | return item.PermsGranter.ToString(); | ||
3419 | } | ||
3420 | } | 3626 | } |
3421 | } | 3627 | } |
3628 | m_host.TaskInventory.LockItemsForRead(false); | ||
3422 | 3629 | ||
3423 | return UUID.Zero.ToString(); | 3630 | return UUID.Zero.ToString(); |
3424 | } | 3631 | } |
@@ -3427,19 +3634,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3427 | { | 3634 | { |
3428 | m_host.AddScriptLPS(1); | 3635 | m_host.AddScriptLPS(1); |
3429 | 3636 | ||
3430 | lock (m_host.TaskInventory) | 3637 | m_host.TaskInventory.LockItemsForRead(true); |
3638 | |||
3639 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3431 | { | 3640 | { |
3432 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3641 | if (item.Type == 10 && item.ItemID == m_itemID) |
3433 | { | 3642 | { |
3434 | if (item.Type == 10 && item.ItemID == m_itemID) | 3643 | int perms = item.PermsMask; |
3435 | { | 3644 | if (m_automaticLinkPermission) |
3436 | int perms = item.PermsMask; | 3645 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3437 | if (m_automaticLinkPermission) | 3646 | m_host.TaskInventory.LockItemsForRead(false); |
3438 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3647 | return perms; |
3439 | return perms; | ||
3440 | } | ||
3441 | } | 3648 | } |
3442 | } | 3649 | } |
3650 | m_host.TaskInventory.LockItemsForRead(false); | ||
3443 | 3651 | ||
3444 | return 0; | 3652 | return 0; |
3445 | } | 3653 | } |
@@ -3472,11 +3680,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3472 | UUID invItemID = InventorySelf(); | 3680 | UUID invItemID = InventorySelf(); |
3473 | 3681 | ||
3474 | TaskInventoryItem item; | 3682 | TaskInventoryItem item; |
3475 | lock (m_host.TaskInventory) | 3683 | m_host.TaskInventory.LockItemsForRead(true); |
3476 | { | 3684 | item = m_host.TaskInventory[invItemID]; |
3477 | item = m_host.TaskInventory[invItemID]; | 3685 | m_host.TaskInventory.LockItemsForRead(false); |
3478 | } | 3686 | |
3479 | |||
3480 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3687 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3481 | && !m_automaticLinkPermission) | 3688 | && !m_automaticLinkPermission) |
3482 | { | 3689 | { |
@@ -3529,16 +3736,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3529 | m_host.AddScriptLPS(1); | 3736 | m_host.AddScriptLPS(1); |
3530 | UUID invItemID = InventorySelf(); | 3737 | UUID invItemID = InventorySelf(); |
3531 | 3738 | ||
3532 | lock (m_host.TaskInventory) | 3739 | m_host.TaskInventory.LockItemsForRead(true); |
3533 | { | ||
3534 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3740 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3535 | && !m_automaticLinkPermission) | 3741 | && !m_automaticLinkPermission) |
3536 | { | 3742 | { |
3537 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3743 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3744 | m_host.TaskInventory.LockItemsForRead(false); | ||
3538 | return; | 3745 | return; |
3539 | } | 3746 | } |
3540 | } | 3747 | m_host.TaskInventory.LockItemsForRead(false); |
3541 | 3748 | ||
3542 | if (linknum < ScriptBaseClass.LINK_THIS) | 3749 | if (linknum < ScriptBaseClass.LINK_THIS) |
3543 | return; | 3750 | return; |
3544 | 3751 | ||
@@ -3715,17 +3922,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3715 | m_host.AddScriptLPS(1); | 3922 | m_host.AddScriptLPS(1); |
3716 | int count = 0; | 3923 | int count = 0; |
3717 | 3924 | ||
3718 | lock (m_host.TaskInventory) | 3925 | m_host.TaskInventory.LockItemsForRead(true); |
3926 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3719 | { | 3927 | { |
3720 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3928 | if (inv.Value.Type == type || type == -1) |
3721 | { | 3929 | { |
3722 | if (inv.Value.Type == type || type == -1) | 3930 | count = count + 1; |
3723 | { | ||
3724 | count = count + 1; | ||
3725 | } | ||
3726 | } | 3931 | } |
3727 | } | 3932 | } |
3728 | 3933 | ||
3934 | m_host.TaskInventory.LockItemsForRead(false); | ||
3729 | return count; | 3935 | return count; |
3730 | } | 3936 | } |
3731 | 3937 | ||
@@ -3734,16 +3940,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3734 | m_host.AddScriptLPS(1); | 3940 | m_host.AddScriptLPS(1); |
3735 | ArrayList keys = new ArrayList(); | 3941 | ArrayList keys = new ArrayList(); |
3736 | 3942 | ||
3737 | lock (m_host.TaskInventory) | 3943 | m_host.TaskInventory.LockItemsForRead(true); |
3944 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3738 | { | 3945 | { |
3739 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3946 | if (inv.Value.Type == type || type == -1) |
3740 | { | 3947 | { |
3741 | if (inv.Value.Type == type || type == -1) | 3948 | keys.Add(inv.Value.Name); |
3742 | { | ||
3743 | keys.Add(inv.Value.Name); | ||
3744 | } | ||
3745 | } | 3949 | } |
3746 | } | 3950 | } |
3951 | m_host.TaskInventory.LockItemsForRead(false); | ||
3747 | 3952 | ||
3748 | if (keys.Count == 0) | 3953 | if (keys.Count == 0) |
3749 | { | 3954 | { |
@@ -3780,20 +3985,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3780 | } | 3985 | } |
3781 | 3986 | ||
3782 | // move the first object found with this inventory name | 3987 | // move the first object found with this inventory name |
3783 | lock (m_host.TaskInventory) | 3988 | m_host.TaskInventory.LockItemsForRead(true); |
3989 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3784 | { | 3990 | { |
3785 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3991 | if (inv.Value.Name == inventory) |
3786 | { | 3992 | { |
3787 | if (inv.Value.Name == inventory) | 3993 | found = true; |
3788 | { | 3994 | objId = inv.Key; |
3789 | found = true; | 3995 | assetType = inv.Value.Type; |
3790 | objId = inv.Key; | 3996 | objName = inv.Value.Name; |
3791 | assetType = inv.Value.Type; | 3997 | break; |
3792 | objName = inv.Value.Name; | ||
3793 | break; | ||
3794 | } | ||
3795 | } | 3998 | } |
3796 | } | 3999 | } |
4000 | m_host.TaskInventory.LockItemsForRead(false); | ||
3797 | 4001 | ||
3798 | if (!found) | 4002 | if (!found) |
3799 | { | 4003 | { |
@@ -3829,33 +4033,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3829 | 4033 | ||
3830 | if (m_TransferModule != null) | 4034 | if (m_TransferModule != null) |
3831 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4035 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4036 | |||
4037 | //This delay should only occur when giving inventory to avatars. | ||
4038 | ScriptSleep(3000); | ||
3832 | } | 4039 | } |
3833 | else | 4040 | else |
3834 | { | 4041 | { |
3835 | // destination is an object | 4042 | // destination is an object |
3836 | World.MoveTaskInventoryItem(destId, m_host, objId); | 4043 | World.MoveTaskInventoryItem(destId, m_host, objId); |
3837 | } | 4044 | } |
3838 | ScriptSleep(3000); | 4045 | |
3839 | } | 4046 | } |
3840 | 4047 | ||
4048 | [DebuggerNonUserCode] | ||
3841 | public void llRemoveInventory(string name) | 4049 | public void llRemoveInventory(string name) |
3842 | { | 4050 | { |
3843 | m_host.AddScriptLPS(1); | 4051 | m_host.AddScriptLPS(1); |
3844 | 4052 | ||
3845 | lock (m_host.TaskInventory) | 4053 | m_host.TaskInventory.LockItemsForRead(true); |
4054 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3846 | { | 4055 | { |
3847 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4056 | if (item.Name == name) |
3848 | { | 4057 | { |
3849 | if (item.Name == name) | 4058 | if (item.ItemID == m_itemID) |
3850 | { | 4059 | throw new ScriptDeleteException(); |
3851 | if (item.ItemID == m_itemID) | 4060 | else |
3852 | throw new ScriptDeleteException(); | 4061 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3853 | else | 4062 | |
3854 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4063 | m_host.TaskInventory.LockItemsForRead(false); |
3855 | return; | 4064 | return; |
3856 | } | ||
3857 | } | 4065 | } |
3858 | } | 4066 | } |
4067 | m_host.TaskInventory.LockItemsForRead(false); | ||
3859 | } | 4068 | } |
3860 | 4069 | ||
3861 | public void llSetText(string text, LSL_Vector color, double alpha) | 4070 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3944,6 +4153,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3944 | { | 4153 | { |
3945 | m_host.AddScriptLPS(1); | 4154 | m_host.AddScriptLPS(1); |
3946 | 4155 | ||
4156 | //Clone is thread safe | ||
3947 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4157 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3948 | 4158 | ||
3949 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4159 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3997,6 +4207,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3997 | ScenePresence presence = World.GetScenePresence(agentId); | 4207 | ScenePresence presence = World.GetScenePresence(agentId); |
3998 | if (presence != null) | 4208 | if (presence != null) |
3999 | { | 4209 | { |
4210 | // agent must not be a god | ||
4211 | if (presence.GodLevel >= 200) return; | ||
4212 | |||
4000 | // agent must be over the owners land | 4213 | // agent must be over the owners land |
4001 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4214 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4002 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4215 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4057,17 +4270,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4057 | UUID soundId = UUID.Zero; | 4270 | UUID soundId = UUID.Zero; |
4058 | if (!UUID.TryParse(impact_sound, out soundId)) | 4271 | if (!UUID.TryParse(impact_sound, out soundId)) |
4059 | { | 4272 | { |
4060 | lock (m_host.TaskInventory) | 4273 | m_host.TaskInventory.LockItemsForRead(true); |
4274 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4061 | { | 4275 | { |
4062 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4276 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4063 | { | 4277 | { |
4064 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4278 | soundId = item.AssetID; |
4065 | { | 4279 | break; |
4066 | soundId = item.AssetID; | ||
4067 | break; | ||
4068 | } | ||
4069 | } | 4280 | } |
4070 | } | 4281 | } |
4282 | m_host.TaskInventory.LockItemsForRead(false); | ||
4071 | } | 4283 | } |
4072 | m_host.CollisionSound = soundId; | 4284 | m_host.CollisionSound = soundId; |
4073 | m_host.CollisionSoundVolume = (float)impact_volume; | 4285 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4113,6 +4325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4113 | UUID partItemID; | 4325 | UUID partItemID; |
4114 | foreach (SceneObjectPart part in parts) | 4326 | foreach (SceneObjectPart part in parts) |
4115 | { | 4327 | { |
4328 | //Clone is thread safe | ||
4116 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4329 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4117 | 4330 | ||
4118 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4331 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4327,17 +4540,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4327 | 4540 | ||
4328 | m_host.AddScriptLPS(1); | 4541 | m_host.AddScriptLPS(1); |
4329 | 4542 | ||
4330 | lock (m_host.TaskInventory) | 4543 | m_host.TaskInventory.LockItemsForRead(true); |
4544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4331 | { | 4545 | { |
4332 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4546 | if (item.Type == 10 && item.ItemID == m_itemID) |
4333 | { | 4547 | { |
4334 | if (item.Type == 10 && item.ItemID == m_itemID) | 4548 | result = item.Name!=null?item.Name:String.Empty; |
4335 | { | 4549 | break; |
4336 | result = item.Name != null ? item.Name : String.Empty; | ||
4337 | break; | ||
4338 | } | ||
4339 | } | 4550 | } |
4340 | } | 4551 | } |
4552 | m_host.TaskInventory.LockItemsForRead(false); | ||
4341 | 4553 | ||
4342 | return result; | 4554 | return result; |
4343 | } | 4555 | } |
@@ -4490,23 +4702,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4490 | { | 4702 | { |
4491 | m_host.AddScriptLPS(1); | 4703 | m_host.AddScriptLPS(1); |
4492 | 4704 | ||
4493 | lock (m_host.TaskInventory) | 4705 | m_host.TaskInventory.LockItemsForRead(true); |
4706 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4494 | { | 4707 | { |
4495 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4708 | if (inv.Value.Name == name) |
4496 | { | 4709 | { |
4497 | if (inv.Value.Name == name) | 4710 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4498 | { | 4711 | { |
4499 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4712 | m_host.TaskInventory.LockItemsForRead(false); |
4500 | { | 4713 | return inv.Value.AssetID.ToString(); |
4501 | return inv.Value.AssetID.ToString(); | 4714 | } |
4502 | } | 4715 | else |
4503 | else | 4716 | { |
4504 | { | 4717 | m_host.TaskInventory.LockItemsForRead(false); |
4505 | return UUID.Zero.ToString(); | 4718 | return UUID.Zero.ToString(); |
4506 | } | ||
4507 | } | 4719 | } |
4508 | } | 4720 | } |
4509 | } | 4721 | } |
4722 | m_host.TaskInventory.LockItemsForRead(false); | ||
4510 | 4723 | ||
4511 | return UUID.Zero.ToString(); | 4724 | return UUID.Zero.ToString(); |
4512 | } | 4725 | } |
@@ -6021,6 +6234,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6021 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6234 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6022 | prules.OuterAngle = (float)tempf; | 6235 | prules.OuterAngle = (float)tempf; |
6023 | break; | 6236 | break; |
6237 | |||
6238 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6239 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6240 | prules.InnerAngle = (float)tempf; | ||
6241 | break; | ||
6242 | |||
6243 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6244 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6245 | prules.OuterAngle = (float)tempf; | ||
6246 | break; | ||
6024 | } | 6247 | } |
6025 | 6248 | ||
6026 | } | 6249 | } |
@@ -6059,14 +6282,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6059 | 6282 | ||
6060 | protected UUID GetTaskInventoryItem(string name) | 6283 | protected UUID GetTaskInventoryItem(string name) |
6061 | { | 6284 | { |
6062 | lock (m_host.TaskInventory) | 6285 | m_host.TaskInventory.LockItemsForRead(true); |
6286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6063 | { | 6287 | { |
6064 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6288 | if (inv.Value.Name == name) |
6065 | { | 6289 | { |
6066 | if (inv.Value.Name == name) | 6290 | m_host.TaskInventory.LockItemsForRead(false); |
6067 | return inv.Key; | 6291 | return inv.Key; |
6068 | } | 6292 | } |
6069 | } | 6293 | } |
6294 | m_host.TaskInventory.LockItemsForRead(false); | ||
6070 | 6295 | ||
6071 | return UUID.Zero; | 6296 | return UUID.Zero; |
6072 | } | 6297 | } |
@@ -6394,22 +6619,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6394 | } | 6619 | } |
6395 | 6620 | ||
6396 | // copy the first script found with this inventory name | 6621 | // copy the first script found with this inventory name |
6397 | lock (m_host.TaskInventory) | 6622 | m_host.TaskInventory.LockItemsForRead(true); |
6623 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6398 | { | 6624 | { |
6399 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6625 | if (inv.Value.Name == name) |
6400 | { | 6626 | { |
6401 | if (inv.Value.Name == name) | 6627 | // make sure the object is a script |
6628 | if (10 == inv.Value.Type) | ||
6402 | { | 6629 | { |
6403 | // make sure the object is a script | 6630 | found = true; |
6404 | if (10 == inv.Value.Type) | 6631 | srcId = inv.Key; |
6405 | { | 6632 | break; |
6406 | found = true; | ||
6407 | srcId = inv.Key; | ||
6408 | break; | ||
6409 | } | ||
6410 | } | 6633 | } |
6411 | } | 6634 | } |
6412 | } | 6635 | } |
6636 | m_host.TaskInventory.LockItemsForRead(false); | ||
6413 | 6637 | ||
6414 | if (!found) | 6638 | if (!found) |
6415 | { | 6639 | { |
@@ -6493,6 +6717,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6493 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6717 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6494 | { | 6718 | { |
6495 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6719 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6720 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6721 | return shapeBlock; | ||
6496 | 6722 | ||
6497 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6723 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6498 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6724 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6563,6 +6789,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6563 | 6789 | ||
6564 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6790 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6565 | { | 6791 | { |
6792 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6793 | return; | ||
6794 | |||
6566 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6795 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6567 | 6796 | ||
6568 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6797 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6612,6 +6841,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6612 | 6841 | ||
6613 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6842 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6614 | { | 6843 | { |
6844 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6845 | return; | ||
6846 | |||
6615 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6847 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6616 | 6848 | ||
6617 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6849 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6654,6 +6886,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6654 | 6886 | ||
6655 | 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) | 6887 | 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) |
6656 | { | 6888 | { |
6889 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6890 | return; | ||
6891 | |||
6657 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6892 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6658 | 6893 | ||
6659 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6894 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6775,6 +7010,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6775 | 7010 | ||
6776 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7011 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6777 | { | 7012 | { |
7013 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7014 | return; | ||
7015 | |||
6778 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7016 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6779 | UUID sculptId; | 7017 | UUID sculptId; |
6780 | 7018 | ||
@@ -6815,7 +7053,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6815 | 7053 | ||
6816 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7054 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6817 | { | 7055 | { |
6818 | m_host.AddScriptLPS(1); | 7056 | m_host.AddScriptLPS(1); |
6819 | 7057 | ||
6820 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7058 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6821 | 7059 | ||
@@ -6830,6 +7068,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6830 | 7068 | ||
6831 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7069 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6832 | { | 7070 | { |
7071 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7072 | return; | ||
7073 | |||
6833 | int idx = 0; | 7074 | int idx = 0; |
6834 | 7075 | ||
6835 | while (idx < rules.Length) | 7076 | while (idx < rules.Length) |
@@ -7661,24 +7902,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7661 | break; | 7902 | break; |
7662 | 7903 | ||
7663 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7904 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7664 | // TODO-------------- | ||
7665 | if (remain < 1) | 7905 | if (remain < 1) |
7666 | return res; | 7906 | return res; |
7907 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7667 | 7908 | ||
7668 | face=(int)rules.GetLSLIntegerItem(idx++); | 7909 | tex = part.Shape.Textures; |
7669 | 7910 | int shiny; | |
7670 | res.Add(new LSL_Integer(0)); | 7911 | if (face == ScriptBaseClass.ALL_SIDES) |
7671 | res.Add(new LSL_Integer(0)); | 7912 | { |
7913 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7914 | { | ||
7915 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7916 | if (shinyness == Shininess.High) | ||
7917 | { | ||
7918 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7919 | } | ||
7920 | else if (shinyness == Shininess.Medium) | ||
7921 | { | ||
7922 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7923 | } | ||
7924 | else if (shinyness == Shininess.Low) | ||
7925 | { | ||
7926 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7927 | } | ||
7928 | else | ||
7929 | { | ||
7930 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7931 | } | ||
7932 | res.Add(new LSL_Integer(shiny)); | ||
7933 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7934 | } | ||
7935 | } | ||
7936 | else | ||
7937 | { | ||
7938 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7939 | if (shinyness == Shininess.High) | ||
7940 | { | ||
7941 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7942 | } | ||
7943 | else if (shinyness == Shininess.Medium) | ||
7944 | { | ||
7945 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7946 | } | ||
7947 | else if (shinyness == Shininess.Low) | ||
7948 | { | ||
7949 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7950 | } | ||
7951 | else | ||
7952 | { | ||
7953 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7954 | } | ||
7955 | res.Add(new LSL_Integer(shiny)); | ||
7956 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7957 | } | ||
7672 | break; | 7958 | break; |
7673 | 7959 | ||
7674 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7960 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7675 | // TODO-------------- | ||
7676 | if (remain < 1) | 7961 | if (remain < 1) |
7677 | return res; | 7962 | return res; |
7963 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7678 | 7964 | ||
7679 | face=(int)rules.GetLSLIntegerItem(idx++); | 7965 | tex = part.Shape.Textures; |
7680 | 7966 | int fullbright; | |
7681 | res.Add(new LSL_Integer(0)); | 7967 | if (face == ScriptBaseClass.ALL_SIDES) |
7968 | { | ||
7969 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7970 | { | ||
7971 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7972 | { | ||
7973 | fullbright = ScriptBaseClass.TRUE; | ||
7974 | } | ||
7975 | else | ||
7976 | { | ||
7977 | fullbright = ScriptBaseClass.FALSE; | ||
7978 | } | ||
7979 | res.Add(new LSL_Integer(fullbright)); | ||
7980 | } | ||
7981 | } | ||
7982 | else | ||
7983 | { | ||
7984 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7985 | { | ||
7986 | fullbright = ScriptBaseClass.TRUE; | ||
7987 | } | ||
7988 | else | ||
7989 | { | ||
7990 | fullbright = ScriptBaseClass.FALSE; | ||
7991 | } | ||
7992 | res.Add(new LSL_Integer(fullbright)); | ||
7993 | } | ||
7682 | break; | 7994 | break; |
7683 | 7995 | ||
7684 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 7996 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7699,14 +8011,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7699 | break; | 8011 | break; |
7700 | 8012 | ||
7701 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8013 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7702 | // TODO-------------- | ||
7703 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8014 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7704 | if (remain < 1) | 8015 | if (remain < 1) |
7705 | return res; | 8016 | return res; |
8017 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7706 | 8018 | ||
7707 | face=(int)rules.GetLSLIntegerItem(idx++); | 8019 | tex = part.Shape.Textures; |
7708 | 8020 | if (face == ScriptBaseClass.ALL_SIDES) | |
7709 | res.Add(new LSL_Integer(0)); | 8021 | { |
8022 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8023 | { | ||
8024 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8025 | { | ||
8026 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8027 | } | ||
8028 | else | ||
8029 | { | ||
8030 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8031 | } | ||
8032 | } | ||
8033 | } | ||
8034 | else | ||
8035 | { | ||
8036 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8037 | { | ||
8038 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8039 | } | ||
8040 | else | ||
8041 | { | ||
8042 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8043 | } | ||
8044 | } | ||
7710 | break; | 8045 | break; |
7711 | 8046 | ||
7712 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8047 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7725,13 +8060,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7725 | break; | 8060 | break; |
7726 | 8061 | ||
7727 | case (int)ScriptBaseClass.PRIM_GLOW: | 8062 | case (int)ScriptBaseClass.PRIM_GLOW: |
7728 | // TODO-------------- | ||
7729 | if (remain < 1) | 8063 | if (remain < 1) |
7730 | return res; | 8064 | return res; |
8065 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7731 | 8066 | ||
7732 | face=(int)rules.GetLSLIntegerItem(idx++); | 8067 | tex = part.Shape.Textures; |
7733 | 8068 | float primglow; | |
7734 | res.Add(new LSL_Float(0)); | 8069 | if (face == ScriptBaseClass.ALL_SIDES) |
8070 | { | ||
8071 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8072 | { | ||
8073 | primglow = tex.GetFace((uint)face).Glow; | ||
8074 | res.Add(new LSL_Float(primglow)); | ||
8075 | } | ||
8076 | } | ||
8077 | else | ||
8078 | { | ||
8079 | primglow = tex.GetFace((uint)face).Glow; | ||
8080 | res.Add(new LSL_Float(primglow)); | ||
8081 | } | ||
7735 | break; | 8082 | break; |
7736 | case (int)ScriptBaseClass.PRIM_TEXT: | 8083 | case (int)ScriptBaseClass.PRIM_TEXT: |
7737 | Color4 textColor = part.GetTextColor(); | 8084 | Color4 textColor = part.GetTextColor(); |
@@ -8268,28 +8615,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8268 | { | 8615 | { |
8269 | m_host.AddScriptLPS(1); | 8616 | m_host.AddScriptLPS(1); |
8270 | 8617 | ||
8271 | lock (m_host.TaskInventory) | 8618 | m_host.TaskInventory.LockItemsForRead(true); |
8619 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8272 | { | 8620 | { |
8273 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8621 | if (inv.Value.Name == item) |
8274 | { | 8622 | { |
8275 | if (inv.Value.Name == item) | 8623 | m_host.TaskInventory.LockItemsForRead(false); |
8624 | switch (mask) | ||
8276 | { | 8625 | { |
8277 | switch (mask) | 8626 | case 0: |
8278 | { | 8627 | return (int)inv.Value.BasePermissions; |
8279 | case 0: | 8628 | case 1: |
8280 | return (int)inv.Value.BasePermissions; | 8629 | return (int)inv.Value.CurrentPermissions; |
8281 | case 1: | 8630 | case 2: |
8282 | return (int)inv.Value.CurrentPermissions; | 8631 | return (int)inv.Value.GroupPermissions; |
8283 | case 2: | 8632 | case 3: |
8284 | return (int)inv.Value.GroupPermissions; | 8633 | return (int)inv.Value.EveryonePermissions; |
8285 | case 3: | 8634 | case 4: |
8286 | return (int)inv.Value.EveryonePermissions; | 8635 | return (int)inv.Value.NextPermissions; |
8287 | case 4: | ||
8288 | return (int)inv.Value.NextPermissions; | ||
8289 | } | ||
8290 | } | 8636 | } |
8291 | } | 8637 | } |
8292 | } | 8638 | } |
8639 | m_host.TaskInventory.LockItemsForRead(false); | ||
8293 | 8640 | ||
8294 | return -1; | 8641 | return -1; |
8295 | } | 8642 | } |
@@ -8336,16 +8683,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8336 | { | 8683 | { |
8337 | m_host.AddScriptLPS(1); | 8684 | m_host.AddScriptLPS(1); |
8338 | 8685 | ||
8339 | lock (m_host.TaskInventory) | 8686 | m_host.TaskInventory.LockItemsForRead(true); |
8687 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8340 | { | 8688 | { |
8341 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8689 | if (inv.Value.Name == item) |
8342 | { | 8690 | { |
8343 | if (inv.Value.Name == item) | 8691 | m_host.TaskInventory.LockItemsForRead(false); |
8344 | { | 8692 | return inv.Value.CreatorID.ToString(); |
8345 | return inv.Value.CreatorID.ToString(); | ||
8346 | } | ||
8347 | } | 8693 | } |
8348 | } | 8694 | } |
8695 | m_host.TaskInventory.LockItemsForRead(false); | ||
8349 | 8696 | ||
8350 | llSay(0, "No item name '" + item + "'"); | 8697 | llSay(0, "No item name '" + item + "'"); |
8351 | 8698 | ||
@@ -8878,16 +9225,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8878 | { | 9225 | { |
8879 | m_host.AddScriptLPS(1); | 9226 | m_host.AddScriptLPS(1); |
8880 | 9227 | ||
8881 | lock (m_host.TaskInventory) | 9228 | m_host.TaskInventory.LockItemsForRead(true); |
9229 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8882 | { | 9230 | { |
8883 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9231 | if (inv.Value.Name == name) |
8884 | { | 9232 | { |
8885 | if (inv.Value.Name == name) | 9233 | m_host.TaskInventory.LockItemsForRead(false); |
8886 | { | 9234 | return inv.Value.Type; |
8887 | return inv.Value.Type; | ||
8888 | } | ||
8889 | } | 9235 | } |
8890 | } | 9236 | } |
9237 | m_host.TaskInventory.LockItemsForRead(false); | ||
8891 | 9238 | ||
8892 | return -1; | 9239 | return -1; |
8893 | } | 9240 | } |
@@ -8898,15 +9245,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8898 | 9245 | ||
8899 | if (quick_pay_buttons.Data.Length < 4) | 9246 | if (quick_pay_buttons.Data.Length < 4) |
8900 | { | 9247 | { |
8901 | LSLError("List must have at least 4 elements"); | 9248 | int x; |
8902 | return; | 9249 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9250 | { | ||
9251 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9252 | } | ||
8903 | } | 9253 | } |
8904 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9254 | int[] nPrice = new int[5]; |
8905 | 9255 | nPrice[0]=price; | |
8906 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9256 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8907 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9257 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8908 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9258 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8909 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9259 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9260 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8910 | m_host.ParentGroup.HasGroupChanged = true; | 9261 | m_host.ParentGroup.HasGroupChanged = true; |
8911 | } | 9262 | } |
8912 | 9263 | ||
@@ -8918,17 +9269,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8918 | if (invItemID == UUID.Zero) | 9269 | if (invItemID == UUID.Zero) |
8919 | return new LSL_Vector(); | 9270 | return new LSL_Vector(); |
8920 | 9271 | ||
8921 | lock (m_host.TaskInventory) | 9272 | m_host.TaskInventory.LockItemsForRead(true); |
9273 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8922 | { | 9274 | { |
8923 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9275 | m_host.TaskInventory.LockItemsForRead(false); |
8924 | return new LSL_Vector(); | 9276 | return new LSL_Vector(); |
9277 | } | ||
8925 | 9278 | ||
8926 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9279 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8927 | { | 9280 | { |
8928 | ShoutError("No permissions to track the camera"); | 9281 | ShoutError("No permissions to track the camera"); |
8929 | return new LSL_Vector(); | 9282 | m_host.TaskInventory.LockItemsForRead(false); |
8930 | } | 9283 | return new LSL_Vector(); |
8931 | } | 9284 | } |
9285 | m_host.TaskInventory.LockItemsForRead(false); | ||
8932 | 9286 | ||
8933 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9287 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8934 | if (presence != null) | 9288 | if (presence != null) |
@@ -8946,17 +9300,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8946 | if (invItemID == UUID.Zero) | 9300 | if (invItemID == UUID.Zero) |
8947 | return new LSL_Rotation(); | 9301 | return new LSL_Rotation(); |
8948 | 9302 | ||
8949 | lock (m_host.TaskInventory) | 9303 | m_host.TaskInventory.LockItemsForRead(true); |
9304 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8950 | { | 9305 | { |
8951 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9306 | m_host.TaskInventory.LockItemsForRead(false); |
8952 | return new LSL_Rotation(); | 9307 | return new LSL_Rotation(); |
8953 | |||
8954 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8955 | { | ||
8956 | ShoutError("No permissions to track the camera"); | ||
8957 | return new LSL_Rotation(); | ||
8958 | } | ||
8959 | } | 9308 | } |
9309 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
9310 | { | ||
9311 | ShoutError("No permissions to track the camera"); | ||
9312 | m_host.TaskInventory.LockItemsForRead(false); | ||
9313 | return new LSL_Rotation(); | ||
9314 | } | ||
9315 | m_host.TaskInventory.LockItemsForRead(false); | ||
8960 | 9316 | ||
8961 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9317 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8962 | if (presence != null) | 9318 | if (presence != null) |
@@ -9106,14 +9462,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9106 | if (objectID == UUID.Zero) return; | 9462 | if (objectID == UUID.Zero) return; |
9107 | 9463 | ||
9108 | UUID agentID; | 9464 | UUID agentID; |
9109 | lock (m_host.TaskInventory) | 9465 | m_host.TaskInventory.LockItemsForRead(true); |
9110 | { | 9466 | // we need the permission first, to know which avatar we want to set the camera for |
9111 | // we need the permission first, to know which avatar we want to set the camera for | 9467 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9112 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9113 | 9468 | ||
9114 | if (agentID == UUID.Zero) return; | 9469 | if (agentID == UUID.Zero) |
9115 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9470 | { |
9471 | m_host.TaskInventory.LockItemsForRead(false); | ||
9472 | return; | ||
9473 | } | ||
9474 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9475 | { | ||
9476 | m_host.TaskInventory.LockItemsForRead(false); | ||
9477 | return; | ||
9116 | } | 9478 | } |
9479 | m_host.TaskInventory.LockItemsForRead(false); | ||
9117 | 9480 | ||
9118 | ScenePresence presence = World.GetScenePresence(agentID); | 9481 | ScenePresence presence = World.GetScenePresence(agentID); |
9119 | 9482 | ||
@@ -9163,12 +9526,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9163 | 9526 | ||
9164 | // we need the permission first, to know which avatar we want to clear the camera for | 9527 | // we need the permission first, to know which avatar we want to clear the camera for |
9165 | UUID agentID; | 9528 | UUID agentID; |
9166 | lock (m_host.TaskInventory) | 9529 | m_host.TaskInventory.LockItemsForRead(true); |
9530 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9531 | if (agentID == UUID.Zero) | ||
9167 | { | 9532 | { |
9168 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9533 | m_host.TaskInventory.LockItemsForRead(false); |
9169 | if (agentID == UUID.Zero) return; | 9534 | return; |
9170 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9171 | } | 9535 | } |
9536 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9537 | { | ||
9538 | m_host.TaskInventory.LockItemsForRead(false); | ||
9539 | return; | ||
9540 | } | ||
9541 | m_host.TaskInventory.LockItemsForRead(false); | ||
9172 | 9542 | ||
9173 | ScenePresence presence = World.GetScenePresence(agentID); | 9543 | ScenePresence presence = World.GetScenePresence(agentID); |
9174 | 9544 | ||
@@ -9625,15 +9995,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9625 | 9995 | ||
9626 | internal UUID ScriptByName(string name) | 9996 | internal UUID ScriptByName(string name) |
9627 | { | 9997 | { |
9628 | lock (m_host.TaskInventory) | 9998 | m_host.TaskInventory.LockItemsForRead(true); |
9999 | |||
10000 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9629 | { | 10001 | { |
9630 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10002 | if (item.Type == 10 && item.Name == name) |
9631 | { | 10003 | { |
9632 | if (item.Type == 10 && item.Name == name) | 10004 | m_host.TaskInventory.LockItemsForRead(false); |
9633 | return item.ItemID; | 10005 | return item.ItemID; |
9634 | } | 10006 | } |
9635 | } | 10007 | } |
9636 | 10008 | ||
10009 | m_host.TaskInventory.LockItemsForRead(false); | ||
10010 | |||
9637 | return UUID.Zero; | 10011 | return UUID.Zero; |
9638 | } | 10012 | } |
9639 | 10013 | ||
@@ -9674,6 +10048,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9674 | { | 10048 | { |
9675 | m_host.AddScriptLPS(1); | 10049 | m_host.AddScriptLPS(1); |
9676 | 10050 | ||
10051 | //Clone is thread safe | ||
9677 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10052 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9678 | 10053 | ||
9679 | UUID assetID = UUID.Zero; | 10054 | UUID assetID = UUID.Zero; |
@@ -9736,6 +10111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9736 | { | 10111 | { |
9737 | m_host.AddScriptLPS(1); | 10112 | m_host.AddScriptLPS(1); |
9738 | 10113 | ||
10114 | //Clone is thread safe | ||
9739 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10115 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9740 | 10116 | ||
9741 | UUID assetID = UUID.Zero; | 10117 | 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/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 ee35fa4..b3e4740 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; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 54074ed..463b052 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Reflection; |
@@ -102,6 +103,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
102 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 103 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
103 | new Dictionary<UUID, IScriptInstance>(); | 104 | new Dictionary<UUID, IScriptInstance>(); |
104 | 105 | ||
106 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
107 | |||
105 | // Maps the asset ID to the assembly | 108 | // Maps the asset ID to the assembly |
106 | 109 | ||
107 | private Dictionary<UUID, string> m_Assemblies = | 110 | private Dictionary<UUID, string> m_Assemblies = |
@@ -123,6 +126,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
123 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); | 126 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); |
124 | IWorkItemResult m_CurrentCompile = null; | 127 | IWorkItemResult m_CurrentCompile = null; |
125 | 128 | ||
129 | private void lockScriptsForRead(bool locked) | ||
130 | { | ||
131 | if (locked) | ||
132 | { | ||
133 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
134 | { | ||
135 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
136 | m_scriptsLock.ExitReadLock(); | ||
137 | } | ||
138 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
139 | { | ||
140 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
141 | m_scriptsLock.ExitWriteLock(); | ||
142 | } | ||
143 | |||
144 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
145 | { | ||
146 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
147 | if (m_scriptsLock.IsWriteLockHeld) | ||
148 | { | ||
149 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
156 | { | ||
157 | m_scriptsLock.ExitReadLock(); | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | private void lockScriptsForWrite(bool locked) | ||
162 | { | ||
163 | if (locked) | ||
164 | { | ||
165 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
166 | { | ||
167 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
168 | m_scriptsLock.ExitReadLock(); | ||
169 | } | ||
170 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
171 | { | ||
172 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
173 | m_scriptsLock.ExitWriteLock(); | ||
174 | } | ||
175 | |||
176 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
177 | { | ||
178 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
179 | if (m_scriptsLock.IsWriteLockHeld) | ||
180 | { | ||
181 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
188 | { | ||
189 | m_scriptsLock.ExitWriteLock(); | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | |||
126 | public string ScriptEngineName | 194 | public string ScriptEngineName |
127 | { | 195 | { |
128 | get { return "XEngine"; } | 196 | get { return "XEngine"; } |
@@ -262,43 +330,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
262 | 330 | ||
263 | public void RemoveRegion(Scene scene) | 331 | public void RemoveRegion(Scene scene) |
264 | { | 332 | { |
265 | lock (m_Scripts) | 333 | lockScriptsForRead(true); |
334 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
266 | { | 335 | { |
267 | foreach (IScriptInstance instance in m_Scripts.Values) | 336 | // Force a final state save |
337 | // | ||
338 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
268 | { | 339 | { |
269 | // Force a final state save | 340 | string assembly = m_Assemblies[instance.AssetID]; |
270 | // | 341 | instance.SaveState(assembly); |
271 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 342 | } |
272 | { | ||
273 | string assembly = m_Assemblies[instance.AssetID]; | ||
274 | instance.SaveState(assembly); | ||
275 | } | ||
276 | 343 | ||
277 | // Clear the event queue and abort the instance thread | 344 | // Clear the event queue and abort the instance thread |
278 | // | 345 | // |
279 | instance.ClearQueue(); | 346 | instance.ClearQueue(); |
280 | instance.Stop(0); | 347 | instance.Stop(0); |
281 | 348 | ||
282 | // Release events, timer, etc | 349 | // Release events, timer, etc |
283 | // | 350 | // |
284 | instance.DestroyScriptInstance(); | 351 | instance.DestroyScriptInstance(); |
285 | 352 | ||
286 | // Unload scripts and app domains | 353 | // Unload scripts and app domains |
287 | // Must be done explicitly because they have infinite | 354 | // Must be done explicitly because they have infinite |
288 | // lifetime | 355 | // lifetime |
289 | // | 356 | // |
290 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 357 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
291 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 358 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
292 | { | 359 | { |
293 | m_DomainScripts.Remove(instance.AppDomain); | 360 | m_DomainScripts.Remove(instance.AppDomain); |
294 | UnloadAppDomain(instance.AppDomain); | 361 | UnloadAppDomain(instance.AppDomain); |
295 | } | ||
296 | } | 362 | } |
297 | m_Scripts.Clear(); | ||
298 | m_PrimObjects.Clear(); | ||
299 | m_Assemblies.Clear(); | ||
300 | m_DomainScripts.Clear(); | ||
301 | } | 363 | } |
364 | lockScriptsForRead(false); | ||
365 | lockScriptsForWrite(true); | ||
366 | m_Scripts.Clear(); | ||
367 | lockScriptsForWrite(false); | ||
368 | m_PrimObjects.Clear(); | ||
369 | m_Assemblies.Clear(); | ||
370 | m_DomainScripts.Clear(); | ||
371 | |||
302 | lock (m_ScriptEngines) | 372 | lock (m_ScriptEngines) |
303 | { | 373 | { |
304 | m_ScriptEngines.Remove(this); | 374 | m_ScriptEngines.Remove(this); |
@@ -357,22 +427,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
357 | 427 | ||
358 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 428 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
359 | 429 | ||
360 | lock (m_Scripts) | 430 | lockScriptsForRead(true); |
361 | { | 431 | foreach (IScriptInstance instance in m_Scripts.Values) |
362 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
363 | instances.Add(instance); | 432 | instances.Add(instance); |
364 | } | 433 | lockScriptsForRead(false); |
365 | 434 | ||
366 | foreach (IScriptInstance i in instances) | 435 | foreach (IScriptInstance i in instances) |
367 | { | 436 | { |
368 | string assembly = String.Empty; | 437 | string assembly = String.Empty; |
369 | 438 | ||
370 | lock (m_Scripts) | 439 | |
371 | { | ||
372 | if (!m_Assemblies.ContainsKey(i.AssetID)) | 440 | if (!m_Assemblies.ContainsKey(i.AssetID)) |
373 | continue; | 441 | continue; |
374 | assembly = m_Assemblies[i.AssetID]; | 442 | assembly = m_Assemblies[i.AssetID]; |
375 | } | 443 | |
376 | 444 | ||
377 | i.SaveState(assembly); | 445 | i.SaveState(assembly); |
378 | } | 446 | } |
@@ -684,170 +752,181 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
684 | } | 752 | } |
685 | } | 753 | } |
686 | 754 | ||
687 | lock (m_Scripts) | 755 | |
756 | |||
757 | ScriptInstance instance = null; | ||
758 | // Create the object record | ||
759 | lockScriptsForRead(true); | ||
760 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
761 | (m_Scripts[itemID].AssetID != assetID)) | ||
688 | { | 762 | { |
689 | ScriptInstance instance = null; | 763 | lockScriptsForRead(false); |
690 | // Create the object record | ||
691 | 764 | ||
692 | if ((!m_Scripts.ContainsKey(itemID)) || | 765 | UUID appDomain = assetID; |
693 | (m_Scripts[itemID].AssetID != assetID)) | ||
694 | { | ||
695 | UUID appDomain = assetID; | ||
696 | 766 | ||
697 | if (part.ParentGroup.IsAttachment) | 767 | if (part.ParentGroup.IsAttachment) |
698 | appDomain = part.ParentGroup.RootPart.UUID; | 768 | appDomain = part.ParentGroup.RootPart.UUID; |
699 | 769 | ||
700 | if (!m_AppDomains.ContainsKey(appDomain)) | 770 | if (!m_AppDomains.ContainsKey(appDomain)) |
771 | { | ||
772 | try | ||
701 | { | 773 | { |
702 | try | 774 | AppDomainSetup appSetup = new AppDomainSetup(); |
703 | { | 775 | // appSetup.ApplicationBase = Path.Combine( |
704 | AppDomainSetup appSetup = new AppDomainSetup(); | 776 | // "ScriptEngines", |
705 | // appSetup.ApplicationBase = Path.Combine( | 777 | // m_Scene.RegionInfo.RegionID.ToString()); |
706 | // "ScriptEngines", | 778 | |
707 | // m_Scene.RegionInfo.RegionID.ToString()); | 779 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
708 | 780 | Evidence evidence = new Evidence(baseEvidence); | |
709 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 781 | |
710 | Evidence evidence = new Evidence(baseEvidence); | 782 | AppDomain sandbox; |
711 | 783 | if (m_AppDomainLoading) | |
712 | AppDomain sandbox; | 784 | sandbox = AppDomain.CreateDomain( |
713 | if (m_AppDomainLoading) | 785 | m_Scene.RegionInfo.RegionID.ToString(), |
714 | sandbox = AppDomain.CreateDomain( | 786 | evidence, appSetup); |
715 | m_Scene.RegionInfo.RegionID.ToString(), | 787 | else |
716 | evidence, appSetup); | 788 | sandbox = AppDomain.CurrentDomain; |
717 | else | 789 | |
718 | sandbox = AppDomain.CurrentDomain; | 790 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
719 | 791 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | |
720 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 792 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); |
721 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 793 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); |
722 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | 794 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); |
723 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | 795 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; |
724 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | 796 | //sandbox.SetAppDomainPolicy(sandboxPolicy); |
725 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | 797 | |
726 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | 798 | m_AppDomains[appDomain] = sandbox; |
727 | 799 | ||
728 | m_AppDomains[appDomain] = sandbox; | 800 | m_AppDomains[appDomain].AssemblyResolve += |
729 | 801 | new ResolveEventHandler( | |
730 | m_AppDomains[appDomain].AssemblyResolve += | 802 | AssemblyResolver.OnAssemblyResolve); |
731 | new ResolveEventHandler( | 803 | m_DomainScripts[appDomain] = new List<UUID>(); |
732 | AssemblyResolver.OnAssemblyResolve); | ||
733 | m_DomainScripts[appDomain] = new List<UUID>(); | ||
734 | } | ||
735 | catch (Exception e) | ||
736 | { | ||
737 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | ||
738 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | ||
739 | m_ScriptFailCount++; | ||
740 | lock (m_AddingAssemblies) | ||
741 | { | ||
742 | m_AddingAssemblies[assembly]--; | ||
743 | } | ||
744 | return false; | ||
745 | } | ||
746 | } | 804 | } |
747 | m_DomainScripts[appDomain].Add(itemID); | 805 | catch (Exception e) |
748 | |||
749 | instance = new ScriptInstance(this, part, | ||
750 | itemID, assetID, assembly, | ||
751 | m_AppDomains[appDomain], | ||
752 | part.ParentGroup.RootPart.Name, | ||
753 | item.Name, startParam, postOnRez, | ||
754 | stateSource, m_MaxScriptQueue); | ||
755 | |||
756 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", | ||
757 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); | ||
758 | |||
759 | if (presence != null) | ||
760 | { | 806 | { |
761 | ShowScriptSaveResponse(item.OwnerID, | 807 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
762 | assetID, "Compile successful", true); | 808 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
809 | m_ScriptFailCount++; | ||
810 | lock (m_AddingAssemblies) | ||
811 | { | ||
812 | m_AddingAssemblies[assembly]--; | ||
813 | } | ||
814 | return false; | ||
763 | } | 815 | } |
816 | } | ||
817 | m_DomainScripts[appDomain].Add(itemID); | ||
764 | 818 | ||
765 | instance.AppDomain = appDomain; | 819 | instance = new ScriptInstance(this, part, |
766 | instance.LineMap = linemap; | 820 | itemID, assetID, assembly, |
821 | m_AppDomains[appDomain], | ||
822 | part.ParentGroup.RootPart.Name, | ||
823 | item.Name, startParam, postOnRez, | ||
824 | stateSource, m_MaxScriptQueue); | ||
767 | 825 | ||
768 | m_Scripts[itemID] = instance; | 826 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", |
769 | } | 827 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); |
770 | 828 | ||
771 | lock (m_PrimObjects) | 829 | if (presence != null) |
772 | { | 830 | { |
773 | if (!m_PrimObjects.ContainsKey(localID)) | 831 | ShowScriptSaveResponse(item.OwnerID, |
774 | m_PrimObjects[localID] = new List<UUID>(); | 832 | assetID, "Compile successful", true); |
833 | } | ||
775 | 834 | ||
776 | if (!m_PrimObjects[localID].Contains(itemID)) | 835 | instance.AppDomain = appDomain; |
777 | m_PrimObjects[localID].Add(itemID); | 836 | instance.LineMap = linemap; |
837 | lockScriptsForWrite(true); | ||
838 | m_Scripts[itemID] = instance; | ||
839 | lockScriptsForWrite(false); | ||
840 | } | ||
841 | else | ||
842 | { | ||
843 | lockScriptsForRead(false); | ||
844 | } | ||
845 | lock (m_PrimObjects) | ||
846 | { | ||
847 | if (!m_PrimObjects.ContainsKey(localID)) | ||
848 | m_PrimObjects[localID] = new List<UUID>(); | ||
778 | 849 | ||
779 | } | 850 | if (!m_PrimObjects[localID].Contains(itemID)) |
851 | m_PrimObjects[localID].Add(itemID); | ||
780 | 852 | ||
781 | if (!m_Assemblies.ContainsKey(assetID)) | 853 | } |
782 | m_Assemblies[assetID] = assembly; | ||
783 | 854 | ||
784 | lock (m_AddingAssemblies) | 855 | if (!m_Assemblies.ContainsKey(assetID)) |
785 | { | 856 | m_Assemblies[assetID] = assembly; |
786 | m_AddingAssemblies[assembly]--; | ||
787 | } | ||
788 | 857 | ||
789 | if (instance!=null) | 858 | lock (m_AddingAssemblies) |
790 | instance.Init(); | 859 | { |
860 | m_AddingAssemblies[assembly]--; | ||
791 | } | 861 | } |
862 | |||
863 | if (instance!=null) | ||
864 | instance.Init(); | ||
865 | |||
792 | return true; | 866 | return true; |
793 | } | 867 | } |
794 | 868 | ||
795 | public void OnRemoveScript(uint localID, UUID itemID) | 869 | public void OnRemoveScript(uint localID, UUID itemID) |
796 | { | 870 | { |
797 | lock (m_Scripts) | 871 | lockScriptsForRead(true); |
872 | // Do we even have it? | ||
873 | if (!m_Scripts.ContainsKey(itemID)) | ||
798 | { | 874 | { |
799 | // Do we even have it? | 875 | lockScriptsForRead(false); |
800 | if (!m_Scripts.ContainsKey(itemID)) | 876 | return; |
801 | return; | 877 | } |
802 | 878 | ||
803 | IScriptInstance instance=m_Scripts[itemID]; | ||
804 | m_Scripts.Remove(itemID); | ||
805 | 879 | ||
806 | instance.ClearQueue(); | 880 | IScriptInstance instance=m_Scripts[itemID]; |
807 | instance.Stop(0); | 881 | lockScriptsForRead(false); |
882 | lockScriptsForWrite(true); | ||
883 | m_Scripts.Remove(itemID); | ||
884 | lockScriptsForWrite(false); | ||
885 | instance.ClearQueue(); | ||
886 | instance.Stop(0); | ||
808 | 887 | ||
809 | // bool objectRemoved = false; | 888 | // bool objectRemoved = false; |
810 | 889 | ||
811 | lock (m_PrimObjects) | 890 | lock (m_PrimObjects) |
891 | { | ||
892 | // Remove the script from it's prim | ||
893 | if (m_PrimObjects.ContainsKey(localID)) | ||
812 | { | 894 | { |
813 | // Remove the script from it's prim | 895 | // Remove inventory item record |
814 | if (m_PrimObjects.ContainsKey(localID)) | 896 | if (m_PrimObjects[localID].Contains(itemID)) |
815 | { | 897 | m_PrimObjects[localID].Remove(itemID); |
816 | // Remove inventory item record | ||
817 | if (m_PrimObjects[localID].Contains(itemID)) | ||
818 | m_PrimObjects[localID].Remove(itemID); | ||
819 | 898 | ||
820 | // If there are no more scripts, remove prim | 899 | // If there are no more scripts, remove prim |
821 | if (m_PrimObjects[localID].Count == 0) | 900 | if (m_PrimObjects[localID].Count == 0) |
822 | { | 901 | { |
823 | m_PrimObjects.Remove(localID); | 902 | m_PrimObjects.Remove(localID); |
824 | // objectRemoved = true; | 903 | // objectRemoved = true; |
825 | } | ||
826 | } | 904 | } |
827 | } | 905 | } |
906 | } | ||
828 | 907 | ||
829 | instance.RemoveState(); | 908 | instance.RemoveState(); |
830 | instance.DestroyScriptInstance(); | 909 | instance.DestroyScriptInstance(); |
831 | |||
832 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | ||
833 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
834 | { | ||
835 | m_DomainScripts.Remove(instance.AppDomain); | ||
836 | UnloadAppDomain(instance.AppDomain); | ||
837 | } | ||
838 | 910 | ||
839 | instance = null; | 911 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
912 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
913 | { | ||
914 | m_DomainScripts.Remove(instance.AppDomain); | ||
915 | UnloadAppDomain(instance.AppDomain); | ||
916 | } | ||
840 | 917 | ||
841 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 918 | instance = null; |
842 | if (handlerObjectRemoved != null) | ||
843 | { | ||
844 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
845 | handlerObjectRemoved(part.UUID); | ||
846 | } | ||
847 | 919 | ||
848 | CleanAssemblies(); | 920 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
921 | if (handlerObjectRemoved != null) | ||
922 | { | ||
923 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
924 | handlerObjectRemoved(part.UUID); | ||
849 | } | 925 | } |
850 | 926 | ||
927 | CleanAssemblies(); | ||
928 | |||
929 | |||
851 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 930 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
852 | if (handlerScriptRemoved != null) | 931 | if (handlerScriptRemoved != null) |
853 | handlerScriptRemoved(itemID); | 932 | handlerScriptRemoved(itemID); |
@@ -1099,12 +1178,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1099 | private IScriptInstance GetInstance(UUID itemID) | 1178 | private IScriptInstance GetInstance(UUID itemID) |
1100 | { | 1179 | { |
1101 | IScriptInstance instance; | 1180 | IScriptInstance instance; |
1102 | lock (m_Scripts) | 1181 | lockScriptsForRead(true); |
1182 | if (!m_Scripts.ContainsKey(itemID)) | ||
1103 | { | 1183 | { |
1104 | if (!m_Scripts.ContainsKey(itemID)) | 1184 | lockScriptsForRead(false); |
1105 | return null; | 1185 | return null; |
1106 | instance = m_Scripts[itemID]; | ||
1107 | } | 1186 | } |
1187 | instance = m_Scripts[itemID]; | ||
1188 | lockScriptsForRead(false); | ||
1108 | return instance; | 1189 | return instance; |
1109 | } | 1190 | } |
1110 | 1191 | ||
@@ -1128,6 +1209,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1128 | return false; | 1209 | return false; |
1129 | } | 1210 | } |
1130 | 1211 | ||
1212 | [DebuggerNonUserCode] | ||
1131 | public void ApiResetScript(UUID itemID) | 1213 | public void ApiResetScript(UUID itemID) |
1132 | { | 1214 | { |
1133 | IScriptInstance instance = GetInstance(itemID); | 1215 | IScriptInstance instance = GetInstance(itemID); |
@@ -1179,6 +1261,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1179 | return UUID.Zero; | 1261 | return UUID.Zero; |
1180 | } | 1262 | } |
1181 | 1263 | ||
1264 | [DebuggerNonUserCode] | ||
1182 | public void SetState(UUID itemID, string newState) | 1265 | public void SetState(UUID itemID, string newState) |
1183 | { | 1266 | { |
1184 | IScriptInstance instance = GetInstance(itemID); | 1267 | IScriptInstance instance = GetInstance(itemID); |
@@ -1199,11 +1282,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1199 | { | 1282 | { |
1200 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 1283 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
1201 | 1284 | ||
1202 | lock (m_Scripts) | 1285 | lockScriptsForRead(true); |
1203 | { | 1286 | foreach (IScriptInstance instance in m_Scripts.Values) |
1204 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
1205 | instances.Add(instance); | 1287 | instances.Add(instance); |
1206 | } | 1288 | lockScriptsForRead(false); |
1207 | 1289 | ||
1208 | foreach (IScriptInstance i in instances) | 1290 | foreach (IScriptInstance i in instances) |
1209 | { | 1291 | { |