diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
5 files changed, 872 insertions, 357 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..4fb5c95 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -113,6 +113,31 @@ 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 != null && avatar.UUID != m_host.OwnerID) | ||
125 | { | ||
126 | if (avatar.IsChildAgent == false) | ||
127 | { | ||
128 | if (avatar.PhysicsActor != null && avatar.PhysicsActor.Position != null) | ||
129 | { | ||
130 | result.Add(avatar.UUID); | ||
131 | result.Add(avatar.PhysicsActor.Position); | ||
132 | result.Add(avatar.Name); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | }); | ||
137 | return result; | ||
138 | } | ||
139 | |||
140 | /// <summary> | ||
116 | /// Get the current Windlight scene | 141 | /// Get the current Windlight scene |
117 | /// </summary> | 142 | /// </summary> |
118 | /// <returns>List of windlight parameters</returns> | 143 | /// <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 5400a4f..0a4544c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
151 | get { return m_ScriptEngine.World; } | 152 | get { return m_ScriptEngine.World; } |
152 | } | 153 | } |
153 | 154 | ||
155 | [DebuggerNonUserCode] | ||
154 | public void state(string newState) | 156 | public void state(string newState) |
155 | { | 157 | { |
156 | m_ScriptEngine.SetState(m_itemID, newState); | 158 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | /// Reset the named script. The script must be present | 162 | /// Reset the named script. The script must be present |
161 | /// in the same prim. | 163 | /// in the same prim. |
162 | /// </summary> | 164 | /// </summary> |
165 | [DebuggerNonUserCode] | ||
163 | public void llResetScript() | 166 | public void llResetScript() |
164 | { | 167 | { |
165 | m_host.AddScriptLPS(1); | 168 | m_host.AddScriptLPS(1); |
@@ -219,6 +222,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
219 | public List<SceneObjectPart> GetLinkParts(int linkType) | 222 | public List<SceneObjectPart> GetLinkParts(int linkType) |
220 | { | 223 | { |
221 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 224 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
225 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
226 | return ret; | ||
222 | ret.Add(m_host); | 227 | ret.Add(m_host); |
223 | 228 | ||
224 | switch (linkType) | 229 | switch (linkType) |
@@ -272,40 +277,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 277 | protected UUID InventorySelf() |
273 | { | 278 | { |
274 | UUID invItemID = new UUID(); | 279 | UUID invItemID = new UUID(); |
275 | 280 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 281 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
282 | { | ||
283 | m_host.TaskInventory.LockItemsForRead(true); | ||
284 | unlock = true; | ||
285 | } | ||
286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 287 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 288 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 289 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 290 | invItemID = inv.Key; |
281 | { | 291 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 292 | } |
286 | } | 293 | } |
287 | 294 | if (unlock) | |
295 | { | ||
296 | m_host.TaskInventory.LockItemsForRead(false); | ||
297 | } | ||
288 | return invItemID; | 298 | return invItemID; |
289 | } | 299 | } |
290 | 300 | ||
291 | protected UUID InventoryKey(string name, int type) | 301 | protected UUID InventoryKey(string name, int type) |
292 | { | 302 | { |
293 | m_host.AddScriptLPS(1); | 303 | m_host.AddScriptLPS(1); |
294 | 304 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 305 | |
306 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 307 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 308 | if (inv.Value.Name == name) |
298 | { | 309 | { |
299 | if (inv.Value.Name == name) | 310 | m_host.TaskInventory.LockItemsForRead(false); |
311 | |||
312 | if (inv.Value.Type != type) | ||
300 | { | 313 | { |
301 | if (inv.Value.Type != type) | 314 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 315 | } |
316 | |||
317 | return inv.Value.AssetID; | ||
306 | } | 318 | } |
307 | } | 319 | } |
308 | 320 | ||
321 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 322 | return UUID.Zero; |
310 | } | 323 | } |
311 | 324 | ||
@@ -313,17 +326,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 326 | { |
314 | m_host.AddScriptLPS(1); | 327 | m_host.AddScriptLPS(1); |
315 | 328 | ||
316 | lock (m_host.TaskInventory) | 329 | |
330 | m_host.TaskInventory.LockItemsForRead(true); | ||
331 | |||
332 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 333 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 334 | if (inv.Value.Name == name) |
319 | { | 335 | { |
320 | if (inv.Value.Name == name) | 336 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 337 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 338 | } |
325 | } | 339 | } |
326 | 340 | ||
341 | m_host.TaskInventory.LockItemsForRead(false); | ||
342 | |||
343 | |||
327 | return UUID.Zero; | 344 | return UUID.Zero; |
328 | } | 345 | } |
329 | 346 | ||
@@ -705,6 +722,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
705 | { | 722 | { |
706 | //A and B should both be normalized | 723 | //A and B should both be normalized |
707 | m_host.AddScriptLPS(1); | 724 | m_host.AddScriptLPS(1); |
725 | /* This method is more accurate than the SL one, and thus causes problems | ||
726 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. | ||
727 | |||
708 | double dotProduct = LSL_Vector.Dot(a, b); | 728 | double dotProduct = LSL_Vector.Dot(a, b); |
709 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 729 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
710 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | 730 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
@@ -721,8 +741,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
721 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 741 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
722 | 742 | ||
723 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | 743 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
724 | } | 744 | */ |
725 | 745 | ||
746 | // This method mimics the 180 errors found in SL | ||
747 | // See www.euclideanspace.com... angleBetween | ||
748 | LSL_Vector vec_a = a; | ||
749 | LSL_Vector vec_b = b; | ||
750 | |||
751 | // Eliminate zero length | ||
752 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
753 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
754 | if (vec_a_mag < 0.00001 || | ||
755 | vec_b_mag < 0.00001) | ||
756 | { | ||
757 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
758 | } | ||
759 | |||
760 | // Normalize | ||
761 | vec_a = llVecNorm(vec_a); | ||
762 | vec_b = llVecNorm(vec_b); | ||
763 | |||
764 | // Calculate axis and rotation angle | ||
765 | LSL_Vector axis = vec_a % vec_b; | ||
766 | LSL_Float cos_theta = vec_a * vec_b; | ||
767 | |||
768 | // Check if parallel | ||
769 | if (cos_theta > 0.99999) | ||
770 | { | ||
771 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
772 | } | ||
773 | |||
774 | // Check if anti-parallel | ||
775 | else if (cos_theta < -0.99999) | ||
776 | { | ||
777 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); | ||
778 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); | ||
779 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); | ||
780 | } | ||
781 | else // other rotation | ||
782 | { | ||
783 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; | ||
784 | axis = llVecNorm(axis); | ||
785 | double x, y, z, s, t; | ||
786 | s = Math.Cos(theta); | ||
787 | t = Math.Sin(theta); | ||
788 | x = axis.x * t; | ||
789 | y = axis.y * t; | ||
790 | z = axis.z * t; | ||
791 | return new LSL_Rotation(x,y,z,s); | ||
792 | } | ||
793 | } | ||
794 | |||
726 | public void llWhisper(int channelID, string text) | 795 | public void llWhisper(int channelID, string text) |
727 | { | 796 | { |
728 | m_host.AddScriptLPS(1); | 797 | m_host.AddScriptLPS(1); |
@@ -1046,10 +1115,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1046 | return detectedParams.TouchUV; | 1115 | return detectedParams.TouchUV; |
1047 | } | 1116 | } |
1048 | 1117 | ||
1118 | [DebuggerNonUserCode] | ||
1049 | public virtual void llDie() | 1119 | public virtual void llDie() |
1050 | { | 1120 | { |
1051 | m_host.AddScriptLPS(1); | 1121 | m_host.AddScriptLPS(1); |
1052 | throw new SelfDeleteException(); | 1122 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1053 | } | 1123 | } |
1054 | 1124 | ||
1055 | public LSL_Float llGround(LSL_Vector offset) | 1125 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1122,6 +1192,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1122 | 1192 | ||
1123 | public void llSetStatus(int status, int value) | 1193 | public void llSetStatus(int status, int value) |
1124 | { | 1194 | { |
1195 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1196 | return; | ||
1125 | m_host.AddScriptLPS(1); | 1197 | m_host.AddScriptLPS(1); |
1126 | 1198 | ||
1127 | int statusrotationaxis = 0; | 1199 | int statusrotationaxis = 0; |
@@ -1351,6 +1423,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1351 | { | 1423 | { |
1352 | m_host.AddScriptLPS(1); | 1424 | m_host.AddScriptLPS(1); |
1353 | 1425 | ||
1426 | SetColor(m_host, color, face); | ||
1427 | } | ||
1428 | |||
1429 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1430 | { | ||
1431 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1432 | return; | ||
1433 | |||
1434 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1435 | Color4 texcolor; | ||
1436 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1437 | { | ||
1438 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1439 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1440 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1441 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1442 | tex.FaceTextures[face].RGBA = texcolor; | ||
1443 | part.UpdateTexture(tex); | ||
1444 | return; | ||
1445 | } | ||
1446 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1447 | { | ||
1448 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1449 | { | ||
1450 | if (tex.FaceTextures[i] != null) | ||
1451 | { | ||
1452 | texcolor = tex.FaceTextures[i].RGBA; | ||
1453 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1454 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1455 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1456 | tex.FaceTextures[i].RGBA = texcolor; | ||
1457 | } | ||
1458 | texcolor = tex.DefaultTexture.RGBA; | ||
1459 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1460 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1461 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1462 | tex.DefaultTexture.RGBA = texcolor; | ||
1463 | } | ||
1464 | part.UpdateTexture(tex); | ||
1465 | return; | ||
1466 | } | ||
1467 | |||
1354 | if (face == ScriptBaseClass.ALL_SIDES) | 1468 | if (face == ScriptBaseClass.ALL_SIDES) |
1355 | face = SceneObjectPart.ALL_SIDES; | 1469 | face = SceneObjectPart.ALL_SIDES; |
1356 | 1470 | ||
@@ -1359,6 +1473,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1359 | 1473 | ||
1360 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1474 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1361 | { | 1475 | { |
1476 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1477 | return; | ||
1478 | |||
1362 | Primitive.TextureEntry tex = part.Shape.Textures; | 1479 | Primitive.TextureEntry tex = part.Shape.Textures; |
1363 | MappingType textype; | 1480 | MappingType textype; |
1364 | textype = MappingType.Default; | 1481 | textype = MappingType.Default; |
@@ -1389,6 +1506,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1389 | 1506 | ||
1390 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1507 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1391 | { | 1508 | { |
1509 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1510 | return; | ||
1511 | |||
1392 | Primitive.TextureEntry tex = part.Shape.Textures; | 1512 | Primitive.TextureEntry tex = part.Shape.Textures; |
1393 | if (face >= 0 && face < GetNumberOfSides(part)) | 1513 | if (face >= 0 && face < GetNumberOfSides(part)) |
1394 | { | 1514 | { |
@@ -1414,6 +1534,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1414 | 1534 | ||
1415 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1535 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1416 | { | 1536 | { |
1537 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1538 | return; | ||
1417 | 1539 | ||
1418 | Shininess sval = new Shininess(); | 1540 | Shininess sval = new Shininess(); |
1419 | 1541 | ||
@@ -1464,6 +1586,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1464 | 1586 | ||
1465 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1587 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1466 | { | 1588 | { |
1589 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1590 | return; | ||
1591 | |||
1467 | Primitive.TextureEntry tex = part.Shape.Textures; | 1592 | Primitive.TextureEntry tex = part.Shape.Textures; |
1468 | if (face >= 0 && face < GetNumberOfSides(part)) | 1593 | if (face >= 0 && face < GetNumberOfSides(part)) |
1469 | { | 1594 | { |
@@ -1524,13 +1649,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1524 | m_host.AddScriptLPS(1); | 1649 | m_host.AddScriptLPS(1); |
1525 | 1650 | ||
1526 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1651 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1527 | 1652 | if (parts.Count > 0) | |
1528 | foreach (SceneObjectPart part in parts) | 1653 | { |
1529 | SetAlpha(part, alpha, face); | 1654 | try |
1655 | { | ||
1656 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1657 | foreach (SceneObjectPart part in parts) | ||
1658 | SetAlpha(part, alpha, face); | ||
1659 | } | ||
1660 | finally | ||
1661 | { | ||
1662 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1663 | } | ||
1664 | } | ||
1530 | } | 1665 | } |
1531 | 1666 | ||
1532 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1667 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1533 | { | 1668 | { |
1669 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1670 | return; | ||
1671 | |||
1534 | Primitive.TextureEntry tex = part.Shape.Textures; | 1672 | Primitive.TextureEntry tex = part.Shape.Textures; |
1535 | Color4 texcolor; | 1673 | Color4 texcolor; |
1536 | if (face >= 0 && face < GetNumberOfSides(part)) | 1674 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1576,7 +1714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1576 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1714 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1577 | float wind, float tension, LSL_Vector Force) | 1715 | float wind, float tension, LSL_Vector Force) |
1578 | { | 1716 | { |
1579 | if (part == null) | 1717 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1580 | return; | 1718 | return; |
1581 | 1719 | ||
1582 | if (flexi) | 1720 | if (flexi) |
@@ -1611,7 +1749,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1611 | /// <param name="falloff"></param> | 1749 | /// <param name="falloff"></param> |
1612 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1750 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1613 | { | 1751 | { |
1614 | if (part == null) | 1752 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1615 | return; | 1753 | return; |
1616 | 1754 | ||
1617 | if (light) | 1755 | if (light) |
@@ -1688,15 +1826,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1688 | m_host.AddScriptLPS(1); | 1826 | m_host.AddScriptLPS(1); |
1689 | 1827 | ||
1690 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 1828 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
1691 | 1829 | if (parts.Count > 0) | |
1692 | foreach (SceneObjectPart part in parts) | 1830 | { |
1693 | SetTexture(part, texture, face); | 1831 | try |
1694 | 1832 | { | |
1833 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
1834 | foreach (SceneObjectPart part in parts) | ||
1835 | SetTexture(part, texture, face); | ||
1836 | } | ||
1837 | finally | ||
1838 | { | ||
1839 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
1840 | } | ||
1841 | } | ||
1695 | ScriptSleep(200); | 1842 | ScriptSleep(200); |
1696 | } | 1843 | } |
1697 | 1844 | ||
1698 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1845 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1699 | { | 1846 | { |
1847 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1848 | return; | ||
1849 | |||
1700 | UUID textureID=new UUID(); | 1850 | UUID textureID=new UUID(); |
1701 | 1851 | ||
1702 | if (!UUID.TryParse(texture, out textureID)) | 1852 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1742,6 +1892,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1742 | 1892 | ||
1743 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1893 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1744 | { | 1894 | { |
1895 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1896 | return; | ||
1897 | |||
1745 | Primitive.TextureEntry tex = part.Shape.Textures; | 1898 | Primitive.TextureEntry tex = part.Shape.Textures; |
1746 | if (face >= 0 && face < GetNumberOfSides(part)) | 1899 | if (face >= 0 && face < GetNumberOfSides(part)) |
1747 | { | 1900 | { |
@@ -1778,6 +1931,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1778 | 1931 | ||
1779 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1932 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1780 | { | 1933 | { |
1934 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1935 | return; | ||
1936 | |||
1781 | Primitive.TextureEntry tex = part.Shape.Textures; | 1937 | Primitive.TextureEntry tex = part.Shape.Textures; |
1782 | if (face >= 0 && face < GetNumberOfSides(part)) | 1938 | if (face >= 0 && face < GetNumberOfSides(part)) |
1783 | { | 1939 | { |
@@ -1814,6 +1970,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1814 | 1970 | ||
1815 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1971 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1816 | { | 1972 | { |
1973 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1974 | return; | ||
1975 | |||
1817 | Primitive.TextureEntry tex = part.Shape.Textures; | 1976 | Primitive.TextureEntry tex = part.Shape.Textures; |
1818 | if (face >= 0 && face < GetNumberOfSides(part)) | 1977 | if (face >= 0 && face < GetNumberOfSides(part)) |
1819 | { | 1978 | { |
@@ -1884,6 +2043,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1884 | 2043 | ||
1885 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2044 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1886 | { | 2045 | { |
2046 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2047 | return; | ||
2048 | |||
1887 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2049 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1888 | LSL_Vector currentPos = llGetLocalPos(); | 2050 | LSL_Vector currentPos = llGetLocalPos(); |
1889 | 2051 | ||
@@ -1970,6 +2132,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1970 | 2132 | ||
1971 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2133 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1972 | { | 2134 | { |
2135 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2136 | return; | ||
2137 | |||
1973 | part.UpdateRotation(rot); | 2138 | part.UpdateRotation(rot); |
1974 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2139 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1975 | 2140 | ||
@@ -2589,12 +2754,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2589 | 2754 | ||
2590 | m_host.AddScriptLPS(1); | 2755 | m_host.AddScriptLPS(1); |
2591 | 2756 | ||
2757 | m_host.TaskInventory.LockItemsForRead(true); | ||
2592 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2758 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2593 | 2759 | m_host.TaskInventory.LockItemsForRead(false); | |
2594 | lock (m_host.TaskInventory) | ||
2595 | { | ||
2596 | item = m_host.TaskInventory[invItemID]; | ||
2597 | } | ||
2598 | 2760 | ||
2599 | if (item.PermsGranter == UUID.Zero) | 2761 | if (item.PermsGranter == UUID.Zero) |
2600 | return 0; | 2762 | return 0; |
@@ -2669,6 +2831,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2669 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2831 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2670 | return; | 2832 | return; |
2671 | 2833 | ||
2834 | //Clone is thread-safe | ||
2672 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2835 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2673 | 2836 | ||
2674 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2837 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2729,6 +2892,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2729 | 2892 | ||
2730 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2893 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2731 | { | 2894 | { |
2895 | /* | ||
2732 | m_host.AddScriptLPS(1); | 2896 | m_host.AddScriptLPS(1); |
2733 | // Determine where we are looking from | 2897 | // Determine where we are looking from |
2734 | LSL_Vector from = llGetPos(); | 2898 | LSL_Vector from = llGetPos(); |
@@ -2748,10 +2912,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2748 | // the angles of rotation in radians into rotation value | 2912 | // the angles of rotation in radians into rotation value |
2749 | 2913 | ||
2750 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2914 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2751 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2915 | |
2752 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2916 | // This would only work if your physics system contains an APID controller: |
2917 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2918 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2919 | |||
2753 | // Orient the object to the angle calculated | 2920 | // Orient the object to the angle calculated |
2754 | //llSetRot(rot); | 2921 | llSetRot(rot); |
2922 | */ | ||
2923 | |||
2924 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2925 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2926 | // http://bugs.meta7.com/view.php?id=28 | ||
2927 | // - Tom | ||
2928 | |||
2929 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2930 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2931 | |||
2932 | } | ||
2933 | |||
2934 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2935 | { | ||
2936 | m_host.AddScriptLPS(1); | ||
2937 | // NotImplemented("llRotLookAt"); | ||
2938 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2939 | |||
2755 | } | 2940 | } |
2756 | 2941 | ||
2757 | public void llStopLookAt() | 2942 | public void llStopLookAt() |
@@ -2800,13 +2985,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2800 | { | 2985 | { |
2801 | TaskInventoryItem item; | 2986 | TaskInventoryItem item; |
2802 | 2987 | ||
2803 | lock (m_host.TaskInventory) | 2988 | m_host.TaskInventory.LockItemsForRead(true); |
2989 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2804 | { | 2990 | { |
2805 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2991 | m_host.TaskInventory.LockItemsForRead(false); |
2806 | return; | 2992 | return; |
2807 | else | ||
2808 | item = m_host.TaskInventory[InventorySelf()]; | ||
2809 | } | 2993 | } |
2994 | else | ||
2995 | { | ||
2996 | item = m_host.TaskInventory[InventorySelf()]; | ||
2997 | } | ||
2998 | m_host.TaskInventory.LockItemsForRead(false); | ||
2810 | 2999 | ||
2811 | if (item.PermsGranter != UUID.Zero) | 3000 | if (item.PermsGranter != UUID.Zero) |
2812 | { | 3001 | { |
@@ -2828,13 +3017,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2828 | { | 3017 | { |
2829 | TaskInventoryItem item; | 3018 | TaskInventoryItem item; |
2830 | 3019 | ||
3020 | m_host.TaskInventory.LockItemsForRead(true); | ||
2831 | lock (m_host.TaskInventory) | 3021 | lock (m_host.TaskInventory) |
2832 | { | 3022 | { |
3023 | |||
2833 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3024 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3025 | { | ||
3026 | m_host.TaskInventory.LockItemsForRead(false); | ||
2834 | return; | 3027 | return; |
3028 | } | ||
2835 | else | 3029 | else |
3030 | { | ||
2836 | item = m_host.TaskInventory[InventorySelf()]; | 3031 | item = m_host.TaskInventory[InventorySelf()]; |
3032 | } | ||
2837 | } | 3033 | } |
3034 | m_host.TaskInventory.LockItemsForRead(false); | ||
2838 | 3035 | ||
2839 | m_host.AddScriptLPS(1); | 3036 | m_host.AddScriptLPS(1); |
2840 | 3037 | ||
@@ -2871,14 +3068,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2871 | 3068 | ||
2872 | TaskInventoryItem item; | 3069 | TaskInventoryItem item; |
2873 | 3070 | ||
2874 | lock (m_host.TaskInventory) | 3071 | m_host.TaskInventory.LockItemsForRead(true); |
3072 | |||
3073 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2875 | { | 3074 | { |
2876 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3075 | m_host.TaskInventory.LockItemsForRead(false); |
2877 | return; | 3076 | return; |
2878 | else | 3077 | } |
2879 | item = m_host.TaskInventory[InventorySelf()]; | 3078 | else |
3079 | { | ||
3080 | item = m_host.TaskInventory[InventorySelf()]; | ||
2880 | } | 3081 | } |
2881 | 3082 | ||
3083 | m_host.TaskInventory.LockItemsForRead(false); | ||
3084 | |||
2882 | if (item.PermsGranter != m_host.OwnerID) | 3085 | if (item.PermsGranter != m_host.OwnerID) |
2883 | return; | 3086 | return; |
2884 | 3087 | ||
@@ -2905,13 +3108,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2905 | 3108 | ||
2906 | TaskInventoryItem item; | 3109 | TaskInventoryItem item; |
2907 | 3110 | ||
2908 | lock (m_host.TaskInventory) | 3111 | m_host.TaskInventory.LockItemsForRead(true); |
3112 | |||
3113 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2909 | { | 3114 | { |
2910 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3115 | m_host.TaskInventory.LockItemsForRead(false); |
2911 | return; | 3116 | return; |
2912 | else | ||
2913 | item = m_host.TaskInventory[InventorySelf()]; | ||
2914 | } | 3117 | } |
3118 | else | ||
3119 | { | ||
3120 | item = m_host.TaskInventory[InventorySelf()]; | ||
3121 | } | ||
3122 | m_host.TaskInventory.LockItemsForRead(false); | ||
3123 | |||
2915 | 3124 | ||
2916 | if (item.PermsGranter != m_host.OwnerID) | 3125 | if (item.PermsGranter != m_host.OwnerID) |
2917 | return; | 3126 | return; |
@@ -2948,8 +3157,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2948 | return m_host.OwnerID.ToString(); | 3157 | return m_host.OwnerID.ToString(); |
2949 | } | 3158 | } |
2950 | 3159 | ||
3160 | [DebuggerNonUserCode] | ||
2951 | public void llInstantMessage(string user, string message) | 3161 | public void llInstantMessage(string user, string message) |
2952 | { | 3162 | { |
3163 | UUID result; | ||
3164 | if (!UUID.TryParse(user, out result)) | ||
3165 | { | ||
3166 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3167 | return; | ||
3168 | } | ||
3169 | |||
3170 | |||
2953 | m_host.AddScriptLPS(1); | 3171 | m_host.AddScriptLPS(1); |
2954 | 3172 | ||
2955 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3173 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2964,7 +3182,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2964 | UUID friendTransactionID = UUID.Random(); | 3182 | UUID friendTransactionID = UUID.Random(); |
2965 | 3183 | ||
2966 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3184 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2967 | 3185 | ||
2968 | GridInstantMessage msg = new GridInstantMessage(); | 3186 | GridInstantMessage msg = new GridInstantMessage(); |
2969 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3187 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2970 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3188 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3113,13 +3331,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3113 | m_host.AddScriptLPS(1); | 3331 | m_host.AddScriptLPS(1); |
3114 | } | 3332 | } |
3115 | 3333 | ||
3116 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3117 | { | ||
3118 | m_host.AddScriptLPS(1); | ||
3119 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3120 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3121 | } | ||
3122 | |||
3123 | public LSL_Integer llStringLength(string str) | 3334 | public LSL_Integer llStringLength(string str) |
3124 | { | 3335 | { |
3125 | m_host.AddScriptLPS(1); | 3336 | m_host.AddScriptLPS(1); |
@@ -3143,14 +3354,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3143 | 3354 | ||
3144 | TaskInventoryItem item; | 3355 | TaskInventoryItem item; |
3145 | 3356 | ||
3146 | lock (m_host.TaskInventory) | 3357 | m_host.TaskInventory.LockItemsForRead(true); |
3358 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3147 | { | 3359 | { |
3148 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3360 | m_host.TaskInventory.LockItemsForRead(false); |
3149 | return; | 3361 | return; |
3150 | else | ||
3151 | item = m_host.TaskInventory[InventorySelf()]; | ||
3152 | } | 3362 | } |
3153 | 3363 | else | |
3364 | { | ||
3365 | item = m_host.TaskInventory[InventorySelf()]; | ||
3366 | } | ||
3367 | m_host.TaskInventory.LockItemsForRead(false); | ||
3154 | if (item.PermsGranter == UUID.Zero) | 3368 | if (item.PermsGranter == UUID.Zero) |
3155 | return; | 3369 | return; |
3156 | 3370 | ||
@@ -3180,13 +3394,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3180 | 3394 | ||
3181 | TaskInventoryItem item; | 3395 | TaskInventoryItem item; |
3182 | 3396 | ||
3183 | lock (m_host.TaskInventory) | 3397 | m_host.TaskInventory.LockItemsForRead(true); |
3398 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3184 | { | 3399 | { |
3185 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3400 | m_host.TaskInventory.LockItemsForRead(false); |
3186 | return; | 3401 | return; |
3187 | else | ||
3188 | item = m_host.TaskInventory[InventorySelf()]; | ||
3189 | } | 3402 | } |
3403 | else | ||
3404 | { | ||
3405 | item = m_host.TaskInventory[InventorySelf()]; | ||
3406 | } | ||
3407 | m_host.TaskInventory.LockItemsForRead(false); | ||
3408 | |||
3190 | 3409 | ||
3191 | if (item.PermsGranter == UUID.Zero) | 3410 | if (item.PermsGranter == UUID.Zero) |
3192 | return; | 3411 | return; |
@@ -3263,10 +3482,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3263 | 3482 | ||
3264 | TaskInventoryItem item; | 3483 | TaskInventoryItem item; |
3265 | 3484 | ||
3266 | lock (m_host.TaskInventory) | 3485 | |
3486 | m_host.TaskInventory.LockItemsForRead(true); | ||
3487 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3488 | { | ||
3489 | m_host.TaskInventory.LockItemsForRead(false); | ||
3490 | return; | ||
3491 | } | ||
3492 | else | ||
3267 | { | 3493 | { |
3268 | item = m_host.TaskInventory[invItemID]; | 3494 | item = m_host.TaskInventory[invItemID]; |
3269 | } | 3495 | } |
3496 | m_host.TaskInventory.LockItemsForRead(false); | ||
3270 | 3497 | ||
3271 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3498 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3272 | { | 3499 | { |
@@ -3298,11 +3525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3298 | 3525 | ||
3299 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3526 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3300 | { | 3527 | { |
3301 | lock (m_host.TaskInventory) | 3528 | m_host.TaskInventory.LockItemsForWrite(true); |
3302 | { | 3529 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3303 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3530 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3304 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3531 | m_host.TaskInventory.LockItemsForWrite(false); |
3305 | } | ||
3306 | 3532 | ||
3307 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3533 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3308 | "run_time_permissions", new Object[] { | 3534 | "run_time_permissions", new Object[] { |
@@ -3322,11 +3548,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3322 | 3548 | ||
3323 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3549 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3324 | { | 3550 | { |
3325 | lock (m_host.TaskInventory) | 3551 | m_host.TaskInventory.LockItemsForWrite(true); |
3326 | { | 3552 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3327 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3553 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3328 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3554 | m_host.TaskInventory.LockItemsForWrite(false); |
3329 | } | ||
3330 | 3555 | ||
3331 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3556 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3332 | "run_time_permissions", new Object[] { | 3557 | "run_time_permissions", new Object[] { |
@@ -3347,11 +3572,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3347 | 3572 | ||
3348 | if (!m_waitingForScriptAnswer) | 3573 | if (!m_waitingForScriptAnswer) |
3349 | { | 3574 | { |
3350 | lock (m_host.TaskInventory) | 3575 | m_host.TaskInventory.LockItemsForWrite(true); |
3351 | { | 3576 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3352 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3577 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3353 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3578 | m_host.TaskInventory.LockItemsForWrite(false); |
3354 | } | ||
3355 | 3579 | ||
3356 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3580 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3357 | m_waitingForScriptAnswer=true; | 3581 | m_waitingForScriptAnswer=true; |
@@ -3386,10 +3610,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3386 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3610 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3387 | llReleaseControls(); | 3611 | llReleaseControls(); |
3388 | 3612 | ||
3389 | lock (m_host.TaskInventory) | 3613 | |
3390 | { | 3614 | m_host.TaskInventory.LockItemsForWrite(true); |
3391 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3615 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3392 | } | 3616 | m_host.TaskInventory.LockItemsForWrite(false); |
3617 | |||
3393 | 3618 | ||
3394 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3619 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3395 | "run_time_permissions", new Object[] { | 3620 | "run_time_permissions", new Object[] { |
@@ -3401,16 +3626,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3401 | { | 3626 | { |
3402 | m_host.AddScriptLPS(1); | 3627 | m_host.AddScriptLPS(1); |
3403 | 3628 | ||
3404 | lock (m_host.TaskInventory) | 3629 | m_host.TaskInventory.LockItemsForRead(true); |
3630 | |||
3631 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3405 | { | 3632 | { |
3406 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3633 | if (item.Type == 10 && item.ItemID == m_itemID) |
3407 | { | 3634 | { |
3408 | if (item.Type == 10 && item.ItemID == m_itemID) | 3635 | m_host.TaskInventory.LockItemsForRead(false); |
3409 | { | 3636 | return item.PermsGranter.ToString(); |
3410 | return item.PermsGranter.ToString(); | ||
3411 | } | ||
3412 | } | 3637 | } |
3413 | } | 3638 | } |
3639 | m_host.TaskInventory.LockItemsForRead(false); | ||
3414 | 3640 | ||
3415 | return UUID.Zero.ToString(); | 3641 | return UUID.Zero.ToString(); |
3416 | } | 3642 | } |
@@ -3419,19 +3645,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3419 | { | 3645 | { |
3420 | m_host.AddScriptLPS(1); | 3646 | m_host.AddScriptLPS(1); |
3421 | 3647 | ||
3422 | lock (m_host.TaskInventory) | 3648 | m_host.TaskInventory.LockItemsForRead(true); |
3649 | |||
3650 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3423 | { | 3651 | { |
3424 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3652 | if (item.Type == 10 && item.ItemID == m_itemID) |
3425 | { | 3653 | { |
3426 | if (item.Type == 10 && item.ItemID == m_itemID) | 3654 | int perms = item.PermsMask; |
3427 | { | 3655 | if (m_automaticLinkPermission) |
3428 | int perms = item.PermsMask; | 3656 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3429 | if (m_automaticLinkPermission) | 3657 | m_host.TaskInventory.LockItemsForRead(false); |
3430 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3658 | return perms; |
3431 | return perms; | ||
3432 | } | ||
3433 | } | 3659 | } |
3434 | } | 3660 | } |
3661 | m_host.TaskInventory.LockItemsForRead(false); | ||
3435 | 3662 | ||
3436 | return 0; | 3663 | return 0; |
3437 | } | 3664 | } |
@@ -3453,9 +3680,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3453 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) | 3680 | public void llSetLinkColor(int linknumber, LSL_Vector color, int face) |
3454 | { | 3681 | { |
3455 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3682 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3456 | 3683 | if (parts.Count > 0) | |
3457 | foreach (SceneObjectPart part in parts) | 3684 | { |
3458 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3685 | try |
3686 | { | ||
3687 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3688 | foreach (SceneObjectPart part in parts) | ||
3689 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
3690 | } | ||
3691 | finally | ||
3692 | { | ||
3693 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3694 | } | ||
3695 | } | ||
3459 | } | 3696 | } |
3460 | 3697 | ||
3461 | public void llCreateLink(string target, int parent) | 3698 | public void llCreateLink(string target, int parent) |
@@ -3464,11 +3701,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3464 | UUID invItemID = InventorySelf(); | 3701 | UUID invItemID = InventorySelf(); |
3465 | 3702 | ||
3466 | TaskInventoryItem item; | 3703 | TaskInventoryItem item; |
3467 | lock (m_host.TaskInventory) | 3704 | m_host.TaskInventory.LockItemsForRead(true); |
3468 | { | 3705 | item = m_host.TaskInventory[invItemID]; |
3469 | item = m_host.TaskInventory[invItemID]; | 3706 | m_host.TaskInventory.LockItemsForRead(false); |
3470 | } | 3707 | |
3471 | |||
3472 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3708 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3473 | && !m_automaticLinkPermission) | 3709 | && !m_automaticLinkPermission) |
3474 | { | 3710 | { |
@@ -3521,16 +3757,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3521 | m_host.AddScriptLPS(1); | 3757 | m_host.AddScriptLPS(1); |
3522 | UUID invItemID = InventorySelf(); | 3758 | UUID invItemID = InventorySelf(); |
3523 | 3759 | ||
3524 | lock (m_host.TaskInventory) | 3760 | m_host.TaskInventory.LockItemsForRead(true); |
3525 | { | ||
3526 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3761 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3527 | && !m_automaticLinkPermission) | 3762 | && !m_automaticLinkPermission) |
3528 | { | 3763 | { |
3529 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3764 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3765 | m_host.TaskInventory.LockItemsForRead(false); | ||
3530 | return; | 3766 | return; |
3531 | } | 3767 | } |
3532 | } | 3768 | m_host.TaskInventory.LockItemsForRead(false); |
3533 | 3769 | ||
3534 | if (linknum < ScriptBaseClass.LINK_THIS) | 3770 | if (linknum < ScriptBaseClass.LINK_THIS) |
3535 | return; | 3771 | return; |
3536 | 3772 | ||
@@ -3569,10 +3805,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3569 | // Restructuring Multiple Prims. | 3805 | // Restructuring Multiple Prims. |
3570 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3806 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3571 | parts.Remove(parentPrim.RootPart); | 3807 | parts.Remove(parentPrim.RootPart); |
3572 | foreach (SceneObjectPart part in parts) | 3808 | if (parts.Count > 0) |
3573 | { | 3809 | { |
3574 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3810 | try |
3811 | { | ||
3812 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3813 | foreach (SceneObjectPart part in parts) | ||
3814 | { | ||
3815 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3816 | } | ||
3817 | } | ||
3818 | finally | ||
3819 | { | ||
3820 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3821 | } | ||
3575 | } | 3822 | } |
3823 | |||
3576 | parentPrim.HasGroupChanged = true; | 3824 | parentPrim.HasGroupChanged = true; |
3577 | parentPrim.ScheduleGroupForFullUpdate(); | 3825 | parentPrim.ScheduleGroupForFullUpdate(); |
3578 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3826 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); |
@@ -3581,11 +3829,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3581 | { | 3829 | { |
3582 | SceneObjectPart newRoot = parts[0]; | 3830 | SceneObjectPart newRoot = parts[0]; |
3583 | parts.Remove(newRoot); | 3831 | parts.Remove(newRoot); |
3584 | foreach (SceneObjectPart part in parts) | 3832 | |
3833 | try | ||
3585 | { | 3834 | { |
3586 | part.UpdateFlag = 0; | 3835 | parts[0].ParentGroup.areUpdatesSuspended = true; |
3587 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | 3836 | foreach (SceneObjectPart part in parts) |
3837 | { | ||
3838 | part.UpdateFlag = 0; | ||
3839 | newRoot.ParentGroup.LinkToGroup(part.ParentGroup); | ||
3840 | } | ||
3588 | } | 3841 | } |
3842 | finally | ||
3843 | { | ||
3844 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3845 | } | ||
3846 | |||
3847 | |||
3589 | newRoot.ParentGroup.HasGroupChanged = true; | 3848 | newRoot.ParentGroup.HasGroupChanged = true; |
3590 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | 3849 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); |
3591 | } | 3850 | } |
@@ -3611,11 +3870,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3611 | 3870 | ||
3612 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); | 3871 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values); |
3613 | parts.Remove(parentPrim.RootPart); | 3872 | parts.Remove(parentPrim.RootPart); |
3614 | 3873 | if (parts.Count > 0) | |
3615 | foreach (SceneObjectPart part in parts) | ||
3616 | { | 3874 | { |
3617 | parentPrim.DelinkFromGroup(part.LocalId, true); | 3875 | try |
3618 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | 3876 | { |
3877 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
3878 | foreach (SceneObjectPart part in parts) | ||
3879 | { | ||
3880 | parentPrim.DelinkFromGroup(part.LocalId, true); | ||
3881 | parentPrim.TriggerScriptChangedEvent(Changed.LINK); | ||
3882 | } | ||
3883 | } | ||
3884 | finally | ||
3885 | { | ||
3886 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
3887 | } | ||
3619 | } | 3888 | } |
3620 | parentPrim.HasGroupChanged = true; | 3889 | parentPrim.HasGroupChanged = true; |
3621 | parentPrim.ScheduleGroupForFullUpdate(); | 3890 | parentPrim.ScheduleGroupForFullUpdate(); |
@@ -3707,17 +3976,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3707 | m_host.AddScriptLPS(1); | 3976 | m_host.AddScriptLPS(1); |
3708 | int count = 0; | 3977 | int count = 0; |
3709 | 3978 | ||
3710 | lock (m_host.TaskInventory) | 3979 | m_host.TaskInventory.LockItemsForRead(true); |
3980 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3711 | { | 3981 | { |
3712 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3982 | if (inv.Value.Type == type || type == -1) |
3713 | { | 3983 | { |
3714 | if (inv.Value.Type == type || type == -1) | 3984 | count = count + 1; |
3715 | { | ||
3716 | count = count + 1; | ||
3717 | } | ||
3718 | } | 3985 | } |
3719 | } | 3986 | } |
3720 | 3987 | ||
3988 | m_host.TaskInventory.LockItemsForRead(false); | ||
3721 | return count; | 3989 | return count; |
3722 | } | 3990 | } |
3723 | 3991 | ||
@@ -3726,16 +3994,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3726 | m_host.AddScriptLPS(1); | 3994 | m_host.AddScriptLPS(1); |
3727 | ArrayList keys = new ArrayList(); | 3995 | ArrayList keys = new ArrayList(); |
3728 | 3996 | ||
3729 | lock (m_host.TaskInventory) | 3997 | m_host.TaskInventory.LockItemsForRead(true); |
3998 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3730 | { | 3999 | { |
3731 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4000 | if (inv.Value.Type == type || type == -1) |
3732 | { | 4001 | { |
3733 | if (inv.Value.Type == type || type == -1) | 4002 | keys.Add(inv.Value.Name); |
3734 | { | ||
3735 | keys.Add(inv.Value.Name); | ||
3736 | } | ||
3737 | } | 4003 | } |
3738 | } | 4004 | } |
4005 | m_host.TaskInventory.LockItemsForRead(false); | ||
3739 | 4006 | ||
3740 | if (keys.Count == 0) | 4007 | if (keys.Count == 0) |
3741 | { | 4008 | { |
@@ -3772,20 +4039,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3772 | } | 4039 | } |
3773 | 4040 | ||
3774 | // move the first object found with this inventory name | 4041 | // move the first object found with this inventory name |
3775 | lock (m_host.TaskInventory) | 4042 | m_host.TaskInventory.LockItemsForRead(true); |
4043 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3776 | { | 4044 | { |
3777 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4045 | if (inv.Value.Name == inventory) |
3778 | { | 4046 | { |
3779 | if (inv.Value.Name == inventory) | 4047 | found = true; |
3780 | { | 4048 | objId = inv.Key; |
3781 | found = true; | 4049 | assetType = inv.Value.Type; |
3782 | objId = inv.Key; | 4050 | objName = inv.Value.Name; |
3783 | assetType = inv.Value.Type; | 4051 | break; |
3784 | objName = inv.Value.Name; | ||
3785 | break; | ||
3786 | } | ||
3787 | } | 4052 | } |
3788 | } | 4053 | } |
4054 | m_host.TaskInventory.LockItemsForRead(false); | ||
3789 | 4055 | ||
3790 | if (!found) | 4056 | if (!found) |
3791 | { | 4057 | { |
@@ -3793,9 +4059,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3793 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 4059 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3794 | } | 4060 | } |
3795 | 4061 | ||
3796 | // check if destination is an avatar | 4062 | // check if destination is an object |
3797 | if (World.GetScenePresence(destId) != null) | 4063 | if (World.GetSceneObjectPart(destId) != null) |
4064 | { | ||
4065 | // destination is an object | ||
4066 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
4067 | } | ||
4068 | else | ||
3798 | { | 4069 | { |
4070 | ScenePresence presence = World.GetScenePresence(destId); | ||
4071 | |||
4072 | if (presence == null) | ||
4073 | { | ||
4074 | UserAccount account = | ||
4075 | World.UserAccountService.GetUserAccount( | ||
4076 | World.RegionInfo.ScopeID, | ||
4077 | destId); | ||
4078 | |||
4079 | if (account == null) | ||
4080 | { | ||
4081 | llSay(0, "Can't find destination "+destId.ToString()); | ||
4082 | return; | ||
4083 | } | ||
4084 | } | ||
4085 | |||
3799 | // destination is an avatar | 4086 | // destination is an avatar |
3800 | InventoryItemBase agentItem = | 4087 | InventoryItemBase agentItem = |
3801 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); | 4088 | World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); |
@@ -3821,33 +4108,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3821 | 4108 | ||
3822 | if (m_TransferModule != null) | 4109 | if (m_TransferModule != null) |
3823 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4110 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4111 | |||
4112 | //This delay should only occur when giving inventory to avatars. | ||
4113 | ScriptSleep(3000); | ||
3824 | } | 4114 | } |
3825 | else | ||
3826 | { | ||
3827 | // destination is an object | ||
3828 | World.MoveTaskInventoryItem(destId, m_host, objId); | ||
3829 | } | ||
3830 | ScriptSleep(3000); | ||
3831 | } | 4115 | } |
3832 | 4116 | ||
4117 | [DebuggerNonUserCode] | ||
3833 | public void llRemoveInventory(string name) | 4118 | public void llRemoveInventory(string name) |
3834 | { | 4119 | { |
3835 | m_host.AddScriptLPS(1); | 4120 | m_host.AddScriptLPS(1); |
3836 | 4121 | ||
3837 | lock (m_host.TaskInventory) | 4122 | m_host.TaskInventory.LockItemsForRead(true); |
4123 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3838 | { | 4124 | { |
3839 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4125 | if (item.Name == name) |
3840 | { | 4126 | { |
3841 | if (item.Name == name) | 4127 | if (item.ItemID == m_itemID) |
3842 | { | 4128 | throw new ScriptDeleteException(); |
3843 | if (item.ItemID == m_itemID) | 4129 | else |
3844 | throw new ScriptDeleteException(); | 4130 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3845 | else | 4131 | |
3846 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4132 | m_host.TaskInventory.LockItemsForRead(false); |
3847 | return; | 4133 | return; |
3848 | } | ||
3849 | } | 4134 | } |
3850 | } | 4135 | } |
4136 | m_host.TaskInventory.LockItemsForRead(false); | ||
3851 | } | 4137 | } |
3852 | 4138 | ||
3853 | public void llSetText(string text, LSL_Vector color, double alpha) | 4139 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3938,6 +4224,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3938 | { | 4224 | { |
3939 | m_host.AddScriptLPS(1); | 4225 | m_host.AddScriptLPS(1); |
3940 | 4226 | ||
4227 | //Clone is thread safe | ||
3941 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4228 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3942 | 4229 | ||
3943 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4230 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3991,6 +4278,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3991 | ScenePresence presence = World.GetScenePresence(agentId); | 4278 | ScenePresence presence = World.GetScenePresence(agentId); |
3992 | if (presence != null) | 4279 | if (presence != null) |
3993 | { | 4280 | { |
4281 | // agent must not be a god | ||
4282 | if (presence.GodLevel >= 200) return; | ||
4283 | |||
3994 | // agent must be over the owners land | 4284 | // agent must be over the owners land |
3995 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4285 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
3996 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4286 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4051,17 +4341,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4051 | UUID soundId = UUID.Zero; | 4341 | UUID soundId = UUID.Zero; |
4052 | if (!UUID.TryParse(impact_sound, out soundId)) | 4342 | if (!UUID.TryParse(impact_sound, out soundId)) |
4053 | { | 4343 | { |
4054 | lock (m_host.TaskInventory) | 4344 | m_host.TaskInventory.LockItemsForRead(true); |
4345 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4055 | { | 4346 | { |
4056 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4347 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4057 | { | 4348 | { |
4058 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4349 | soundId = item.AssetID; |
4059 | { | 4350 | break; |
4060 | soundId = item.AssetID; | ||
4061 | break; | ||
4062 | } | ||
4063 | } | 4351 | } |
4064 | } | 4352 | } |
4353 | m_host.TaskInventory.LockItemsForRead(false); | ||
4065 | } | 4354 | } |
4066 | m_host.CollisionSound = soundId; | 4355 | m_host.CollisionSound = soundId; |
4067 | m_host.CollisionSoundVolume = (float)impact_volume; | 4356 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4107,6 +4396,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4107 | UUID partItemID; | 4396 | UUID partItemID; |
4108 | foreach (SceneObjectPart part in parts) | 4397 | foreach (SceneObjectPart part in parts) |
4109 | { | 4398 | { |
4399 | //Clone is thread safe | ||
4110 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4400 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4111 | 4401 | ||
4112 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4402 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4321,17 +4611,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4321 | 4611 | ||
4322 | m_host.AddScriptLPS(1); | 4612 | m_host.AddScriptLPS(1); |
4323 | 4613 | ||
4324 | lock (m_host.TaskInventory) | 4614 | m_host.TaskInventory.LockItemsForRead(true); |
4615 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4325 | { | 4616 | { |
4326 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4617 | if (item.Type == 10 && item.ItemID == m_itemID) |
4327 | { | 4618 | { |
4328 | if (item.Type == 10 && item.ItemID == m_itemID) | 4619 | result = item.Name!=null?item.Name:String.Empty; |
4329 | { | 4620 | break; |
4330 | result = item.Name != null ? item.Name : String.Empty; | ||
4331 | break; | ||
4332 | } | ||
4333 | } | 4621 | } |
4334 | } | 4622 | } |
4623 | m_host.TaskInventory.LockItemsForRead(false); | ||
4335 | 4624 | ||
4336 | return result; | 4625 | return result; |
4337 | } | 4626 | } |
@@ -4484,23 +4773,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4484 | { | 4773 | { |
4485 | m_host.AddScriptLPS(1); | 4774 | m_host.AddScriptLPS(1); |
4486 | 4775 | ||
4487 | lock (m_host.TaskInventory) | 4776 | m_host.TaskInventory.LockItemsForRead(true); |
4777 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4488 | { | 4778 | { |
4489 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4779 | if (inv.Value.Name == name) |
4490 | { | 4780 | { |
4491 | if (inv.Value.Name == name) | 4781 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4492 | { | 4782 | { |
4493 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4783 | m_host.TaskInventory.LockItemsForRead(false); |
4494 | { | 4784 | return inv.Value.AssetID.ToString(); |
4495 | return inv.Value.AssetID.ToString(); | 4785 | } |
4496 | } | 4786 | else |
4497 | else | 4787 | { |
4498 | { | 4788 | m_host.TaskInventory.LockItemsForRead(false); |
4499 | return UUID.Zero.ToString(); | 4789 | return UUID.Zero.ToString(); |
4500 | } | ||
4501 | } | 4790 | } |
4502 | } | 4791 | } |
4503 | } | 4792 | } |
4793 | m_host.TaskInventory.LockItemsForRead(false); | ||
4504 | 4794 | ||
4505 | return UUID.Zero.ToString(); | 4795 | return UUID.Zero.ToString(); |
4506 | } | 4796 | } |
@@ -5436,10 +5726,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5436 | m_host.AddScriptLPS(1); | 5726 | m_host.AddScriptLPS(1); |
5437 | 5727 | ||
5438 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 5728 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
5439 | 5729 | if (parts.Count > 0) | |
5440 | foreach (var part in parts) | ||
5441 | { | 5730 | { |
5442 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | 5731 | try |
5732 | { | ||
5733 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
5734 | foreach (var part in parts) | ||
5735 | { | ||
5736 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
5737 | } | ||
5738 | } | ||
5739 | finally | ||
5740 | { | ||
5741 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
5742 | } | ||
5443 | } | 5743 | } |
5444 | } | 5744 | } |
5445 | 5745 | ||
@@ -6018,6 +6318,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6018 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6318 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6019 | prules.OuterAngle = (float)tempf; | 6319 | prules.OuterAngle = (float)tempf; |
6020 | break; | 6320 | break; |
6321 | |||
6322 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6323 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6324 | prules.InnerAngle = (float)tempf; | ||
6325 | break; | ||
6326 | |||
6327 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6328 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6329 | prules.OuterAngle = (float)tempf; | ||
6330 | break; | ||
6021 | } | 6331 | } |
6022 | 6332 | ||
6023 | } | 6333 | } |
@@ -6056,14 +6366,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6056 | 6366 | ||
6057 | protected UUID GetTaskInventoryItem(string name) | 6367 | protected UUID GetTaskInventoryItem(string name) |
6058 | { | 6368 | { |
6059 | lock (m_host.TaskInventory) | 6369 | m_host.TaskInventory.LockItemsForRead(true); |
6370 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6060 | { | 6371 | { |
6061 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6372 | if (inv.Value.Name == name) |
6062 | { | 6373 | { |
6063 | if (inv.Value.Name == name) | 6374 | m_host.TaskInventory.LockItemsForRead(false); |
6064 | return inv.Key; | 6375 | return inv.Key; |
6065 | } | 6376 | } |
6066 | } | 6377 | } |
6378 | m_host.TaskInventory.LockItemsForRead(false); | ||
6067 | 6379 | ||
6068 | return UUID.Zero; | 6380 | return UUID.Zero; |
6069 | } | 6381 | } |
@@ -6391,22 +6703,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6391 | } | 6703 | } |
6392 | 6704 | ||
6393 | // copy the first script found with this inventory name | 6705 | // copy the first script found with this inventory name |
6394 | lock (m_host.TaskInventory) | 6706 | m_host.TaskInventory.LockItemsForRead(true); |
6707 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6395 | { | 6708 | { |
6396 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6709 | if (inv.Value.Name == name) |
6397 | { | 6710 | { |
6398 | if (inv.Value.Name == name) | 6711 | // make sure the object is a script |
6712 | if (10 == inv.Value.Type) | ||
6399 | { | 6713 | { |
6400 | // make sure the object is a script | 6714 | found = true; |
6401 | if (10 == inv.Value.Type) | 6715 | srcId = inv.Key; |
6402 | { | 6716 | break; |
6403 | found = true; | ||
6404 | srcId = inv.Key; | ||
6405 | break; | ||
6406 | } | ||
6407 | } | 6717 | } |
6408 | } | 6718 | } |
6409 | } | 6719 | } |
6720 | m_host.TaskInventory.LockItemsForRead(false); | ||
6410 | 6721 | ||
6411 | if (!found) | 6722 | if (!found) |
6412 | { | 6723 | { |
@@ -6490,6 +6801,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6490 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6801 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6491 | { | 6802 | { |
6492 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6803 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6804 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6805 | return shapeBlock; | ||
6493 | 6806 | ||
6494 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6807 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6495 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6808 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6560,6 +6873,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6560 | 6873 | ||
6561 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6874 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6562 | { | 6875 | { |
6876 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6877 | return; | ||
6878 | |||
6563 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6879 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6564 | 6880 | ||
6565 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6881 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6609,6 +6925,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6609 | 6925 | ||
6610 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6926 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6611 | { | 6927 | { |
6928 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6929 | return; | ||
6930 | |||
6612 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6931 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6613 | 6932 | ||
6614 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6933 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6651,6 +6970,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6651 | 6970 | ||
6652 | 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) | 6971 | 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) |
6653 | { | 6972 | { |
6973 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6974 | return; | ||
6975 | |||
6654 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6976 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6655 | 6977 | ||
6656 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6978 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6772,6 +7094,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6772 | 7094 | ||
6773 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7095 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6774 | { | 7096 | { |
7097 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7098 | return; | ||
7099 | |||
6775 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7100 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6776 | UUID sculptId; | 7101 | UUID sculptId; |
6777 | 7102 | ||
@@ -6787,13 +7112,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6787 | shapeBlock.PathScaleX = 100; | 7112 | shapeBlock.PathScaleX = 100; |
6788 | shapeBlock.PathScaleY = 150; | 7113 | shapeBlock.PathScaleY = 150; |
6789 | 7114 | ||
6790 | if (type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && | 7115 | if ((type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER) == 0 && |
6791 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && | 7116 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE) == 0 && |
6792 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && | 7117 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE) == 0 && |
6793 | type != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) | 7118 | (type & (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS) == 0) |
6794 | { | 7119 | { |
6795 | // default | 7120 | // default |
6796 | type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7121 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
6797 | } | 7122 | } |
6798 | 7123 | ||
6799 | // retain pathcurve | 7124 | // retain pathcurve |
@@ -6812,12 +7137,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6812 | 7137 | ||
6813 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7138 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6814 | { | 7139 | { |
6815 | m_host.AddScriptLPS(1); | 7140 | m_host.AddScriptLPS(1); |
6816 | 7141 | ||
6817 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7142 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6818 | 7143 | if (parts.Count>0) | |
6819 | foreach (SceneObjectPart part in parts) | 7144 | { |
6820 | SetPrimParams(part, rules); | 7145 | try |
7146 | { | ||
7147 | parts[0].ParentGroup.areUpdatesSuspended = true; | ||
7148 | foreach (SceneObjectPart part in parts) | ||
7149 | SetPrimParams(part, rules); | ||
7150 | } | ||
7151 | finally | ||
7152 | { | ||
7153 | parts[0].ParentGroup.areUpdatesSuspended = false; | ||
7154 | } | ||
7155 | } | ||
6821 | } | 7156 | } |
6822 | 7157 | ||
6823 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) | 7158 | public void llSetLinkPrimitiveParamsFast(int linknumber, LSL_List rules) |
@@ -6827,6 +7162,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6827 | 7162 | ||
6828 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7163 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6829 | { | 7164 | { |
7165 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7166 | return; | ||
7167 | |||
6830 | int idx = 0; | 7168 | int idx = 0; |
6831 | 7169 | ||
6832 | while (idx < rules.Length) | 7170 | while (idx < rules.Length) |
@@ -7658,24 +7996,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7658 | break; | 7996 | break; |
7659 | 7997 | ||
7660 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7998 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7661 | // TODO-------------- | ||
7662 | if (remain < 1) | 7999 | if (remain < 1) |
7663 | return res; | 8000 | return res; |
8001 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7664 | 8002 | ||
7665 | face=(int)rules.GetLSLIntegerItem(idx++); | 8003 | tex = part.Shape.Textures; |
7666 | 8004 | int shiny; | |
7667 | res.Add(new LSL_Integer(0)); | 8005 | if (face == ScriptBaseClass.ALL_SIDES) |
7668 | res.Add(new LSL_Integer(0)); | 8006 | { |
8007 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8008 | { | ||
8009 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8010 | if (shinyness == Shininess.High) | ||
8011 | { | ||
8012 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8013 | } | ||
8014 | else if (shinyness == Shininess.Medium) | ||
8015 | { | ||
8016 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8017 | } | ||
8018 | else if (shinyness == Shininess.Low) | ||
8019 | { | ||
8020 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8021 | } | ||
8022 | else | ||
8023 | { | ||
8024 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8025 | } | ||
8026 | res.Add(new LSL_Integer(shiny)); | ||
8027 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8028 | } | ||
8029 | } | ||
8030 | else | ||
8031 | { | ||
8032 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
8033 | if (shinyness == Shininess.High) | ||
8034 | { | ||
8035 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
8036 | } | ||
8037 | else if (shinyness == Shininess.Medium) | ||
8038 | { | ||
8039 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
8040 | } | ||
8041 | else if (shinyness == Shininess.Low) | ||
8042 | { | ||
8043 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
8044 | } | ||
8045 | else | ||
8046 | { | ||
8047 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
8048 | } | ||
8049 | res.Add(new LSL_Integer(shiny)); | ||
8050 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
8051 | } | ||
7669 | break; | 8052 | break; |
7670 | 8053 | ||
7671 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8054 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7672 | // TODO-------------- | ||
7673 | if (remain < 1) | 8055 | if (remain < 1) |
7674 | return res; | 8056 | return res; |
8057 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7675 | 8058 | ||
7676 | face=(int)rules.GetLSLIntegerItem(idx++); | 8059 | tex = part.Shape.Textures; |
7677 | 8060 | int fullbright; | |
7678 | res.Add(new LSL_Integer(0)); | 8061 | if (face == ScriptBaseClass.ALL_SIDES) |
8062 | { | ||
8063 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8064 | { | ||
8065 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8066 | { | ||
8067 | fullbright = ScriptBaseClass.TRUE; | ||
8068 | } | ||
8069 | else | ||
8070 | { | ||
8071 | fullbright = ScriptBaseClass.FALSE; | ||
8072 | } | ||
8073 | res.Add(new LSL_Integer(fullbright)); | ||
8074 | } | ||
8075 | } | ||
8076 | else | ||
8077 | { | ||
8078 | if (tex.GetFace((uint)face).Fullbright == true) | ||
8079 | { | ||
8080 | fullbright = ScriptBaseClass.TRUE; | ||
8081 | } | ||
8082 | else | ||
8083 | { | ||
8084 | fullbright = ScriptBaseClass.FALSE; | ||
8085 | } | ||
8086 | res.Add(new LSL_Integer(fullbright)); | ||
8087 | } | ||
7679 | break; | 8088 | break; |
7680 | 8089 | ||
7681 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 8090 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7696,14 +8105,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7696 | break; | 8105 | break; |
7697 | 8106 | ||
7698 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 8107 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7699 | // TODO-------------- | ||
7700 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 8108 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7701 | if (remain < 1) | 8109 | if (remain < 1) |
7702 | return res; | 8110 | return res; |
8111 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7703 | 8112 | ||
7704 | face=(int)rules.GetLSLIntegerItem(idx++); | 8113 | tex = part.Shape.Textures; |
7705 | 8114 | if (face == ScriptBaseClass.ALL_SIDES) | |
7706 | res.Add(new LSL_Integer(0)); | 8115 | { |
8116 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8117 | { | ||
8118 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8119 | { | ||
8120 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8121 | } | ||
8122 | else | ||
8123 | { | ||
8124 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8125 | } | ||
8126 | } | ||
8127 | } | ||
8128 | else | ||
8129 | { | ||
8130 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8131 | { | ||
8132 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8133 | } | ||
8134 | else | ||
8135 | { | ||
8136 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8137 | } | ||
8138 | } | ||
7707 | break; | 8139 | break; |
7708 | 8140 | ||
7709 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8141 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7722,13 +8154,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7722 | break; | 8154 | break; |
7723 | 8155 | ||
7724 | case (int)ScriptBaseClass.PRIM_GLOW: | 8156 | case (int)ScriptBaseClass.PRIM_GLOW: |
7725 | // TODO-------------- | ||
7726 | if (remain < 1) | 8157 | if (remain < 1) |
7727 | return res; | 8158 | return res; |
8159 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7728 | 8160 | ||
7729 | face=(int)rules.GetLSLIntegerItem(idx++); | 8161 | tex = part.Shape.Textures; |
7730 | 8162 | float primglow; | |
7731 | res.Add(new LSL_Float(0)); | 8163 | if (face == ScriptBaseClass.ALL_SIDES) |
8164 | { | ||
8165 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8166 | { | ||
8167 | primglow = tex.GetFace((uint)face).Glow; | ||
8168 | res.Add(new LSL_Float(primglow)); | ||
8169 | } | ||
8170 | } | ||
8171 | else | ||
8172 | { | ||
8173 | primglow = tex.GetFace((uint)face).Glow; | ||
8174 | res.Add(new LSL_Float(primglow)); | ||
8175 | } | ||
7732 | break; | 8176 | break; |
7733 | case (int)ScriptBaseClass.PRIM_TEXT: | 8177 | case (int)ScriptBaseClass.PRIM_TEXT: |
7734 | Color4 textColor = part.GetTextColor(); | 8178 | Color4 textColor = part.GetTextColor(); |
@@ -8265,28 +8709,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8265 | { | 8709 | { |
8266 | m_host.AddScriptLPS(1); | 8710 | m_host.AddScriptLPS(1); |
8267 | 8711 | ||
8268 | lock (m_host.TaskInventory) | 8712 | m_host.TaskInventory.LockItemsForRead(true); |
8713 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8269 | { | 8714 | { |
8270 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8715 | if (inv.Value.Name == item) |
8271 | { | 8716 | { |
8272 | if (inv.Value.Name == item) | 8717 | m_host.TaskInventory.LockItemsForRead(false); |
8718 | switch (mask) | ||
8273 | { | 8719 | { |
8274 | switch (mask) | 8720 | case 0: |
8275 | { | 8721 | return (int)inv.Value.BasePermissions; |
8276 | case 0: | 8722 | case 1: |
8277 | return (int)inv.Value.BasePermissions; | 8723 | return (int)inv.Value.CurrentPermissions; |
8278 | case 1: | 8724 | case 2: |
8279 | return (int)inv.Value.CurrentPermissions; | 8725 | return (int)inv.Value.GroupPermissions; |
8280 | case 2: | 8726 | case 3: |
8281 | return (int)inv.Value.GroupPermissions; | 8727 | return (int)inv.Value.EveryonePermissions; |
8282 | case 3: | 8728 | case 4: |
8283 | return (int)inv.Value.EveryonePermissions; | 8729 | return (int)inv.Value.NextPermissions; |
8284 | case 4: | ||
8285 | return (int)inv.Value.NextPermissions; | ||
8286 | } | ||
8287 | } | 8730 | } |
8288 | } | 8731 | } |
8289 | } | 8732 | } |
8733 | m_host.TaskInventory.LockItemsForRead(false); | ||
8290 | 8734 | ||
8291 | return -1; | 8735 | return -1; |
8292 | } | 8736 | } |
@@ -8333,16 +8777,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8333 | { | 8777 | { |
8334 | m_host.AddScriptLPS(1); | 8778 | m_host.AddScriptLPS(1); |
8335 | 8779 | ||
8336 | lock (m_host.TaskInventory) | 8780 | m_host.TaskInventory.LockItemsForRead(true); |
8781 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8337 | { | 8782 | { |
8338 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8783 | if (inv.Value.Name == item) |
8339 | { | 8784 | { |
8340 | if (inv.Value.Name == item) | 8785 | m_host.TaskInventory.LockItemsForRead(false); |
8341 | { | 8786 | return inv.Value.CreatorID.ToString(); |
8342 | return inv.Value.CreatorID.ToString(); | ||
8343 | } | ||
8344 | } | 8787 | } |
8345 | } | 8788 | } |
8789 | m_host.TaskInventory.LockItemsForRead(false); | ||
8346 | 8790 | ||
8347 | llSay(0, "No item name '" + item + "'"); | 8791 | llSay(0, "No item name '" + item + "'"); |
8348 | 8792 | ||
@@ -8602,17 +9046,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8602 | int width = 0; | 9046 | int width = 0; |
8603 | int height = 0; | 9047 | int height = 0; |
8604 | 9048 | ||
8605 | ParcelMediaCommandEnum? commandToSend = null; | 9049 | uint commandToSend = 0; |
8606 | float time = 0.0f; // default is from start | 9050 | float time = 0.0f; // default is from start |
8607 | 9051 | ||
8608 | ScenePresence presence = null; | 9052 | ScenePresence presence = null; |
8609 | 9053 | ||
8610 | for (int i = 0; i < commandList.Data.Length; i++) | 9054 | for (int i = 0; i < commandList.Data.Length; i++) |
8611 | { | 9055 | { |
8612 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 9056 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8613 | switch (command) | 9057 | switch (command) |
8614 | { | 9058 | { |
8615 | case ParcelMediaCommandEnum.Agent: | 9059 | case (uint)ParcelMediaCommandEnum.Agent: |
8616 | // we send only to one agent | 9060 | // we send only to one agent |
8617 | if ((i + 1) < commandList.Length) | 9061 | if ((i + 1) < commandList.Length) |
8618 | { | 9062 | { |
@@ -8629,25 +9073,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8629 | } | 9073 | } |
8630 | break; | 9074 | break; |
8631 | 9075 | ||
8632 | case ParcelMediaCommandEnum.Loop: | 9076 | case (uint)ParcelMediaCommandEnum.Loop: |
8633 | loop = 1; | 9077 | loop = 1; |
8634 | commandToSend = command; | 9078 | commandToSend = command; |
8635 | update = true; //need to send the media update packet to set looping | 9079 | update = true; //need to send the media update packet to set looping |
8636 | break; | 9080 | break; |
8637 | 9081 | ||
8638 | case ParcelMediaCommandEnum.Play: | 9082 | case (uint)ParcelMediaCommandEnum.Play: |
8639 | loop = 0; | 9083 | loop = 0; |
8640 | commandToSend = command; | 9084 | commandToSend = command; |
8641 | update = true; //need to send the media update packet to make sure it doesn't loop | 9085 | update = true; //need to send the media update packet to make sure it doesn't loop |
8642 | break; | 9086 | break; |
8643 | 9087 | ||
8644 | case ParcelMediaCommandEnum.Pause: | 9088 | case (uint)ParcelMediaCommandEnum.Pause: |
8645 | case ParcelMediaCommandEnum.Stop: | 9089 | case (uint)ParcelMediaCommandEnum.Stop: |
8646 | case ParcelMediaCommandEnum.Unload: | 9090 | case (uint)ParcelMediaCommandEnum.Unload: |
8647 | commandToSend = command; | 9091 | commandToSend = command; |
8648 | break; | 9092 | break; |
8649 | 9093 | ||
8650 | case ParcelMediaCommandEnum.Url: | 9094 | case (uint)ParcelMediaCommandEnum.Url: |
8651 | if ((i + 1) < commandList.Length) | 9095 | if ((i + 1) < commandList.Length) |
8652 | { | 9096 | { |
8653 | if (commandList.Data[i + 1] is LSL_String) | 9097 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8660,7 +9104,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8660 | } | 9104 | } |
8661 | break; | 9105 | break; |
8662 | 9106 | ||
8663 | case ParcelMediaCommandEnum.Texture: | 9107 | case (uint)ParcelMediaCommandEnum.Texture: |
8664 | if ((i + 1) < commandList.Length) | 9108 | if ((i + 1) < commandList.Length) |
8665 | { | 9109 | { |
8666 | if (commandList.Data[i + 1] is LSL_String) | 9110 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8673,7 +9117,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8673 | } | 9117 | } |
8674 | break; | 9118 | break; |
8675 | 9119 | ||
8676 | case ParcelMediaCommandEnum.Time: | 9120 | case (uint)ParcelMediaCommandEnum.Time: |
8677 | if ((i + 1) < commandList.Length) | 9121 | if ((i + 1) < commandList.Length) |
8678 | { | 9122 | { |
8679 | if (commandList.Data[i + 1] is LSL_Float) | 9123 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -8685,7 +9129,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8685 | } | 9129 | } |
8686 | break; | 9130 | break; |
8687 | 9131 | ||
8688 | case ParcelMediaCommandEnum.AutoAlign: | 9132 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
8689 | if ((i + 1) < commandList.Length) | 9133 | if ((i + 1) < commandList.Length) |
8690 | { | 9134 | { |
8691 | if (commandList.Data[i + 1] is LSL_Integer) | 9135 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8699,7 +9143,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8699 | } | 9143 | } |
8700 | break; | 9144 | break; |
8701 | 9145 | ||
8702 | case ParcelMediaCommandEnum.Type: | 9146 | case (uint)ParcelMediaCommandEnum.Type: |
8703 | if ((i + 1) < commandList.Length) | 9147 | if ((i + 1) < commandList.Length) |
8704 | { | 9148 | { |
8705 | if (commandList.Data[i + 1] is LSL_String) | 9149 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8712,7 +9156,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8712 | } | 9156 | } |
8713 | break; | 9157 | break; |
8714 | 9158 | ||
8715 | case ParcelMediaCommandEnum.Desc: | 9159 | case (uint)ParcelMediaCommandEnum.Desc: |
8716 | if ((i + 1) < commandList.Length) | 9160 | if ((i + 1) < commandList.Length) |
8717 | { | 9161 | { |
8718 | if (commandList.Data[i + 1] is LSL_String) | 9162 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8725,7 +9169,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8725 | } | 9169 | } |
8726 | break; | 9170 | break; |
8727 | 9171 | ||
8728 | case ParcelMediaCommandEnum.Size: | 9172 | case (uint)ParcelMediaCommandEnum.Size: |
8729 | if ((i + 2) < commandList.Length) | 9173 | if ((i + 2) < commandList.Length) |
8730 | { | 9174 | { |
8731 | if (commandList.Data[i + 1] is LSL_Integer) | 9175 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8795,7 +9239,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8795 | } | 9239 | } |
8796 | } | 9240 | } |
8797 | 9241 | ||
8798 | if (commandToSend != null) | 9242 | if (commandToSend != 0) |
8799 | { | 9243 | { |
8800 | // the commandList contained a start/stop/... command, too | 9244 | // the commandList contained a start/stop/... command, too |
8801 | if (presence == null) | 9245 | if (presence == null) |
@@ -8875,16 +9319,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8875 | { | 9319 | { |
8876 | m_host.AddScriptLPS(1); | 9320 | m_host.AddScriptLPS(1); |
8877 | 9321 | ||
8878 | lock (m_host.TaskInventory) | 9322 | m_host.TaskInventory.LockItemsForRead(true); |
9323 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8879 | { | 9324 | { |
8880 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9325 | if (inv.Value.Name == name) |
8881 | { | 9326 | { |
8882 | if (inv.Value.Name == name) | 9327 | m_host.TaskInventory.LockItemsForRead(false); |
8883 | { | 9328 | return inv.Value.Type; |
8884 | return inv.Value.Type; | ||
8885 | } | ||
8886 | } | 9329 | } |
8887 | } | 9330 | } |
9331 | m_host.TaskInventory.LockItemsForRead(false); | ||
8888 | 9332 | ||
8889 | return -1; | 9333 | return -1; |
8890 | } | 9334 | } |
@@ -8895,15 +9339,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8895 | 9339 | ||
8896 | if (quick_pay_buttons.Data.Length < 4) | 9340 | if (quick_pay_buttons.Data.Length < 4) |
8897 | { | 9341 | { |
8898 | LSLError("List must have at least 4 elements"); | 9342 | int x; |
8899 | return; | 9343 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9344 | { | ||
9345 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9346 | } | ||
8900 | } | 9347 | } |
8901 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9348 | int[] nPrice = new int[5]; |
8902 | 9349 | nPrice[0]=price; | |
8903 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9350 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8904 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9351 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8905 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9352 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8906 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9353 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9354 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8907 | m_host.ParentGroup.HasGroupChanged = true; | 9355 | m_host.ParentGroup.HasGroupChanged = true; |
8908 | } | 9356 | } |
8909 | 9357 | ||
@@ -8915,17 +9363,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8915 | if (invItemID == UUID.Zero) | 9363 | if (invItemID == UUID.Zero) |
8916 | return new LSL_Vector(); | 9364 | return new LSL_Vector(); |
8917 | 9365 | ||
8918 | lock (m_host.TaskInventory) | 9366 | m_host.TaskInventory.LockItemsForRead(true); |
9367 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8919 | { | 9368 | { |
8920 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9369 | m_host.TaskInventory.LockItemsForRead(false); |
8921 | return new LSL_Vector(); | 9370 | return new LSL_Vector(); |
9371 | } | ||
8922 | 9372 | ||
8923 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9373 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8924 | { | 9374 | { |
8925 | ShoutError("No permissions to track the camera"); | 9375 | ShoutError("No permissions to track the camera"); |
8926 | return new LSL_Vector(); | 9376 | m_host.TaskInventory.LockItemsForRead(false); |
8927 | } | 9377 | return new LSL_Vector(); |
8928 | } | 9378 | } |
9379 | m_host.TaskInventory.LockItemsForRead(false); | ||
8929 | 9380 | ||
8930 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9381 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8931 | if (presence != null) | 9382 | if (presence != null) |
@@ -8943,17 +9394,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8943 | if (invItemID == UUID.Zero) | 9394 | if (invItemID == UUID.Zero) |
8944 | return new LSL_Rotation(); | 9395 | return new LSL_Rotation(); |
8945 | 9396 | ||
8946 | lock (m_host.TaskInventory) | 9397 | m_host.TaskInventory.LockItemsForRead(true); |
9398 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8947 | { | 9399 | { |
8948 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9400 | m_host.TaskInventory.LockItemsForRead(false); |
8949 | return new LSL_Rotation(); | 9401 | return new LSL_Rotation(); |
8950 | 9402 | } | |
8951 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9403 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8952 | { | 9404 | { |
8953 | ShoutError("No permissions to track the camera"); | 9405 | ShoutError("No permissions to track the camera"); |
8954 | return new LSL_Rotation(); | 9406 | m_host.TaskInventory.LockItemsForRead(false); |
8955 | } | 9407 | return new LSL_Rotation(); |
8956 | } | 9408 | } |
9409 | m_host.TaskInventory.LockItemsForRead(false); | ||
8957 | 9410 | ||
8958 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9411 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8959 | if (presence != null) | 9412 | if (presence != null) |
@@ -9103,14 +9556,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9103 | if (objectID == UUID.Zero) return; | 9556 | if (objectID == UUID.Zero) return; |
9104 | 9557 | ||
9105 | UUID agentID; | 9558 | UUID agentID; |
9106 | lock (m_host.TaskInventory) | 9559 | m_host.TaskInventory.LockItemsForRead(true); |
9107 | { | 9560 | // we need the permission first, to know which avatar we want to set the camera for |
9108 | // we need the permission first, to know which avatar we want to set the camera for | 9561 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9109 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9110 | 9562 | ||
9111 | if (agentID == UUID.Zero) return; | 9563 | if (agentID == UUID.Zero) |
9112 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9564 | { |
9565 | m_host.TaskInventory.LockItemsForRead(false); | ||
9566 | return; | ||
9113 | } | 9567 | } |
9568 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9569 | { | ||
9570 | m_host.TaskInventory.LockItemsForRead(false); | ||
9571 | return; | ||
9572 | } | ||
9573 | m_host.TaskInventory.LockItemsForRead(false); | ||
9114 | 9574 | ||
9115 | ScenePresence presence = World.GetScenePresence(agentID); | 9575 | ScenePresence presence = World.GetScenePresence(agentID); |
9116 | 9576 | ||
@@ -9160,12 +9620,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9160 | 9620 | ||
9161 | // we need the permission first, to know which avatar we want to clear the camera for | 9621 | // we need the permission first, to know which avatar we want to clear the camera for |
9162 | UUID agentID; | 9622 | UUID agentID; |
9163 | lock (m_host.TaskInventory) | 9623 | m_host.TaskInventory.LockItemsForRead(true); |
9624 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9625 | if (agentID == UUID.Zero) | ||
9164 | { | 9626 | { |
9165 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9627 | m_host.TaskInventory.LockItemsForRead(false); |
9166 | if (agentID == UUID.Zero) return; | 9628 | return; |
9167 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9629 | } |
9630 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9631 | { | ||
9632 | m_host.TaskInventory.LockItemsForRead(false); | ||
9633 | return; | ||
9168 | } | 9634 | } |
9635 | m_host.TaskInventory.LockItemsForRead(false); | ||
9169 | 9636 | ||
9170 | ScenePresence presence = World.GetScenePresence(agentID); | 9637 | ScenePresence presence = World.GetScenePresence(agentID); |
9171 | 9638 | ||
@@ -9622,15 +10089,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9622 | 10089 | ||
9623 | internal UUID ScriptByName(string name) | 10090 | internal UUID ScriptByName(string name) |
9624 | { | 10091 | { |
9625 | lock (m_host.TaskInventory) | 10092 | m_host.TaskInventory.LockItemsForRead(true); |
10093 | |||
10094 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9626 | { | 10095 | { |
9627 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 10096 | if (item.Type == 10 && item.Name == name) |
9628 | { | 10097 | { |
9629 | if (item.Type == 10 && item.Name == name) | 10098 | m_host.TaskInventory.LockItemsForRead(false); |
9630 | return item.ItemID; | 10099 | return item.ItemID; |
9631 | } | 10100 | } |
9632 | } | 10101 | } |
9633 | 10102 | ||
10103 | m_host.TaskInventory.LockItemsForRead(false); | ||
10104 | |||
9634 | return UUID.Zero; | 10105 | return UUID.Zero; |
9635 | } | 10106 | } |
9636 | 10107 | ||
@@ -9671,6 +10142,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9671 | { | 10142 | { |
9672 | m_host.AddScriptLPS(1); | 10143 | m_host.AddScriptLPS(1); |
9673 | 10144 | ||
10145 | //Clone is thread safe | ||
9674 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10146 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9675 | 10147 | ||
9676 | UUID assetID = UUID.Zero; | 10148 | UUID assetID = UUID.Zero; |
@@ -9733,6 +10205,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9733 | { | 10205 | { |
9734 | m_host.AddScriptLPS(1); | 10206 | m_host.AddScriptLPS(1); |
9735 | 10207 | ||
10208 | //Clone is thread safe | ||
9736 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10209 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9737 | 10210 | ||
9738 | UUID assetID = UUID.Zero; | 10211 | 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 dde664e..f2a2f32 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -769,18 +769,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
769 | if (target != null) | 769 | if (target != null) |
770 | { | 770 | { |
771 | UUID animID=UUID.Zero; | 771 | UUID animID=UUID.Zero; |
772 | lock (m_host.TaskInventory) | 772 | m_host.TaskInventory.LockItemsForRead(true); |
773 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
773 | { | 774 | { |
774 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 775 | if (inv.Value.Name == animation) |
775 | { | 776 | { |
776 | if (inv.Value.Name == animation) | 777 | if (inv.Value.Type == (int)AssetType.Animation) |
777 | { | 778 | animID = inv.Value.AssetID; |
778 | if (inv.Value.Type == (int)AssetType.Animation) | 779 | continue; |
779 | animID = inv.Value.AssetID; | ||
780 | continue; | ||
781 | } | ||
782 | } | 780 | } |
783 | } | 781 | } |
782 | m_host.TaskInventory.LockItemsForRead(false); | ||
784 | if (animID == UUID.Zero) | 783 | if (animID == UUID.Zero) |
785 | target.Animator.AddAnimation(animation, m_host.UUID); | 784 | target.Animator.AddAnimation(animation, m_host.UUID); |
786 | else | 785 | else |
@@ -802,18 +801,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
802 | if (target != null) | 801 | if (target != null) |
803 | { | 802 | { |
804 | UUID animID=UUID.Zero; | 803 | UUID animID=UUID.Zero; |
805 | lock (m_host.TaskInventory) | 804 | m_host.TaskInventory.LockItemsForRead(true); |
805 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
806 | { | 806 | { |
807 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 807 | if (inv.Value.Name == animation) |
808 | { | 808 | { |
809 | if (inv.Value.Name == animation) | 809 | if (inv.Value.Type == (int)AssetType.Animation) |
810 | { | 810 | animID = inv.Value.AssetID; |
811 | if (inv.Value.Type == (int)AssetType.Animation) | 811 | continue; |
812 | animID = inv.Value.AssetID; | ||
813 | continue; | ||
814 | } | ||
815 | } | 812 | } |
816 | } | 813 | } |
814 | m_host.TaskInventory.LockItemsForRead(false); | ||
817 | 815 | ||
818 | if (animID == UUID.Zero) | 816 | if (animID == UUID.Zero) |
819 | target.Animator.RemoveAnimation(animation); | 817 | target.Animator.RemoveAnimation(animation); |
@@ -1664,6 +1662,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1664 | 1662 | ||
1665 | if (!UUID.TryParse(name, out assetID)) | 1663 | if (!UUID.TryParse(name, out assetID)) |
1666 | { | 1664 | { |
1665 | m_host.TaskInventory.LockItemsForRead(true); | ||
1667 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1666 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1668 | { | 1667 | { |
1669 | if (item.Type == 7 && item.Name == name) | 1668 | if (item.Type == 7 && item.Name == name) |
@@ -1671,6 +1670,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1671 | assetID = item.AssetID; | 1670 | assetID = item.AssetID; |
1672 | } | 1671 | } |
1673 | } | 1672 | } |
1673 | m_host.TaskInventory.LockItemsForRead(false); | ||
1674 | } | 1674 | } |
1675 | 1675 | ||
1676 | if (assetID == UUID.Zero) | 1676 | if (assetID == UUID.Zero) |
@@ -1717,6 +1717,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1717 | 1717 | ||
1718 | if (!UUID.TryParse(name, out assetID)) | 1718 | if (!UUID.TryParse(name, out assetID)) |
1719 | { | 1719 | { |
1720 | m_host.TaskInventory.LockItemsForRead(true); | ||
1720 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1721 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1721 | { | 1722 | { |
1722 | if (item.Type == 7 && item.Name == name) | 1723 | if (item.Type == 7 && item.Name == name) |
@@ -1724,6 +1725,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1724 | assetID = item.AssetID; | 1725 | assetID = item.AssetID; |
1725 | } | 1726 | } |
1726 | } | 1727 | } |
1728 | m_host.TaskInventory.LockItemsForRead(false); | ||
1727 | } | 1729 | } |
1728 | 1730 | ||
1729 | if (assetID == UUID.Zero) | 1731 | if (assetID == UUID.Zero) |
@@ -1774,6 +1776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1774 | 1776 | ||
1775 | if (!UUID.TryParse(name, out assetID)) | 1777 | if (!UUID.TryParse(name, out assetID)) |
1776 | { | 1778 | { |
1779 | m_host.TaskInventory.LockItemsForRead(true); | ||
1777 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1780 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1778 | { | 1781 | { |
1779 | if (item.Type == 7 && item.Name == name) | 1782 | if (item.Type == 7 && item.Name == name) |
@@ -1781,6 +1784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1781 | assetID = item.AssetID; | 1784 | assetID = item.AssetID; |
1782 | } | 1785 | } |
1783 | } | 1786 | } |
1787 | m_host.TaskInventory.LockItemsForRead(false); | ||
1784 | } | 1788 | } |
1785 | 1789 | ||
1786 | if (assetID == UUID.Zero) | 1790 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 5c2abd5..a5b1124 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
204 | // Is the sensor type is AGENT and not SCRIPTED then include agents | 204 | // Is the sensor type is AGENT and not SCRIPTED then include agents |
205 | if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) | 205 | if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) |
206 | { | 206 | { |
207 | sensedEntities.AddRange(doAgentSensor(ts)); | 207 | sensedEntities.AddRange(doAgentSensor(ts)); |
208 | } | 208 | } |
209 | 209 | ||
210 | // If SCRIPTED or PASSIVE or ACTIVE check objects | 210 | // If SCRIPTED or PASSIVE or ACTIVE check objects |
@@ -309,6 +309,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
309 | // in mouselook. | 309 | // in mouselook. |
310 | 310 | ||
311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); |
312 | fromRegionPos = avatar.AbsolutePosition; | ||
312 | q = avatar.Rotation; | 313 | q = avatar.Rotation; |
313 | } | 314 | } |
314 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 315 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -422,6 +423,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
422 | SceneObjectPart SensePoint = ts.host; | 423 | SceneObjectPart SensePoint = ts.host; |
423 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 424 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; |
424 | Quaternion q = SensePoint.RotationOffset; | 425 | Quaternion q = SensePoint.RotationOffset; |
426 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | ||
427 | { | ||
428 | // In attachments, the sensor cone always orients with the | ||
429 | // avatar rotation. This may include a nonzero elevation if | ||
430 | // in mouselook. | ||
431 | |||
432 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | ||
433 | fromRegionPos = avatar.AbsolutePosition; | ||
434 | q = avatar.Rotation; | ||
435 | } | ||
425 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 436 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
426 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 437 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
427 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 438 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..2fd33fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
109 | if (Timers.Count == 0) | 109 | if (Timers.Count == 0) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
112 | lock (TimerListLock) | 113 | lock (TimerListLock) |
113 | { | 114 | { |
114 | // Go through all timers | 115 | // Go through all timers |
115 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 116 | tvals = Timers.Values; |
116 | foreach (TimerClass ts in tvals) | 117 | } |
118 | |||
119 | foreach (TimerClass ts in tvals) | ||
120 | { | ||
121 | // Time has passed? | ||
122 | if (ts.next < DateTime.Now.Ticks) | ||
117 | { | 123 | { |
118 | // Time has passed? | 124 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
119 | if (ts.next < DateTime.Now.Ticks) | 125 | // Add it to queue |
120 | { | 126 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
121 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 127 | new EventParams("timer", new Object[0], |
122 | // Add it to queue | 128 | new DetectParams[0])); |
123 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 129 | // set next interval |
124 | new EventParams("timer", new Object[0], | 130 | |
125 | new DetectParams[0])); | 131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
126 | // set next interval | 132 | ts.next = DateTime.Now.Ticks + ts.interval; |
127 | |||
128 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
129 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |