diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
4 files changed, 352 insertions, 253 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9a905f1..e694f15 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
151 | get { return m_ScriptEngine.World; } | 152 | get { return m_ScriptEngine.World; } |
152 | } | 153 | } |
153 | 154 | ||
155 | [DebuggerNonUserCode] | ||
154 | public void state(string newState) | 156 | public void state(string newState) |
155 | { | 157 | { |
156 | m_ScriptEngine.SetState(m_itemID, newState); | 158 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | /// Reset the named script. The script must be present | 162 | /// Reset the named script. The script must be present |
161 | /// in the same prim. | 163 | /// in the same prim. |
162 | /// </summary> | 164 | /// </summary> |
165 | [DebuggerNonUserCode] | ||
163 | public void llResetScript() | 166 | public void llResetScript() |
164 | { | 167 | { |
165 | m_host.AddScriptLPS(1); | 168 | m_host.AddScriptLPS(1); |
@@ -272,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 275 | protected UUID InventorySelf() |
273 | { | 276 | { |
274 | UUID invItemID = new UUID(); | 277 | UUID invItemID = new UUID(); |
275 | 278 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 279 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
280 | { | ||
281 | m_host.TaskInventory.LockItemsForRead(true); | ||
282 | unlock = true; | ||
283 | } | ||
284 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 285 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 286 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 287 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 288 | invItemID = inv.Key; |
281 | { | 289 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 290 | } |
286 | } | 291 | } |
287 | 292 | if (unlock) | |
293 | { | ||
294 | m_host.TaskInventory.LockItemsForRead(false); | ||
295 | } | ||
288 | return invItemID; | 296 | return invItemID; |
289 | } | 297 | } |
290 | 298 | ||
291 | protected UUID InventoryKey(string name, int type) | 299 | protected UUID InventoryKey(string name, int type) |
292 | { | 300 | { |
293 | m_host.AddScriptLPS(1); | 301 | m_host.AddScriptLPS(1); |
294 | 302 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 303 | |
304 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 305 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 306 | if (inv.Value.Name == name) |
298 | { | 307 | { |
299 | if (inv.Value.Name == name) | 308 | m_host.TaskInventory.LockItemsForRead(false); |
309 | |||
310 | if (inv.Value.Type != type) | ||
300 | { | 311 | { |
301 | if (inv.Value.Type != type) | 312 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 313 | } |
314 | |||
315 | return inv.Value.AssetID; | ||
306 | } | 316 | } |
307 | } | 317 | } |
308 | 318 | ||
319 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 320 | return UUID.Zero; |
310 | } | 321 | } |
311 | 322 | ||
@@ -313,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 324 | { |
314 | m_host.AddScriptLPS(1); | 325 | m_host.AddScriptLPS(1); |
315 | 326 | ||
316 | lock (m_host.TaskInventory) | 327 | |
328 | m_host.TaskInventory.LockItemsForRead(true); | ||
329 | |||
330 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 331 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 332 | if (inv.Value.Name == name) |
319 | { | 333 | { |
320 | if (inv.Value.Name == name) | 334 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 335 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 336 | } |
325 | } | 337 | } |
326 | 338 | ||
339 | m_host.TaskInventory.LockItemsForRead(false); | ||
340 | |||
341 | |||
327 | return UUID.Zero; | 342 | return UUID.Zero; |
328 | } | 343 | } |
329 | 344 | ||
@@ -2555,12 +2570,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2570 | ||
2556 | m_host.AddScriptLPS(1); | 2571 | m_host.AddScriptLPS(1); |
2557 | 2572 | ||
2573 | m_host.TaskInventory.LockItemsForRead(true); | ||
2558 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2574 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2559 | 2575 | m_host.TaskInventory.LockItemsForRead(false); | |
2560 | lock (m_host.TaskInventory) | ||
2561 | { | ||
2562 | item = m_host.TaskInventory[invItemID]; | ||
2563 | } | ||
2564 | 2576 | ||
2565 | if (item.PermsGranter == UUID.Zero) | 2577 | if (item.PermsGranter == UUID.Zero) |
2566 | return 0; | 2578 | return 0; |
@@ -2635,6 +2647,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2635 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2647 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2636 | return; | 2648 | return; |
2637 | 2649 | ||
2650 | //Clone is thread-safe | ||
2638 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2651 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2639 | 2652 | ||
2640 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2653 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2720,11 +2733,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2720 | // Orient the object to the angle calculated | 2733 | // Orient the object to the angle calculated |
2721 | llSetRot(rot); | 2734 | llSetRot(rot); |
2722 | } | 2735 | } |
2736 | |||
2737 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2738 | { | ||
2739 | m_host.AddScriptLPS(1); | ||
2740 | // NotImplemented("llRotLookAt"); | ||
2741 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2742 | |||
2743 | } | ||
2744 | |||
2723 | 2745 | ||
2724 | public void llStopLookAt() | 2746 | public void llStopLookAt() |
2725 | { | 2747 | { |
2726 | m_host.AddScriptLPS(1); | 2748 | m_host.AddScriptLPS(1); |
2727 | NotImplemented("llStopLookAt"); | 2749 | // NotImplemented("llStopLookAt"); |
2750 | m_host.StopLookAt(); | ||
2728 | } | 2751 | } |
2729 | 2752 | ||
2730 | public void llSetTimerEvent(double sec) | 2753 | public void llSetTimerEvent(double sec) |
@@ -2758,13 +2781,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2758 | { | 2781 | { |
2759 | TaskInventoryItem item; | 2782 | TaskInventoryItem item; |
2760 | 2783 | ||
2761 | lock (m_host.TaskInventory) | 2784 | m_host.TaskInventory.LockItemsForRead(true); |
2785 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2762 | { | 2786 | { |
2763 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2787 | m_host.TaskInventory.LockItemsForRead(false); |
2764 | return; | 2788 | return; |
2765 | else | 2789 | } |
2766 | item = m_host.TaskInventory[InventorySelf()]; | 2790 | else |
2791 | { | ||
2792 | item = m_host.TaskInventory[InventorySelf()]; | ||
2767 | } | 2793 | } |
2794 | m_host.TaskInventory.LockItemsForRead(false); | ||
2768 | 2795 | ||
2769 | if (item.PermsGranter != UUID.Zero) | 2796 | if (item.PermsGranter != UUID.Zero) |
2770 | { | 2797 | { |
@@ -2786,13 +2813,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2786 | { | 2813 | { |
2787 | TaskInventoryItem item; | 2814 | TaskInventoryItem item; |
2788 | 2815 | ||
2816 | m_host.TaskInventory.LockItemsForRead(true); | ||
2789 | lock (m_host.TaskInventory) | 2817 | lock (m_host.TaskInventory) |
2790 | { | 2818 | { |
2819 | |||
2791 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2820 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2821 | { | ||
2822 | m_host.TaskInventory.LockItemsForRead(false); | ||
2792 | return; | 2823 | return; |
2824 | } | ||
2793 | else | 2825 | else |
2826 | { | ||
2794 | item = m_host.TaskInventory[InventorySelf()]; | 2827 | item = m_host.TaskInventory[InventorySelf()]; |
2828 | } | ||
2795 | } | 2829 | } |
2830 | m_host.TaskInventory.LockItemsForRead(false); | ||
2796 | 2831 | ||
2797 | m_host.AddScriptLPS(1); | 2832 | m_host.AddScriptLPS(1); |
2798 | 2833 | ||
@@ -2829,14 +2864,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2829 | 2864 | ||
2830 | TaskInventoryItem item; | 2865 | TaskInventoryItem item; |
2831 | 2866 | ||
2832 | lock (m_host.TaskInventory) | 2867 | m_host.TaskInventory.LockItemsForRead(true); |
2868 | |||
2869 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2833 | { | 2870 | { |
2834 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2871 | m_host.TaskInventory.LockItemsForRead(false); |
2835 | return; | 2872 | return; |
2836 | else | 2873 | } |
2837 | item = m_host.TaskInventory[InventorySelf()]; | 2874 | else |
2875 | { | ||
2876 | item = m_host.TaskInventory[InventorySelf()]; | ||
2838 | } | 2877 | } |
2839 | 2878 | ||
2879 | m_host.TaskInventory.LockItemsForRead(false); | ||
2880 | |||
2840 | if (item.PermsGranter != m_host.OwnerID) | 2881 | if (item.PermsGranter != m_host.OwnerID) |
2841 | return; | 2882 | return; |
2842 | 2883 | ||
@@ -2861,13 +2902,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2861 | 2902 | ||
2862 | TaskInventoryItem item; | 2903 | TaskInventoryItem item; |
2863 | 2904 | ||
2864 | lock (m_host.TaskInventory) | 2905 | m_host.TaskInventory.LockItemsForRead(true); |
2906 | |||
2907 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2865 | { | 2908 | { |
2866 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2909 | m_host.TaskInventory.LockItemsForRead(false); |
2867 | return; | 2910 | return; |
2868 | else | ||
2869 | item = m_host.TaskInventory[InventorySelf()]; | ||
2870 | } | 2911 | } |
2912 | else | ||
2913 | { | ||
2914 | item = m_host.TaskInventory[InventorySelf()]; | ||
2915 | } | ||
2916 | m_host.TaskInventory.LockItemsForRead(false); | ||
2917 | |||
2871 | 2918 | ||
2872 | if (item.PermsGranter != m_host.OwnerID) | 2919 | if (item.PermsGranter != m_host.OwnerID) |
2873 | return; | 2920 | return; |
@@ -2903,8 +2950,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2903 | return m_host.OwnerID.ToString(); | 2950 | return m_host.OwnerID.ToString(); |
2904 | } | 2951 | } |
2905 | 2952 | ||
2953 | [DebuggerNonUserCode] | ||
2906 | public void llInstantMessage(string user, string message) | 2954 | public void llInstantMessage(string user, string message) |
2907 | { | 2955 | { |
2956 | UUID result; | ||
2957 | if (!UUID.TryParse(user, out result)) | ||
2958 | { | ||
2959 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
2960 | return; | ||
2961 | } | ||
2962 | |||
2963 | |||
2908 | m_host.AddScriptLPS(1); | 2964 | m_host.AddScriptLPS(1); |
2909 | 2965 | ||
2910 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 2966 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2919,7 +2975,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2919 | UUID friendTransactionID = UUID.Random(); | 2975 | UUID friendTransactionID = UUID.Random(); |
2920 | 2976 | ||
2921 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 2977 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2922 | 2978 | ||
2923 | GridInstantMessage msg = new GridInstantMessage(); | 2979 | GridInstantMessage msg = new GridInstantMessage(); |
2924 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 2980 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2925 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 2981 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3068,12 +3124,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3068 | m_host.AddScriptLPS(1); | 3124 | m_host.AddScriptLPS(1); |
3069 | } | 3125 | } |
3070 | 3126 | ||
3071 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3072 | { | ||
3073 | m_host.AddScriptLPS(1); | ||
3074 | NotImplemented("llRotLookAt"); | ||
3075 | } | ||
3076 | |||
3077 | public LSL_Integer llStringLength(string str) | 3127 | public LSL_Integer llStringLength(string str) |
3078 | { | 3128 | { |
3079 | m_host.AddScriptLPS(1); | 3129 | m_host.AddScriptLPS(1); |
@@ -3097,14 +3147,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3097 | 3147 | ||
3098 | TaskInventoryItem item; | 3148 | TaskInventoryItem item; |
3099 | 3149 | ||
3100 | lock (m_host.TaskInventory) | 3150 | m_host.TaskInventory.LockItemsForRead(true); |
3151 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3101 | { | 3152 | { |
3102 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3153 | m_host.TaskInventory.LockItemsForRead(false); |
3103 | return; | 3154 | return; |
3104 | else | ||
3105 | item = m_host.TaskInventory[InventorySelf()]; | ||
3106 | } | 3155 | } |
3107 | 3156 | else | |
3157 | { | ||
3158 | item = m_host.TaskInventory[InventorySelf()]; | ||
3159 | } | ||
3160 | m_host.TaskInventory.LockItemsForRead(false); | ||
3108 | if (item.PermsGranter == UUID.Zero) | 3161 | if (item.PermsGranter == UUID.Zero) |
3109 | return; | 3162 | return; |
3110 | 3163 | ||
@@ -3134,13 +3187,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3134 | 3187 | ||
3135 | TaskInventoryItem item; | 3188 | TaskInventoryItem item; |
3136 | 3189 | ||
3137 | lock (m_host.TaskInventory) | 3190 | m_host.TaskInventory.LockItemsForRead(true); |
3191 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3138 | { | 3192 | { |
3139 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3193 | m_host.TaskInventory.LockItemsForRead(false); |
3140 | return; | 3194 | return; |
3141 | else | ||
3142 | item = m_host.TaskInventory[InventorySelf()]; | ||
3143 | } | 3195 | } |
3196 | else | ||
3197 | { | ||
3198 | item = m_host.TaskInventory[InventorySelf()]; | ||
3199 | } | ||
3200 | m_host.TaskInventory.LockItemsForRead(false); | ||
3201 | |||
3144 | 3202 | ||
3145 | if (item.PermsGranter == UUID.Zero) | 3203 | if (item.PermsGranter == UUID.Zero) |
3146 | return; | 3204 | return; |
@@ -3213,10 +3271,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3213 | 3271 | ||
3214 | TaskInventoryItem item; | 3272 | TaskInventoryItem item; |
3215 | 3273 | ||
3216 | lock (m_host.TaskInventory) | 3274 | |
3275 | m_host.TaskInventory.LockItemsForRead(true); | ||
3276 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3277 | { | ||
3278 | m_host.TaskInventory.LockItemsForRead(false); | ||
3279 | return; | ||
3280 | } | ||
3281 | else | ||
3217 | { | 3282 | { |
3218 | item = m_host.TaskInventory[invItemID]; | 3283 | item = m_host.TaskInventory[invItemID]; |
3219 | } | 3284 | } |
3285 | m_host.TaskInventory.LockItemsForRead(false); | ||
3220 | 3286 | ||
3221 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3287 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3222 | { | 3288 | { |
@@ -3248,11 +3314,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3248 | 3314 | ||
3249 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3315 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3250 | { | 3316 | { |
3251 | lock (m_host.TaskInventory) | 3317 | m_host.TaskInventory.LockItemsForWrite(true); |
3252 | { | 3318 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3253 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3319 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3254 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3320 | m_host.TaskInventory.LockItemsForWrite(false); |
3255 | } | ||
3256 | 3321 | ||
3257 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3322 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3258 | "run_time_permissions", new Object[] { | 3323 | "run_time_permissions", new Object[] { |
@@ -3272,11 +3337,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3272 | 3337 | ||
3273 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3338 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3274 | { | 3339 | { |
3275 | lock (m_host.TaskInventory) | 3340 | m_host.TaskInventory.LockItemsForWrite(true); |
3276 | { | 3341 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3277 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3342 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3278 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3343 | m_host.TaskInventory.LockItemsForWrite(false); |
3279 | } | ||
3280 | 3344 | ||
3281 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3345 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3282 | "run_time_permissions", new Object[] { | 3346 | "run_time_permissions", new Object[] { |
@@ -3297,11 +3361,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3297 | 3361 | ||
3298 | if (!m_waitingForScriptAnswer) | 3362 | if (!m_waitingForScriptAnswer) |
3299 | { | 3363 | { |
3300 | lock (m_host.TaskInventory) | 3364 | m_host.TaskInventory.LockItemsForWrite(true); |
3301 | { | 3365 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3302 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3366 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3303 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3367 | m_host.TaskInventory.LockItemsForWrite(false); |
3304 | } | ||
3305 | 3368 | ||
3306 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3369 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3307 | m_waitingForScriptAnswer=true; | 3370 | m_waitingForScriptAnswer=true; |
@@ -3336,10 +3399,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3336 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3399 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3337 | llReleaseControls(); | 3400 | llReleaseControls(); |
3338 | 3401 | ||
3339 | lock (m_host.TaskInventory) | 3402 | |
3340 | { | 3403 | m_host.TaskInventory.LockItemsForWrite(true); |
3341 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3404 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3342 | } | 3405 | m_host.TaskInventory.LockItemsForWrite(false); |
3406 | |||
3343 | 3407 | ||
3344 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3408 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3345 | "run_time_permissions", new Object[] { | 3409 | "run_time_permissions", new Object[] { |
@@ -3351,16 +3415,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3351 | { | 3415 | { |
3352 | m_host.AddScriptLPS(1); | 3416 | m_host.AddScriptLPS(1); |
3353 | 3417 | ||
3354 | lock (m_host.TaskInventory) | 3418 | m_host.TaskInventory.LockItemsForRead(true); |
3419 | |||
3420 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3355 | { | 3421 | { |
3356 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3422 | if (item.Type == 10 && item.ItemID == m_itemID) |
3357 | { | 3423 | { |
3358 | if (item.Type == 10 && item.ItemID == m_itemID) | 3424 | m_host.TaskInventory.LockItemsForRead(false); |
3359 | { | 3425 | return item.PermsGranter.ToString(); |
3360 | return item.PermsGranter.ToString(); | ||
3361 | } | ||
3362 | } | 3426 | } |
3363 | } | 3427 | } |
3428 | m_host.TaskInventory.LockItemsForRead(false); | ||
3364 | 3429 | ||
3365 | return UUID.Zero.ToString(); | 3430 | return UUID.Zero.ToString(); |
3366 | } | 3431 | } |
@@ -3369,19 +3434,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3369 | { | 3434 | { |
3370 | m_host.AddScriptLPS(1); | 3435 | m_host.AddScriptLPS(1); |
3371 | 3436 | ||
3372 | lock (m_host.TaskInventory) | 3437 | m_host.TaskInventory.LockItemsForRead(true); |
3438 | |||
3439 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3373 | { | 3440 | { |
3374 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3441 | if (item.Type == 10 && item.ItemID == m_itemID) |
3375 | { | 3442 | { |
3376 | if (item.Type == 10 && item.ItemID == m_itemID) | 3443 | int perms = item.PermsMask; |
3377 | { | 3444 | if (m_automaticLinkPermission) |
3378 | int perms = item.PermsMask; | 3445 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3379 | if (m_automaticLinkPermission) | 3446 | m_host.TaskInventory.LockItemsForRead(false); |
3380 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3447 | return perms; |
3381 | return perms; | ||
3382 | } | ||
3383 | } | 3448 | } |
3384 | } | 3449 | } |
3450 | m_host.TaskInventory.LockItemsForRead(false); | ||
3385 | 3451 | ||
3386 | return 0; | 3452 | return 0; |
3387 | } | 3453 | } |
@@ -3414,11 +3480,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3414 | UUID invItemID = InventorySelf(); | 3480 | UUID invItemID = InventorySelf(); |
3415 | 3481 | ||
3416 | TaskInventoryItem item; | 3482 | TaskInventoryItem item; |
3417 | lock (m_host.TaskInventory) | 3483 | m_host.TaskInventory.LockItemsForRead(true); |
3418 | { | 3484 | item = m_host.TaskInventory[invItemID]; |
3419 | item = m_host.TaskInventory[invItemID]; | 3485 | m_host.TaskInventory.LockItemsForRead(false); |
3420 | } | 3486 | |
3421 | |||
3422 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3487 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3423 | && !m_automaticLinkPermission) | 3488 | && !m_automaticLinkPermission) |
3424 | { | 3489 | { |
@@ -3471,16 +3536,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3471 | m_host.AddScriptLPS(1); | 3536 | m_host.AddScriptLPS(1); |
3472 | UUID invItemID = InventorySelf(); | 3537 | UUID invItemID = InventorySelf(); |
3473 | 3538 | ||
3474 | lock (m_host.TaskInventory) | 3539 | m_host.TaskInventory.LockItemsForRead(true); |
3475 | { | ||
3476 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3540 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3477 | && !m_automaticLinkPermission) | 3541 | && !m_automaticLinkPermission) |
3478 | { | 3542 | { |
3479 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3543 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3544 | m_host.TaskInventory.LockItemsForRead(false); | ||
3480 | return; | 3545 | return; |
3481 | } | 3546 | } |
3482 | } | 3547 | m_host.TaskInventory.LockItemsForRead(false); |
3483 | 3548 | ||
3484 | if (linknum < ScriptBaseClass.LINK_THIS) | 3549 | if (linknum < ScriptBaseClass.LINK_THIS) |
3485 | return; | 3550 | return; |
3486 | 3551 | ||
@@ -3657,17 +3722,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3657 | m_host.AddScriptLPS(1); | 3722 | m_host.AddScriptLPS(1); |
3658 | int count = 0; | 3723 | int count = 0; |
3659 | 3724 | ||
3660 | lock (m_host.TaskInventory) | 3725 | m_host.TaskInventory.LockItemsForRead(true); |
3726 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3661 | { | 3727 | { |
3662 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3728 | if (inv.Value.Type == type || type == -1) |
3663 | { | 3729 | { |
3664 | if (inv.Value.Type == type || type == -1) | 3730 | count = count + 1; |
3665 | { | ||
3666 | count = count + 1; | ||
3667 | } | ||
3668 | } | 3731 | } |
3669 | } | 3732 | } |
3670 | 3733 | ||
3734 | m_host.TaskInventory.LockItemsForRead(false); | ||
3671 | return count; | 3735 | return count; |
3672 | } | 3736 | } |
3673 | 3737 | ||
@@ -3676,16 +3740,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3676 | m_host.AddScriptLPS(1); | 3740 | m_host.AddScriptLPS(1); |
3677 | ArrayList keys = new ArrayList(); | 3741 | ArrayList keys = new ArrayList(); |
3678 | 3742 | ||
3679 | lock (m_host.TaskInventory) | 3743 | m_host.TaskInventory.LockItemsForRead(true); |
3744 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3680 | { | 3745 | { |
3681 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3746 | if (inv.Value.Type == type || type == -1) |
3682 | { | 3747 | { |
3683 | if (inv.Value.Type == type || type == -1) | 3748 | keys.Add(inv.Value.Name); |
3684 | { | ||
3685 | keys.Add(inv.Value.Name); | ||
3686 | } | ||
3687 | } | 3749 | } |
3688 | } | 3750 | } |
3751 | m_host.TaskInventory.LockItemsForRead(false); | ||
3689 | 3752 | ||
3690 | if (keys.Count == 0) | 3753 | if (keys.Count == 0) |
3691 | { | 3754 | { |
@@ -3722,20 +3785,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3722 | } | 3785 | } |
3723 | 3786 | ||
3724 | // move the first object found with this inventory name | 3787 | // move the first object found with this inventory name |
3725 | lock (m_host.TaskInventory) | 3788 | m_host.TaskInventory.LockItemsForRead(true); |
3789 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3726 | { | 3790 | { |
3727 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3791 | if (inv.Value.Name == inventory) |
3728 | { | 3792 | { |
3729 | if (inv.Value.Name == inventory) | 3793 | found = true; |
3730 | { | 3794 | objId = inv.Key; |
3731 | found = true; | 3795 | assetType = inv.Value.Type; |
3732 | objId = inv.Key; | 3796 | objName = inv.Value.Name; |
3733 | assetType = inv.Value.Type; | 3797 | break; |
3734 | objName = inv.Value.Name; | ||
3735 | break; | ||
3736 | } | ||
3737 | } | 3798 | } |
3738 | } | 3799 | } |
3800 | m_host.TaskInventory.LockItemsForRead(false); | ||
3739 | 3801 | ||
3740 | if (!found) | 3802 | if (!found) |
3741 | { | 3803 | { |
@@ -3780,24 +3842,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3780 | ScriptSleep(3000); | 3842 | ScriptSleep(3000); |
3781 | } | 3843 | } |
3782 | 3844 | ||
3845 | [DebuggerNonUserCode] | ||
3783 | public void llRemoveInventory(string name) | 3846 | public void llRemoveInventory(string name) |
3784 | { | 3847 | { |
3785 | m_host.AddScriptLPS(1); | 3848 | m_host.AddScriptLPS(1); |
3786 | 3849 | ||
3787 | lock (m_host.TaskInventory) | 3850 | m_host.TaskInventory.LockItemsForRead(true); |
3851 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3788 | { | 3852 | { |
3789 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3853 | if (item.Name == name) |
3790 | { | 3854 | { |
3791 | if (item.Name == name) | 3855 | if (item.ItemID == m_itemID) |
3792 | { | 3856 | throw new ScriptDeleteException(); |
3793 | if (item.ItemID == m_itemID) | 3857 | else |
3794 | throw new ScriptDeleteException(); | 3858 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3795 | else | 3859 | |
3796 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3860 | m_host.TaskInventory.LockItemsForRead(false); |
3797 | return; | 3861 | return; |
3798 | } | ||
3799 | } | 3862 | } |
3800 | } | 3863 | } |
3864 | m_host.TaskInventory.LockItemsForRead(false); | ||
3801 | } | 3865 | } |
3802 | 3866 | ||
3803 | public void llSetText(string text, LSL_Vector color, double alpha) | 3867 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3886,6 +3950,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3886 | { | 3950 | { |
3887 | m_host.AddScriptLPS(1); | 3951 | m_host.AddScriptLPS(1); |
3888 | 3952 | ||
3953 | //Clone is thread safe | ||
3889 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3954 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3890 | 3955 | ||
3891 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3956 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3976,17 +4041,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3976 | UUID soundId = UUID.Zero; | 4041 | UUID soundId = UUID.Zero; |
3977 | if (!UUID.TryParse(impact_sound, out soundId)) | 4042 | if (!UUID.TryParse(impact_sound, out soundId)) |
3978 | { | 4043 | { |
3979 | lock (m_host.TaskInventory) | 4044 | m_host.TaskInventory.LockItemsForRead(true); |
4045 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3980 | { | 4046 | { |
3981 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4047 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3982 | { | 4048 | { |
3983 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4049 | soundId = item.AssetID; |
3984 | { | 4050 | break; |
3985 | soundId = item.AssetID; | ||
3986 | break; | ||
3987 | } | ||
3988 | } | 4051 | } |
3989 | } | 4052 | } |
4053 | m_host.TaskInventory.LockItemsForRead(false); | ||
3990 | } | 4054 | } |
3991 | m_host.CollisionSound = soundId; | 4055 | m_host.CollisionSound = soundId; |
3992 | m_host.CollisionSoundVolume = (float)impact_volume; | 4056 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4032,6 +4096,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4032 | UUID partItemID; | 4096 | UUID partItemID; |
4033 | foreach (SceneObjectPart part in parts) | 4097 | foreach (SceneObjectPart part in parts) |
4034 | { | 4098 | { |
4099 | //Clone is thread safe | ||
4035 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4100 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4036 | 4101 | ||
4037 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4102 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4239,17 +4304,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4239 | 4304 | ||
4240 | m_host.AddScriptLPS(1); | 4305 | m_host.AddScriptLPS(1); |
4241 | 4306 | ||
4242 | lock (m_host.TaskInventory) | 4307 | m_host.TaskInventory.LockItemsForRead(true); |
4308 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4243 | { | 4309 | { |
4244 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4310 | if (item.Type == 10 && item.ItemID == m_itemID) |
4245 | { | 4311 | { |
4246 | if (item.Type == 10 && item.ItemID == m_itemID) | 4312 | result = item.Name!=null?item.Name:String.Empty; |
4247 | { | 4313 | break; |
4248 | result = item.Name!=null?item.Name:String.Empty; | ||
4249 | break; | ||
4250 | } | ||
4251 | } | 4314 | } |
4252 | } | 4315 | } |
4316 | m_host.TaskInventory.LockItemsForRead(false); | ||
4253 | 4317 | ||
4254 | return result; | 4318 | return result; |
4255 | } | 4319 | } |
@@ -4507,23 +4571,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4507 | { | 4571 | { |
4508 | m_host.AddScriptLPS(1); | 4572 | m_host.AddScriptLPS(1); |
4509 | 4573 | ||
4510 | lock (m_host.TaskInventory) | 4574 | m_host.TaskInventory.LockItemsForRead(true); |
4575 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4511 | { | 4576 | { |
4512 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4577 | if (inv.Value.Name == name) |
4513 | { | 4578 | { |
4514 | if (inv.Value.Name == name) | 4579 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4515 | { | 4580 | { |
4516 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4581 | m_host.TaskInventory.LockItemsForRead(false); |
4517 | { | 4582 | return inv.Value.AssetID.ToString(); |
4518 | return inv.Value.AssetID.ToString(); | 4583 | } |
4519 | } | 4584 | else |
4520 | else | 4585 | { |
4521 | { | 4586 | m_host.TaskInventory.LockItemsForRead(false); |
4522 | return UUID.Zero.ToString(); | 4587 | return UUID.Zero.ToString(); |
4523 | } | ||
4524 | } | 4588 | } |
4525 | } | 4589 | } |
4526 | } | 4590 | } |
4591 | m_host.TaskInventory.LockItemsForRead(false); | ||
4527 | 4592 | ||
4528 | return UUID.Zero.ToString(); | 4593 | return UUID.Zero.ToString(); |
4529 | } | 4594 | } |
@@ -6019,14 +6084,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6019 | 6084 | ||
6020 | protected UUID GetTaskInventoryItem(string name) | 6085 | protected UUID GetTaskInventoryItem(string name) |
6021 | { | 6086 | { |
6022 | lock (m_host.TaskInventory) | 6087 | m_host.TaskInventory.LockItemsForRead(true); |
6088 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6023 | { | 6089 | { |
6024 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6090 | if (inv.Value.Name == name) |
6025 | { | 6091 | { |
6026 | if (inv.Value.Name == name) | 6092 | m_host.TaskInventory.LockItemsForRead(false); |
6027 | return inv.Key; | 6093 | return inv.Key; |
6028 | } | 6094 | } |
6029 | } | 6095 | } |
6096 | m_host.TaskInventory.LockItemsForRead(false); | ||
6030 | 6097 | ||
6031 | return UUID.Zero; | 6098 | return UUID.Zero; |
6032 | } | 6099 | } |
@@ -6337,22 +6404,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6337 | } | 6404 | } |
6338 | 6405 | ||
6339 | // copy the first script found with this inventory name | 6406 | // copy the first script found with this inventory name |
6340 | lock (m_host.TaskInventory) | 6407 | m_host.TaskInventory.LockItemsForRead(true); |
6408 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6341 | { | 6409 | { |
6342 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6410 | if (inv.Value.Name == name) |
6343 | { | 6411 | { |
6344 | if (inv.Value.Name == name) | 6412 | // make sure the object is a script |
6413 | if (10 == inv.Value.Type) | ||
6345 | { | 6414 | { |
6346 | // make sure the object is a script | 6415 | found = true; |
6347 | if (10 == inv.Value.Type) | 6416 | srcId = inv.Key; |
6348 | { | 6417 | break; |
6349 | found = true; | ||
6350 | srcId = inv.Key; | ||
6351 | break; | ||
6352 | } | ||
6353 | } | 6418 | } |
6354 | } | 6419 | } |
6355 | } | 6420 | } |
6421 | m_host.TaskInventory.LockItemsForRead(false); | ||
6356 | 6422 | ||
6357 | if (!found) | 6423 | if (!found) |
6358 | { | 6424 | { |
@@ -8155,28 +8221,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8155 | { | 8221 | { |
8156 | m_host.AddScriptLPS(1); | 8222 | m_host.AddScriptLPS(1); |
8157 | 8223 | ||
8158 | lock (m_host.TaskInventory) | 8224 | m_host.TaskInventory.LockItemsForRead(true); |
8225 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8159 | { | 8226 | { |
8160 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8227 | if (inv.Value.Name == item) |
8161 | { | 8228 | { |
8162 | if (inv.Value.Name == item) | 8229 | m_host.TaskInventory.LockItemsForRead(false); |
8230 | switch (mask) | ||
8163 | { | 8231 | { |
8164 | switch (mask) | 8232 | case 0: |
8165 | { | 8233 | return (int)inv.Value.BasePermissions; |
8166 | case 0: | 8234 | case 1: |
8167 | return (int)inv.Value.BasePermissions; | 8235 | return (int)inv.Value.CurrentPermissions; |
8168 | case 1: | 8236 | case 2: |
8169 | return (int)inv.Value.CurrentPermissions; | 8237 | return (int)inv.Value.GroupPermissions; |
8170 | case 2: | 8238 | case 3: |
8171 | return (int)inv.Value.GroupPermissions; | 8239 | return (int)inv.Value.EveryonePermissions; |
8172 | case 3: | 8240 | case 4: |
8173 | return (int)inv.Value.EveryonePermissions; | 8241 | return (int)inv.Value.NextPermissions; |
8174 | case 4: | ||
8175 | return (int)inv.Value.NextPermissions; | ||
8176 | } | ||
8177 | } | 8242 | } |
8178 | } | 8243 | } |
8179 | } | 8244 | } |
8245 | m_host.TaskInventory.LockItemsForRead(false); | ||
8180 | 8246 | ||
8181 | return -1; | 8247 | return -1; |
8182 | } | 8248 | } |
@@ -8191,16 +8257,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8191 | { | 8257 | { |
8192 | m_host.AddScriptLPS(1); | 8258 | m_host.AddScriptLPS(1); |
8193 | 8259 | ||
8194 | lock (m_host.TaskInventory) | 8260 | m_host.TaskInventory.LockItemsForRead(true); |
8261 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8195 | { | 8262 | { |
8196 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8263 | if (inv.Value.Name == item) |
8197 | { | 8264 | { |
8198 | if (inv.Value.Name == item) | 8265 | m_host.TaskInventory.LockItemsForRead(false); |
8199 | { | 8266 | return inv.Value.CreatorID.ToString(); |
8200 | return inv.Value.CreatorID.ToString(); | ||
8201 | } | ||
8202 | } | 8267 | } |
8203 | } | 8268 | } |
8269 | m_host.TaskInventory.LockItemsForRead(false); | ||
8204 | 8270 | ||
8205 | llSay(0, "No item name '" + item + "'"); | 8271 | llSay(0, "No item name '" + item + "'"); |
8206 | 8272 | ||
@@ -8724,16 +8790,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8724 | { | 8790 | { |
8725 | m_host.AddScriptLPS(1); | 8791 | m_host.AddScriptLPS(1); |
8726 | 8792 | ||
8727 | lock (m_host.TaskInventory) | 8793 | m_host.TaskInventory.LockItemsForRead(true); |
8794 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8728 | { | 8795 | { |
8729 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8796 | if (inv.Value.Name == name) |
8730 | { | 8797 | { |
8731 | if (inv.Value.Name == name) | 8798 | m_host.TaskInventory.LockItemsForRead(false); |
8732 | { | 8799 | return inv.Value.Type; |
8733 | return inv.Value.Type; | ||
8734 | } | ||
8735 | } | 8800 | } |
8736 | } | 8801 | } |
8802 | m_host.TaskInventory.LockItemsForRead(false); | ||
8737 | 8803 | ||
8738 | return -1; | 8804 | return -1; |
8739 | } | 8805 | } |
@@ -8764,17 +8830,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8764 | if (invItemID == UUID.Zero) | 8830 | if (invItemID == UUID.Zero) |
8765 | return new LSL_Vector(); | 8831 | return new LSL_Vector(); |
8766 | 8832 | ||
8767 | lock (m_host.TaskInventory) | 8833 | m_host.TaskInventory.LockItemsForRead(true); |
8834 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8768 | { | 8835 | { |
8769 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8836 | m_host.TaskInventory.LockItemsForRead(false); |
8770 | return new LSL_Vector(); | 8837 | return new LSL_Vector(); |
8838 | } | ||
8771 | 8839 | ||
8772 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8840 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8773 | { | 8841 | { |
8774 | ShoutError("No permissions to track the camera"); | 8842 | ShoutError("No permissions to track the camera"); |
8775 | return new LSL_Vector(); | 8843 | m_host.TaskInventory.LockItemsForRead(false); |
8776 | } | 8844 | return new LSL_Vector(); |
8777 | } | 8845 | } |
8846 | m_host.TaskInventory.LockItemsForRead(false); | ||
8778 | 8847 | ||
8779 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8848 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8780 | if (presence != null) | 8849 | if (presence != null) |
@@ -8792,17 +8861,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8792 | if (invItemID == UUID.Zero) | 8861 | if (invItemID == UUID.Zero) |
8793 | return new LSL_Rotation(); | 8862 | return new LSL_Rotation(); |
8794 | 8863 | ||
8795 | lock (m_host.TaskInventory) | 8864 | m_host.TaskInventory.LockItemsForRead(true); |
8865 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8796 | { | 8866 | { |
8797 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8867 | m_host.TaskInventory.LockItemsForRead(false); |
8798 | return new LSL_Rotation(); | 8868 | return new LSL_Rotation(); |
8799 | |||
8800 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8801 | { | ||
8802 | ShoutError("No permissions to track the camera"); | ||
8803 | return new LSL_Rotation(); | ||
8804 | } | ||
8805 | } | 8869 | } |
8870 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8871 | { | ||
8872 | ShoutError("No permissions to track the camera"); | ||
8873 | m_host.TaskInventory.LockItemsForRead(false); | ||
8874 | return new LSL_Rotation(); | ||
8875 | } | ||
8876 | m_host.TaskInventory.LockItemsForRead(false); | ||
8806 | 8877 | ||
8807 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8878 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8808 | if (presence != null) | 8879 | if (presence != null) |
@@ -8952,14 +9023,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8952 | if (objectID == UUID.Zero) return; | 9023 | if (objectID == UUID.Zero) return; |
8953 | 9024 | ||
8954 | UUID agentID; | 9025 | UUID agentID; |
8955 | lock (m_host.TaskInventory) | 9026 | m_host.TaskInventory.LockItemsForRead(true); |
8956 | { | 9027 | // we need the permission first, to know which avatar we want to set the camera for |
8957 | // we need the permission first, to know which avatar we want to set the camera for | 9028 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8958 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8959 | 9029 | ||
8960 | if (agentID == UUID.Zero) return; | 9030 | if (agentID == UUID.Zero) |
8961 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9031 | { |
9032 | m_host.TaskInventory.LockItemsForRead(false); | ||
9033 | return; | ||
8962 | } | 9034 | } |
9035 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9036 | { | ||
9037 | m_host.TaskInventory.LockItemsForRead(false); | ||
9038 | return; | ||
9039 | } | ||
9040 | m_host.TaskInventory.LockItemsForRead(false); | ||
8963 | 9041 | ||
8964 | ScenePresence presence = World.GetScenePresence(agentID); | 9042 | ScenePresence presence = World.GetScenePresence(agentID); |
8965 | 9043 | ||
@@ -9009,12 +9087,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9009 | 9087 | ||
9010 | // we need the permission first, to know which avatar we want to clear the camera for | 9088 | // we need the permission first, to know which avatar we want to clear the camera for |
9011 | UUID agentID; | 9089 | UUID agentID; |
9012 | lock (m_host.TaskInventory) | 9090 | m_host.TaskInventory.LockItemsForRead(true); |
9091 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9092 | if (agentID == UUID.Zero) | ||
9093 | { | ||
9094 | m_host.TaskInventory.LockItemsForRead(false); | ||
9095 | return; | ||
9096 | } | ||
9097 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9013 | { | 9098 | { |
9014 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9099 | m_host.TaskInventory.LockItemsForRead(false); |
9015 | if (agentID == UUID.Zero) return; | 9100 | return; |
9016 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9017 | } | 9101 | } |
9102 | m_host.TaskInventory.LockItemsForRead(false); | ||
9018 | 9103 | ||
9019 | ScenePresence presence = World.GetScenePresence(agentID); | 9104 | ScenePresence presence = World.GetScenePresence(agentID); |
9020 | 9105 | ||
@@ -9471,15 +9556,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9471 | 9556 | ||
9472 | internal UUID ScriptByName(string name) | 9557 | internal UUID ScriptByName(string name) |
9473 | { | 9558 | { |
9474 | lock (m_host.TaskInventory) | 9559 | m_host.TaskInventory.LockItemsForRead(true); |
9560 | |||
9561 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9475 | { | 9562 | { |
9476 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9563 | if (item.Type == 10 && item.Name == name) |
9477 | { | 9564 | { |
9478 | if (item.Type == 10 && item.Name == name) | 9565 | m_host.TaskInventory.LockItemsForRead(false); |
9479 | return item.ItemID; | 9566 | return item.ItemID; |
9480 | } | 9567 | } |
9481 | } | 9568 | } |
9482 | 9569 | ||
9570 | m_host.TaskInventory.LockItemsForRead(false); | ||
9571 | |||
9483 | return UUID.Zero; | 9572 | return UUID.Zero; |
9484 | } | 9573 | } |
9485 | 9574 | ||
@@ -9520,6 +9609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9520 | { | 9609 | { |
9521 | m_host.AddScriptLPS(1); | 9610 | m_host.AddScriptLPS(1); |
9522 | 9611 | ||
9612 | //Clone is thread safe | ||
9523 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9613 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9524 | 9614 | ||
9525 | UUID assetID = UUID.Zero; | 9615 | UUID assetID = UUID.Zero; |
@@ -9582,6 +9672,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9582 | { | 9672 | { |
9583 | m_host.AddScriptLPS(1); | 9673 | m_host.AddScriptLPS(1); |
9584 | 9674 | ||
9675 | //Clone is thread safe | ||
9585 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9676 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9586 | 9677 | ||
9587 | UUID assetID = UUID.Zero; | 9678 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 5501679..7f739b1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | if (target != null) | 728 | if (target != null) |
729 | { | 729 | { |
730 | UUID animID=UUID.Zero; | 730 | UUID animID=UUID.Zero; |
731 | lock (m_host.TaskInventory) | 731 | m_host.TaskInventory.LockItemsForRead(true); |
732 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
732 | { | 733 | { |
733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 734 | if (inv.Value.Name == animation) |
734 | { | 735 | { |
735 | if (inv.Value.Name == animation) | 736 | if (inv.Value.Type == (int)AssetType.Animation) |
736 | { | 737 | animID = inv.Value.AssetID; |
737 | if (inv.Value.Type == (int)AssetType.Animation) | 738 | continue; |
738 | animID = inv.Value.AssetID; | ||
739 | continue; | ||
740 | } | ||
741 | } | 739 | } |
742 | } | 740 | } |
741 | m_host.TaskInventory.LockItemsForRead(false); | ||
743 | if (animID == UUID.Zero) | 742 | if (animID == UUID.Zero) |
744 | target.Animator.AddAnimation(animation, m_host.UUID); | 743 | target.Animator.AddAnimation(animation, m_host.UUID); |
745 | else | 744 | else |
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
761 | if (target != null) | 760 | if (target != null) |
762 | { | 761 | { |
763 | UUID animID=UUID.Zero; | 762 | UUID animID=UUID.Zero; |
764 | lock (m_host.TaskInventory) | 763 | m_host.TaskInventory.LockItemsForRead(true); |
764 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
765 | { | 765 | { |
766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 766 | if (inv.Value.Name == animation) |
767 | { | 767 | { |
768 | if (inv.Value.Name == animation) | 768 | if (inv.Value.Type == (int)AssetType.Animation) |
769 | { | 769 | animID = inv.Value.AssetID; |
770 | if (inv.Value.Type == (int)AssetType.Animation) | 770 | continue; |
771 | animID = inv.Value.AssetID; | ||
772 | continue; | ||
773 | } | ||
774 | } | 771 | } |
775 | } | 772 | } |
773 | m_host.TaskInventory.LockItemsForRead(false); | ||
776 | 774 | ||
777 | if (animID == UUID.Zero) | 775 | if (animID == UUID.Zero) |
778 | target.Animator.RemoveAnimation(animation); | 776 | target.Animator.RemoveAnimation(animation); |
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1541 | 1539 | ||
1542 | if (!UUID.TryParse(name, out assetID)) | 1540 | if (!UUID.TryParse(name, out assetID)) |
1543 | { | 1541 | { |
1542 | m_host.TaskInventory.LockItemsForRead(true); | ||
1544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1543 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1545 | { | 1544 | { |
1546 | if (item.Type == 7 && item.Name == name) | 1545 | if (item.Type == 7 && item.Name == name) |
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1548 | assetID = item.AssetID; | 1547 | assetID = item.AssetID; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1550 | m_host.TaskInventory.LockItemsForRead(false); | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if (assetID == UUID.Zero) | 1553 | if (assetID == UUID.Zero) |
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1594 | 1594 | ||
1595 | if (!UUID.TryParse(name, out assetID)) | 1595 | if (!UUID.TryParse(name, out assetID)) |
1596 | { | 1596 | { |
1597 | m_host.TaskInventory.LockItemsForRead(true); | ||
1597 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1598 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1598 | { | 1599 | { |
1599 | if (item.Type == 7 && item.Name == name) | 1600 | if (item.Type == 7 && item.Name == name) |
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1601 | assetID = item.AssetID; | 1602 | assetID = item.AssetID; |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1605 | m_host.TaskInventory.LockItemsForRead(false); | ||
1604 | } | 1606 | } |
1605 | 1607 | ||
1606 | if (assetID == UUID.Zero) | 1608 | if (assetID == UUID.Zero) |
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1651 | 1653 | ||
1652 | if (!UUID.TryParse(name, out assetID)) | 1654 | if (!UUID.TryParse(name, out assetID)) |
1653 | { | 1655 | { |
1656 | m_host.TaskInventory.LockItemsForRead(true); | ||
1654 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1657 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1655 | { | 1658 | { |
1656 | if (item.Type == 7 && item.Name == name) | 1659 | if (item.Type == 7 && item.Name == name) |
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1658 | assetID = item.AssetID; | 1661 | assetID = item.AssetID; |
1659 | } | 1662 | } |
1660 | } | 1663 | } |
1664 | m_host.TaskInventory.LockItemsForRead(false); | ||
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | if (assetID == UUID.Zero) | 1667 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 7f67599..15e0408 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
131 | return (eventFlags); | 132 | return (eventFlags); |
132 | } | 133 | } |
133 | 134 | ||
135 | [DebuggerNonUserCode] | ||
134 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 136 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
135 | { | 137 | { |
136 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 138 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 121159c..a44abb0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |