diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
4 files changed, 342 insertions, 252 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f5cda2c..b387728 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 | ||
@@ -2546,12 +2561,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2546 | 2561 | ||
2547 | m_host.AddScriptLPS(1); | 2562 | m_host.AddScriptLPS(1); |
2548 | 2563 | ||
2564 | m_host.TaskInventory.LockItemsForRead(true); | ||
2549 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2565 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2550 | 2566 | m_host.TaskInventory.LockItemsForRead(false); | |
2551 | lock (m_host.TaskInventory) | ||
2552 | { | ||
2553 | item = m_host.TaskInventory[invItemID]; | ||
2554 | } | ||
2555 | 2567 | ||
2556 | if (item.PermsGranter == UUID.Zero) | 2568 | if (item.PermsGranter == UUID.Zero) |
2557 | return 0; | 2569 | return 0; |
@@ -2626,6 +2638,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2626 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2638 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2627 | return; | 2639 | return; |
2628 | 2640 | ||
2641 | //Clone is thread-safe | ||
2629 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2642 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2630 | 2643 | ||
2631 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2644 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2711,11 +2724,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2711 | // Orient the object to the angle calculated | 2724 | // Orient the object to the angle calculated |
2712 | llSetRot(rot); | 2725 | llSetRot(rot); |
2713 | } | 2726 | } |
2727 | |||
2728 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2729 | { | ||
2730 | m_host.AddScriptLPS(1); | ||
2731 | // NotImplemented("llRotLookAt"); | ||
2732 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2733 | |||
2734 | } | ||
2735 | |||
2714 | 2736 | ||
2715 | public void llStopLookAt() | 2737 | public void llStopLookAt() |
2716 | { | 2738 | { |
2717 | m_host.AddScriptLPS(1); | 2739 | m_host.AddScriptLPS(1); |
2718 | NotImplemented("llStopLookAt"); | 2740 | // NotImplemented("llStopLookAt"); |
2741 | m_host.StopLookAt(); | ||
2719 | } | 2742 | } |
2720 | 2743 | ||
2721 | public void llSetTimerEvent(double sec) | 2744 | public void llSetTimerEvent(double sec) |
@@ -2749,13 +2772,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2749 | { | 2772 | { |
2750 | TaskInventoryItem item; | 2773 | TaskInventoryItem item; |
2751 | 2774 | ||
2752 | lock (m_host.TaskInventory) | 2775 | m_host.TaskInventory.LockItemsForRead(true); |
2776 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2753 | { | 2777 | { |
2754 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2778 | m_host.TaskInventory.LockItemsForRead(false); |
2755 | return; | 2779 | return; |
2756 | else | 2780 | } |
2757 | item = m_host.TaskInventory[InventorySelf()]; | 2781 | else |
2782 | { | ||
2783 | item = m_host.TaskInventory[InventorySelf()]; | ||
2758 | } | 2784 | } |
2785 | m_host.TaskInventory.LockItemsForRead(false); | ||
2759 | 2786 | ||
2760 | if (item.PermsGranter != UUID.Zero) | 2787 | if (item.PermsGranter != UUID.Zero) |
2761 | { | 2788 | { |
@@ -2777,13 +2804,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2777 | { | 2804 | { |
2778 | TaskInventoryItem item; | 2805 | TaskInventoryItem item; |
2779 | 2806 | ||
2807 | m_host.TaskInventory.LockItemsForRead(true); | ||
2780 | lock (m_host.TaskInventory) | 2808 | lock (m_host.TaskInventory) |
2781 | { | 2809 | { |
2810 | |||
2782 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2811 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2812 | { | ||
2813 | m_host.TaskInventory.LockItemsForRead(false); | ||
2783 | return; | 2814 | return; |
2815 | } | ||
2784 | else | 2816 | else |
2817 | { | ||
2785 | item = m_host.TaskInventory[InventorySelf()]; | 2818 | item = m_host.TaskInventory[InventorySelf()]; |
2819 | } | ||
2786 | } | 2820 | } |
2821 | m_host.TaskInventory.LockItemsForRead(false); | ||
2787 | 2822 | ||
2788 | m_host.AddScriptLPS(1); | 2823 | m_host.AddScriptLPS(1); |
2789 | 2824 | ||
@@ -2820,13 +2855,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2820 | 2855 | ||
2821 | TaskInventoryItem item; | 2856 | TaskInventoryItem item; |
2822 | 2857 | ||
2823 | lock (m_host.TaskInventory) | 2858 | m_host.TaskInventory.LockItemsForRead(true); |
2859 | |||
2860 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2824 | { | 2861 | { |
2825 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2862 | m_host.TaskInventory.LockItemsForRead(false); |
2826 | return; | 2863 | return; |
2827 | else | ||
2828 | item = m_host.TaskInventory[InventorySelf()]; | ||
2829 | } | 2864 | } |
2865 | else | ||
2866 | { | ||
2867 | item = m_host.TaskInventory[InventorySelf()]; | ||
2868 | } | ||
2869 | |||
2870 | m_host.TaskInventory.LockItemsForRead(false); | ||
2830 | 2871 | ||
2831 | if (item.PermsGranter != m_host.OwnerID) | 2872 | if (item.PermsGranter != m_host.OwnerID) |
2832 | return; | 2873 | return; |
@@ -2852,13 +2893,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2852 | 2893 | ||
2853 | TaskInventoryItem item; | 2894 | TaskInventoryItem item; |
2854 | 2895 | ||
2855 | lock (m_host.TaskInventory) | 2896 | m_host.TaskInventory.LockItemsForRead(true); |
2897 | |||
2898 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2856 | { | 2899 | { |
2857 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2900 | m_host.TaskInventory.LockItemsForRead(false); |
2858 | return; | 2901 | return; |
2859 | else | ||
2860 | item = m_host.TaskInventory[InventorySelf()]; | ||
2861 | } | 2902 | } |
2903 | else | ||
2904 | { | ||
2905 | item = m_host.TaskInventory[InventorySelf()]; | ||
2906 | } | ||
2907 | m_host.TaskInventory.LockItemsForRead(false); | ||
2908 | |||
2862 | 2909 | ||
2863 | if (item.PermsGranter != m_host.OwnerID) | 2910 | if (item.PermsGranter != m_host.OwnerID) |
2864 | return; | 2911 | return; |
@@ -3059,12 +3106,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3059 | m_host.AddScriptLPS(1); | 3106 | m_host.AddScriptLPS(1); |
3060 | } | 3107 | } |
3061 | 3108 | ||
3062 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3063 | { | ||
3064 | m_host.AddScriptLPS(1); | ||
3065 | NotImplemented("llRotLookAt"); | ||
3066 | } | ||
3067 | |||
3068 | public LSL_Integer llStringLength(string str) | 3109 | public LSL_Integer llStringLength(string str) |
3069 | { | 3110 | { |
3070 | m_host.AddScriptLPS(1); | 3111 | m_host.AddScriptLPS(1); |
@@ -3088,14 +3129,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3088 | 3129 | ||
3089 | TaskInventoryItem item; | 3130 | TaskInventoryItem item; |
3090 | 3131 | ||
3091 | lock (m_host.TaskInventory) | 3132 | m_host.TaskInventory.LockItemsForRead(true); |
3133 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3092 | { | 3134 | { |
3093 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3135 | m_host.TaskInventory.LockItemsForRead(false); |
3094 | return; | 3136 | return; |
3095 | else | ||
3096 | item = m_host.TaskInventory[InventorySelf()]; | ||
3097 | } | 3137 | } |
3098 | 3138 | else | |
3139 | { | ||
3140 | item = m_host.TaskInventory[InventorySelf()]; | ||
3141 | } | ||
3142 | m_host.TaskInventory.LockItemsForRead(false); | ||
3099 | if (item.PermsGranter == UUID.Zero) | 3143 | if (item.PermsGranter == UUID.Zero) |
3100 | return; | 3144 | return; |
3101 | 3145 | ||
@@ -3125,13 +3169,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3125 | 3169 | ||
3126 | TaskInventoryItem item; | 3170 | TaskInventoryItem item; |
3127 | 3171 | ||
3128 | lock (m_host.TaskInventory) | 3172 | m_host.TaskInventory.LockItemsForRead(true); |
3173 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3129 | { | 3174 | { |
3130 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3175 | m_host.TaskInventory.LockItemsForRead(false); |
3131 | return; | 3176 | return; |
3132 | else | 3177 | } |
3133 | item = m_host.TaskInventory[InventorySelf()]; | 3178 | else |
3179 | { | ||
3180 | item = m_host.TaskInventory[InventorySelf()]; | ||
3134 | } | 3181 | } |
3182 | m_host.TaskInventory.LockItemsForRead(false); | ||
3183 | |||
3135 | 3184 | ||
3136 | if (item.PermsGranter == UUID.Zero) | 3185 | if (item.PermsGranter == UUID.Zero) |
3137 | return; | 3186 | return; |
@@ -3204,10 +3253,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3204 | 3253 | ||
3205 | TaskInventoryItem item; | 3254 | TaskInventoryItem item; |
3206 | 3255 | ||
3207 | lock (m_host.TaskInventory) | 3256 | |
3257 | m_host.TaskInventory.LockItemsForRead(true); | ||
3258 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3259 | { | ||
3260 | m_host.TaskInventory.LockItemsForRead(false); | ||
3261 | return; | ||
3262 | } | ||
3263 | else | ||
3208 | { | 3264 | { |
3209 | item = m_host.TaskInventory[invItemID]; | 3265 | item = m_host.TaskInventory[invItemID]; |
3210 | } | 3266 | } |
3267 | m_host.TaskInventory.LockItemsForRead(false); | ||
3211 | 3268 | ||
3212 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3269 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3213 | { | 3270 | { |
@@ -3239,11 +3296,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3239 | 3296 | ||
3240 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3297 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3241 | { | 3298 | { |
3242 | lock (m_host.TaskInventory) | 3299 | m_host.TaskInventory.LockItemsForWrite(true); |
3243 | { | 3300 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3244 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3301 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3245 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3302 | m_host.TaskInventory.LockItemsForWrite(false); |
3246 | } | ||
3247 | 3303 | ||
3248 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3304 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3249 | "run_time_permissions", new Object[] { | 3305 | "run_time_permissions", new Object[] { |
@@ -3263,11 +3319,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3263 | 3319 | ||
3264 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3320 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3265 | { | 3321 | { |
3266 | lock (m_host.TaskInventory) | 3322 | m_host.TaskInventory.LockItemsForWrite(true); |
3267 | { | 3323 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3268 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3324 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3269 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3325 | m_host.TaskInventory.LockItemsForWrite(false); |
3270 | } | ||
3271 | 3326 | ||
3272 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3327 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3273 | "run_time_permissions", new Object[] { | 3328 | "run_time_permissions", new Object[] { |
@@ -3288,11 +3343,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3288 | 3343 | ||
3289 | if (!m_waitingForScriptAnswer) | 3344 | if (!m_waitingForScriptAnswer) |
3290 | { | 3345 | { |
3291 | lock (m_host.TaskInventory) | 3346 | m_host.TaskInventory.LockItemsForWrite(true); |
3292 | { | 3347 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3293 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3348 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3294 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3349 | m_host.TaskInventory.LockItemsForWrite(false); |
3295 | } | ||
3296 | 3350 | ||
3297 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3351 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3298 | m_waitingForScriptAnswer=true; | 3352 | m_waitingForScriptAnswer=true; |
@@ -3327,10 +3381,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3327 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3381 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3328 | llReleaseControls(); | 3382 | llReleaseControls(); |
3329 | 3383 | ||
3330 | lock (m_host.TaskInventory) | 3384 | |
3331 | { | 3385 | m_host.TaskInventory.LockItemsForWrite(true); |
3332 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3386 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3333 | } | 3387 | m_host.TaskInventory.LockItemsForWrite(false); |
3388 | |||
3334 | 3389 | ||
3335 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3390 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3336 | "run_time_permissions", new Object[] { | 3391 | "run_time_permissions", new Object[] { |
@@ -3342,16 +3397,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3342 | { | 3397 | { |
3343 | m_host.AddScriptLPS(1); | 3398 | m_host.AddScriptLPS(1); |
3344 | 3399 | ||
3345 | lock (m_host.TaskInventory) | 3400 | m_host.TaskInventory.LockItemsForRead(true); |
3401 | |||
3402 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3346 | { | 3403 | { |
3347 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3404 | if (item.Type == 10 && item.ItemID == m_itemID) |
3348 | { | 3405 | { |
3349 | if (item.Type == 10 && item.ItemID == m_itemID) | 3406 | m_host.TaskInventory.LockItemsForRead(false); |
3350 | { | 3407 | return item.PermsGranter.ToString(); |
3351 | return item.PermsGranter.ToString(); | ||
3352 | } | ||
3353 | } | 3408 | } |
3354 | } | 3409 | } |
3410 | m_host.TaskInventory.LockItemsForRead(false); | ||
3355 | 3411 | ||
3356 | return UUID.Zero.ToString(); | 3412 | return UUID.Zero.ToString(); |
3357 | } | 3413 | } |
@@ -3360,19 +3416,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3360 | { | 3416 | { |
3361 | m_host.AddScriptLPS(1); | 3417 | m_host.AddScriptLPS(1); |
3362 | 3418 | ||
3363 | lock (m_host.TaskInventory) | 3419 | m_host.TaskInventory.LockItemsForRead(true); |
3420 | |||
3421 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3364 | { | 3422 | { |
3365 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3423 | if (item.Type == 10 && item.ItemID == m_itemID) |
3366 | { | 3424 | { |
3367 | if (item.Type == 10 && item.ItemID == m_itemID) | 3425 | int perms = item.PermsMask; |
3368 | { | 3426 | if (m_automaticLinkPermission) |
3369 | int perms = item.PermsMask; | 3427 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3370 | if (m_automaticLinkPermission) | 3428 | m_host.TaskInventory.LockItemsForRead(false); |
3371 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3429 | return perms; |
3372 | return perms; | ||
3373 | } | ||
3374 | } | 3430 | } |
3375 | } | 3431 | } |
3432 | m_host.TaskInventory.LockItemsForRead(false); | ||
3376 | 3433 | ||
3377 | return 0; | 3434 | return 0; |
3378 | } | 3435 | } |
@@ -3405,11 +3462,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3405 | UUID invItemID = InventorySelf(); | 3462 | UUID invItemID = InventorySelf(); |
3406 | 3463 | ||
3407 | TaskInventoryItem item; | 3464 | TaskInventoryItem item; |
3408 | lock (m_host.TaskInventory) | 3465 | m_host.TaskInventory.LockItemsForRead(true); |
3409 | { | 3466 | item = m_host.TaskInventory[invItemID]; |
3410 | item = m_host.TaskInventory[invItemID]; | 3467 | m_host.TaskInventory.LockItemsForRead(false); |
3411 | } | 3468 | |
3412 | |||
3413 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3469 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3414 | && !m_automaticLinkPermission) | 3470 | && !m_automaticLinkPermission) |
3415 | { | 3471 | { |
@@ -3462,16 +3518,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3462 | m_host.AddScriptLPS(1); | 3518 | m_host.AddScriptLPS(1); |
3463 | UUID invItemID = InventorySelf(); | 3519 | UUID invItemID = InventorySelf(); |
3464 | 3520 | ||
3465 | lock (m_host.TaskInventory) | 3521 | m_host.TaskInventory.LockItemsForRead(true); |
3466 | { | ||
3467 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3522 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3468 | && !m_automaticLinkPermission) | 3523 | && !m_automaticLinkPermission) |
3469 | { | 3524 | { |
3470 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3525 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3526 | m_host.TaskInventory.LockItemsForRead(false); | ||
3471 | return; | 3527 | return; |
3472 | } | 3528 | } |
3473 | } | 3529 | m_host.TaskInventory.LockItemsForRead(false); |
3474 | 3530 | ||
3475 | if (linknum < ScriptBaseClass.LINK_THIS) | 3531 | if (linknum < ScriptBaseClass.LINK_THIS) |
3476 | return; | 3532 | return; |
3477 | 3533 | ||
@@ -3640,17 +3696,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3640 | m_host.AddScriptLPS(1); | 3696 | m_host.AddScriptLPS(1); |
3641 | int count = 0; | 3697 | int count = 0; |
3642 | 3698 | ||
3643 | lock (m_host.TaskInventory) | 3699 | m_host.TaskInventory.LockItemsForRead(true); |
3700 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3644 | { | 3701 | { |
3645 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3702 | if (inv.Value.Type == type || type == -1) |
3646 | { | 3703 | { |
3647 | if (inv.Value.Type == type || type == -1) | 3704 | count = count + 1; |
3648 | { | ||
3649 | count = count + 1; | ||
3650 | } | ||
3651 | } | 3705 | } |
3652 | } | 3706 | } |
3653 | 3707 | ||
3708 | m_host.TaskInventory.LockItemsForRead(false); | ||
3654 | return count; | 3709 | return count; |
3655 | } | 3710 | } |
3656 | 3711 | ||
@@ -3659,16 +3714,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3659 | m_host.AddScriptLPS(1); | 3714 | m_host.AddScriptLPS(1); |
3660 | ArrayList keys = new ArrayList(); | 3715 | ArrayList keys = new ArrayList(); |
3661 | 3716 | ||
3662 | lock (m_host.TaskInventory) | 3717 | m_host.TaskInventory.LockItemsForRead(true); |
3718 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3663 | { | 3719 | { |
3664 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3720 | if (inv.Value.Type == type || type == -1) |
3665 | { | 3721 | { |
3666 | if (inv.Value.Type == type || type == -1) | 3722 | keys.Add(inv.Value.Name); |
3667 | { | ||
3668 | keys.Add(inv.Value.Name); | ||
3669 | } | ||
3670 | } | 3723 | } |
3671 | } | 3724 | } |
3725 | m_host.TaskInventory.LockItemsForRead(false); | ||
3672 | 3726 | ||
3673 | if (keys.Count == 0) | 3727 | if (keys.Count == 0) |
3674 | { | 3728 | { |
@@ -3705,20 +3759,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3705 | } | 3759 | } |
3706 | 3760 | ||
3707 | // move the first object found with this inventory name | 3761 | // move the first object found with this inventory name |
3708 | lock (m_host.TaskInventory) | 3762 | m_host.TaskInventory.LockItemsForRead(true); |
3763 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3709 | { | 3764 | { |
3710 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3765 | if (inv.Value.Name == inventory) |
3711 | { | 3766 | { |
3712 | if (inv.Value.Name == inventory) | 3767 | found = true; |
3713 | { | 3768 | objId = inv.Key; |
3714 | found = true; | 3769 | assetType = inv.Value.Type; |
3715 | objId = inv.Key; | 3770 | objName = inv.Value.Name; |
3716 | assetType = inv.Value.Type; | 3771 | break; |
3717 | objName = inv.Value.Name; | ||
3718 | break; | ||
3719 | } | ||
3720 | } | 3772 | } |
3721 | } | 3773 | } |
3774 | m_host.TaskInventory.LockItemsForRead(false); | ||
3722 | 3775 | ||
3723 | if (!found) | 3776 | if (!found) |
3724 | { | 3777 | { |
@@ -3763,24 +3816,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3763 | ScriptSleep(3000); | 3816 | ScriptSleep(3000); |
3764 | } | 3817 | } |
3765 | 3818 | ||
3819 | [DebuggerNonUserCode] | ||
3766 | public void llRemoveInventory(string name) | 3820 | public void llRemoveInventory(string name) |
3767 | { | 3821 | { |
3768 | m_host.AddScriptLPS(1); | 3822 | m_host.AddScriptLPS(1); |
3769 | 3823 | ||
3770 | lock (m_host.TaskInventory) | 3824 | m_host.TaskInventory.LockItemsForRead(true); |
3825 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3771 | { | 3826 | { |
3772 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3827 | if (item.Name == name) |
3773 | { | 3828 | { |
3774 | if (item.Name == name) | 3829 | if (item.ItemID == m_itemID) |
3775 | { | 3830 | throw new ScriptDeleteException(); |
3776 | if (item.ItemID == m_itemID) | 3831 | else |
3777 | throw new ScriptDeleteException(); | 3832 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3778 | else | 3833 | |
3779 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3834 | m_host.TaskInventory.LockItemsForRead(false); |
3780 | return; | 3835 | return; |
3781 | } | ||
3782 | } | 3836 | } |
3783 | } | 3837 | } |
3838 | m_host.TaskInventory.LockItemsForRead(false); | ||
3784 | } | 3839 | } |
3785 | 3840 | ||
3786 | public void llSetText(string text, LSL_Vector color, double alpha) | 3841 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3869,6 +3924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3869 | { | 3924 | { |
3870 | m_host.AddScriptLPS(1); | 3925 | m_host.AddScriptLPS(1); |
3871 | 3926 | ||
3927 | //Clone is thread safe | ||
3872 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3928 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3873 | 3929 | ||
3874 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3930 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3959,17 +4015,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3959 | UUID soundId = UUID.Zero; | 4015 | UUID soundId = UUID.Zero; |
3960 | if (!UUID.TryParse(impact_sound, out soundId)) | 4016 | if (!UUID.TryParse(impact_sound, out soundId)) |
3961 | { | 4017 | { |
3962 | lock (m_host.TaskInventory) | 4018 | m_host.TaskInventory.LockItemsForRead(true); |
4019 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3963 | { | 4020 | { |
3964 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4021 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3965 | { | 4022 | { |
3966 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4023 | soundId = item.AssetID; |
3967 | { | 4024 | break; |
3968 | soundId = item.AssetID; | ||
3969 | break; | ||
3970 | } | ||
3971 | } | 4025 | } |
3972 | } | 4026 | } |
4027 | m_host.TaskInventory.LockItemsForRead(false); | ||
3973 | } | 4028 | } |
3974 | m_host.CollisionSound = soundId; | 4029 | m_host.CollisionSound = soundId; |
3975 | m_host.CollisionSoundVolume = (float)impact_volume; | 4030 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4015,6 +4070,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4015 | UUID partItemID; | 4070 | UUID partItemID; |
4016 | foreach (SceneObjectPart part in parts) | 4071 | foreach (SceneObjectPart part in parts) |
4017 | { | 4072 | { |
4073 | //Clone is thread safe | ||
4018 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4074 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4019 | 4075 | ||
4020 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4076 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4222,17 +4278,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4222 | 4278 | ||
4223 | m_host.AddScriptLPS(1); | 4279 | m_host.AddScriptLPS(1); |
4224 | 4280 | ||
4225 | lock (m_host.TaskInventory) | 4281 | m_host.TaskInventory.LockItemsForRead(true); |
4282 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4226 | { | 4283 | { |
4227 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4284 | if (item.Type == 10 && item.ItemID == m_itemID) |
4228 | { | 4285 | { |
4229 | if (item.Type == 10 && item.ItemID == m_itemID) | 4286 | result = item.Name!=null?item.Name:String.Empty; |
4230 | { | 4287 | break; |
4231 | result = item.Name!=null?item.Name:String.Empty; | ||
4232 | break; | ||
4233 | } | ||
4234 | } | 4288 | } |
4235 | } | 4289 | } |
4290 | m_host.TaskInventory.LockItemsForRead(false); | ||
4236 | 4291 | ||
4237 | return result; | 4292 | return result; |
4238 | } | 4293 | } |
@@ -4490,23 +4545,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4490 | { | 4545 | { |
4491 | m_host.AddScriptLPS(1); | 4546 | m_host.AddScriptLPS(1); |
4492 | 4547 | ||
4493 | lock (m_host.TaskInventory) | 4548 | m_host.TaskInventory.LockItemsForRead(true); |
4549 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4494 | { | 4550 | { |
4495 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4551 | if (inv.Value.Name == name) |
4496 | { | 4552 | { |
4497 | if (inv.Value.Name == name) | 4553 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4498 | { | 4554 | { |
4499 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4555 | m_host.TaskInventory.LockItemsForRead(false); |
4500 | { | 4556 | return inv.Value.AssetID.ToString(); |
4501 | return inv.Value.AssetID.ToString(); | 4557 | } |
4502 | } | 4558 | else |
4503 | else | 4559 | { |
4504 | { | 4560 | m_host.TaskInventory.LockItemsForRead(false); |
4505 | return UUID.Zero.ToString(); | 4561 | return UUID.Zero.ToString(); |
4506 | } | ||
4507 | } | 4562 | } |
4508 | } | 4563 | } |
4509 | } | 4564 | } |
4565 | m_host.TaskInventory.LockItemsForRead(false); | ||
4510 | 4566 | ||
4511 | return UUID.Zero.ToString(); | 4567 | return UUID.Zero.ToString(); |
4512 | } | 4568 | } |
@@ -6002,14 +6058,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6002 | 6058 | ||
6003 | protected UUID GetTaskInventoryItem(string name) | 6059 | protected UUID GetTaskInventoryItem(string name) |
6004 | { | 6060 | { |
6005 | lock (m_host.TaskInventory) | 6061 | m_host.TaskInventory.LockItemsForRead(true); |
6062 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6006 | { | 6063 | { |
6007 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6064 | if (inv.Value.Name == name) |
6008 | { | 6065 | { |
6009 | if (inv.Value.Name == name) | 6066 | m_host.TaskInventory.LockItemsForRead(false); |
6010 | return inv.Key; | 6067 | return inv.Key; |
6011 | } | 6068 | } |
6012 | } | 6069 | } |
6070 | m_host.TaskInventory.LockItemsForRead(false); | ||
6013 | 6071 | ||
6014 | return UUID.Zero; | 6072 | return UUID.Zero; |
6015 | } | 6073 | } |
@@ -6320,22 +6378,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6320 | } | 6378 | } |
6321 | 6379 | ||
6322 | // copy the first script found with this inventory name | 6380 | // copy the first script found with this inventory name |
6323 | lock (m_host.TaskInventory) | 6381 | m_host.TaskInventory.LockItemsForRead(true); |
6382 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6324 | { | 6383 | { |
6325 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6384 | if (inv.Value.Name == name) |
6326 | { | 6385 | { |
6327 | if (inv.Value.Name == name) | 6386 | // make sure the object is a script |
6387 | if (10 == inv.Value.Type) | ||
6328 | { | 6388 | { |
6329 | // make sure the object is a script | 6389 | found = true; |
6330 | if (10 == inv.Value.Type) | 6390 | srcId = inv.Key; |
6331 | { | 6391 | break; |
6332 | found = true; | ||
6333 | srcId = inv.Key; | ||
6334 | break; | ||
6335 | } | ||
6336 | } | 6392 | } |
6337 | } | 6393 | } |
6338 | } | 6394 | } |
6395 | m_host.TaskInventory.LockItemsForRead(false); | ||
6339 | 6396 | ||
6340 | if (!found) | 6397 | if (!found) |
6341 | { | 6398 | { |
@@ -8138,28 +8195,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8138 | { | 8195 | { |
8139 | m_host.AddScriptLPS(1); | 8196 | m_host.AddScriptLPS(1); |
8140 | 8197 | ||
8141 | lock (m_host.TaskInventory) | 8198 | m_host.TaskInventory.LockItemsForRead(true); |
8199 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8142 | { | 8200 | { |
8143 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8201 | if (inv.Value.Name == item) |
8144 | { | 8202 | { |
8145 | if (inv.Value.Name == item) | 8203 | m_host.TaskInventory.LockItemsForRead(false); |
8204 | switch (mask) | ||
8146 | { | 8205 | { |
8147 | switch (mask) | 8206 | case 0: |
8148 | { | 8207 | return (int)inv.Value.BasePermissions; |
8149 | case 0: | 8208 | case 1: |
8150 | return (int)inv.Value.BasePermissions; | 8209 | return (int)inv.Value.CurrentPermissions; |
8151 | case 1: | 8210 | case 2: |
8152 | return (int)inv.Value.CurrentPermissions; | 8211 | return (int)inv.Value.GroupPermissions; |
8153 | case 2: | 8212 | case 3: |
8154 | return (int)inv.Value.GroupPermissions; | 8213 | return (int)inv.Value.EveryonePermissions; |
8155 | case 3: | 8214 | case 4: |
8156 | return (int)inv.Value.EveryonePermissions; | 8215 | return (int)inv.Value.NextPermissions; |
8157 | case 4: | ||
8158 | return (int)inv.Value.NextPermissions; | ||
8159 | } | ||
8160 | } | 8216 | } |
8161 | } | 8217 | } |
8162 | } | 8218 | } |
8219 | m_host.TaskInventory.LockItemsForRead(false); | ||
8163 | 8220 | ||
8164 | return -1; | 8221 | return -1; |
8165 | } | 8222 | } |
@@ -8174,16 +8231,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8174 | { | 8231 | { |
8175 | m_host.AddScriptLPS(1); | 8232 | m_host.AddScriptLPS(1); |
8176 | 8233 | ||
8177 | lock (m_host.TaskInventory) | 8234 | m_host.TaskInventory.LockItemsForRead(true); |
8235 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8178 | { | 8236 | { |
8179 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8237 | if (inv.Value.Name == item) |
8180 | { | 8238 | { |
8181 | if (inv.Value.Name == item) | 8239 | m_host.TaskInventory.LockItemsForRead(false); |
8182 | { | 8240 | return inv.Value.CreatorID.ToString(); |
8183 | return inv.Value.CreatorID.ToString(); | ||
8184 | } | ||
8185 | } | 8241 | } |
8186 | } | 8242 | } |
8243 | m_host.TaskInventory.LockItemsForRead(false); | ||
8187 | 8244 | ||
8188 | llSay(0, "No item name '" + item + "'"); | 8245 | llSay(0, "No item name '" + item + "'"); |
8189 | 8246 | ||
@@ -8707,16 +8764,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8707 | { | 8764 | { |
8708 | m_host.AddScriptLPS(1); | 8765 | m_host.AddScriptLPS(1); |
8709 | 8766 | ||
8710 | lock (m_host.TaskInventory) | 8767 | m_host.TaskInventory.LockItemsForRead(true); |
8768 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8711 | { | 8769 | { |
8712 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8770 | if (inv.Value.Name == name) |
8713 | { | 8771 | { |
8714 | if (inv.Value.Name == name) | 8772 | m_host.TaskInventory.LockItemsForRead(false); |
8715 | { | 8773 | return inv.Value.Type; |
8716 | return inv.Value.Type; | ||
8717 | } | ||
8718 | } | 8774 | } |
8719 | } | 8775 | } |
8776 | m_host.TaskInventory.LockItemsForRead(false); | ||
8720 | 8777 | ||
8721 | return -1; | 8778 | return -1; |
8722 | } | 8779 | } |
@@ -8747,17 +8804,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8747 | if (invItemID == UUID.Zero) | 8804 | if (invItemID == UUID.Zero) |
8748 | return new LSL_Vector(); | 8805 | return new LSL_Vector(); |
8749 | 8806 | ||
8750 | lock (m_host.TaskInventory) | 8807 | m_host.TaskInventory.LockItemsForRead(true); |
8808 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8751 | { | 8809 | { |
8752 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8810 | m_host.TaskInventory.LockItemsForRead(false); |
8753 | return new LSL_Vector(); | 8811 | return new LSL_Vector(); |
8812 | } | ||
8754 | 8813 | ||
8755 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8814 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8756 | { | 8815 | { |
8757 | ShoutError("No permissions to track the camera"); | 8816 | ShoutError("No permissions to track the camera"); |
8758 | return new LSL_Vector(); | 8817 | m_host.TaskInventory.LockItemsForRead(false); |
8759 | } | 8818 | return new LSL_Vector(); |
8760 | } | 8819 | } |
8820 | m_host.TaskInventory.LockItemsForRead(false); | ||
8761 | 8821 | ||
8762 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8822 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8763 | if (presence != null) | 8823 | if (presence != null) |
@@ -8775,17 +8835,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8775 | if (invItemID == UUID.Zero) | 8835 | if (invItemID == UUID.Zero) |
8776 | return new LSL_Rotation(); | 8836 | return new LSL_Rotation(); |
8777 | 8837 | ||
8778 | lock (m_host.TaskInventory) | 8838 | m_host.TaskInventory.LockItemsForRead(true); |
8839 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8779 | { | 8840 | { |
8780 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8841 | m_host.TaskInventory.LockItemsForRead(false); |
8781 | return new LSL_Rotation(); | 8842 | return new LSL_Rotation(); |
8782 | |||
8783 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8784 | { | ||
8785 | ShoutError("No permissions to track the camera"); | ||
8786 | return new LSL_Rotation(); | ||
8787 | } | ||
8788 | } | 8843 | } |
8844 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8845 | { | ||
8846 | ShoutError("No permissions to track the camera"); | ||
8847 | m_host.TaskInventory.LockItemsForRead(false); | ||
8848 | return new LSL_Rotation(); | ||
8849 | } | ||
8850 | m_host.TaskInventory.LockItemsForRead(false); | ||
8789 | 8851 | ||
8790 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8852 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8791 | if (presence != null) | 8853 | if (presence != null) |
@@ -8935,14 +8997,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8935 | if (objectID == UUID.Zero) return; | 8997 | if (objectID == UUID.Zero) return; |
8936 | 8998 | ||
8937 | UUID agentID; | 8999 | UUID agentID; |
8938 | lock (m_host.TaskInventory) | 9000 | m_host.TaskInventory.LockItemsForRead(true); |
8939 | { | 9001 | // we need the permission first, to know which avatar we want to set the camera for |
8940 | // we need the permission first, to know which avatar we want to set the camera for | 9002 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8941 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8942 | 9003 | ||
8943 | if (agentID == UUID.Zero) return; | 9004 | if (agentID == UUID.Zero) |
8944 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9005 | { |
9006 | m_host.TaskInventory.LockItemsForRead(false); | ||
9007 | return; | ||
8945 | } | 9008 | } |
9009 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9010 | { | ||
9011 | m_host.TaskInventory.LockItemsForRead(false); | ||
9012 | return; | ||
9013 | } | ||
9014 | m_host.TaskInventory.LockItemsForRead(false); | ||
8946 | 9015 | ||
8947 | ScenePresence presence = World.GetScenePresence(agentID); | 9016 | ScenePresence presence = World.GetScenePresence(agentID); |
8948 | 9017 | ||
@@ -8992,12 +9061,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8992 | 9061 | ||
8993 | // we need the permission first, to know which avatar we want to clear the camera for | 9062 | // we need the permission first, to know which avatar we want to clear the camera for |
8994 | UUID agentID; | 9063 | UUID agentID; |
8995 | lock (m_host.TaskInventory) | 9064 | m_host.TaskInventory.LockItemsForRead(true); |
9065 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9066 | if (agentID == UUID.Zero) | ||
9067 | { | ||
9068 | m_host.TaskInventory.LockItemsForRead(false); | ||
9069 | return; | ||
9070 | } | ||
9071 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
8996 | { | 9072 | { |
8997 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9073 | m_host.TaskInventory.LockItemsForRead(false); |
8998 | if (agentID == UUID.Zero) return; | 9074 | return; |
8999 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9000 | } | 9075 | } |
9076 | m_host.TaskInventory.LockItemsForRead(false); | ||
9001 | 9077 | ||
9002 | ScenePresence presence = World.GetScenePresence(agentID); | 9078 | ScenePresence presence = World.GetScenePresence(agentID); |
9003 | 9079 | ||
@@ -9454,15 +9530,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9454 | 9530 | ||
9455 | internal UUID ScriptByName(string name) | 9531 | internal UUID ScriptByName(string name) |
9456 | { | 9532 | { |
9457 | lock (m_host.TaskInventory) | 9533 | m_host.TaskInventory.LockItemsForRead(true); |
9534 | |||
9535 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9458 | { | 9536 | { |
9459 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9537 | if (item.Type == 10 && item.Name == name) |
9460 | { | 9538 | { |
9461 | if (item.Type == 10 && item.Name == name) | 9539 | m_host.TaskInventory.LockItemsForRead(false); |
9462 | return item.ItemID; | 9540 | return item.ItemID; |
9463 | } | 9541 | } |
9464 | } | 9542 | } |
9465 | 9543 | ||
9544 | m_host.TaskInventory.LockItemsForRead(false); | ||
9545 | |||
9466 | return UUID.Zero; | 9546 | return UUID.Zero; |
9467 | } | 9547 | } |
9468 | 9548 | ||
@@ -9503,6 +9583,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9503 | { | 9583 | { |
9504 | m_host.AddScriptLPS(1); | 9584 | m_host.AddScriptLPS(1); |
9505 | 9585 | ||
9586 | //Clone is thread safe | ||
9506 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9587 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9507 | 9588 | ||
9508 | UUID assetID = UUID.Zero; | 9589 | UUID assetID = UUID.Zero; |
@@ -9565,6 +9646,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9565 | { | 9646 | { |
9566 | m_host.AddScriptLPS(1); | 9647 | m_host.AddScriptLPS(1); |
9567 | 9648 | ||
9649 | //Clone is thread safe | ||
9568 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9650 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9569 | 9651 | ||
9570 | UUID assetID = UUID.Zero; | 9652 | 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); |