aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs166
1 files changed, 77 insertions, 89 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 62654ee..443ea72 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -494,12 +494,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
494 { 494 {
495 UUID item; 495 UUID item;
496 496
497 m_host.AddScriptLPS(1); 497 if ((item = GetScriptByName(name)) == UUID.Zero)
498 498 {
499 if ((item = GetScriptByName(name)) != UUID.Zero) 499 m_host.AddScriptLPS(1);
500 m_ScriptEngine.ResetScript(item);
501 else
502 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 }
503 } 510 }
504 511
505 public LSL_Integer llGetScriptState(string name) 512 public LSL_Integer llGetScriptState(string name)
@@ -2725,9 +2732,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2725 /// <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>
2726 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust) 2733 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust)
2727 { 2734 {
2728 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 2735 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted || part.ParentGroup.inTransit)
2729 return; 2736 return;
2730 2737
2738
2731 LSL_Vector currentPos = GetPartLocalPos(part); 2739 LSL_Vector currentPos = GetPartLocalPos(part);
2732 LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); 2740 LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust);
2733 2741
@@ -5751,29 +5759,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5751 { 5759 {
5752 m_host.AddScriptLPS(1); 5760 m_host.AddScriptLPS(1);
5753 if (index < 0) 5761 if (index < 0)
5754 {
5755 index = src.Length + index; 5762 index = src.Length + index;
5756 } 5763
5757 if (index >= src.Length || index < 0) 5764 if (index >= src.Length || index < 0)
5758 {
5759 return 0; 5765 return 0;
5760 } 5766
5767 object item = src.Data[index];
5761 5768
5762 // Vectors & Rotations always return zero in SL, but 5769 // Vectors & Rotations always return zero in SL, but
5763 // 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.
5764 else if (src.Data[index] is LSL_Vector || 5771 if (item is LSL_Vector || item is LSL_Rotation)
5765 src.Data[index] is LSL_Rotation)
5766 {
5767 return 0; 5772 return 0;
5768 } 5773
5769 try 5774 try
5770 { 5775 {
5771 5776 if (item is LSL_Integer)
5772 if (src.Data[index] is LSL_Integer) 5777 return (LSL_Integer)item;
5773 return (LSL_Integer)src.Data[index]; 5778 else if (item is LSL_Float)
5774 else if (src.Data[index] is LSL_Float) 5779 return Convert.ToInt32(((LSL_Float)item).value);;
5775 return Convert.ToInt32(((LSL_Float)src.Data[index]).value); 5780 return new LSL_Integer(item.ToString());
5776 return new LSL_Integer(src.Data[index].ToString());
5777 } 5781 }
5778 catch (FormatException) 5782 catch (FormatException)
5779 { 5783 {
@@ -5785,38 +5789,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5785 { 5789 {
5786 m_host.AddScriptLPS(1); 5790 m_host.AddScriptLPS(1);
5787 if (index < 0) 5791 if (index < 0)
5788 {
5789 index = src.Length + index; 5792 index = src.Length + index;
5790 } 5793
5791 if (index >= src.Length || index < 0) 5794 if (index >= src.Length || index < 0)
5792 { 5795 return 0;
5793 return 0.0; 5796
5794 } 5797 object item = src.Data[index];
5795 5798
5796 // Vectors & Rotations always return zero in SL 5799 // Vectors & Rotations always return zero in SL
5797 else if (src.Data[index] is LSL_Vector || 5800 if(item is LSL_Vector || item is LSL_Rotation)
5798 src.Data[index] is LSL_Rotation)
5799 {
5800 return 0; 5801 return 0;
5801 } 5802
5802 // 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
5803 else 5804 if (item is LSL_Key)
5804 { 5805 {
5805 UUID uuidt; 5806 UUID uuidt;
5806 if (src.Data[index] is LSL_Key && UUID.TryParse(src.Data[index].ToString(), out uuidt)) 5807 string s = item.ToString();
5807 { 5808 if(UUID.TryParse(s, out uuidt))
5808 return Convert.ToDouble(new LSL_Integer(src.Data[index].ToString()).value); 5809 return Convert.ToDouble(new LSL_Integer(s).value);
5809 } 5810 else
5811 return 0;
5810 } 5812 }
5813
5811 try 5814 try
5812 { 5815 {
5813 if (src.Data[index] is LSL_Integer) 5816 if (item is LSL_Integer)
5814 return Convert.ToDouble(((LSL_Integer)src.Data[index]).value); 5817 return Convert.ToDouble(((LSL_Integer)item).value);
5815 else if (src.Data[index] is LSL_Float) 5818 else if (item is LSL_Float)
5816 return Convert.ToDouble(((LSL_Float)src.Data[index]).value); 5819 return Convert.ToDouble(((LSL_Float)item).value);
5817 else if (src.Data[index] is LSL_String) 5820 else if (item is LSL_String)
5818 { 5821 {
5819 string str = ((LSL_String) src.Data[index]).m_string; 5822 string str = ((LSL_String)item).m_string;
5820 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)"); 5823 Match m = Regex.Match(str, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)");
5821 if (m != Match.Empty) 5824 if (m != Match.Empty)
5822 { 5825 {
@@ -5824,12 +5827,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5824 double d = 0.0; 5827 double d = 0.0;
5825 if (!Double.TryParse(str, out d)) 5828 if (!Double.TryParse(str, out d))
5826 return 0.0; 5829 return 0.0;
5827
5828 return d; 5830 return d;
5829 } 5831 }
5830 return 0.0; 5832 return 0.0;
5831 } 5833 }
5832 return Convert.ToDouble(src.Data[index]); 5834 return Convert.ToDouble(item);
5833 } 5835 }
5834 catch (FormatException) 5836 catch (FormatException)
5835 { 5837 {
@@ -5841,13 +5843,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5841 { 5843 {
5842 m_host.AddScriptLPS(1); 5844 m_host.AddScriptLPS(1);
5843 if (index < 0) 5845 if (index < 0)
5844 {
5845 index = src.Length + index; 5846 index = src.Length + index;
5846 } 5847
5847 if (index >= src.Length || index < 0) 5848 if (index >= src.Length || index < 0)
5848 {
5849 return String.Empty; 5849 return String.Empty;
5850 } 5850
5851 return src.Data[index].ToString(); 5851 return src.Data[index].ToString();
5852 } 5852 }
5853 5853
@@ -5855,14 +5855,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5855 { 5855 {
5856 m_host.AddScriptLPS(1); 5856 m_host.AddScriptLPS(1);
5857 if (index < 0) 5857 if (index < 0)
5858 {
5859 index = src.Length + index; 5858 index = src.Length + index;
5860 }
5861 5859
5862 if (index >= src.Length || index < 0) 5860 if (index >= src.Length || index < 0)
5863 { 5861 return String.Empty;
5864 return ""; 5862
5865 } 5863 object item = src.Data[index];
5866 5864
5867 // SL spits out an empty string for types other than key & string 5865 // SL spits out an empty string for types other than key & string
5868 // At the time of patching, LSL_Key is currently LSL_String, 5866 // At the time of patching, LSL_Key is currently LSL_String,
@@ -5871,31 +5869,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5871 // as it's own struct 5869 // as it's own struct
5872 // NOTE: 3rd case is needed because a NULL_KEY comes through as 5870 // NOTE: 3rd case is needed because a NULL_KEY comes through as
5873 // type 'obj' and wrongly returns "" 5871 // type 'obj' and wrongly returns ""
5874 else if (!(src.Data[index] is LSL_String || 5872 if (!(item is LSL_String ||
5875 src.Data[index] is LSL_Key || 5873 item is LSL_Key ||
5876 src.Data[index].ToString() == "00000000-0000-0000-0000-000000000000")) 5874 item.ToString() == "00000000-0000-0000-0000-000000000000"))
5877 { 5875 {
5878 return ""; 5876 return String.Empty;
5879 } 5877 }
5880 5878
5881 return src.Data[index].ToString(); 5879 return item.ToString();
5882 } 5880 }
5883 5881
5884 public LSL_Vector llList2Vector(LSL_List src, int index) 5882 public LSL_Vector llList2Vector(LSL_List src, int index)
5885 { 5883 {
5886 m_host.AddScriptLPS(1); 5884 m_host.AddScriptLPS(1);
5887 if (index < 0) 5885 if (index < 0)
5888 {
5889 index = src.Length + index; 5886 index = src.Length + index;
5890 } 5887
5891 if (index >= src.Length || index < 0) 5888 if (index >= src.Length || index < 0)
5892 {
5893 return new LSL_Vector(0, 0, 0); 5889 return new LSL_Vector(0, 0, 0);
5894 } 5890
5895 if (src.Data[index].GetType() == typeof(LSL_Vector)) 5891 object item = src.Data[index];
5896 { 5892
5897 return (LSL_Vector)src.Data[index]; 5893 if (item.GetType() == typeof(LSL_Vector))
5898 } 5894 return (LSL_Vector)item;
5899 5895
5900 // SL spits always out ZERO_VECTOR for anything other than 5896 // SL spits always out ZERO_VECTOR for anything other than
5901 // strings or vectors. Although keys always return ZERO_VECTOR, 5897 // strings or vectors. Although keys always return ZERO_VECTOR,
@@ -5903,28 +5899,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5903 // a string, a key as string and a string that by coincidence 5899 // a string, a key as string and a string that by coincidence
5904 // is a string, so we're going to leave that up to the 5900 // is a string, so we're going to leave that up to the
5905 // LSL_Vector constructor. 5901 // LSL_Vector constructor.
5906 else if (!(src.Data[index] is LSL_String || 5902 if(item is LSL_Vector)
5907 src.Data[index] is LSL_Vector)) 5903 return (LSL_Vector) item;
5908 { 5904
5909 return new LSL_Vector(0, 0, 0); 5905 if (item is LSL_String)
5910 } 5906 return new LSL_Vector(item.ToString());
5911 else 5907
5912 { 5908 return new LSL_Vector(0, 0, 0);
5913 return new LSL_Vector(src.Data[index].ToString());
5914 }
5915 } 5909 }
5916 5910
5917 public LSL_Rotation llList2Rot(LSL_List src, int index) 5911 public LSL_Rotation llList2Rot(LSL_List src, int index)
5918 { 5912 {
5919 m_host.AddScriptLPS(1); 5913 m_host.AddScriptLPS(1);
5920 if (index < 0) 5914 if (index < 0)
5921 {
5922 index = src.Length + index; 5915 index = src.Length + index;
5923 } 5916
5924 if (index >= src.Length || index < 0) 5917 if (index >= src.Length || index < 0)
5925 {
5926 return new LSL_Rotation(0, 0, 0, 1); 5918 return new LSL_Rotation(0, 0, 0, 1);
5927 } 5919
5920 object item = src.Data[index];
5928 5921
5929 // SL spits always out ZERO_ROTATION for anything other than 5922 // SL spits always out ZERO_ROTATION for anything other than
5930 // strings or vectors. Although keys always return ZERO_ROTATION, 5923 // strings or vectors. Although keys always return ZERO_ROTATION,
@@ -5932,19 +5925,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5932 // a string, a key as string and a string that by coincidence 5925 // a string, a key as string and a string that by coincidence
5933 // is a string, so we're going to leave that up to the 5926 // is a string, so we're going to leave that up to the
5934 // LSL_Rotation constructor. 5927 // LSL_Rotation constructor.
5935 else if (!(src.Data[index] is LSL_String || 5928
5936 src.Data[index] is LSL_Rotation)) 5929 if (item.GetType() == typeof(LSL_Rotation))
5937 { 5930 return (LSL_Rotation)item;
5938 return new LSL_Rotation(0, 0, 0, 1); 5931
5939 } 5932 if (item is LSL_String)
5940 else if (src.Data[index].GetType() == typeof(LSL_Rotation))
5941 {
5942 return (LSL_Rotation)src.Data[index];
5943 }
5944 else
5945 {
5946 return new LSL_Rotation(src.Data[index].ToString()); 5933 return new LSL_Rotation(src.Data[index].ToString());
5947 } 5934
5935 return new LSL_Rotation(0, 0, 0, 1);
5948 } 5936 }
5949 5937
5950 public LSL_List llList2List(LSL_List src, int start, int end) 5938 public LSL_List llList2List(LSL_List src, int start, int end)