diff options
author | UbitUmarov | 2017-04-25 17:59:53 +0100 |
---|---|---|
committer | UbitUmarov | 2017-04-25 17:59:53 +0100 |
commit | a680d8b8d700f78beb1a9eea98b52d59118efe2e (patch) | |
tree | dd084e74fb61400c704a14dcfa8689670acb9ec2 /OpenSim/Region/ScriptEngine/Shared | |
parent | Merge branch 'master' into httptests (diff) | |
parent | move mesh pbs creation code out of mesh upload code into to PrimitiveBaseShap... (diff) | |
download | opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.zip opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.gz opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.bz2 opensim-SC-a680d8b8d700f78beb1a9eea98b52d59118efe2e.tar.xz |
fix merge
Diffstat (limited to '')
8 files changed, 591 insertions, 110 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ad7fc6c..47c3cb8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -424,6 +424,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
424 | return lease; | 424 | return lease; |
425 | } | 425 | } |
426 | 426 | ||
427 | protected SceneObjectPart MonitoringObject() | ||
428 | { | ||
429 | UUID m = m_host.ParentGroup.MonitoringObject; | ||
430 | if (m == UUID.Zero) | ||
431 | return null; | ||
432 | |||
433 | SceneObjectPart p = m_ScriptEngine.World.GetSceneObjectPart(m); | ||
434 | if (p == null) | ||
435 | m_host.ParentGroup.MonitoringObject = UUID.Zero; | ||
436 | |||
437 | return p; | ||
438 | } | ||
439 | |||
427 | protected virtual void ScriptSleep(int delay) | 440 | protected virtual void ScriptSleep(int delay) |
428 | { | 441 | { |
429 | delay = (int)((float)delay * m_ScriptDelayFactor); | 442 | delay = (int)((float)delay * m_ScriptDelayFactor); |
@@ -481,12 +494,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
481 | { | 494 | { |
482 | UUID item; | 495 | UUID item; |
483 | 496 | ||
484 | m_host.AddScriptLPS(1); | 497 | if ((item = GetScriptByName(name)) == UUID.Zero) |
485 | 498 | { | |
486 | if ((item = GetScriptByName(name)) != UUID.Zero) | 499 | m_host.AddScriptLPS(1); |
487 | m_ScriptEngine.ResetScript(item); | ||
488 | else | ||
489 | Error("llResetOtherScript", "Can't find script '" + name + "'"); | 500 | Error("llResetOtherScript", "Can't find script '" + name + "'"); |
501 | return; | ||
502 | } | ||
503 | if(item == m_item.ItemID) | ||
504 | llResetScript(); | ||
505 | else | ||
506 | { | ||
507 | m_host.AddScriptLPS(1); | ||
508 | m_ScriptEngine.ResetScript(item); | ||
509 | } | ||
490 | } | 510 | } |
491 | 511 | ||
492 | public LSL_Integer llGetScriptState(string name) | 512 | public LSL_Integer llGetScriptState(string name) |
@@ -2712,9 +2732,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2712 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> | 2732 | /// <param name="adjust">if TRUE, will cap the distance to 10m.</param> |
2713 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) | 2733 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) |
2714 | { | 2734 | { |
2715 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 2735 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted || part.ParentGroup.inTransit) |
2716 | return; | 2736 | return; |
2717 | 2737 | ||
2738 | |||
2718 | LSL_Vector currentPos = GetPartLocalPos(part); | 2739 | LSL_Vector currentPos = GetPartLocalPos(part); |
2719 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); | 2740 | LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); |
2720 | 2741 | ||
@@ -2722,7 +2743,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2722 | if (part.ParentGroup.RootPart == part) | 2743 | if (part.ParentGroup.RootPart == part) |
2723 | { | 2744 | { |
2724 | SceneObjectGroup parent = part.ParentGroup; | 2745 | SceneObjectGroup parent = part.ParentGroup; |
2725 | if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) | 2746 | if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent, false, (Vector3)toPos)) |
2726 | return; | 2747 | return; |
2727 | parent.UpdateGroupPosition((Vector3)toPos); | 2748 | parent.UpdateGroupPosition((Vector3)toPos); |
2728 | } | 2749 | } |
@@ -5738,29 +5759,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5738 | { | 5759 | { |
5739 | m_host.AddScriptLPS(1); | 5760 | m_host.AddScriptLPS(1); |
5740 | if (index < 0) | 5761 | if (index < 0) |
5741 | { | ||
5742 | index = src.Length + index; | 5762 | index = src.Length + index; |
5743 | } | 5763 | |
5744 | if (index >= src.Length || index < 0) | 5764 | if (index >= src.Length || index < 0) |
5745 | { | ||
5746 | return 0; | 5765 | return 0; |
5747 | } | 5766 | |
5767 | object item = src.Data[index]; | ||
5748 | 5768 | ||
5749 | // Vectors & Rotations always return zero in SL, but | 5769 | // Vectors & Rotations always return zero in SL, but |
5750 | // keys don't always return zero, it seems to be a bit complex. | 5770 | // keys don't always return zero, it seems to be a bit complex. |
5751 | else if (src.Data[index] is LSL_Vector || | 5771 | if (item is LSL_Vector || item is LSL_Rotation) |
5752 | src.Data[index] is LSL_Rotation) | ||
5753 | { | ||
5754 | return 0; | 5772 | return 0; |
5755 | } | 5773 | |
5756 | try | 5774 | try |
5757 | { | 5775 | { |
5758 | 5776 | if (item is LSL_Integer) | |
5759 | if (src.Data[index] is LSL_Integer) | 5777 | return (LSL_Integer)item; |
5760 | return (LSL_Integer)src.Data[index]; | 5778 | else if (item is LSL_Float) |
5761 | else if (src.Data[index] is LSL_Float) | 5779 | return Convert.ToInt32(((LSL_Float)item).value);; |
5762 | return Convert.ToInt32(((LSL_Float)src.Data[index]).value); | 5780 | return new LSL_Integer(item.ToString()); |
5763 | return new LSL_Integer(src.Data[index].ToString()); | ||
5764 | } | 5781 | } |
5765 | catch (FormatException) | 5782 | catch (FormatException) |
5766 | { | 5783 | { |
@@ -5772,38 +5789,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5772 | { | 5789 | { |
5773 | m_host.AddScriptLPS(1); | 5790 | m_host.AddScriptLPS(1); |
5774 | if (index < 0) | 5791 | if (index < 0) |
5775 | { | ||
5776 | index = src.Length + index; | 5792 | index = src.Length + index; |
5777 | } | 5793 | |
5778 | if (index >= src.Length || index < 0) | 5794 | if (index >= src.Length || index < 0) |
5779 | { | 5795 | return 0; |
5780 | return 0.0; | 5796 | |
5781 | } | 5797 | object item = src.Data[index]; |
5782 | 5798 | ||
5783 | // Vectors & Rotations always return zero in SL | 5799 | // Vectors & Rotations always return zero in SL |
5784 | else if (src.Data[index] is LSL_Vector || | 5800 | if(item is LSL_Vector || item is LSL_Rotation) |
5785 | src.Data[index] is LSL_Rotation) | ||
5786 | { | ||
5787 | return 0; | 5801 | return 0; |
5788 | } | 5802 | |
5789 | // valid keys seem to get parsed as integers then converted to floats | 5803 | // valid keys seem to get parsed as integers then converted to floats |
5790 | else | 5804 | if (item is LSL_Key) |
5791 | { | 5805 | { |
5792 | UUID uuidt; | 5806 | UUID uuidt; |
5793 | if (src.Data[index] is LSL_Key && UUID.TryParse(src.Data[index].ToString(), out uuidt)) | 5807 | string s = item.ToString(); |
5794 | { | 5808 | if(UUID.TryParse(s, out uuidt)) |
5795 | return Convert.ToDouble(new LSL_Integer(src.Data[index].ToString()).value); | 5809 | return Convert.ToDouble(new LSL_Integer(s).value); |
5796 | } | 5810 | // we can't do this because a string is also a LSL_Key for now :( |
5811 | // else | ||
5812 | // return 0; | ||
5797 | } | 5813 | } |
5814 | |||
5798 | try | 5815 | try |
5799 | { | 5816 | { |
5800 | if (src.Data[index] is LSL_Integer) | 5817 | if (item is LSL_Integer) |
5801 | return Convert.ToDouble(((LSL_Integer)src.Data[index]).value); | 5818 | return Convert.ToDouble(((LSL_Integer)item).value); |
5802 | else if (src.Data[index] is LSL_Float) | 5819 | else if (item is LSL_Float) |
5803 | return Convert.ToDouble(((LSL_Float)src.Data[index]).value); | 5820 | return Convert.ToDouble(((LSL_Float)item).value); |
5804 | else if (src.Data[index] is LSL_String) | 5821 | else if (item is LSL_String) |
5805 | { | 5822 | { |
5806 | string str = ((LSL_String) src.Data[index]).m_string; | 5823 | string str = ((LSL_String)item).m_string; |
5807 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); | 5824 | Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); |
5808 | if (m != Match.Empty) | 5825 | if (m != Match.Empty) |
5809 | { | 5826 | { |
@@ -5811,12 +5828,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5811 | double d = 0.0; | 5828 | double d = 0.0; |
5812 | if (!Double.TryParse(str, out d)) | 5829 | if (!Double.TryParse(str, out d)) |
5813 | return 0.0; | 5830 | return 0.0; |
5814 | |||
5815 | return d; | 5831 | return d; |
5816 | } | 5832 | } |
5817 | return 0.0; | 5833 | return 0.0; |
5818 | } | 5834 | } |
5819 | return Convert.ToDouble(src.Data[index]); | 5835 | return Convert.ToDouble(item); |
5820 | } | 5836 | } |
5821 | catch (FormatException) | 5837 | catch (FormatException) |
5822 | { | 5838 | { |
@@ -5828,13 +5844,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5828 | { | 5844 | { |
5829 | m_host.AddScriptLPS(1); | 5845 | m_host.AddScriptLPS(1); |
5830 | if (index < 0) | 5846 | if (index < 0) |
5831 | { | ||
5832 | index = src.Length + index; | 5847 | index = src.Length + index; |
5833 | } | 5848 | |
5834 | if (index >= src.Length || index < 0) | 5849 | if (index >= src.Length || index < 0) |
5835 | { | ||
5836 | return String.Empty; | 5850 | return String.Empty; |
5837 | } | 5851 | |
5838 | return src.Data[index].ToString(); | 5852 | return src.Data[index].ToString(); |
5839 | } | 5853 | } |
5840 | 5854 | ||
@@ -5842,14 +5856,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5842 | { | 5856 | { |
5843 | m_host.AddScriptLPS(1); | 5857 | m_host.AddScriptLPS(1); |
5844 | if (index < 0) | 5858 | if (index < 0) |
5845 | { | ||
5846 | index = src.Length + index; | 5859 | index = src.Length + index; |
5847 | } | ||
5848 | 5860 | ||
5849 | if (index >= src.Length || index < 0) | 5861 | if (index >= src.Length || index < 0) |
5850 | { | 5862 | return String.Empty; |
5851 | return ""; | 5863 | |
5852 | } | 5864 | object item = src.Data[index]; |
5853 | 5865 | ||
5854 | // SL spits out an empty string for types other than key & string | 5866 | // SL spits out an empty string for types other than key & string |
5855 | // At the time of patching, LSL_Key is currently LSL_String, | 5867 | // At the time of patching, LSL_Key is currently LSL_String, |
@@ -5858,31 +5870,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5858 | // as it's own struct | 5870 | // as it's own struct |
5859 | // NOTE: 3rd case is needed because a NULL_KEY comes through as | 5871 | // NOTE: 3rd case is needed because a NULL_KEY comes through as |
5860 | // type 'obj' and wrongly returns "" | 5872 | // type 'obj' and wrongly returns "" |
5861 | else if (!(src.Data[index] is LSL_String || | 5873 | if (!(item is LSL_String || |
5862 | src.Data[index] is LSL_Key || | 5874 | item is LSL_Key || |
5863 | src.Data[index].ToString() == "00000000-0000-0000-0000-000000000000")) | 5875 | item.ToString() == "00000000-0000-0000-0000-000000000000")) |
5864 | { | 5876 | { |
5865 | return ""; | 5877 | return String.Empty; |
5866 | } | 5878 | } |
5867 | 5879 | ||
5868 | return src.Data[index].ToString(); | 5880 | return item.ToString(); |
5869 | } | 5881 | } |
5870 | 5882 | ||
5871 | public LSL_Vector llList2Vector(LSL_List src, int index) | 5883 | public LSL_Vector llList2Vector(LSL_List src, int index) |
5872 | { | 5884 | { |
5873 | m_host.AddScriptLPS(1); | 5885 | m_host.AddScriptLPS(1); |
5874 | if (index < 0) | 5886 | if (index < 0) |
5875 | { | ||
5876 | index = src.Length + index; | 5887 | index = src.Length + index; |
5877 | } | 5888 | |
5878 | if (index >= src.Length || index < 0) | 5889 | if (index >= src.Length || index < 0) |
5879 | { | ||
5880 | return new LSL_Vector(0, 0, 0); | 5890 | return new LSL_Vector(0, 0, 0); |
5881 | } | 5891 | |
5882 | if (src.Data[index].GetType() == typeof(LSL_Vector)) | 5892 | object item = src.Data[index]; |
5883 | { | 5893 | |
5884 | return (LSL_Vector)src.Data[index]; | 5894 | if (item.GetType() == typeof(LSL_Vector)) |
5885 | } | 5895 | return (LSL_Vector)item; |
5886 | 5896 | ||
5887 | // SL spits always out ZERO_VECTOR for anything other than | 5897 | // SL spits always out ZERO_VECTOR for anything other than |
5888 | // strings or vectors. Although keys always return ZERO_VECTOR, | 5898 | // strings or vectors. Although keys always return ZERO_VECTOR, |
@@ -5890,28 +5900,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5890 | // a string, a key as string and a string that by coincidence | 5900 | // a string, a key as string and a string that by coincidence |
5891 | // is a string, so we're going to leave that up to the | 5901 | // is a string, so we're going to leave that up to the |
5892 | // LSL_Vector constructor. | 5902 | // LSL_Vector constructor. |
5893 | else if (!(src.Data[index] is LSL_String || | 5903 | if(item is LSL_Vector) |
5894 | src.Data[index] is LSL_Vector)) | 5904 | return (LSL_Vector) item; |
5895 | { | 5905 | |
5896 | return new LSL_Vector(0, 0, 0); | 5906 | if (item is LSL_String) |
5897 | } | 5907 | return new LSL_Vector(item.ToString()); |
5898 | else | 5908 | |
5899 | { | 5909 | return new LSL_Vector(0, 0, 0); |
5900 | return new LSL_Vector(src.Data[index].ToString()); | ||
5901 | } | ||
5902 | } | 5910 | } |
5903 | 5911 | ||
5904 | public LSL_Rotation llList2Rot(LSL_List src, int index) | 5912 | public LSL_Rotation llList2Rot(LSL_List src, int index) |
5905 | { | 5913 | { |
5906 | m_host.AddScriptLPS(1); | 5914 | m_host.AddScriptLPS(1); |
5907 | if (index < 0) | 5915 | if (index < 0) |
5908 | { | ||
5909 | index = src.Length + index; | 5916 | index = src.Length + index; |
5910 | } | 5917 | |
5911 | if (index >= src.Length || index < 0) | 5918 | if (index >= src.Length || index < 0) |
5912 | { | ||
5913 | return new LSL_Rotation(0, 0, 0, 1); | 5919 | return new LSL_Rotation(0, 0, 0, 1); |
5914 | } | 5920 | |
5921 | object item = src.Data[index]; | ||
5915 | 5922 | ||
5916 | // SL spits always out ZERO_ROTATION for anything other than | 5923 | // SL spits always out ZERO_ROTATION for anything other than |
5917 | // strings or vectors. Although keys always return ZERO_ROTATION, | 5924 | // strings or vectors. Although keys always return ZERO_ROTATION, |
@@ -5919,19 +5926,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5919 | // a string, a key as string and a string that by coincidence | 5926 | // a string, a key as string and a string that by coincidence |
5920 | // is a string, so we're going to leave that up to the | 5927 | // is a string, so we're going to leave that up to the |
5921 | // LSL_Rotation constructor. | 5928 | // LSL_Rotation constructor. |
5922 | else if (!(src.Data[index] is LSL_String || | 5929 | |
5923 | src.Data[index] is LSL_Rotation)) | 5930 | if (item.GetType() == typeof(LSL_Rotation)) |
5924 | { | 5931 | return (LSL_Rotation)item; |
5925 | return new LSL_Rotation(0, 0, 0, 1); | 5932 | |
5926 | } | 5933 | if (item is LSL_String) |
5927 | else if (src.Data[index].GetType() == typeof(LSL_Rotation)) | ||
5928 | { | ||
5929 | return (LSL_Rotation)src.Data[index]; | ||
5930 | } | ||
5931 | else | ||
5932 | { | ||
5933 | return new LSL_Rotation(src.Data[index].ToString()); | 5934 | return new LSL_Rotation(src.Data[index].ToString()); |
5934 | } | 5935 | |
5936 | return new LSL_Rotation(0, 0, 0, 1); | ||
5935 | } | 5937 | } |
5936 | 5938 | ||
5937 | public LSL_List llList2List(LSL_List src, int start, int end) | 5939 | public LSL_List llList2List(LSL_List src, int start, int end) |
@@ -7963,7 +7965,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7963 | public LSL_Integer llScriptDanger(LSL_Vector pos) | 7965 | public LSL_Integer llScriptDanger(LSL_Vector pos) |
7964 | { | 7966 | { |
7965 | m_host.AddScriptLPS(1); | 7967 | m_host.AddScriptLPS(1); |
7966 | bool result = World.ScriptDanger(m_host.LocalId, pos); | 7968 | bool result = World.LSLScriptDanger(m_host, pos); |
7967 | if (result) | 7969 | if (result) |
7968 | { | 7970 | { |
7969 | return 1; | 7971 | return 1; |
@@ -7972,7 +7974,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7972 | { | 7974 | { |
7973 | return 0; | 7975 | return 0; |
7974 | } | 7976 | } |
7975 | |||
7976 | } | 7977 | } |
7977 | 7978 | ||
7978 | public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel) | 7979 | public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel) |
@@ -8849,10 +8850,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8849 | } | 8850 | } |
8850 | 8851 | ||
8851 | public void llSetPhysicsMaterial(int material_bits, | 8852 | public void llSetPhysicsMaterial(int material_bits, |
8852 | float material_gravity_modifier, float material_restitution, | 8853 | LSL_Float material_gravity_modifier, LSL_Float material_restitution, |
8853 | float material_friction, float material_density) | 8854 | LSL_Float material_friction, LSL_Float material_density) |
8854 | { | 8855 | { |
8855 | SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); | 8856 | SetPhysicsMaterial(m_host, material_bits, (float)material_density, (float)material_friction, (float)material_restitution, (float)material_gravity_modifier); |
8856 | } | 8857 | } |
8857 | 8858 | ||
8858 | // vector up using libomv (c&p from sop ) | 8859 | // vector up using libomv (c&p from sop ) |
@@ -11297,6 +11298,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11297 | } | 11298 | } |
11298 | break; | 11299 | break; |
11299 | 11300 | ||
11301 | case (int)ScriptBaseClass.PRIM_NORMAL: | ||
11302 | case (int)ScriptBaseClass.PRIM_SPECULAR: | ||
11303 | case (int)ScriptBaseClass.PRIM_ALPHA_MODE: | ||
11304 | if (remain < 1) | ||
11305 | return new LSL_List(); | ||
11306 | |||
11307 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
11308 | tex = part.Shape.Textures; | ||
11309 | if (face == ScriptBaseClass.ALL_SIDES) | ||
11310 | { | ||
11311 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
11312 | { | ||
11313 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
11314 | getLSLFaceMaterial(ref res, code, part, texface); | ||
11315 | } | ||
11316 | } | ||
11317 | else | ||
11318 | { | ||
11319 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
11320 | { | ||
11321 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | ||
11322 | getLSLFaceMaterial(ref res, code, part, texface); | ||
11323 | } | ||
11324 | } | ||
11325 | break; | ||
11326 | |||
11300 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 11327 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
11301 | 11328 | ||
11302 | // TODO: Should be issuing a runtime script warning in this case. | 11329 | // TODO: Should be issuing a runtime script warning in this case. |
@@ -11310,6 +11337,108 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11310 | return new LSL_List(); | 11337 | return new LSL_List(); |
11311 | } | 11338 | } |
11312 | 11339 | ||
11340 | /* | ||
11341 | private string filterTextureUUIDbyRights(UUID origID, SceneObjectPart part, bool checkTaskInventory, bool returnInvName) | ||
11342 | { | ||
11343 | if(checkTaskInventory) | ||
11344 | { | ||
11345 | lock (part.TaskInventory) | ||
11346 | { | ||
11347 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in part.TaskInventory) | ||
11348 | { | ||
11349 | if (inv.Value.AssetID == origID) | ||
11350 | { | ||
11351 | if(inv.Value.InvType == (int)InventoryType.Texture) | ||
11352 | { | ||
11353 | if(returnInvName) | ||
11354 | return inv.Value.Name; | ||
11355 | else | ||
11356 | return origID.ToString(); | ||
11357 | } | ||
11358 | else | ||
11359 | return UUID.Zero.ToString(); | ||
11360 | } | ||
11361 | } | ||
11362 | } | ||
11363 | } | ||
11364 | |||
11365 | if(World.Permissions.CanEditObject(m_host.ParentGroup.UUID, m_host.ParentGroup.RootPart.OwnerID)) | ||
11366 | return origID.ToString(); | ||
11367 | |||
11368 | return UUID.Zero.ToString(); | ||
11369 | } | ||
11370 | */ | ||
11371 | private void getLSLFaceMaterial(ref LSL_List res, int code, SceneObjectPart part, Primitive.TextureEntryFace texface) | ||
11372 | { | ||
11373 | UUID matID = texface.MaterialID; | ||
11374 | if(matID != UUID.Zero) | ||
11375 | { | ||
11376 | AssetBase MatAsset = World.AssetService.Get(matID.ToString()); | ||
11377 | if(MatAsset != null) | ||
11378 | { | ||
11379 | Byte[] data = MatAsset.Data; | ||
11380 | OSDMap osdmat = (OSDMap)OSDParser.DeserializeLLSDXml(data); | ||
11381 | if(osdmat != null && osdmat.ContainsKey("NormMap")) | ||
11382 | { | ||
11383 | string mapIDstr; | ||
11384 | FaceMaterial mat = new FaceMaterial(matID, osdmat); | ||
11385 | if(code == ScriptBaseClass.PRIM_NORMAL) | ||
11386 | { | ||
11387 | // mapIDstr = filterTextureUUIDbyRights(mat.NormalMapID, part, true, false); | ||
11388 | mapIDstr = mat.NormalMapID.ToString(); | ||
11389 | res.Add(new LSL_String(mapIDstr)); | ||
11390 | res.Add(new LSL_Vector(mat.NormalRepeatX, mat.NormalRepeatY, 0)); | ||
11391 | res.Add(new LSL_Vector(mat.NormalOffsetX, mat.NormalOffsetY, 0)); | ||
11392 | res.Add(new LSL_Float(mat.NormalRotation)); | ||
11393 | } | ||
11394 | else if(code == ScriptBaseClass.PRIM_SPECULAR ) | ||
11395 | { | ||
11396 | // mapIDstr = filterTextureUUIDbyRights(mat.SpecularMapID, part, true, false); | ||
11397 | const float colorScale = 1.0f/255f; | ||
11398 | mapIDstr = mat.SpecularMapID.ToString(); | ||
11399 | res.Add(new LSL_String(mapIDstr)); | ||
11400 | res.Add(new LSL_Vector(mat.SpecularRepeatX, mat.SpecularRepeatY, 0)); | ||
11401 | res.Add(new LSL_Vector(mat.SpecularOffsetX, mat.SpecularOffsetY, 0)); | ||
11402 | res.Add(new LSL_Float(mat.SpecularRotation)); | ||
11403 | res.Add(new LSL_Vector(mat.SpecularLightColor.R * colorScale, | ||
11404 | mat.SpecularLightColor.G * colorScale, | ||
11405 | mat.SpecularLightColor.B * colorScale)); | ||
11406 | res.Add(new LSL_Integer(mat.SpecularLightExponent)); | ||
11407 | res.Add(new LSL_Integer(mat.EnvironmentIntensity)); | ||
11408 | } | ||
11409 | else if(code == ScriptBaseClass.PRIM_ALPHA_MODE) | ||
11410 | { | ||
11411 | res.Add(new LSL_Integer(mat.DiffuseAlphaMode)); | ||
11412 | res.Add(new LSL_Integer(mat.AlphaMaskCutoff)); | ||
11413 | } | ||
11414 | return; | ||
11415 | } | ||
11416 | } | ||
11417 | matID = UUID.Zero; | ||
11418 | } | ||
11419 | if(matID == UUID.Zero) | ||
11420 | { | ||
11421 | if(code == (int)ScriptBaseClass.PRIM_NORMAL || code == (int)ScriptBaseClass.PRIM_SPECULAR ) | ||
11422 | { | ||
11423 | res.Add(new LSL_String(UUID.Zero.ToString())); | ||
11424 | res.Add(new LSL_Vector(1.0, 1.0, 0)); | ||
11425 | res.Add(new LSL_Vector(0, 0, 0)); | ||
11426 | res.Add(new LSL_Float(0)); | ||
11427 | |||
11428 | if(code == (int)ScriptBaseClass.PRIM_SPECULAR) | ||
11429 | { | ||
11430 | res.Add(new LSL_Vector(1.0, 1.0, 1.0)); | ||
11431 | res.Add(new LSL_Integer(51)); | ||
11432 | res.Add(new LSL_Integer(0)); | ||
11433 | } | ||
11434 | } | ||
11435 | else if(code == (int)ScriptBaseClass.PRIM_ALPHA_MODE) | ||
11436 | { | ||
11437 | res.Add(new LSL_Integer(1)); | ||
11438 | res.Add(new LSL_Integer(0)); | ||
11439 | } | ||
11440 | } | ||
11441 | } | ||
11313 | 11442 | ||
11314 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) | 11443 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) |
11315 | { | 11444 | { |
@@ -15867,7 +15996,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
15867 | return; | 15996 | return; |
15868 | } | 15997 | } |
15869 | 15998 | ||
15870 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
15871 | group.RootPart.AttachedPos = group.AbsolutePosition; | 15999 | group.RootPart.AttachedPos = group.AbsolutePosition; |
15872 | 16000 | ||
15873 | group.ResetIDs(); | 16001 | group.ResetIDs(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e769c6d..e12cedf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -260,7 +260,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
260 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | 260 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
261 | } | 261 | } |
262 | 262 | ||
263 | // Returns of the function is allowed. Throws a script exception if not allowed. | 263 | // Returns if OSSL is enabled. Throws a script exception if OSSL is not allowed.. |
264 | // for safe funtions always active | ||
265 | public void CheckThreatLevel() | ||
266 | { | ||
267 | if (!m_OSFunctionsEnabled) | ||
268 | OSSLError(String.Format("{0} permission denied. All OS functions are disabled.")); // throws | ||
269 | } | ||
270 | |||
271 | // Returns if the function is allowed. Throws a script exception if not allowed. | ||
264 | public void CheckThreatLevel(ThreatLevel level, string function) | 272 | public void CheckThreatLevel(ThreatLevel level, string function) |
265 | { | 273 | { |
266 | if (!m_OSFunctionsEnabled) | 274 | if (!m_OSFunctionsEnabled) |
@@ -1716,7 +1724,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1716 | 1724 | ||
1717 | public LSL_Integer osCheckODE() | 1725 | public LSL_Integer osCheckODE() |
1718 | { | 1726 | { |
1727 | CheckThreatLevel(); | ||
1719 | m_host.AddScriptLPS(1); | 1728 | m_host.AddScriptLPS(1); |
1729 | |||
1720 | LSL_Integer ret = 0; // false | 1730 | LSL_Integer ret = 0; // false |
1721 | if (m_ScriptEngine.World.PhysicsScene != null) | 1731 | if (m_ScriptEngine.World.PhysicsScene != null) |
1722 | { | 1732 | { |
@@ -1757,10 +1767,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1757 | 1767 | ||
1758 | public string osGetPhysicsEngineName() | 1768 | public string osGetPhysicsEngineName() |
1759 | { | 1769 | { |
1760 | // not doing security checks | 1770 | CheckThreatLevel(); |
1761 | // this whould limit the use of this | ||
1762 | |||
1763 | m_host.AddScriptLPS(1); | 1771 | m_host.AddScriptLPS(1); |
1772 | |||
1764 | string ret = "NoEngine"; | 1773 | string ret = "NoEngine"; |
1765 | if (m_ScriptEngine.World.PhysicsScene != null) | 1774 | if (m_ScriptEngine.World.PhysicsScene != null) |
1766 | { | 1775 | { |
@@ -1771,6 +1780,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1771 | } | 1780 | } |
1772 | return ret; | 1781 | return ret; |
1773 | } | 1782 | } |
1783 | |||
1774 | public string osGetSimulatorVersion() | 1784 | public string osGetSimulatorVersion() |
1775 | { | 1785 | { |
1776 | // High because it can be used to target attacks to known weaknesses | 1786 | // High because it can be used to target attacks to known weaknesses |
@@ -2038,6 +2048,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2038 | m_host.Inventory.AddInventoryItemExclusive(taskItem, false); | 2048 | m_host.Inventory.AddInventoryItemExclusive(taskItem, false); |
2039 | else | 2049 | else |
2040 | m_host.Inventory.AddInventoryItem(taskItem, false); | 2050 | m_host.Inventory.AddInventoryItem(taskItem, false); |
2051 | m_host.ParentGroup.AggregatePerms(); | ||
2041 | 2052 | ||
2042 | return taskItem; | 2053 | return taskItem; |
2043 | } | 2054 | } |
@@ -3537,7 +3548,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3537 | 3548 | ||
3538 | LSL_Float health = new LSL_Float(-1); | 3549 | LSL_Float health = new LSL_Float(-1); |
3539 | ScenePresence presence = World.GetScenePresence(new UUID(avatar)); | 3550 | ScenePresence presence = World.GetScenePresence(new UUID(avatar)); |
3540 | if (presence != null) health = presence.Health; | 3551 | if (presence != null) |
3552 | health = presence.Health; | ||
3541 | return health; | 3553 | return health; |
3542 | } | 3554 | } |
3543 | 3555 | ||
@@ -3577,7 +3589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3577 | UUID avatarId = new UUID(avatar); | 3589 | UUID avatarId = new UUID(avatar); |
3578 | ScenePresence presence = World.GetScenePresence(avatarId); | 3590 | ScenePresence presence = World.GetScenePresence(avatarId); |
3579 | 3591 | ||
3580 | if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) | 3592 | if (presence != null) |
3581 | { | 3593 | { |
3582 | float health = presence.Health; | 3594 | float health = presence.Health; |
3583 | health += (float)healing; | 3595 | health += (float)healing; |
@@ -3597,7 +3609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3597 | UUID avatarId = new UUID(avatar); | 3609 | UUID avatarId = new UUID(avatar); |
3598 | ScenePresence presence = World.GetScenePresence(avatarId); | 3610 | ScenePresence presence = World.GetScenePresence(avatarId); |
3599 | 3611 | ||
3600 | if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) | 3612 | if (presence != null) |
3601 | { | 3613 | { |
3602 | if (health > 100.0) | 3614 | if (health > 100.0) |
3603 | health = 100.0; | 3615 | health = 100.0; |
@@ -3616,7 +3628,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3616 | UUID avatarId = new UUID(avatar); | 3628 | UUID avatarId = new UUID(avatar); |
3617 | ScenePresence presence = World.GetScenePresence(avatarId); | 3629 | ScenePresence presence = World.GetScenePresence(avatarId); |
3618 | 3630 | ||
3619 | if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) | 3631 | if (presence != null) |
3620 | presence.HealRate = (float)healrate; | 3632 | presence.HealRate = (float)healrate; |
3621 | } | 3633 | } |
3622 | 3634 | ||
@@ -4362,6 +4374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4362 | 4374 | ||
4363 | public void osCollisionSound(string impact_sound, double impact_volume) | 4375 | public void osCollisionSound(string impact_sound, double impact_volume) |
4364 | { | 4376 | { |
4377 | CheckThreatLevel(); | ||
4365 | m_host.AddScriptLPS(1); | 4378 | m_host.AddScriptLPS(1); |
4366 | 4379 | ||
4367 | if(impact_sound == "") | 4380 | if(impact_sound == "") |
@@ -4394,6 +4407,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4394 | // still not very usefull, detector is lost on rez, restarts, etc | 4407 | // still not very usefull, detector is lost on rez, restarts, etc |
4395 | public void osVolumeDetect(int detect) | 4408 | public void osVolumeDetect(int detect) |
4396 | { | 4409 | { |
4410 | CheckThreatLevel(); | ||
4397 | m_host.AddScriptLPS(1); | 4411 | m_host.AddScriptLPS(1); |
4398 | 4412 | ||
4399 | if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment) | 4413 | if (m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted || m_host.ParentGroup.IsAttachment) |
@@ -4402,5 +4416,285 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4402 | m_host.ScriptSetVolumeDetect(detect != 0); | 4416 | m_host.ScriptSetVolumeDetect(detect != 0); |
4403 | } | 4417 | } |
4404 | 4418 | ||
4419 | /// <summary> | ||
4420 | /// Get inertial data | ||
4421 | /// </summary> | ||
4422 | /// <remarks> | ||
4423 | /// </remarks> | ||
4424 | /// <returns> | ||
4425 | /// a LSL list with contents: | ||
4426 | /// LSL_Float mass, the total mass of a linkset | ||
4427 | /// LSL_Vector CenterOfMass, center mass relative to root prim | ||
4428 | /// LSL_Vector Inertia, elements of diagonal of inertia Ixx,Iyy,Izz divided by total mass | ||
4429 | /// LSL_Vector aux, elements of upper triagle of inertia Ixy (= Iyx), Ixz (= Izx), Iyz(= Izy) divided by total mass | ||
4430 | /// </returns> | ||
4431 | public LSL_List osGetInertiaData() | ||
4432 | { | ||
4433 | CheckThreatLevel(); | ||
4434 | m_host.AddScriptLPS(1); | ||
4435 | |||
4436 | LSL_List result = new LSL_List(); | ||
4437 | float TotalMass; | ||
4438 | Vector3 CenterOfMass; | ||
4439 | Vector3 Inertia; | ||
4440 | Vector4 aux; | ||
4441 | |||
4442 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4443 | if(sog== null || sog.IsDeleted) | ||
4444 | return result; | ||
4445 | |||
4446 | sog.GetInertiaData(out TotalMass, out CenterOfMass, out Inertia, out aux ); | ||
4447 | if(TotalMass > 0) | ||
4448 | { | ||
4449 | float t = 1.0f/TotalMass; | ||
4450 | Inertia.X *= t; | ||
4451 | Inertia.Y *= t; | ||
4452 | Inertia.Z *= t; | ||
4453 | |||
4454 | aux.X *= t; | ||
4455 | aux.Y *= t; | ||
4456 | aux.Z *= t; | ||
4457 | } | ||
4458 | |||
4459 | result.Add(new LSL_Float(TotalMass)); | ||
4460 | result.Add(new LSL_Vector(CenterOfMass.X, CenterOfMass.Y, CenterOfMass.Z)); | ||
4461 | result.Add(new LSL_Vector(Inertia.X, Inertia.Y, Inertia.Z)); | ||
4462 | result.Add(new LSL_Vector(aux.X, aux.Y, aux.Z)); | ||
4463 | return result; | ||
4464 | } | ||
4465 | |||
4466 | /// <summary> | ||
4467 | /// set inertial data | ||
4468 | /// replaces the automatic calculation of mass, center of mass and inertia | ||
4469 | /// | ||
4470 | /// </summary> | ||
4471 | /// <param name="Mass">total mass of linkset</param> | ||
4472 | /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param> | ||
4473 | /// <param name="principalInertiaScaled">moment of inertia relative to principal axis and center of mass,Ixx, Iyy, Izz divided by mass</param> | ||
4474 | /// <param name="lslrot">rotation of the inertia, relative to local axis</param> | ||
4475 | /// <remarks> | ||
4476 | /// the inertia argument is is inertia divided by mass, so corresponds only to the geometric distribution of mass and both can be changed independently. | ||
4477 | /// </remarks> | ||
4478 | |||
4479 | public void osSetInertia(LSL_Float mass, LSL_Vector centerOfMass, LSL_Vector principalInertiaScaled, LSL_Rotation lslrot) | ||
4480 | { | ||
4481 | CheckThreatLevel(); | ||
4482 | m_host.AddScriptLPS(1); | ||
4483 | |||
4484 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4485 | if(sog== null || sog.IsDeleted) | ||
4486 | return; | ||
4487 | |||
4488 | if(mass < 0 || principalInertiaScaled.x < 0 || principalInertiaScaled.y < 0 || principalInertiaScaled.z < 0) | ||
4489 | return; | ||
4490 | |||
4491 | // need more checks | ||
4492 | |||
4493 | Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); | ||
4494 | Vector3 Inertia; | ||
4495 | float m = (float)mass; | ||
4496 | |||
4497 | Inertia.X = m * (float)principalInertiaScaled.x; | ||
4498 | Inertia.Y = m * (float)principalInertiaScaled.y; | ||
4499 | Inertia.Z = m * (float)principalInertiaScaled.z; | ||
4500 | |||
4501 | Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.y, (float)lslrot.s); | ||
4502 | rot.Normalize(); | ||
4503 | |||
4504 | sog.SetInertiaData(m, CenterOfMass, Inertia, rot ); | ||
4505 | } | ||
4506 | |||
4507 | /// <summary> | ||
4508 | /// set inertial data as a sphere | ||
4509 | /// replaces the automatic calculation of mass, center of mass and inertia | ||
4510 | /// | ||
4511 | /// </summary> | ||
4512 | /// <param name="Mass">total mass of linkset</param> | ||
4513 | /// <param name="boxsize">size of the Box</param> | ||
4514 | /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param> | ||
4515 | /// <param name="lslrot">rotation of the box, and so inertia, relative to local axis</param> | ||
4516 | /// <remarks> | ||
4517 | /// </remarks> | ||
4518 | public void osSetInertiaAsBox(LSL_Float mass, LSL_Vector boxSize, LSL_Vector centerOfMass, LSL_Rotation lslrot) | ||
4519 | { | ||
4520 | CheckThreatLevel(); | ||
4521 | m_host.AddScriptLPS(1); | ||
4522 | |||
4523 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4524 | if(sog== null || sog.IsDeleted) | ||
4525 | return; | ||
4526 | |||
4527 | if(mass < 0) | ||
4528 | return; | ||
4529 | |||
4530 | // need more checks | ||
4531 | |||
4532 | Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); | ||
4533 | Vector3 Inertia; | ||
4534 | float lx = (float)boxSize.x; | ||
4535 | float ly = (float)boxSize.y; | ||
4536 | float lz = (float)boxSize.z; | ||
4537 | float m = (float)mass; | ||
4538 | float t = m / 12.0f; | ||
4539 | |||
4540 | Inertia.X = t * (ly*ly + lz*lz); | ||
4541 | Inertia.Y = t * (lx*lx + lz*lz); | ||
4542 | Inertia.Z = t * (lx*lx + ly*ly); | ||
4543 | |||
4544 | Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.z, (float)lslrot.s); | ||
4545 | rot.Normalize(); | ||
4546 | |||
4547 | sog.SetInertiaData(m, CenterOfMass, Inertia, rot ); | ||
4548 | } | ||
4549 | |||
4550 | /// <summary> | ||
4551 | /// set inertial data as a sphere | ||
4552 | /// replaces the automatic calculation of mass, center of mass and inertia | ||
4553 | /// | ||
4554 | /// </summary> | ||
4555 | /// <param name="Mass">total mass of linkset</param> | ||
4556 | /// <param name="radius">radius of the sphere</param> | ||
4557 | /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param> | ||
4558 | /// <remarks> | ||
4559 | /// </remarks> | ||
4560 | public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, LSL_Vector centerOfMass) | ||
4561 | { | ||
4562 | CheckThreatLevel(); | ||
4563 | m_host.AddScriptLPS(1); | ||
4564 | |||
4565 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4566 | if(sog== null || sog.IsDeleted) | ||
4567 | return; | ||
4568 | |||
4569 | if(mass < 0) | ||
4570 | return; | ||
4571 | |||
4572 | // need more checks | ||
4573 | |||
4574 | Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); | ||
4575 | Vector3 Inertia; | ||
4576 | float r = (float)radius; | ||
4577 | float m = (float)mass; | ||
4578 | float t = 0.4f * m * r * r; | ||
4579 | |||
4580 | Inertia.X = t; | ||
4581 | Inertia.Y = t; | ||
4582 | Inertia.Z = t; | ||
4583 | |||
4584 | sog.SetInertiaData(m, CenterOfMass, Inertia, new Vector4(0f, 0f, 0f,1.0f)); | ||
4585 | } | ||
4586 | |||
4587 | /// <summary> | ||
4588 | /// set inertial data as a cylinder | ||
4589 | /// replaces the automatic calculation of mass, center of mass and inertia | ||
4590 | /// | ||
4591 | /// </summary> | ||
4592 | /// <param name="Mass">total mass of linkset</param> | ||
4593 | /// <param name="radius">radius of the cylinder</param> | ||
4594 | /// <param name="lenght">lenght of the cylinder</param> | ||
4595 | /// <param name="centerOfMass">location of center of mass relative to root prim in local coords</param> | ||
4596 | /// <param name="lslrot">rotation of the cylinder, and so inertia, relative to local axis</param> | ||
4597 | /// <remarks> | ||
4598 | /// cylinder axis aligned with Z axis. For other orientations provide the rotation. | ||
4599 | /// </remarks> | ||
4600 | public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, LSL_Vector centerOfMass, LSL_Rotation lslrot) | ||
4601 | { | ||
4602 | CheckThreatLevel(); | ||
4603 | m_host.AddScriptLPS(1); | ||
4604 | |||
4605 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4606 | if(sog== null || sog.IsDeleted) | ||
4607 | return; | ||
4608 | |||
4609 | if(mass < 0) | ||
4610 | return; | ||
4611 | |||
4612 | // need more checks | ||
4613 | |||
4614 | Vector3 CenterOfMass = new Vector3((float)centerOfMass.x,(float)centerOfMass.y,(float)centerOfMass.z); | ||
4615 | Vector3 Inertia; | ||
4616 | float m = (float)mass; | ||
4617 | float r = (float)radius; | ||
4618 | r *= r; | ||
4619 | Inertia.Z = 0.5f * m * r; | ||
4620 | float t = (float)lenght; | ||
4621 | t *= t; | ||
4622 | t += 3.0f * r; | ||
4623 | t *= 8.333333e-2f * m; | ||
4624 | |||
4625 | Inertia.X = t; | ||
4626 | Inertia.Y = t; | ||
4627 | |||
4628 | Vector4 rot = new Vector4((float)lslrot.x, (float)lslrot.y, (float)lslrot.z, (float)lslrot.s); | ||
4629 | rot.Normalize(); | ||
4630 | |||
4631 | sog.SetInertiaData(m, CenterOfMass, Inertia, rot); | ||
4632 | } | ||
4633 | |||
4634 | /// <summary> | ||
4635 | /// removes inertial data manual override | ||
4636 | /// default automatic calculation is used again | ||
4637 | /// | ||
4638 | /// </summary> | ||
4639 | public void osClearInertia() | ||
4640 | { | ||
4641 | CheckThreatLevel(); | ||
4642 | m_host.AddScriptLPS(1); | ||
4643 | |||
4644 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4645 | if(sog== null || sog.IsDeleted) | ||
4646 | return; | ||
4647 | |||
4648 | sog.SetInertiaData(-1, Vector3.Zero, Vector3.Zero, Vector4.Zero ); | ||
4649 | } | ||
4650 | |||
4651 | /// <summary> | ||
4652 | /// teleports a object (full linkset) | ||
4653 | /// </summary> | ||
4654 | /// <param name="objectUUID">the id of the linkset to teleport</param> | ||
4655 | /// <param name="targetPos">target position</param> | ||
4656 | /// <param name="rotation"> a rotation to apply</param> | ||
4657 | /// <param name="flags">several flags/param> | ||
4658 | /// <remarks> | ||
4659 | /// only does teleport local to region | ||
4660 | /// if object has scripts, owner must have rights to run scripts on target location | ||
4661 | /// object owner must have rights to enter ojects on target location | ||
4662 | /// target location parcel must have enought free prims capacity for the linkset prims | ||
4663 | /// all avatars siting on the object must have access to target location | ||
4664 | /// has a cool down time. retries before expire reset it | ||
4665 | /// fail conditions are silent ignored | ||
4666 | /// </remarks> | ||
4667 | public LSL_Integer osTeleportObject(LSL_Key objectUUID, LSL_Vector targetPos, LSL_Rotation rotation, LSL_Integer flags) | ||
4668 | { | ||
4669 | CheckThreatLevel(ThreatLevel.Severe, "osTeleportObject"); | ||
4670 | m_host.AddScriptLPS(1); | ||
4671 | |||
4672 | UUID objUUID; | ||
4673 | if (!UUID.TryParse(objectUUID, out objUUID)) | ||
4674 | { | ||
4675 | OSSLShoutError("osTeleportObject() invalid object Key"); | ||
4676 | return -1; | ||
4677 | } | ||
4678 | |||
4679 | SceneObjectGroup sog = World.GetSceneObjectGroup(objUUID); | ||
4680 | if(sog== null || sog.IsDeleted) | ||
4681 | return -1; | ||
4682 | |||
4683 | UUID myid = m_host.ParentGroup.UUID; | ||
4684 | |||
4685 | return sog.TeleportObject(myid, targetPos, rotation, flags); | ||
4686 | // a delay here may break vehicles | ||
4687 | } | ||
4688 | |||
4689 | public LSL_Integer osGetLinkNumber(LSL_String name) | ||
4690 | { | ||
4691 | CheckThreatLevel(); | ||
4692 | m_host.AddScriptLPS(1); | ||
4693 | |||
4694 | SceneObjectGroup sog = m_host.ParentGroup; | ||
4695 | if(sog== null || sog.IsDeleted) | ||
4696 | return -1; | ||
4697 | return sog.GetLinkNumber(name); | ||
4698 | } | ||
4405 | } | 4699 | } |
4406 | } | 4700 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index cc52403..17c977f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -434,7 +434,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
434 | LSL_String llXorBase64Strings(string str1, string str2); | 434 | LSL_String llXorBase64Strings(string str1, string str2); |
435 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 435 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
436 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); | 436 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); |
437 | void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); | 437 | void llSetPhysicsMaterial(int material_bits, LSL_Float material_gravity_modifier, LSL_Float material_restitution, LSL_Float material_friction, LSL_Float material_density); |
438 | 438 | ||
439 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); | 439 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); |
440 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); | 440 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index bee060a..bd5d008 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -38,6 +38,7 @@ using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | |||
38 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 38 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
39 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 39 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
40 | 40 | ||
41 | |||
41 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | 42 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces |
42 | { | 43 | { |
43 | /// <summary> | 44 | /// <summary> |
@@ -50,7 +51,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
50 | /// </summary> | 51 | /// </summary> |
51 | public enum ThreatLevel | 52 | public enum ThreatLevel |
52 | { | 53 | { |
53 | // Not documented, presumably means permanently disabled ? | ||
54 | NoAccess = -1, | 54 | NoAccess = -1, |
55 | 55 | ||
56 | /// <summary> | 56 | /// <summary> |
@@ -486,6 +486,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
486 | LSL_String osRequestURL(LSL_List options); | 486 | LSL_String osRequestURL(LSL_List options); |
487 | LSL_String osRequestSecureURL(LSL_List options); | 487 | LSL_String osRequestSecureURL(LSL_List options); |
488 | void osCollisionSound(string impact_sound, double impact_volume); | 488 | void osCollisionSound(string impact_sound, double impact_volume); |
489 | |||
489 | void osVolumeDetect(int detect); | 490 | void osVolumeDetect(int detect); |
491 | |||
492 | LSL_List osGetInertiaData(); | ||
493 | void osClearInertia(); | ||
494 | void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot); | ||
495 | void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass); | ||
496 | void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot); | ||
497 | |||
498 | LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags); | ||
499 | LSL_Integer osGetLinkNumber(LSL_String name); | ||
490 | } | 500 | } |
491 | } | 501 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 3a90c77..ce0fa48 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -853,5 +853,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
853 | /// process message parameter as regex | 853 | /// process message parameter as regex |
854 | /// </summary> | 854 | /// </summary> |
855 | public const int OS_LISTEN_REGEX_MESSAGE = 0x2; | 855 | public const int OS_LISTEN_REGEX_MESSAGE = 0x2; |
856 | |||
857 | // for osTeleportObject | ||
858 | public const int OSTPOBJ_NONE = 0x0; | ||
859 | public const int OSTPOBJ_STOPATTARGET = 0x1; // stops at destination | ||
860 | public const int OSTPOBJ_STOPONFAIL = 0x2; // stops at jump point if tp fails | ||
861 | public const int OSTPOBJ_SETROT = 0x4; // the rotation is the final rotation, otherwise is a added rotation | ||
862 | |||
856 | } | 863 | } |
857 | } | 864 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 1a42c3a..c39248b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -2036,7 +2036,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
2036 | m_LSL_Functions.llSetKeyframedMotion(frames, options); | 2036 | m_LSL_Functions.llSetKeyframedMotion(frames, options); |
2037 | } | 2037 | } |
2038 | 2038 | ||
2039 | public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density) | 2039 | public void llSetPhysicsMaterial(int material_bits, LSL_Float material_gravity_modifier, LSL_Float material_restitution, LSL_Float material_friction, LSL_Float material_density) |
2040 | { | 2040 | { |
2041 | m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); | 2041 | m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); |
2042 | } | 2042 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 6164734..9eac114 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -1114,5 +1114,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1114 | { | 1114 | { |
1115 | m_OSSL_Functions.osVolumeDetect(detect); | 1115 | m_OSSL_Functions.osVolumeDetect(detect); |
1116 | } | 1116 | } |
1117 | |||
1118 | public LSL_List osGetInertiaData() | ||
1119 | { | ||
1120 | return m_OSSL_Functions.osGetInertiaData(); | ||
1121 | } | ||
1122 | |||
1123 | public void osSetInertiaAsBox(LSL_Float mass, vector boxSize, vector centerOfMass, rotation rot) | ||
1124 | { | ||
1125 | m_OSSL_Functions.osSetInertiaAsBox(mass, boxSize, centerOfMass, rot); | ||
1126 | } | ||
1127 | |||
1128 | public void osSetInertiaAsSphere(LSL_Float mass, LSL_Float radius, vector centerOfMass) | ||
1129 | { | ||
1130 | m_OSSL_Functions.osSetInertiaAsSphere(mass, radius, centerOfMass); | ||
1131 | } | ||
1132 | |||
1133 | public void osSetInertiaAsCylinder(LSL_Float mass, LSL_Float radius, LSL_Float lenght, vector centerOfMass,rotation lslrot) | ||
1134 | { | ||
1135 | m_OSSL_Functions.osSetInertiaAsCylinder( mass, radius, lenght, centerOfMass, lslrot); | ||
1136 | } | ||
1137 | |||
1138 | public void osClearInertia() | ||
1139 | { | ||
1140 | m_OSSL_Functions.osClearInertia(); | ||
1141 | } | ||
1142 | |||
1143 | public LSL_Integer osTeleportObject(LSL_Key objectUUID, vector targetPos, rotation targetrotation, LSL_Integer flags) | ||
1144 | { | ||
1145 | return m_OSSL_Functions.osTeleportObject(objectUUID, targetPos, targetrotation, flags); | ||
1146 | } | ||
1147 | |||
1148 | public LSL_Integer osGetLinkNumber(LSL_String name) | ||
1149 | { | ||
1150 | return m_OSSL_Functions.osGetLinkNumber(name); | ||
1151 | } | ||
1117 | } | 1152 | } |
1118 | } | 1153 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index d652b0d1..16b87b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Framework; | |||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
40 | using OpenSim.Region.OptionalModules.World.NPC; | 40 | using OpenSim.Region.OptionalModules.World.NPC; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.CoreModules.World.Permissions; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | 43 | using OpenSim.Region.ScriptEngine.Shared; |
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | 44 | using OpenSim.Region.ScriptEngine.Shared.Api; |
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 45 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
@@ -63,12 +64,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
63 | base.SetUp(); | 64 | base.SetUp(); |
64 | 65 | ||
65 | IConfigSource initConfigSource = new IniConfigSource(); | 66 | IConfigSource initConfigSource = new IniConfigSource(); |
66 | IConfig config = initConfigSource.AddConfig("XEngine"); | 67 | IConfig config = initConfigSource.AddConfig("Startup"); |
68 | config.Set("serverside_object_permissions", true); | ||
69 | config =initConfigSource.AddConfig("Permissions"); | ||
70 | config.Set("permissionmodules", "DefaultPermissionsModule"); | ||
71 | config.Set("serverside_object_permissions", true); | ||
72 | config.Set("propagate_permissions", true); | ||
73 | |||
74 | config = initConfigSource.AddConfig("XEngine"); | ||
67 | config.Set("Enabled", "true"); | 75 | config.Set("Enabled", "true"); |
68 | 76 | ||
69 | m_scene = new SceneHelpers().SetupScene(); | 77 | m_scene = new SceneHelpers().SetupScene(); |
70 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | 78 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new object[] { new DefaultPermissionsModule() }); |
71 | |||
72 | m_engine = new XEngine.XEngine(); | 79 | m_engine = new XEngine.XEngine(); |
73 | m_engine.Initialise(initConfigSource); | 80 | m_engine.Initialise(initConfigSource); |
74 | m_engine.AddRegion(m_scene); | 81 | m_engine.AddRegion(m_scene); |