diff options
Diffstat (limited to '')
6 files changed, 491 insertions, 380 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d235bac..267928b 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 | ||
@@ -3649,17 +3714,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3649 | m_host.AddScriptLPS(1); | 3714 | m_host.AddScriptLPS(1); |
3650 | int count = 0; | 3715 | int count = 0; |
3651 | 3716 | ||
3652 | lock (m_host.TaskInventory) | 3717 | m_host.TaskInventory.LockItemsForRead(true); |
3718 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3653 | { | 3719 | { |
3654 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3720 | if (inv.Value.Type == type || type == -1) |
3655 | { | 3721 | { |
3656 | if (inv.Value.Type == type || type == -1) | 3722 | count = count + 1; |
3657 | { | ||
3658 | count = count + 1; | ||
3659 | } | ||
3660 | } | 3723 | } |
3661 | } | 3724 | } |
3662 | 3725 | ||
3726 | m_host.TaskInventory.LockItemsForRead(false); | ||
3663 | return count; | 3727 | return count; |
3664 | } | 3728 | } |
3665 | 3729 | ||
@@ -3668,16 +3732,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3668 | m_host.AddScriptLPS(1); | 3732 | m_host.AddScriptLPS(1); |
3669 | ArrayList keys = new ArrayList(); | 3733 | ArrayList keys = new ArrayList(); |
3670 | 3734 | ||
3671 | lock (m_host.TaskInventory) | 3735 | m_host.TaskInventory.LockItemsForRead(true); |
3736 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3672 | { | 3737 | { |
3673 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3738 | if (inv.Value.Type == type || type == -1) |
3674 | { | 3739 | { |
3675 | if (inv.Value.Type == type || type == -1) | 3740 | keys.Add(inv.Value.Name); |
3676 | { | ||
3677 | keys.Add(inv.Value.Name); | ||
3678 | } | ||
3679 | } | 3741 | } |
3680 | } | 3742 | } |
3743 | m_host.TaskInventory.LockItemsForRead(false); | ||
3681 | 3744 | ||
3682 | if (keys.Count == 0) | 3745 | if (keys.Count == 0) |
3683 | { | 3746 | { |
@@ -3714,20 +3777,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3714 | } | 3777 | } |
3715 | 3778 | ||
3716 | // move the first object found with this inventory name | 3779 | // move the first object found with this inventory name |
3717 | lock (m_host.TaskInventory) | 3780 | m_host.TaskInventory.LockItemsForRead(true); |
3781 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3718 | { | 3782 | { |
3719 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3783 | if (inv.Value.Name == inventory) |
3720 | { | 3784 | { |
3721 | if (inv.Value.Name == inventory) | 3785 | found = true; |
3722 | { | 3786 | objId = inv.Key; |
3723 | found = true; | 3787 | assetType = inv.Value.Type; |
3724 | objId = inv.Key; | 3788 | objName = inv.Value.Name; |
3725 | assetType = inv.Value.Type; | 3789 | break; |
3726 | objName = inv.Value.Name; | ||
3727 | break; | ||
3728 | } | ||
3729 | } | 3790 | } |
3730 | } | 3791 | } |
3792 | m_host.TaskInventory.LockItemsForRead(false); | ||
3731 | 3793 | ||
3732 | if (!found) | 3794 | if (!found) |
3733 | { | 3795 | { |
@@ -3772,24 +3834,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3772 | ScriptSleep(3000); | 3834 | ScriptSleep(3000); |
3773 | } | 3835 | } |
3774 | 3836 | ||
3837 | [DebuggerNonUserCode] | ||
3775 | public void llRemoveInventory(string name) | 3838 | public void llRemoveInventory(string name) |
3776 | { | 3839 | { |
3777 | m_host.AddScriptLPS(1); | 3840 | m_host.AddScriptLPS(1); |
3778 | 3841 | ||
3779 | lock (m_host.TaskInventory) | 3842 | m_host.TaskInventory.LockItemsForRead(true); |
3843 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3780 | { | 3844 | { |
3781 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3845 | if (item.Name == name) |
3782 | { | 3846 | { |
3783 | if (item.Name == name) | 3847 | if (item.ItemID == m_itemID) |
3784 | { | 3848 | throw new ScriptDeleteException(); |
3785 | if (item.ItemID == m_itemID) | 3849 | else |
3786 | throw new ScriptDeleteException(); | 3850 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3787 | else | 3851 | |
3788 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3852 | m_host.TaskInventory.LockItemsForRead(false); |
3789 | return; | 3853 | return; |
3790 | } | ||
3791 | } | 3854 | } |
3792 | } | 3855 | } |
3856 | m_host.TaskInventory.LockItemsForRead(false); | ||
3793 | } | 3857 | } |
3794 | 3858 | ||
3795 | public void llSetText(string text, LSL_Vector color, double alpha) | 3859 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3878,6 +3942,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3878 | { | 3942 | { |
3879 | m_host.AddScriptLPS(1); | 3943 | m_host.AddScriptLPS(1); |
3880 | 3944 | ||
3945 | //Clone is thread safe | ||
3881 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3946 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3882 | 3947 | ||
3883 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3948 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3968,17 +4033,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3968 | UUID soundId = UUID.Zero; | 4033 | UUID soundId = UUID.Zero; |
3969 | if (!UUID.TryParse(impact_sound, out soundId)) | 4034 | if (!UUID.TryParse(impact_sound, out soundId)) |
3970 | { | 4035 | { |
3971 | lock (m_host.TaskInventory) | 4036 | m_host.TaskInventory.LockItemsForRead(true); |
4037 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3972 | { | 4038 | { |
3973 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4039 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3974 | { | 4040 | { |
3975 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4041 | soundId = item.AssetID; |
3976 | { | 4042 | break; |
3977 | soundId = item.AssetID; | ||
3978 | break; | ||
3979 | } | ||
3980 | } | 4043 | } |
3981 | } | 4044 | } |
4045 | m_host.TaskInventory.LockItemsForRead(false); | ||
3982 | } | 4046 | } |
3983 | m_host.CollisionSound = soundId; | 4047 | m_host.CollisionSound = soundId; |
3984 | m_host.CollisionSoundVolume = (float)impact_volume; | 4048 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4024,6 +4088,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4024 | UUID partItemID; | 4088 | UUID partItemID; |
4025 | foreach (SceneObjectPart part in parts) | 4089 | foreach (SceneObjectPart part in parts) |
4026 | { | 4090 | { |
4091 | //Clone is thread safe | ||
4027 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4092 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4028 | 4093 | ||
4029 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4094 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4231,17 +4296,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4231 | 4296 | ||
4232 | m_host.AddScriptLPS(1); | 4297 | m_host.AddScriptLPS(1); |
4233 | 4298 | ||
4234 | lock (m_host.TaskInventory) | 4299 | m_host.TaskInventory.LockItemsForRead(true); |
4300 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4235 | { | 4301 | { |
4236 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4302 | if (item.Type == 10 && item.ItemID == m_itemID) |
4237 | { | 4303 | { |
4238 | if (item.Type == 10 && item.ItemID == m_itemID) | 4304 | result = item.Name!=null?item.Name:String.Empty; |
4239 | { | 4305 | break; |
4240 | result = item.Name!=null?item.Name:String.Empty; | ||
4241 | break; | ||
4242 | } | ||
4243 | } | 4306 | } |
4244 | } | 4307 | } |
4308 | m_host.TaskInventory.LockItemsForRead(false); | ||
4245 | 4309 | ||
4246 | return result; | 4310 | return result; |
4247 | } | 4311 | } |
@@ -4499,23 +4563,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4499 | { | 4563 | { |
4500 | m_host.AddScriptLPS(1); | 4564 | m_host.AddScriptLPS(1); |
4501 | 4565 | ||
4502 | lock (m_host.TaskInventory) | 4566 | m_host.TaskInventory.LockItemsForRead(true); |
4567 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4503 | { | 4568 | { |
4504 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4569 | if (inv.Value.Name == name) |
4505 | { | 4570 | { |
4506 | if (inv.Value.Name == name) | 4571 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4507 | { | 4572 | { |
4508 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4573 | m_host.TaskInventory.LockItemsForRead(false); |
4509 | { | 4574 | return inv.Value.AssetID.ToString(); |
4510 | return inv.Value.AssetID.ToString(); | 4575 | } |
4511 | } | 4576 | else |
4512 | else | 4577 | { |
4513 | { | 4578 | m_host.TaskInventory.LockItemsForRead(false); |
4514 | return UUID.Zero.ToString(); | 4579 | return UUID.Zero.ToString(); |
4515 | } | ||
4516 | } | 4580 | } |
4517 | } | 4581 | } |
4518 | } | 4582 | } |
4583 | m_host.TaskInventory.LockItemsForRead(false); | ||
4519 | 4584 | ||
4520 | return UUID.Zero.ToString(); | 4585 | return UUID.Zero.ToString(); |
4521 | } | 4586 | } |
@@ -6011,14 +6076,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6011 | 6076 | ||
6012 | protected UUID GetTaskInventoryItem(string name) | 6077 | protected UUID GetTaskInventoryItem(string name) |
6013 | { | 6078 | { |
6014 | lock (m_host.TaskInventory) | 6079 | m_host.TaskInventory.LockItemsForRead(true); |
6080 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6015 | { | 6081 | { |
6016 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6082 | if (inv.Value.Name == name) |
6017 | { | 6083 | { |
6018 | if (inv.Value.Name == name) | 6084 | m_host.TaskInventory.LockItemsForRead(false); |
6019 | return inv.Key; | 6085 | return inv.Key; |
6020 | } | 6086 | } |
6021 | } | 6087 | } |
6088 | m_host.TaskInventory.LockItemsForRead(false); | ||
6022 | 6089 | ||
6023 | return UUID.Zero; | 6090 | return UUID.Zero; |
6024 | } | 6091 | } |
@@ -6329,22 +6396,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6329 | } | 6396 | } |
6330 | 6397 | ||
6331 | // copy the first script found with this inventory name | 6398 | // copy the first script found with this inventory name |
6332 | lock (m_host.TaskInventory) | 6399 | m_host.TaskInventory.LockItemsForRead(true); |
6400 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6333 | { | 6401 | { |
6334 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6402 | if (inv.Value.Name == name) |
6335 | { | 6403 | { |
6336 | if (inv.Value.Name == name) | 6404 | // make sure the object is a script |
6405 | if (10 == inv.Value.Type) | ||
6337 | { | 6406 | { |
6338 | // make sure the object is a script | 6407 | found = true; |
6339 | if (10 == inv.Value.Type) | 6408 | srcId = inv.Key; |
6340 | { | 6409 | break; |
6341 | found = true; | ||
6342 | srcId = inv.Key; | ||
6343 | break; | ||
6344 | } | ||
6345 | } | 6410 | } |
6346 | } | 6411 | } |
6347 | } | 6412 | } |
6413 | m_host.TaskInventory.LockItemsForRead(false); | ||
6348 | 6414 | ||
6349 | if (!found) | 6415 | if (!found) |
6350 | { | 6416 | { |
@@ -8147,28 +8213,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8147 | { | 8213 | { |
8148 | m_host.AddScriptLPS(1); | 8214 | m_host.AddScriptLPS(1); |
8149 | 8215 | ||
8150 | lock (m_host.TaskInventory) | 8216 | m_host.TaskInventory.LockItemsForRead(true); |
8217 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8151 | { | 8218 | { |
8152 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8219 | if (inv.Value.Name == item) |
8153 | { | 8220 | { |
8154 | if (inv.Value.Name == item) | 8221 | m_host.TaskInventory.LockItemsForRead(false); |
8222 | switch (mask) | ||
8155 | { | 8223 | { |
8156 | switch (mask) | 8224 | case 0: |
8157 | { | 8225 | return (int)inv.Value.BasePermissions; |
8158 | case 0: | 8226 | case 1: |
8159 | return (int)inv.Value.BasePermissions; | 8227 | return (int)inv.Value.CurrentPermissions; |
8160 | case 1: | 8228 | case 2: |
8161 | return (int)inv.Value.CurrentPermissions; | 8229 | return (int)inv.Value.GroupPermissions; |
8162 | case 2: | 8230 | case 3: |
8163 | return (int)inv.Value.GroupPermissions; | 8231 | return (int)inv.Value.EveryonePermissions; |
8164 | case 3: | 8232 | case 4: |
8165 | return (int)inv.Value.EveryonePermissions; | 8233 | return (int)inv.Value.NextPermissions; |
8166 | case 4: | ||
8167 | return (int)inv.Value.NextPermissions; | ||
8168 | } | ||
8169 | } | 8234 | } |
8170 | } | 8235 | } |
8171 | } | 8236 | } |
8237 | m_host.TaskInventory.LockItemsForRead(false); | ||
8172 | 8238 | ||
8173 | return -1; | 8239 | return -1; |
8174 | } | 8240 | } |
@@ -8183,16 +8249,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8183 | { | 8249 | { |
8184 | m_host.AddScriptLPS(1); | 8250 | m_host.AddScriptLPS(1); |
8185 | 8251 | ||
8186 | lock (m_host.TaskInventory) | 8252 | m_host.TaskInventory.LockItemsForRead(true); |
8253 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8187 | { | 8254 | { |
8188 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8255 | if (inv.Value.Name == item) |
8189 | { | 8256 | { |
8190 | if (inv.Value.Name == item) | 8257 | m_host.TaskInventory.LockItemsForRead(false); |
8191 | { | 8258 | return inv.Value.CreatorID.ToString(); |
8192 | return inv.Value.CreatorID.ToString(); | ||
8193 | } | ||
8194 | } | 8259 | } |
8195 | } | 8260 | } |
8261 | m_host.TaskInventory.LockItemsForRead(false); | ||
8196 | 8262 | ||
8197 | llSay(0, "No item name '" + item + "'"); | 8263 | llSay(0, "No item name '" + item + "'"); |
8198 | 8264 | ||
@@ -8716,16 +8782,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8716 | { | 8782 | { |
8717 | m_host.AddScriptLPS(1); | 8783 | m_host.AddScriptLPS(1); |
8718 | 8784 | ||
8719 | lock (m_host.TaskInventory) | 8785 | m_host.TaskInventory.LockItemsForRead(true); |
8786 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8720 | { | 8787 | { |
8721 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8788 | if (inv.Value.Name == name) |
8722 | { | 8789 | { |
8723 | if (inv.Value.Name == name) | 8790 | m_host.TaskInventory.LockItemsForRead(false); |
8724 | { | 8791 | return inv.Value.Type; |
8725 | return inv.Value.Type; | ||
8726 | } | ||
8727 | } | 8792 | } |
8728 | } | 8793 | } |
8794 | m_host.TaskInventory.LockItemsForRead(false); | ||
8729 | 8795 | ||
8730 | return -1; | 8796 | return -1; |
8731 | } | 8797 | } |
@@ -8756,17 +8822,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8756 | if (invItemID == UUID.Zero) | 8822 | if (invItemID == UUID.Zero) |
8757 | return new LSL_Vector(); | 8823 | return new LSL_Vector(); |
8758 | 8824 | ||
8759 | lock (m_host.TaskInventory) | 8825 | m_host.TaskInventory.LockItemsForRead(true); |
8826 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8760 | { | 8827 | { |
8761 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8828 | m_host.TaskInventory.LockItemsForRead(false); |
8762 | return new LSL_Vector(); | 8829 | return new LSL_Vector(); |
8830 | } | ||
8763 | 8831 | ||
8764 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8832 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8765 | { | 8833 | { |
8766 | ShoutError("No permissions to track the camera"); | 8834 | ShoutError("No permissions to track the camera"); |
8767 | return new LSL_Vector(); | 8835 | m_host.TaskInventory.LockItemsForRead(false); |
8768 | } | 8836 | return new LSL_Vector(); |
8769 | } | 8837 | } |
8838 | m_host.TaskInventory.LockItemsForRead(false); | ||
8770 | 8839 | ||
8771 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8840 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8772 | if (presence != null) | 8841 | if (presence != null) |
@@ -8784,17 +8853,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8784 | if (invItemID == UUID.Zero) | 8853 | if (invItemID == UUID.Zero) |
8785 | return new LSL_Rotation(); | 8854 | return new LSL_Rotation(); |
8786 | 8855 | ||
8787 | lock (m_host.TaskInventory) | 8856 | m_host.TaskInventory.LockItemsForRead(true); |
8857 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8788 | { | 8858 | { |
8789 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8859 | m_host.TaskInventory.LockItemsForRead(false); |
8790 | return new LSL_Rotation(); | 8860 | return new LSL_Rotation(); |
8791 | |||
8792 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8793 | { | ||
8794 | ShoutError("No permissions to track the camera"); | ||
8795 | return new LSL_Rotation(); | ||
8796 | } | ||
8797 | } | 8861 | } |
8862 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8863 | { | ||
8864 | ShoutError("No permissions to track the camera"); | ||
8865 | m_host.TaskInventory.LockItemsForRead(false); | ||
8866 | return new LSL_Rotation(); | ||
8867 | } | ||
8868 | m_host.TaskInventory.LockItemsForRead(false); | ||
8798 | 8869 | ||
8799 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8870 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8800 | if (presence != null) | 8871 | if (presence != null) |
@@ -8944,14 +9015,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8944 | if (objectID == UUID.Zero) return; | 9015 | if (objectID == UUID.Zero) return; |
8945 | 9016 | ||
8946 | UUID agentID; | 9017 | UUID agentID; |
8947 | lock (m_host.TaskInventory) | 9018 | m_host.TaskInventory.LockItemsForRead(true); |
8948 | { | 9019 | // we need the permission first, to know which avatar we want to set the camera for |
8949 | // we need the permission first, to know which avatar we want to set the camera for | 9020 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8950 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8951 | 9021 | ||
8952 | if (agentID == UUID.Zero) return; | 9022 | if (agentID == UUID.Zero) |
8953 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9023 | { |
9024 | m_host.TaskInventory.LockItemsForRead(false); | ||
9025 | return; | ||
8954 | } | 9026 | } |
9027 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9028 | { | ||
9029 | m_host.TaskInventory.LockItemsForRead(false); | ||
9030 | return; | ||
9031 | } | ||
9032 | m_host.TaskInventory.LockItemsForRead(false); | ||
8955 | 9033 | ||
8956 | ScenePresence presence = World.GetScenePresence(agentID); | 9034 | ScenePresence presence = World.GetScenePresence(agentID); |
8957 | 9035 | ||
@@ -9001,12 +9079,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9001 | 9079 | ||
9002 | // we need the permission first, to know which avatar we want to clear the camera for | 9080 | // we need the permission first, to know which avatar we want to clear the camera for |
9003 | UUID agentID; | 9081 | UUID agentID; |
9004 | lock (m_host.TaskInventory) | 9082 | m_host.TaskInventory.LockItemsForRead(true); |
9083 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9084 | if (agentID == UUID.Zero) | ||
9085 | { | ||
9086 | m_host.TaskInventory.LockItemsForRead(false); | ||
9087 | return; | ||
9088 | } | ||
9089 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9005 | { | 9090 | { |
9006 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9091 | m_host.TaskInventory.LockItemsForRead(false); |
9007 | if (agentID == UUID.Zero) return; | 9092 | return; |
9008 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9009 | } | 9093 | } |
9094 | m_host.TaskInventory.LockItemsForRead(false); | ||
9010 | 9095 | ||
9011 | ScenePresence presence = World.GetScenePresence(agentID); | 9096 | ScenePresence presence = World.GetScenePresence(agentID); |
9012 | 9097 | ||
@@ -9463,15 +9548,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9463 | 9548 | ||
9464 | internal UUID ScriptByName(string name) | 9549 | internal UUID ScriptByName(string name) |
9465 | { | 9550 | { |
9466 | lock (m_host.TaskInventory) | 9551 | m_host.TaskInventory.LockItemsForRead(true); |
9552 | |||
9553 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9467 | { | 9554 | { |
9468 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9555 | if (item.Type == 10 && item.Name == name) |
9469 | { | 9556 | { |
9470 | if (item.Type == 10 && item.Name == name) | 9557 | m_host.TaskInventory.LockItemsForRead(false); |
9471 | return item.ItemID; | 9558 | return item.ItemID; |
9472 | } | 9559 | } |
9473 | } | 9560 | } |
9474 | 9561 | ||
9562 | m_host.TaskInventory.LockItemsForRead(false); | ||
9563 | |||
9475 | return UUID.Zero; | 9564 | return UUID.Zero; |
9476 | } | 9565 | } |
9477 | 9566 | ||
@@ -9512,6 +9601,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9512 | { | 9601 | { |
9513 | m_host.AddScriptLPS(1); | 9602 | m_host.AddScriptLPS(1); |
9514 | 9603 | ||
9604 | //Clone is thread safe | ||
9515 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9605 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9516 | 9606 | ||
9517 | UUID assetID = UUID.Zero; | 9607 | UUID assetID = UUID.Zero; |
@@ -9574,6 +9664,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9574 | { | 9664 | { |
9575 | m_host.AddScriptLPS(1); | 9665 | m_host.AddScriptLPS(1); |
9576 | 9666 | ||
9667 | //Clone is thread safe | ||
9577 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9668 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9578 | 9669 | ||
9579 | UUID assetID = UUID.Zero; | 9670 | 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); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 5c5d57e..8333a27 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -237,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
237 | 238 | ||
238 | if (part != null) | 239 | if (part != null) |
239 | { | 240 | { |
240 | lock (part.TaskInventory) | 241 | part.TaskInventory.LockItemsForRead(true); |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
241 | { | 243 | { |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
243 | { | ||
244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
245 | } | ||
246 | } | 245 | } |
246 | part.TaskInventory.LockItemsForRead(false); | ||
247 | } | 247 | } |
248 | 248 | ||
249 | ApiManager am = new ApiManager(); | 249 | ApiManager am = new ApiManager(); |
@@ -428,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
428 | { | 428 | { |
429 | int permsMask; | 429 | int permsMask; |
430 | UUID permsGranter; | 430 | UUID permsGranter; |
431 | lock (part.TaskInventory) | 431 | part.TaskInventory.LockItemsForRead(true); |
432 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
432 | { | 433 | { |
433 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 434 | part.TaskInventory.LockItemsForRead(false); |
434 | return; | 435 | return; |
435 | |||
436 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
437 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
438 | } | 436 | } |
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | part.TaskInventory.LockItemsForRead(false); | ||
439 | 440 | ||
440 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
441 | { | 442 | { |
@@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
544 | return true; | 545 | return true; |
545 | } | 546 | } |
546 | 547 | ||
548 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
547 | public void SetState(string state) | 549 | public void SetState(string state) |
548 | { | 550 | { |
549 | if (state == State) | 551 | if (state == State) |
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
555 | new DetectParams[0])); | 557 | new DetectParams[0])); |
556 | PostEvent(new EventParams("state_entry", new Object[0], | 558 | PostEvent(new EventParams("state_entry", new Object[0], |
557 | new DetectParams[0])); | 559 | new DetectParams[0])); |
558 | 560 | ||
559 | throw new EventAbortException(); | 561 | throw new EventAbortException(); |
560 | } | 562 | } |
561 | 563 | ||
@@ -638,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
638 | /// <returns></returns> | 640 | /// <returns></returns> |
639 | public object EventProcessor() | 641 | public object EventProcessor() |
640 | { | 642 | { |
643 | |||
644 | EventParams data = null; | ||
645 | |||
646 | lock (m_EventQueue) | ||
647 | { | ||
641 | lock (m_Script) | 648 | lock (m_Script) |
642 | { | 649 | { |
643 | EventParams data = null; | 650 | data = (EventParams) m_EventQueue.Dequeue(); |
644 | 651 | if (data == null) // Shouldn't happen | |
645 | lock (m_EventQueue) | ||
646 | { | 652 | { |
647 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) |
648 | if (data == null) // Shouldn't happen | ||
649 | { | 654 | { |
650 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 655 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
651 | { | ||
652 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | m_CurrentResult = null; | ||
657 | } | ||
658 | return 0; | ||
659 | } | 656 | } |
660 | 657 | else | |
661 | if (data.EventName == "timer") | ||
662 | m_TimerQueued = false; | ||
663 | if (data.EventName == "control") | ||
664 | { | 658 | { |
665 | if (m_ControlEventsInQueue > 0) | 659 | m_CurrentResult = null; |
666 | m_ControlEventsInQueue--; | ||
667 | } | 660 | } |
668 | if (data.EventName == "collision") | 661 | return 0; |
669 | m_CollisionInQueue = false; | ||
670 | } | 662 | } |
671 | |||
672 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
673 | 663 | ||
674 | m_DetectParams = data.DetectParams; | 664 | if (data.EventName == "timer") |
675 | 665 | m_TimerQueued = false; | |
676 | if (data.EventName == "state") // Hardcoded state change | 666 | if (data.EventName == "control") |
677 | { | 667 | { |
678 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 668 | if (m_ControlEventsInQueue > 0) |
679 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 669 | m_ControlEventsInQueue--; |
680 | m_State=data.Params[0].ToString(); | 670 | } |
681 | AsyncCommandManager.RemoveScript(m_Engine, | 671 | if (data.EventName == "collision") |
682 | m_LocalID, m_ItemID); | 672 | m_CollisionInQueue = false; |
673 | } | ||
674 | } | ||
675 | lock(m_Script) | ||
676 | { | ||
677 | |||
678 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
683 | 679 | ||
684 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 680 | m_DetectParams = data.DetectParams; |
685 | m_LocalID); | 681 | |
686 | if (part != null) | 682 | if (data.EventName == "state") // Hardcoded state change |
687 | { | 683 | { |
688 | part.SetScriptEvents(m_ItemID, | 684 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
689 | (int)m_Script.GetStateEventFlags(State)); | 685 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); |
690 | } | 686 | m_State=data.Params[0].ToString(); |
687 | AsyncCommandManager.RemoveScript(m_Engine, | ||
688 | m_LocalID, m_ItemID); | ||
689 | |||
690 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | ||
691 | m_LocalID); | ||
692 | if (part != null) | ||
693 | { | ||
694 | part.SetScriptEvents(m_ItemID, | ||
695 | (int)m_Script.GetStateEventFlags(State)); | ||
691 | } | 696 | } |
692 | else | 697 | } |
698 | else | ||
699 | { | ||
700 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | ||
701 | data.EventName == "control") // Don't freeze avies! | ||
693 | { | 702 | { |
694 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 703 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
695 | data.EventName == "control") // Don't freeze avies! | 704 | m_LocalID); |
696 | { | 705 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
697 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 706 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
698 | m_LocalID); | ||
699 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | ||
700 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
701 | 707 | ||
702 | try | 708 | try |
703 | { | 709 | { |
704 | m_CurrentEvent = data.EventName; | 710 | m_CurrentEvent = data.EventName; |
705 | m_EventStart = DateTime.Now; | 711 | m_EventStart = DateTime.Now; |
706 | m_InEvent = true; | 712 | m_InEvent = true; |
707 | 713 | ||
708 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 714 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
709 | 715 | ||
710 | m_InEvent = false; | 716 | m_InEvent = false; |
711 | m_CurrentEvent = String.Empty; | 717 | m_CurrentEvent = String.Empty; |
712 | 718 | ||
713 | if (m_SaveState) | 719 | if (m_SaveState) |
714 | { | 720 | { |
715 | // This will be the very first event we deliver | 721 | // This will be the very first event we deliver |
716 | // (state_entry) in default state | 722 | // (state_entry) in default state |
717 | // | 723 | // |
718 | 724 | ||
719 | SaveState(m_Assembly); | 725 | SaveState(m_Assembly); |
720 | 726 | ||
721 | m_SaveState = false; | 727 | m_SaveState = false; |
722 | } | ||
723 | } | 728 | } |
724 | catch (Exception e) | 729 | } |
725 | { | 730 | catch (Exception e) |
726 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); | 731 | { |
727 | m_InEvent = false; | 732 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); |
728 | m_CurrentEvent = String.Empty; | 733 | m_InEvent = false; |
734 | m_CurrentEvent = String.Empty; | ||
729 | 735 | ||
730 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) | 736 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) |
731 | { | 737 | { |
732 | try | 738 | try |
733 | { | ||
734 | // DISPLAY ERROR INWORLD | ||
735 | string text = FormatException(e); | ||
736 | |||
737 | if (text.Length > 1000) | ||
738 | text = text.Substring(0, 1000); | ||
739 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
740 | ChatTypeEnum.DebugChannel, 2147483647, | ||
741 | part.AbsolutePosition, | ||
742 | part.Name, part.UUID, false); | ||
743 | } | ||
744 | catch (Exception) | ||
745 | { | ||
746 | } | ||
747 | // catch (Exception e2) // LEGIT: User Scripting | ||
748 | // { | ||
749 | // m_log.Error("[SCRIPT]: "+ | ||
750 | // "Error displaying error in-world: " + | ||
751 | // e2.ToString()); | ||
752 | // m_log.Error("[SCRIPT]: " + | ||
753 | // "Errormessage: Error compiling script:\r\n" + | ||
754 | // e.ToString()); | ||
755 | // } | ||
756 | } | ||
757 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
758 | { | 739 | { |
759 | m_InSelfDelete = true; | 740 | // DISPLAY ERROR INWORLD |
760 | if (part != null && part.ParentGroup != null) | 741 | string text = FormatException(e); |
761 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 742 | |
743 | if (text.Length > 1000) | ||
744 | text = text.Substring(0, 1000); | ||
745 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
746 | ChatTypeEnum.DebugChannel, 2147483647, | ||
747 | part.AbsolutePosition, | ||
748 | part.Name, part.UUID, false); | ||
762 | } | 749 | } |
763 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 750 | catch (Exception) |
764 | { | 751 | { |
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
768 | } | 752 | } |
753 | // catch (Exception e2) // LEGIT: User Scripting | ||
754 | // { | ||
755 | // m_log.Error("[SCRIPT]: "+ | ||
756 | // "Error displaying error in-world: " + | ||
757 | // e2.ToString()); | ||
758 | // m_log.Error("[SCRIPT]: " + | ||
759 | // "Errormessage: Error compiling script:\r\n" + | ||
760 | // e.ToString()); | ||
761 | // } | ||
762 | } | ||
763 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
764 | { | ||
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
768 | } | ||
769 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | ||
770 | { | ||
771 | m_InSelfDelete = true; | ||
772 | if (part != null && part.ParentGroup != null) | ||
773 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
769 | } | 774 | } |
770 | } | 775 | } |
771 | } | 776 | } |
777 | } | ||
772 | 778 | ||
773 | lock (m_EventQueue) | 779 | lock (m_EventQueue) |
780 | { | ||
781 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | ||
774 | { | 782 | { |
775 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 783 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
776 | { | 784 | } |
777 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 785 | else |
778 | } | 786 | { |
779 | else | 787 | m_CurrentResult = null; |
780 | { | ||
781 | m_CurrentResult = null; | ||
782 | } | ||
783 | } | 788 | } |
789 | } | ||
784 | 790 | ||
785 | m_DetectParams = null; | 791 | m_DetectParams = null; |
786 | 792 | ||
787 | return 0; | 793 | return 0; |
788 | } | 794 | } |
789 | } | 795 | } |
790 | 796 | ||
791 | public int EventTime() | 797 | public int EventTime() |
@@ -824,6 +830,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
824 | new Object[0], new DetectParams[0])); | 830 | new Object[0], new DetectParams[0])); |
825 | } | 831 | } |
826 | 832 | ||
833 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
827 | public void ApiResetScript() | 834 | public void ApiResetScript() |
828 | { | 835 | { |
829 | // bool running = Running; | 836 | // bool running = Running; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 3f38bb6..1fc31c5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -429,6 +429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
429 | } | 429 | } |
430 | } | 430 | } |
431 | 431 | ||
432 | public int Size | ||
433 | { | ||
434 | get { return 0; } | ||
435 | } | ||
436 | |||
432 | public object[] Data | 437 | public object[] Data |
433 | { | 438 | { |
434 | get { | 439 | get { |