aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-05-08 22:58:34 +0100
committerJustin Clark-Casey (justincc)2012-05-08 23:05:01 +0100
commit01b78235db71994ba3e37bd6ea297bed7e4576b9 (patch)
tree91a89fd18939632973180287f78085723b6b9b9c /OpenSim/Region/ScriptEngine/Shared/Api
parentPerform SceneGraph.DuplicateObject() under existing m_updateLock already used... (diff)
downloadopensim-SC_OLD-01b78235db71994ba3e37bd6ea297bed7e4576b9.zip
opensim-SC_OLD-01b78235db71994ba3e37bd6ea297bed7e4576b9.tar.gz
opensim-SC_OLD-01b78235db71994ba3e37bd6ea297bed7e4576b9.tar.bz2
opensim-SC_OLD-01b78235db71994ba3e37bd6ea297bed7e4576b9.tar.xz
Instead of constantly looking up unchanging self item in script code, pass in self item on initialization.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs244
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs29
4 files changed, 118 insertions, 169 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 704dfc3..e8e4dab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -87,9 +87,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
87 protected uint m_localID; 87 protected uint m_localID;
88 88
89 /// <summary> 89 /// <summary>
90 /// The UUID of the item that hosts this script 90 /// The item that hosts this script
91 /// </summary> 91 /// </summary>
92 protected UUID m_itemID; 92 protected TaskInventoryItem m_item;
93 93
94 protected bool throwErrorOnNotImplemented = true; 94 protected bool throwErrorOnNotImplemented = true;
95 protected AsyncCommandManager AsyncCommands = null; 95 protected AsyncCommandManager AsyncCommands = null;
@@ -108,12 +108,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
108 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = 108 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
109 new Dictionary<UUID, UserInfoCacheEntry>(); 109 new Dictionary<UUID, UserInfoCacheEntry>();
110 110
111 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 111 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item)
112 { 112 {
113 m_ScriptEngine = ScriptEngine; 113 m_ScriptEngine = ScriptEngine;
114 m_host = host; 114 m_host = host;
115 m_localID = localID; 115 m_localID = localID;
116 m_itemID = itemID; 116 m_item = item;
117 117
118 m_ScriptDelayFactor = 118 m_ScriptDelayFactor =
119 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 119 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
@@ -163,7 +163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
163 163
164 public void state(string newState) 164 public void state(string newState)
165 { 165 {
166 m_ScriptEngine.SetState(m_itemID, newState); 166 m_ScriptEngine.SetState(m_item.ItemID, newState);
167 } 167 }
168 168
169 /// <summary> 169 /// <summary>
@@ -173,7 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
173 public void llResetScript() 173 public void llResetScript()
174 { 174 {
175 m_host.AddScriptLPS(1); 175 m_host.AddScriptLPS(1);
176 m_ScriptEngine.ApiResetScript(m_itemID); 176 m_ScriptEngine.ApiResetScript(m_item.ItemID);
177 } 177 }
178 178
179 public void llResetOtherScript(string name) 179 public void llResetOtherScript(string name)
@@ -272,20 +272,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
272 } 272 }
273 } 273 }
274 274
275 /// <summary>
276 /// Get the inventory item that hosts ourselves.
277 /// </summary>
278 /// <remarks>
279 /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need
280 /// to keep looking ourselves up.
281 /// </remarks>
282 /// <returns></returns>
283 protected TaskInventoryItem GetSelfInventoryItem()
284 {
285 lock (m_host.TaskInventory)
286 return m_host.TaskInventory[m_itemID];
287 }
288
289 protected UUID InventoryKey(string name, int type) 275 protected UUID InventoryKey(string name, int type)
290 { 276 {
291 m_host.AddScriptLPS(1); 277 m_host.AddScriptLPS(1);
@@ -857,7 +843,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
857 UUID.TryParse(ID, out keyID); 843 UUID.TryParse(ID, out keyID);
858 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 844 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
859 if (wComm != null) 845 if (wComm != null)
860 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); 846 return wComm.Listen(m_localID, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
861 else 847 else
862 return -1; 848 return -1;
863 } 849 }
@@ -867,7 +853,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
867 m_host.AddScriptLPS(1); 853 m_host.AddScriptLPS(1);
868 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 854 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
869 if (wComm != null) 855 if (wComm != null)
870 wComm.ListenControl(m_itemID, number, active); 856 wComm.ListenControl(m_item.ItemID, number, active);
871 } 857 }
872 858
873 public void llListenRemove(int number) 859 public void llListenRemove(int number)
@@ -875,7 +861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
875 m_host.AddScriptLPS(1); 861 m_host.AddScriptLPS(1);
876 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 862 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
877 if (wComm != null) 863 if (wComm != null)
878 wComm.ListenRemove(m_itemID, number); 864 wComm.ListenRemove(m_item.ItemID, number);
879 } 865 }
880 866
881 public void llSensor(string name, string id, int type, double range, double arc) 867 public void llSensor(string name, string id, int type, double range, double arc)
@@ -884,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
884 UUID keyID = UUID.Zero; 870 UUID keyID = UUID.Zero;
885 UUID.TryParse(id, out keyID); 871 UUID.TryParse(id, out keyID);
886 872
887 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 873 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_item.ItemID, name, keyID, type, range, arc, m_host);
888 } 874 }
889 875
890 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 876 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -893,13 +879,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
893 UUID keyID = UUID.Zero; 879 UUID keyID = UUID.Zero;
894 UUID.TryParse(id, out keyID); 880 UUID.TryParse(id, out keyID);
895 881
896 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 882 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_item.ItemID, name, keyID, type, range, arc, rate, m_host);
897 } 883 }
898 884
899 public void llSensorRemove() 885 public void llSensorRemove()
900 { 886 {
901 m_host.AddScriptLPS(1); 887 m_host.AddScriptLPS(1);
902 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); 888 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_item.ItemID);
903 } 889 }
904 890
905 public string resolveName(UUID objecUUID) 891 public string resolveName(UUID objecUUID)
@@ -940,7 +926,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
940 public LSL_String llDetectedName(int number) 926 public LSL_String llDetectedName(int number)
941 { 927 {
942 m_host.AddScriptLPS(1); 928 m_host.AddScriptLPS(1);
943 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 929 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
944 if (detectedParams == null) 930 if (detectedParams == null)
945 return String.Empty; 931 return String.Empty;
946 return detectedParams.Name; 932 return detectedParams.Name;
@@ -949,7 +935,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
949 public LSL_String llDetectedKey(int number) 935 public LSL_String llDetectedKey(int number)
950 { 936 {
951 m_host.AddScriptLPS(1); 937 m_host.AddScriptLPS(1);
952 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 938 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
953 if (detectedParams == null) 939 if (detectedParams == null)
954 return String.Empty; 940 return String.Empty;
955 return detectedParams.Key.ToString(); 941 return detectedParams.Key.ToString();
@@ -958,7 +944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
958 public LSL_String llDetectedOwner(int number) 944 public LSL_String llDetectedOwner(int number)
959 { 945 {
960 m_host.AddScriptLPS(1); 946 m_host.AddScriptLPS(1);
961 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 947 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
962 if (detectedParams == null) 948 if (detectedParams == null)
963 return String.Empty; 949 return String.Empty;
964 return detectedParams.Owner.ToString(); 950 return detectedParams.Owner.ToString();
@@ -967,7 +953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
967 public LSL_Integer llDetectedType(int number) 953 public LSL_Integer llDetectedType(int number)
968 { 954 {
969 m_host.AddScriptLPS(1); 955 m_host.AddScriptLPS(1);
970 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 956 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
971 if (detectedParams == null) 957 if (detectedParams == null)
972 return 0; 958 return 0;
973 return new LSL_Integer(detectedParams.Type); 959 return new LSL_Integer(detectedParams.Type);
@@ -976,7 +962,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
976 public LSL_Vector llDetectedPos(int number) 962 public LSL_Vector llDetectedPos(int number)
977 { 963 {
978 m_host.AddScriptLPS(1); 964 m_host.AddScriptLPS(1);
979 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 965 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
980 if (detectedParams == null) 966 if (detectedParams == null)
981 return new LSL_Vector(); 967 return new LSL_Vector();
982 return detectedParams.Position; 968 return detectedParams.Position;
@@ -985,7 +971,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
985 public LSL_Vector llDetectedVel(int number) 971 public LSL_Vector llDetectedVel(int number)
986 { 972 {
987 m_host.AddScriptLPS(1); 973 m_host.AddScriptLPS(1);
988 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 974 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
989 if (detectedParams == null) 975 if (detectedParams == null)
990 return new LSL_Vector(); 976 return new LSL_Vector();
991 return detectedParams.Velocity; 977 return detectedParams.Velocity;
@@ -994,7 +980,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
994 public LSL_Vector llDetectedGrab(int number) 980 public LSL_Vector llDetectedGrab(int number)
995 { 981 {
996 m_host.AddScriptLPS(1); 982 m_host.AddScriptLPS(1);
997 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 983 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
998 if (parms == null) 984 if (parms == null)
999 return new LSL_Vector(0, 0, 0); 985 return new LSL_Vector(0, 0, 0);
1000 986
@@ -1004,7 +990,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1004 public LSL_Rotation llDetectedRot(int number) 990 public LSL_Rotation llDetectedRot(int number)
1005 { 991 {
1006 m_host.AddScriptLPS(1); 992 m_host.AddScriptLPS(1);
1007 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 993 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1008 if (detectedParams == null) 994 if (detectedParams == null)
1009 return new LSL_Rotation(); 995 return new LSL_Rotation();
1010 return detectedParams.Rotation; 996 return detectedParams.Rotation;
@@ -1013,7 +999,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1013 public LSL_Integer llDetectedGroup(int number) 999 public LSL_Integer llDetectedGroup(int number)
1014 { 1000 {
1015 m_host.AddScriptLPS(1); 1001 m_host.AddScriptLPS(1);
1016 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1002 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1017 if (detectedParams == null) 1003 if (detectedParams == null)
1018 return new LSL_Integer(0); 1004 return new LSL_Integer(0);
1019 if (m_host.GroupID == detectedParams.Group) 1005 if (m_host.GroupID == detectedParams.Group)
@@ -1024,7 +1010,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1024 public LSL_Integer llDetectedLinkNumber(int number) 1010 public LSL_Integer llDetectedLinkNumber(int number)
1025 { 1011 {
1026 m_host.AddScriptLPS(1); 1012 m_host.AddScriptLPS(1);
1027 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1013 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1028 if (parms == null) 1014 if (parms == null)
1029 return new LSL_Integer(0); 1015 return new LSL_Integer(0);
1030 1016
@@ -1037,7 +1023,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1037 public LSL_Vector llDetectedTouchBinormal(int index) 1023 public LSL_Vector llDetectedTouchBinormal(int index)
1038 { 1024 {
1039 m_host.AddScriptLPS(1); 1025 m_host.AddScriptLPS(1);
1040 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1026 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1041 if (detectedParams == null) 1027 if (detectedParams == null)
1042 return new LSL_Vector(); 1028 return new LSL_Vector();
1043 return detectedParams.TouchBinormal; 1029 return detectedParams.TouchBinormal;
@@ -1049,7 +1035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1049 public LSL_Integer llDetectedTouchFace(int index) 1035 public LSL_Integer llDetectedTouchFace(int index)
1050 { 1036 {
1051 m_host.AddScriptLPS(1); 1037 m_host.AddScriptLPS(1);
1052 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1038 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1053 if (detectedParams == null) 1039 if (detectedParams == null)
1054 return new LSL_Integer(-1); 1040 return new LSL_Integer(-1);
1055 return new LSL_Integer(detectedParams.TouchFace); 1041 return new LSL_Integer(detectedParams.TouchFace);
@@ -1061,7 +1047,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1061 public LSL_Vector llDetectedTouchNormal(int index) 1047 public LSL_Vector llDetectedTouchNormal(int index)
1062 { 1048 {
1063 m_host.AddScriptLPS(1); 1049 m_host.AddScriptLPS(1);
1064 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1050 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1065 if (detectedParams == null) 1051 if (detectedParams == null)
1066 return new LSL_Vector(); 1052 return new LSL_Vector();
1067 return detectedParams.TouchNormal; 1053 return detectedParams.TouchNormal;
@@ -1073,7 +1059,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1073 public LSL_Vector llDetectedTouchPos(int index) 1059 public LSL_Vector llDetectedTouchPos(int index)
1074 { 1060 {
1075 m_host.AddScriptLPS(1); 1061 m_host.AddScriptLPS(1);
1076 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1062 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1077 if (detectedParams == null) 1063 if (detectedParams == null)
1078 return new LSL_Vector(); 1064 return new LSL_Vector();
1079 return detectedParams.TouchPos; 1065 return detectedParams.TouchPos;
@@ -1085,7 +1071,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1085 public LSL_Vector llDetectedTouchST(int index) 1071 public LSL_Vector llDetectedTouchST(int index)
1086 { 1072 {
1087 m_host.AddScriptLPS(1); 1073 m_host.AddScriptLPS(1);
1088 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1074 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1089 if (detectedParams == null) 1075 if (detectedParams == null)
1090 return new LSL_Vector(-1.0, -1.0, 0.0); 1076 return new LSL_Vector(-1.0, -1.0, 0.0);
1091 return detectedParams.TouchST; 1077 return detectedParams.TouchST;
@@ -1097,7 +1083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1097 public LSL_Vector llDetectedTouchUV(int index) 1083 public LSL_Vector llDetectedTouchUV(int index)
1098 { 1084 {
1099 m_host.AddScriptLPS(1); 1085 m_host.AddScriptLPS(1);
1100 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1086 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1101 if (detectedParams == null) 1087 if (detectedParams == null)
1102 return new LSL_Vector(-1.0, -1.0, 0.0); 1088 return new LSL_Vector(-1.0, -1.0, 0.0);
1103 return detectedParams.TouchUV; 1089 return detectedParams.TouchUV;
@@ -2702,12 +2688,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2702 { 2688 {
2703 m_host.AddScriptLPS(1); 2689 m_host.AddScriptLPS(1);
2704 2690
2705 TaskInventoryItem item = GetSelfInventoryItem(); 2691 if (m_item.PermsGranter == UUID.Zero)
2706
2707 if (item.PermsGranter == UUID.Zero)
2708 return 0; 2692 return 0;
2709 2693
2710 if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) 2694 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
2711 { 2695 {
2712 LSLError("No permissions to give money"); 2696 LSLError("No permissions to give money");
2713 return 0; 2697 return 0;
@@ -2890,7 +2874,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2890 sec = m_MinTimerInterval; 2874 sec = m_MinTimerInterval;
2891 m_host.AddScriptLPS(1); 2875 m_host.AddScriptLPS(1);
2892 // Setting timer repeat 2876 // Setting timer repeat
2893 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); 2877 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_item.ItemID, sec);
2894 } 2878 }
2895 2879
2896 public virtual void llSleep(double sec) 2880 public virtual void llSleep(double sec)
@@ -2945,17 +2929,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2945 2929
2946 public void llTakeControls(int controls, int accept, int pass_on) 2930 public void llTakeControls(int controls, int accept, int pass_on)
2947 { 2931 {
2948 TaskInventoryItem item = GetSelfInventoryItem(); 2932 if (m_item.PermsGranter != UUID.Zero)
2949
2950 if (item.PermsGranter != UUID.Zero)
2951 { 2933 {
2952 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 2934 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
2953 2935
2954 if (presence != null) 2936 if (presence != null)
2955 { 2937 {
2956 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 2938 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
2957 { 2939 {
2958 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 2940 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_item.ItemID);
2959 } 2941 }
2960 } 2942 }
2961 } 2943 }
@@ -2967,20 +2949,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2967 { 2949 {
2968 m_host.AddScriptLPS(1); 2950 m_host.AddScriptLPS(1);
2969 2951
2970 TaskInventoryItem item = GetSelfInventoryItem(); 2952 if (m_item.PermsGranter != UUID.Zero)
2971
2972 if (item.PermsGranter != UUID.Zero)
2973 { 2953 {
2974 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 2954 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
2975 2955
2976 if (presence != null) 2956 if (presence != null)
2977 { 2957 {
2978 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 2958 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
2979 { 2959 {
2980 // Unregister controls from Presence 2960 // Unregister controls from Presence
2981 presence.UnRegisterControlEventsToScript(m_localID, m_itemID); 2961 presence.UnRegisterControlEventsToScript(m_localID, m_item.ItemID);
2982 // Remove Take Control permission. 2962 // Remove Take Control permission.
2983 item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; 2963 m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
2984 } 2964 }
2985 } 2965 }
2986 } 2966 }
@@ -3042,12 +3022,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3042// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) 3022// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
3043// return; 3023// return;
3044 3024
3045 TaskInventoryItem item = GetSelfInventoryItem(); 3025 if (m_item.PermsGranter != m_host.OwnerID)
3046
3047 if (item.PermsGranter != m_host.OwnerID)
3048 return; 3026 return;
3049 3027
3050 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3028 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3051 AttachToAvatar(attachmentPoint); 3029 AttachToAvatar(attachmentPoint);
3052 } 3030 }
3053 3031
@@ -3058,12 +3036,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3058 if (m_host.ParentGroup.AttachmentPoint == 0) 3036 if (m_host.ParentGroup.AttachmentPoint == 0)
3059 return; 3037 return;
3060 3038
3061 TaskInventoryItem item = GetSelfInventoryItem(); 3039 if (m_item.PermsGranter != m_host.OwnerID)
3062
3063 if (item.PermsGranter != m_host.OwnerID)
3064 return; 3040 return;
3065 3041
3066 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3042 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3067 DetachFromAvatar(); 3043 DetachFromAvatar();
3068 } 3044 }
3069 3045
@@ -3245,7 +3221,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3245 m_host.AddScriptLPS(1); 3221 m_host.AddScriptLPS(1);
3246 try 3222 try
3247 { 3223 {
3248 m_ScriptEngine.SetMinEventDelay(m_itemID, delay); 3224 m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay);
3249 } 3225 }
3250 catch (NotImplementedException) 3226 catch (NotImplementedException)
3251 { 3227 {
@@ -3298,14 +3274,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3298 { 3274 {
3299 m_host.AddScriptLPS(1); 3275 m_host.AddScriptLPS(1);
3300 3276
3301 TaskInventoryItem item = GetSelfInventoryItem(); 3277 if (m_item.PermsGranter == UUID.Zero)
3302
3303 if (item.PermsGranter == UUID.Zero)
3304 return; 3278 return;
3305 3279
3306 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 3280 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3307 { 3281 {
3308 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3282 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3309 3283
3310 if (presence != null) 3284 if (presence != null)
3311 { 3285 {
@@ -3323,21 +3297,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3323 { 3297 {
3324 m_host.AddScriptLPS(1); 3298 m_host.AddScriptLPS(1);
3325 3299
3326 TaskInventoryItem item = GetSelfInventoryItem(); 3300 if (m_item.PermsGranter == UUID.Zero)
3327
3328 if (item.PermsGranter == UUID.Zero)
3329 return; 3301 return;
3330 3302
3331 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 3303 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3332 { 3304 {
3333 UUID animID = new UUID(); 3305 UUID animID = new UUID();
3334 3306
3335 if (!UUID.TryParse(anim, out animID)) 3307 if (!UUID.TryParse(anim, out animID))
3336 { 3308 {
3337 animID=InventoryKey(anim); 3309 animID = InventoryKey(anim);
3338 } 3310 }
3339 3311
3340 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3312 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3341 3313
3342 if (presence != null) 3314 if (presence != null)
3343 { 3315 {
@@ -3373,7 +3345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3373 public LSL_Integer llGetStartParameter() 3345 public LSL_Integer llGetStartParameter()
3374 { 3346 {
3375 m_host.AddScriptLPS(1); 3347 m_host.AddScriptLPS(1);
3376 return m_ScriptEngine.GetStartParameter(m_itemID); 3348 return m_ScriptEngine.GetStartParameter(m_item.ItemID);
3377 } 3349 }
3378 3350
3379 public void llRequestPermissions(string agent, int perm) 3351 public void llRequestPermissions(string agent, int perm)
@@ -3383,16 +3355,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3383 if (!UUID.TryParse(agent, out agentID)) 3355 if (!UUID.TryParse(agent, out agentID))
3384 return; 3356 return;
3385 3357
3386 TaskInventoryItem item = GetSelfInventoryItem();
3387
3388 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3358 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3389 { 3359 {
3390 llReleaseControls(); 3360 llReleaseControls();
3391 3361
3392 item.PermsGranter = UUID.Zero; 3362 m_item.PermsGranter = UUID.Zero;
3393 item.PermsMask = 0; 3363 m_item.PermsMask = 0;
3394 3364
3395 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3365 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3396 "run_time_permissions", new Object[] { 3366 "run_time_permissions", new Object[] {
3397 new LSL_Integer(0) }, 3367 new LSL_Integer(0) },
3398 new DetectParams[0])); 3368 new DetectParams[0]));
@@ -3400,7 +3370,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3400 return; 3370 return;
3401 } 3371 }
3402 3372
3403 if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3373 if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3404 llReleaseControls(); 3374 llReleaseControls();
3405 3375
3406 m_host.AddScriptLPS(1); 3376 m_host.AddScriptLPS(1);
@@ -3417,11 +3387,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3417 { 3387 {
3418 lock (m_host.TaskInventory) 3388 lock (m_host.TaskInventory)
3419 { 3389 {
3420 m_host.TaskInventory[m_itemID].PermsGranter = agentID; 3390 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3421 m_host.TaskInventory[m_itemID].PermsMask = perm; 3391 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3422 } 3392 }
3423 3393
3424 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3394 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3425 "run_time_permissions", new Object[] { 3395 "run_time_permissions", new Object[] {
3426 new LSL_Integer(perm) }, 3396 new LSL_Integer(perm) },
3427 new DetectParams[0])); 3397 new DetectParams[0]));
@@ -3441,11 +3411,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3441 { 3411 {
3442 lock (m_host.TaskInventory) 3412 lock (m_host.TaskInventory)
3443 { 3413 {
3444 m_host.TaskInventory[m_itemID].PermsGranter = agentID; 3414 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3445 m_host.TaskInventory[m_itemID].PermsMask = perm; 3415 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3446 } 3416 }
3447 3417
3448 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3418 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3449 "run_time_permissions", new Object[] { 3419 "run_time_permissions", new Object[] {
3450 new LSL_Integer(perm) }, 3420 new LSL_Integer(perm) },
3451 new DetectParams[0])); 3421 new DetectParams[0]));
@@ -3466,8 +3436,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3466 { 3436 {
3467 lock (m_host.TaskInventory) 3437 lock (m_host.TaskInventory)
3468 { 3438 {
3469 m_host.TaskInventory[m_itemID].PermsGranter = agentID; 3439 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3470 m_host.TaskInventory[m_itemID].PermsMask = 0; 3440 m_host.TaskInventory[m_item.ItemID].PermsMask = 0;
3471 } 3441 }
3472 3442
3473 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3443 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3475,13 +3445,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3475 } 3445 }
3476 3446
3477 presence.ControllingClient.SendScriptQuestion( 3447 presence.ControllingClient.SendScriptQuestion(
3478 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm); 3448 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm);
3479 3449
3480 return; 3450 return;
3481 } 3451 }
3482 3452
3483 // Requested agent is not in range, refuse perms 3453 // Requested agent is not in range, refuse perms
3484 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3454 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3485 "run_time_permissions", new Object[] { 3455 "run_time_permissions", new Object[] {
3486 new LSL_Integer(0) }, 3456 new LSL_Integer(0) },
3487 new DetectParams[0])); 3457 new DetectParams[0]));
@@ -3500,10 +3470,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3500 3470
3501 lock (m_host.TaskInventory) 3471 lock (m_host.TaskInventory)
3502 { 3472 {
3503 m_host.TaskInventory[m_itemID].PermsMask = answer; 3473 m_host.TaskInventory[m_item.ItemID].PermsMask = answer;
3504 } 3474 }
3505 3475
3506 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3476 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3507 "run_time_permissions", new Object[] { 3477 "run_time_permissions", new Object[] {
3508 new LSL_Integer(answer) }, 3478 new LSL_Integer(answer) },
3509 new DetectParams[0])); 3479 new DetectParams[0]));
@@ -3513,14 +3483,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3513 { 3483 {
3514 m_host.AddScriptLPS(1); 3484 m_host.AddScriptLPS(1);
3515 3485
3516 return GetSelfInventoryItem().PermsGranter.ToString(); 3486 return m_item.PermsGranter.ToString();
3517 } 3487 }
3518 3488
3519 public LSL_Integer llGetPermissions() 3489 public LSL_Integer llGetPermissions()
3520 { 3490 {
3521 m_host.AddScriptLPS(1); 3491 m_host.AddScriptLPS(1);
3522 3492
3523 int perms = GetSelfInventoryItem().PermsMask; 3493 int perms = m_item.PermsMask;
3524 3494
3525 if (m_automaticLinkPermission) 3495 if (m_automaticLinkPermission)
3526 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3496 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
@@ -3558,9 +3528,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3558 if (!UUID.TryParse(target, out targetID)) 3528 if (!UUID.TryParse(target, out targetID))
3559 return; 3529 return;
3560 3530
3561 TaskInventoryItem item = GetSelfInventoryItem(); 3531 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3562
3563 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3564 && !m_automaticLinkPermission) 3532 && !m_automaticLinkPermission)
3565 { 3533 {
3566 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3534 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -3568,7 +3536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3568 } 3536 }
3569 3537
3570 IClientAPI client = null; 3538 IClientAPI client = null;
3571 ScenePresence sp = World.GetScenePresence(item.PermsGranter); 3539 ScenePresence sp = World.GetScenePresence(m_item.PermsGranter);
3572 if (sp != null) 3540 if (sp != null)
3573 client = sp.ControllingClient; 3541 client = sp.ControllingClient;
3574 3542
@@ -3615,7 +3583,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3615 { 3583 {
3616 m_host.AddScriptLPS(1); 3584 m_host.AddScriptLPS(1);
3617 3585
3618 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3586 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3619 && !m_automaticLinkPermission) 3587 && !m_automaticLinkPermission)
3620 { 3588 {
3621 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3589 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -3986,7 +3954,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3986 { 3954 {
3987 if (item.Name == name) 3955 if (item.Name == name)
3988 { 3956 {
3989 if (item.ItemID == m_itemID) 3957 if (item.ItemID == m_item.ItemID)
3990 throw new ScriptDeleteException(); 3958 throw new ScriptDeleteException();
3991 else 3959 else
3992 m_host.Inventory.RemoveInventoryItem(item.ItemID); 3960 m_host.Inventory.RemoveInventoryItem(item.ItemID);
@@ -4122,7 +4090,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4122 4090
4123 UUID tid = AsyncCommands. 4091 UUID tid = AsyncCommands.
4124 DataserverPlugin.RegisterRequest(m_localID, 4092 DataserverPlugin.RegisterRequest(m_localID,
4125 m_itemID, rq.ToString()); 4093 m_item.ItemID, rq.ToString());
4126 4094
4127 AsyncCommands. 4095 AsyncCommands.
4128 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4096 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -4143,7 +4111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4143 { 4111 {
4144 UUID tid = AsyncCommands. 4112 UUID tid = AsyncCommands.
4145 DataserverPlugin.RegisterRequest(m_localID, 4113 DataserverPlugin.RegisterRequest(m_localID,
4146 m_itemID, item.AssetID.ToString()); 4114 m_item.ItemID, item.AssetID.ToString());
4147 4115
4148 Vector3 region = new Vector3( 4116 Vector3 region = new Vector3(
4149 World.RegionInfo.RegionLocX * Constants.RegionSize, 4117 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -4498,9 +4466,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4498 { 4466 {
4499 m_host.AddScriptLPS(1); 4467 m_host.AddScriptLPS(1);
4500 4468
4501 TaskInventoryItem item = GetSelfInventoryItem(); 4469 return m_item.Name != null ? m_item.Name : String.Empty;
4502
4503 return item.Name != null ? item.Name : String.Empty;
4504 } 4470 }
4505 4471
4506 public LSL_Integer llGetLinkNumberOfSides(int link) 4472 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -6598,14 +6564,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6598 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 6564 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
6599 if (xmlrpcMod.IsEnabled()) 6565 if (xmlrpcMod.IsEnabled())
6600 { 6566 {
6601 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); 6567 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_item.ItemID, UUID.Zero);
6602 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); 6568 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
6603 if (xmlRpcRouter != null) 6569 if (xmlRpcRouter != null)
6604 { 6570 {
6605 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; 6571 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName;
6606 6572
6607 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, 6573 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID,
6608 m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, 6574 m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName,
6609 xmlrpcMod.Port.ToString())); 6575 xmlrpcMod.Port.ToString()));
6610 } 6576 }
6611 object[] resobj = new object[] 6577 object[] resobj = new object[]
@@ -6617,7 +6583,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6617 new LSL_Integer(0), 6583 new LSL_Integer(0),
6618 new LSL_String(String.Empty) 6584 new LSL_String(String.Empty)
6619 }; 6585 };
6620 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, 6586 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj,
6621 new DetectParams[0])); 6587 new DetectParams[0]));
6622 } 6588 }
6623 ScriptSleep(1000); 6589 ScriptSleep(1000);
@@ -6628,7 +6594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6628 m_host.AddScriptLPS(1); 6594 m_host.AddScriptLPS(1);
6629 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 6595 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
6630 ScriptSleep(3000); 6596 ScriptSleep(3000);
6631 return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); 6597 return (xmlrpcMod.SendRemoteData(m_localID, m_item.ItemID, channel, dest, idata, sdata)).ToString();
6632 } 6598 }
6633 6599
6634 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) 6600 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
@@ -9049,13 +9015,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9049 { 9015 {
9050 m_host.AddScriptLPS(1); 9016 m_host.AddScriptLPS(1);
9051 if (m_UrlModule != null) 9017 if (m_UrlModule != null)
9052 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 9018 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
9053 return UUID.Zero.ToString(); 9019 return UUID.Zero.ToString();
9054 } 9020 }
9055 9021
9056 public LSL_String llRequestSimulatorData(string simulator, int data) 9022 public LSL_String llRequestSimulatorData(string simulator, int data)
9057 { 9023 {
9058 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 9024 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL");
9059 9025
9060 try 9026 try
9061 { 9027 {
@@ -9117,7 +9083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9117 UUID rq = UUID.Random(); 9083 UUID rq = UUID.Random();
9118 9084
9119 UUID tid = AsyncCommands. 9085 UUID tid = AsyncCommands.
9120 DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 9086 DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString());
9121 9087
9122 AsyncCommands. 9088 AsyncCommands.
9123 DataserverPlugin.DataserverReply(rq.ToString(), reply); 9089 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -9136,7 +9102,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9136 m_host.AddScriptLPS(1); 9102 m_host.AddScriptLPS(1);
9137 9103
9138 if (m_UrlModule != null) 9104 if (m_UrlModule != null)
9139 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 9105 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
9140 return UUID.Zero.ToString(); 9106 return UUID.Zero.ToString();
9141 } 9107 }
9142 9108
@@ -9602,12 +9568,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9602 { 9568 {
9603 m_host.AddScriptLPS(1); 9569 m_host.AddScriptLPS(1);
9604 9570
9605 TaskInventoryItem item = GetSelfInventoryItem(); 9571 if (m_item.PermsGranter == UUID.Zero)
9606
9607 if (item.PermsGranter == UUID.Zero)
9608 return new LSL_Vector(); 9572 return new LSL_Vector();
9609 9573
9610 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9574 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9611 { 9575 {
9612 ShoutError("No permissions to track the camera"); 9576 ShoutError("No permissions to track the camera");
9613 return new LSL_Vector(); 9577 return new LSL_Vector();
@@ -9626,12 +9590,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9626 { 9590 {
9627 m_host.AddScriptLPS(1); 9591 m_host.AddScriptLPS(1);
9628 9592
9629 TaskInventoryItem item = GetSelfInventoryItem(); 9593 if (m_item.PermsGranter == UUID.Zero)
9630
9631 if (item.PermsGranter == UUID.Zero)
9632 return new LSL_Rotation(); 9594 return new LSL_Rotation();
9633 9595
9634 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9596 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9635 { 9597 {
9636 ShoutError("No permissions to track the camera"); 9598 ShoutError("No permissions to track the camera");
9637 return new LSL_Rotation(); 9599 return new LSL_Rotation();
@@ -9696,7 +9658,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9696 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) 9658 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt)
9697 { 9659 {
9698 m_host.AddScriptLPS(1); 9660 m_host.AddScriptLPS(1);
9699 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 9661 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0);
9700 if (detectedParams == null) return; // only works on the first detected avatar 9662 if (detectedParams == null) return; // only works on the first detected avatar
9701 9663
9702 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 9664 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
@@ -9813,15 +9775,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9813 if (objectID == UUID.Zero) 9775 if (objectID == UUID.Zero)
9814 return; 9776 return;
9815 9777
9816 TaskInventoryItem item = GetSelfInventoryItem();
9817
9818 // we need the permission first, to know which avatar we want to set the camera for 9778 // we need the permission first, to know which avatar we want to set the camera for
9819 UUID agentID = item.PermsGranter; 9779 UUID agentID = m_item.PermsGranter;
9820 9780
9821 if (agentID == UUID.Zero) 9781 if (agentID == UUID.Zero)
9822 return; 9782 return;
9823 9783
9824 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 9784 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9825 return; 9785 return;
9826 9786
9827 ScenePresence presence = World.GetScenePresence(agentID); 9787 ScenePresence presence = World.GetScenePresence(agentID);
@@ -9867,15 +9827,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9867 if (objectID == UUID.Zero) 9827 if (objectID == UUID.Zero)
9868 return; 9828 return;
9869 9829
9870 TaskInventoryItem item = GetSelfInventoryItem();
9871
9872 // we need the permission first, to know which avatar we want to clear the camera for 9830 // we need the permission first, to know which avatar we want to clear the camera for
9873 UUID agentID = item.PermsGranter; 9831 UUID agentID = m_item.PermsGranter;
9874 9832
9875 if (agentID == UUID.Zero) 9833 if (agentID == UUID.Zero)
9876 return; 9834 return;
9877 9835
9878 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 9836 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9879 return; 9837 return;
9880 9838
9881 ScenePresence presence = World.GetScenePresence(agentID); 9839 ScenePresence presence = World.GetScenePresence(agentID);
@@ -10025,7 +9983,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10025 } 9983 }
10026 9984
10027 UUID reqID = httpScriptMod. 9985 UUID reqID = httpScriptMod.
10028 StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); 9986 StartHttpRequest(m_localID, m_item.ItemID, url, param, httpHeaders, body);
10029 9987
10030 if (reqID != UUID.Zero) 9988 if (reqID != UUID.Zero)
10031 return reqID.ToString(); 9989 return reqID.ToString();
@@ -10455,7 +10413,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10455 } 10413 }
10456 10414
10457 // was: UUID tid = tid = AsyncCommands. 10415 // was: UUID tid = tid = AsyncCommands.
10458 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 10416 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, assetID.ToString());
10459 10417
10460 if (NotecardCache.IsCached(assetID)) 10418 if (NotecardCache.IsCached(assetID))
10461 { 10419 {
@@ -10517,7 +10475,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10517 } 10475 }
10518 10476
10519 // was: UUID tid = tid = AsyncCommands. 10477 // was: UUID tid = tid = AsyncCommands.
10520 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 10478 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, assetID.ToString());
10521 10479
10522 if (NotecardCache.IsCached(assetID)) 10480 if (NotecardCache.IsCached(assetID))
10523 { 10481 {
@@ -10575,7 +10533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10575 public void print(string str) 10533 public void print(string str)
10576 { 10534 {
10577 // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print 10535 // yes, this is a real LSL function. See: http://wiki.secondlife.com/wiki/Print
10578 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 10536 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL");
10579 if (ossl != null) 10537 if (ossl != null)
10580 { 10538 {
10581 ossl.CheckThreatLevel(ThreatLevel.High, "print"); 10539 ossl.CheckThreatLevel(ThreatLevel.High, "print");
@@ -10603,7 +10561,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10603 { 10561 {
10604 UUID rq = UUID.Random(); 10562 UUID rq = UUID.Random();
10605 10563
10606 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 10564 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString());
10607 10565
10608 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); 10566 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
10609 10567
@@ -10619,7 +10577,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10619 { 10577 {
10620 UUID rq = UUID.Random(); 10578 UUID rq = UUID.Random();
10621 10579
10622 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 10580 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_item.ItemID, rq.ToString());
10623 10581
10624 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); 10582 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
10625 10583
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index df20126..cd47d96 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -59,16 +59,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
59 internal IScriptEngine m_ScriptEngine; 59 internal IScriptEngine m_ScriptEngine;
60 internal SceneObjectPart m_host; 60 internal SceneObjectPart m_host;
61 internal uint m_localID; 61 internal uint m_localID;
62 internal UUID m_itemID;
63 internal bool m_LSFunctionsEnabled = false; 62 internal bool m_LSFunctionsEnabled = false;
64 internal IScriptModuleComms m_comms = null; 63 internal IScriptModuleComms m_comms = null;
65 64
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item)
67 { 66 {
68 m_ScriptEngine = ScriptEngine; 67 m_ScriptEngine = ScriptEngine;
69 m_host = host; 68 m_host = host;
70 m_localID = localID; 69 m_localID = localID;
71 m_itemID = itemID;
72 70
73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 71 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
74 m_LSFunctionsEnabled = true; 72 m_LSFunctionsEnabled = true;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7c07e15..a578b50 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -58,16 +58,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
58 internal IScriptEngine m_ScriptEngine; 58 internal IScriptEngine m_ScriptEngine;
59 internal SceneObjectPart m_host; 59 internal SceneObjectPart m_host;
60 internal uint m_localID; 60 internal uint m_localID;
61 internal UUID m_itemID; 61 internal TaskInventoryItem m_item;
62 internal bool m_MODFunctionsEnabled = false; 62 internal bool m_MODFunctionsEnabled = false;
63 internal IScriptModuleComms m_comms = null; 63 internal IScriptModuleComms m_comms = null;
64 64
65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item)
66 { 66 {
67 m_ScriptEngine = ScriptEngine; 67 m_ScriptEngine = ScriptEngine;
68 m_host = host; 68 m_host = host;
69 m_localID = localID; 69 m_localID = localID;
70 m_itemID = itemID; 70 m_item = item;
71 71
72 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) 72 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))
73 m_MODFunctionsEnabled = true; 73 m_MODFunctionsEnabled = true;
@@ -252,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
252 // non-null but don't trust it completely 252 // non-null but don't trust it completely
253 try 253 try
254 { 254 {
255 object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); 255 object result = m_comms.InvokeOperation(m_host.UUID, m_item.ItemID, fname, convertedParms);
256 if (result != null) 256 if (result != null)
257 return result; 257 return result;
258 258
@@ -279,7 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
279 279
280 UUID req = UUID.Random(); 280 UUID req = UUID.Random();
281 281
282 m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); 282 m_comms.RaiseEvent(m_item.ItemID, req.ToString(), module, command, k);
283 283
284 return req.ToString(); 284 return req.ToString();
285 } 285 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 3b67966..9b2022a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -134,19 +134,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
134 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there 134 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
135 internal SceneObjectPart m_host; 135 internal SceneObjectPart m_host;
136 internal uint m_localID; 136 internal uint m_localID;
137 internal UUID m_itemID; 137 internal TaskInventoryItem m_item;
138 internal bool m_OSFunctionsEnabled = false; 138 internal bool m_OSFunctionsEnabled = false;
139 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 139 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
140 internal float m_ScriptDelayFactor = 1.0f; 140 internal float m_ScriptDelayFactor = 1.0f;
141 internal float m_ScriptDistanceFactor = 1.0f; 141 internal float m_ScriptDistanceFactor = 1.0f;
142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
143 143
144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, TaskInventoryItem item)
145 { 145 {
146 m_ScriptEngine = ScriptEngine; 146 m_ScriptEngine = ScriptEngine;
147 m_host = host; 147 m_host = host;
148 m_localID = localID; 148 m_localID = localID;
149 m_itemID = itemID; 149 m_item = item;
150 150
151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
152 m_OSFunctionsEnabled = true; 152 m_OSFunctionsEnabled = true;
@@ -224,7 +224,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
224 if (m_LSL_Api != null) 224 if (m_LSL_Api != null)
225 return; 225 return;
226 226
227 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_itemID, "LSL"); 227 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL");
228 } 228 }
229 229
230 // 230 //
@@ -343,22 +343,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
343 return; 343 return;
344 } 344 }
345 345
346 TaskInventoryItem ti = m_host.Inventory.GetInventoryItem(m_itemID); 346 UUID ownerID = m_item.OwnerID;
347 if (ti == null)
348 {
349 OSSLError(
350 String.Format("{0} permission error. Can't find script in prim inventory.",
351 function));
352 }
353
354 UUID ownerID = ti.OwnerID;
355 347
356 //OSSL only may be used if object is in the same group as the parcel 348 //OSSL only may be used if object is in the same group as the parcel
357 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) 349 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER"))
358 { 350 {
359 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); 351 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
360 352
361 if (land.LandData.GroupID == ti.GroupID && land.LandData.GroupID != UUID.Zero) 353 if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
362 { 354 {
363 return; 355 return;
364 } 356 }
@@ -394,13 +386,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
394 } 386 }
395 } 387 }
396 388
397 if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID)) 389 if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
398 OSSLError( 390 OSSLError(
399 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", 391 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
400 function)); 392 function));
401 if (ti.CreatorID != ownerID) 393
394 if (m_item.CreatorID != ownerID)
402 { 395 {
403 if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0) 396 if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
404 OSSLError( 397 OSSLError(
405 String.Format("{0} permission denied. Script permissions error.", 398 String.Format("{0} permission denied. Script permissions error.",
406 function)); 399 function));
@@ -1183,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1183 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); 1176 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
1184 m_host.AddScriptLPS(1); 1177 m_host.AddScriptLPS(1);
1185 1178
1186 m_host.SetScriptEvents(m_itemID, events); 1179 m_host.SetScriptEvents(m_item.ItemID, events);
1187 } 1180 }
1188 1181
1189 public void osSetRegionWaterHeight(double height) 1182 public void osSetRegionWaterHeight(double height)