diff options
author | CasperW | 2009-12-23 14:14:20 +0100 |
---|---|---|
committer | CasperW | 2009-12-23 14:14:20 +0100 |
commit | b575bf25245102fd43d025081b249cb730b865ac (patch) | |
tree | 6885014c82156fc21ccc2d792a308ad931339b12 | |
parent | Merge branch 'master' into casper (diff) | |
download | opensim-SC_OLD-b575bf25245102fd43d025081b249cb730b865ac.zip opensim-SC_OLD-b575bf25245102fd43d025081b249cb730b865ac.tar.gz opensim-SC_OLD-b575bf25245102fd43d025081b249cb730b865ac.tar.bz2 opensim-SC_OLD-b575bf25245102fd43d025081b249cb730b865ac.tar.xz |
Added some null reference and deleted group checks to certain functions to fix region crash scenarios.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 114 |
1 files changed, 85 insertions, 29 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2da498a..84c2722 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -221,7 +221,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
221 | 221 | ||
222 | public List<SceneObjectPart> GetLinkParts(int linkType) | 222 | public List<SceneObjectPart> GetLinkParts(int linkType) |
223 | { | 223 | { |
224 | 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; | ||
225 | ret.Add(m_host); | 227 | ret.Add(m_host); |
226 | 228 | ||
227 | switch (linkType) | 229 | switch (linkType) |
@@ -1136,7 +1138,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1136 | } | 1138 | } |
1137 | 1139 | ||
1138 | public void llSetStatus(int status, int value) | 1140 | public void llSetStatus(int status, int value) |
1139 | { | 1141 | { |
1142 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1143 | return; | ||
1140 | m_host.AddScriptLPS(1); | 1144 | m_host.AddScriptLPS(1); |
1141 | 1145 | ||
1142 | int statusrotationaxis = 0; | 1146 | int statusrotationaxis = 0; |
@@ -1290,7 +1294,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1290 | } | 1294 | } |
1291 | 1295 | ||
1292 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) | 1296 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) |
1293 | { | 1297 | { |
1294 | // TODO: this needs to trigger a persistance save as well | 1298 | // TODO: this needs to trigger a persistance save as well |
1295 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1299 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1296 | return; | 1300 | return; |
@@ -1349,7 +1353,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1349 | } | 1353 | } |
1350 | 1354 | ||
1351 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | 1355 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) |
1352 | { | 1356 | { |
1357 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1358 | return; | ||
1359 | |||
1353 | Primitive.TextureEntry tex = part.Shape.Textures; | 1360 | Primitive.TextureEntry tex = part.Shape.Textures; |
1354 | Color4 texcolor; | 1361 | Color4 texcolor; |
1355 | if (face >= 0 && face < GetNumberOfSides(part)) | 1362 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1386,7 +1393,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1386 | } | 1393 | } |
1387 | 1394 | ||
1388 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1395 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1389 | { | 1396 | { |
1397 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1398 | return; | ||
1399 | |||
1390 | Primitive.TextureEntry tex = part.Shape.Textures; | 1400 | Primitive.TextureEntry tex = part.Shape.Textures; |
1391 | MappingType textype; | 1401 | MappingType textype; |
1392 | textype = MappingType.Default; | 1402 | textype = MappingType.Default; |
@@ -1416,7 +1426,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1416 | } | 1426 | } |
1417 | 1427 | ||
1418 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1428 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1419 | { | 1429 | { |
1430 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1431 | return; | ||
1432 | |||
1420 | Primitive.TextureEntry tex = part.Shape.Textures; | 1433 | Primitive.TextureEntry tex = part.Shape.Textures; |
1421 | if (face >= 0 && face < GetNumberOfSides(part)) | 1434 | if (face >= 0 && face < GetNumberOfSides(part)) |
1422 | { | 1435 | { |
@@ -1441,7 +1454,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1441 | } | 1454 | } |
1442 | 1455 | ||
1443 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1456 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1444 | { | 1457 | { |
1458 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1459 | return; | ||
1445 | 1460 | ||
1446 | Shininess sval = new Shininess(); | 1461 | Shininess sval = new Shininess(); |
1447 | 1462 | ||
@@ -1491,7 +1506,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1491 | } | 1506 | } |
1492 | 1507 | ||
1493 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1508 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1494 | { | 1509 | { |
1510 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1511 | return; | ||
1512 | |||
1495 | Primitive.TextureEntry tex = part.Shape.Textures; | 1513 | Primitive.TextureEntry tex = part.Shape.Textures; |
1496 | if (face >= 0 && face < GetNumberOfSides(part)) | 1514 | if (face >= 0 && face < GetNumberOfSides(part)) |
1497 | { | 1515 | { |
@@ -1558,7 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1558 | } | 1576 | } |
1559 | 1577 | ||
1560 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1578 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1561 | { | 1579 | { |
1580 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1581 | return; | ||
1582 | |||
1562 | Primitive.TextureEntry tex = part.Shape.Textures; | 1583 | Primitive.TextureEntry tex = part.Shape.Textures; |
1563 | Color4 texcolor; | 1584 | Color4 texcolor; |
1564 | if (face >= 0 && face < GetNumberOfSides(part)) | 1585 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1603,8 +1624,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1603 | /// <param name="Force"></param> | 1624 | /// <param name="Force"></param> |
1604 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1625 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1605 | float wind, float tension, LSL_Vector Force) | 1626 | float wind, float tension, LSL_Vector Force) |
1606 | { | 1627 | { |
1607 | if (part == null) | 1628 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1608 | return; | 1629 | return; |
1609 | 1630 | ||
1610 | if (flexi) | 1631 | if (flexi) |
@@ -1638,8 +1659,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1638 | /// <param name="radius"></param> | 1659 | /// <param name="radius"></param> |
1639 | /// <param name="falloff"></param> | 1660 | /// <param name="falloff"></param> |
1640 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1661 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1641 | { | 1662 | { |
1642 | if (part == null) | 1663 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1643 | return; | 1664 | return; |
1644 | 1665 | ||
1645 | if (light) | 1666 | if (light) |
@@ -1724,7 +1745,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1724 | } | 1745 | } |
1725 | 1746 | ||
1726 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1747 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1727 | { | 1748 | { |
1749 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1750 | return; | ||
1751 | |||
1728 | UUID textureID=new UUID(); | 1752 | UUID textureID=new UUID(); |
1729 | 1753 | ||
1730 | if (!UUID.TryParse(texture, out textureID)) | 1754 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1769,7 +1793,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1769 | } | 1793 | } |
1770 | 1794 | ||
1771 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1795 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1772 | { | 1796 | { |
1797 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1798 | return; | ||
1799 | |||
1773 | Primitive.TextureEntry tex = part.Shape.Textures; | 1800 | Primitive.TextureEntry tex = part.Shape.Textures; |
1774 | if (face >= 0 && face < GetNumberOfSides(part)) | 1801 | if (face >= 0 && face < GetNumberOfSides(part)) |
1775 | { | 1802 | { |
@@ -1805,7 +1832,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1805 | } | 1832 | } |
1806 | 1833 | ||
1807 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1834 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1808 | { | 1835 | { |
1836 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1837 | return; | ||
1838 | |||
1809 | Primitive.TextureEntry tex = part.Shape.Textures; | 1839 | Primitive.TextureEntry tex = part.Shape.Textures; |
1810 | if (face >= 0 && face < GetNumberOfSides(part)) | 1840 | if (face >= 0 && face < GetNumberOfSides(part)) |
1811 | { | 1841 | { |
@@ -1841,7 +1871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1841 | } | 1871 | } |
1842 | 1872 | ||
1843 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1873 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1844 | { | 1874 | { |
1875 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1876 | return; | ||
1877 | |||
1845 | Primitive.TextureEntry tex = part.Shape.Textures; | 1878 | Primitive.TextureEntry tex = part.Shape.Textures; |
1846 | if (face >= 0 && face < GetNumberOfSides(part)) | 1879 | if (face >= 0 && face < GetNumberOfSides(part)) |
1847 | { | 1880 | { |
@@ -1911,7 +1944,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1911 | } | 1944 | } |
1912 | 1945 | ||
1913 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 1946 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1914 | { | 1947 | { |
1948 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1949 | return; | ||
1950 | |||
1915 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 1951 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1916 | LSL_Vector currentPos = llGetLocalPos(); | 1952 | LSL_Vector currentPos = llGetLocalPos(); |
1917 | 1953 | ||
@@ -2005,7 +2041,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2005 | } | 2041 | } |
2006 | 2042 | ||
2007 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2043 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
2008 | { | 2044 | { |
2045 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2046 | return; | ||
2047 | |||
2009 | part.UpdateRotation(rot); | 2048 | part.UpdateRotation(rot); |
2010 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2049 | // Update rotation does not move the object in the physics scene if it's a linkset. |
2011 | 2050 | ||
@@ -6500,8 +6539,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6500 | } | 6539 | } |
6501 | 6540 | ||
6502 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6541 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6503 | { | 6542 | { |
6504 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6543 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6544 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6545 | return shapeBlock; | ||
6505 | 6546 | ||
6506 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6547 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6507 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6548 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6570,7 +6611,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6570 | } | 6611 | } |
6571 | 6612 | ||
6572 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6613 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6573 | { | 6614 | { |
6615 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6616 | return; | ||
6617 | |||
6574 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6618 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6575 | 6619 | ||
6576 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6620 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6618,7 +6662,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6618 | } | 6662 | } |
6619 | 6663 | ||
6620 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6664 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6621 | { | 6665 | { |
6666 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6667 | return; | ||
6668 | |||
6622 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6669 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6623 | 6670 | ||
6624 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6671 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6659,7 +6706,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6659 | } | 6706 | } |
6660 | 6707 | ||
6661 | 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) | 6708 | 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) |
6662 | { | 6709 | { |
6710 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6711 | return; | ||
6712 | |||
6663 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6713 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6664 | 6714 | ||
6665 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6715 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6779,7 +6829,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6779 | } | 6829 | } |
6780 | 6830 | ||
6781 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6831 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6782 | { | 6832 | { |
6833 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6834 | return; | ||
6835 | |||
6783 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6836 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6784 | UUID sculptId; | 6837 | UUID sculptId; |
6785 | 6838 | ||
@@ -6813,14 +6866,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6813 | } | 6866 | } |
6814 | 6867 | ||
6815 | public void llSetPrimitiveParams(LSL_List rules) | 6868 | public void llSetPrimitiveParams(LSL_List rules) |
6816 | { | 6869 | { |
6817 | m_host.AddScriptLPS(1); | 6870 | m_host.AddScriptLPS(1); |
6818 | SetPrimParams(m_host, rules); | 6871 | SetPrimParams(m_host, rules); |
6819 | } | 6872 | } |
6820 | 6873 | ||
6821 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 6874 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6822 | { | 6875 | { |
6823 | m_host.AddScriptLPS(1); | 6876 | m_host.AddScriptLPS(1); |
6824 | 6877 | ||
6825 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6878 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6826 | 6879 | ||
@@ -6829,7 +6882,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6829 | } | 6882 | } |
6830 | 6883 | ||
6831 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 6884 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6832 | { | 6885 | { |
6886 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6887 | return; | ||
6888 | |||
6833 | int idx = 0; | 6889 | int idx = 0; |
6834 | 6890 | ||
6835 | while (idx < rules.Length) | 6891 | while (idx < rules.Length) |