diff options
author | root | 2009-11-26 20:41:38 +0100 |
---|---|---|
committer | root | 2009-11-26 20:41:38 +0100 |
commit | 2c3f6aaa878b5458eeeab8544226ff53b7172f5a (patch) | |
tree | 48941505962693508016fafb479c2baaf1b3568f /OpenSim/Region/ScriptEngine | |
parent | First attempt at mult-sit on large single prims. (diff) | |
parent | Remove OS version crap from about dialog (diff) | |
download | opensim-SC_OLD-2c3f6aaa878b5458eeeab8544226ff53b7172f5a.zip opensim-SC_OLD-2c3f6aaa878b5458eeeab8544226ff53b7172f5a.tar.gz opensim-SC_OLD-2c3f6aaa878b5458eeeab8544226ff53b7172f5a.tar.bz2 opensim-SC_OLD-2c3f6aaa878b5458eeeab8544226ff53b7172f5a.tar.xz |
Merge branch 'careminster' into tests
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
11 files changed, 743 insertions, 399 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index f49aea8..ae148a9 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs | |||
@@ -96,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces | |||
96 | UUID GetDetectID(int idx); | 96 | UUID GetDetectID(int idx); |
97 | void SaveState(string assembly); | 97 | void SaveState(string assembly); |
98 | void DestroyScriptInstance(); | 98 | void DestroyScriptInstance(); |
99 | bool CanBeDeleted(); | ||
100 | 99 | ||
101 | IScriptApi GetApi(string name); | 100 | IScriptApi GetApi(string name); |
102 | 101 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 50b2fb5..8274fbf 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 | ||
@@ -1987,6 +2002,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1987 | 2002 | ||
1988 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type | 2003 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type |
1989 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | 2004 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; |
2005 | |||
2006 | // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line | ||
2007 | // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt | ||
2008 | // It's perfectly okay when the object is not an active physical body though. | ||
2009 | // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against | ||
2010 | // but only if the object is not physial and active. This is important for rotating doors. | ||
2011 | // without the absoluteposition = absoluteposition happening, the doors do not move in the physics | ||
2012 | // scene | ||
2013 | if (part.PhysActor != null && !part.PhysActor.IsPhysical) | ||
2014 | { | ||
2015 | part.ParentGroup.ResetChildPrimPhysicsPositions(); | ||
2016 | } | ||
1990 | } | 2017 | } |
1991 | 2018 | ||
1992 | /// <summary> | 2019 | /// <summary> |
@@ -2534,12 +2561,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2534 | 2561 | ||
2535 | m_host.AddScriptLPS(1); | 2562 | m_host.AddScriptLPS(1); |
2536 | 2563 | ||
2564 | m_host.TaskInventory.LockItemsForRead(true); | ||
2537 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2565 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2538 | 2566 | m_host.TaskInventory.LockItemsForRead(false); | |
2539 | lock (m_host.TaskInventory) | ||
2540 | { | ||
2541 | item = m_host.TaskInventory[invItemID]; | ||
2542 | } | ||
2543 | 2567 | ||
2544 | if (item.PermsGranter == UUID.Zero) | 2568 | if (item.PermsGranter == UUID.Zero) |
2545 | return 0; | 2569 | return 0; |
@@ -2614,6 +2638,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2614 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2638 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2615 | return; | 2639 | return; |
2616 | 2640 | ||
2641 | //Clone is thread-safe | ||
2617 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2642 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2618 | 2643 | ||
2619 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2644 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2747,13 +2772,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2747 | { | 2772 | { |
2748 | TaskInventoryItem item; | 2773 | TaskInventoryItem item; |
2749 | 2774 | ||
2750 | lock (m_host.TaskInventory) | 2775 | m_host.TaskInventory.LockItemsForRead(true); |
2776 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2751 | { | 2777 | { |
2752 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2778 | m_host.TaskInventory.LockItemsForRead(false); |
2753 | return; | 2779 | return; |
2754 | else | ||
2755 | item = m_host.TaskInventory[InventorySelf()]; | ||
2756 | } | 2780 | } |
2781 | else | ||
2782 | { | ||
2783 | item = m_host.TaskInventory[InventorySelf()]; | ||
2784 | } | ||
2785 | m_host.TaskInventory.LockItemsForRead(false); | ||
2757 | 2786 | ||
2758 | if (item.PermsGranter != UUID.Zero) | 2787 | if (item.PermsGranter != UUID.Zero) |
2759 | { | 2788 | { |
@@ -2775,13 +2804,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2775 | { | 2804 | { |
2776 | TaskInventoryItem item; | 2805 | TaskInventoryItem item; |
2777 | 2806 | ||
2807 | m_host.TaskInventory.LockItemsForRead(true); | ||
2778 | lock (m_host.TaskInventory) | 2808 | lock (m_host.TaskInventory) |
2779 | { | 2809 | { |
2810 | |||
2780 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2811 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2812 | { | ||
2813 | m_host.TaskInventory.LockItemsForRead(false); | ||
2781 | return; | 2814 | return; |
2815 | } | ||
2782 | else | 2816 | else |
2817 | { | ||
2783 | item = m_host.TaskInventory[InventorySelf()]; | 2818 | item = m_host.TaskInventory[InventorySelf()]; |
2819 | } | ||
2784 | } | 2820 | } |
2821 | m_host.TaskInventory.LockItemsForRead(false); | ||
2785 | 2822 | ||
2786 | m_host.AddScriptLPS(1); | 2823 | m_host.AddScriptLPS(1); |
2787 | 2824 | ||
@@ -2818,14 +2855,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2818 | 2855 | ||
2819 | TaskInventoryItem item; | 2856 | TaskInventoryItem item; |
2820 | 2857 | ||
2821 | lock (m_host.TaskInventory) | 2858 | m_host.TaskInventory.LockItemsForRead(true); |
2859 | |||
2860 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2822 | { | 2861 | { |
2823 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2862 | m_host.TaskInventory.LockItemsForRead(false); |
2824 | return; | 2863 | return; |
2825 | else | 2864 | } |
2826 | item = m_host.TaskInventory[InventorySelf()]; | 2865 | else |
2866 | { | ||
2867 | item = m_host.TaskInventory[InventorySelf()]; | ||
2827 | } | 2868 | } |
2828 | 2869 | ||
2870 | m_host.TaskInventory.LockItemsForRead(false); | ||
2871 | |||
2829 | if (item.PermsGranter != m_host.OwnerID) | 2872 | if (item.PermsGranter != m_host.OwnerID) |
2830 | return; | 2873 | return; |
2831 | 2874 | ||
@@ -2850,13 +2893,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2850 | 2893 | ||
2851 | TaskInventoryItem item; | 2894 | TaskInventoryItem item; |
2852 | 2895 | ||
2853 | lock (m_host.TaskInventory) | 2896 | m_host.TaskInventory.LockItemsForRead(true); |
2897 | |||
2898 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2854 | { | 2899 | { |
2855 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2900 | m_host.TaskInventory.LockItemsForRead(false); |
2856 | return; | 2901 | return; |
2857 | else | 2902 | } |
2858 | item = m_host.TaskInventory[InventorySelf()]; | 2903 | else |
2904 | { | ||
2905 | item = m_host.TaskInventory[InventorySelf()]; | ||
2859 | } | 2906 | } |
2907 | m_host.TaskInventory.LockItemsForRead(false); | ||
2908 | |||
2860 | 2909 | ||
2861 | if (item.PermsGranter != m_host.OwnerID) | 2910 | if (item.PermsGranter != m_host.OwnerID) |
2862 | return; | 2911 | return; |
@@ -3080,14 +3129,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3080 | 3129 | ||
3081 | TaskInventoryItem item; | 3130 | TaskInventoryItem item; |
3082 | 3131 | ||
3083 | lock (m_host.TaskInventory) | 3132 | m_host.TaskInventory.LockItemsForRead(true); |
3133 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3084 | { | 3134 | { |
3085 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3135 | m_host.TaskInventory.LockItemsForRead(false); |
3086 | return; | 3136 | return; |
3087 | else | ||
3088 | item = m_host.TaskInventory[InventorySelf()]; | ||
3089 | } | 3137 | } |
3090 | 3138 | else | |
3139 | { | ||
3140 | item = m_host.TaskInventory[InventorySelf()]; | ||
3141 | } | ||
3142 | m_host.TaskInventory.LockItemsForRead(false); | ||
3091 | if (item.PermsGranter == UUID.Zero) | 3143 | if (item.PermsGranter == UUID.Zero) |
3092 | return; | 3144 | return; |
3093 | 3145 | ||
@@ -3117,13 +3169,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3117 | 3169 | ||
3118 | TaskInventoryItem item; | 3170 | TaskInventoryItem item; |
3119 | 3171 | ||
3120 | lock (m_host.TaskInventory) | 3172 | m_host.TaskInventory.LockItemsForRead(true); |
3173 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3121 | { | 3174 | { |
3122 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3175 | m_host.TaskInventory.LockItemsForRead(false); |
3123 | return; | 3176 | return; |
3124 | else | 3177 | } |
3125 | item = m_host.TaskInventory[InventorySelf()]; | 3178 | else |
3179 | { | ||
3180 | item = m_host.TaskInventory[InventorySelf()]; | ||
3126 | } | 3181 | } |
3182 | m_host.TaskInventory.LockItemsForRead(false); | ||
3183 | |||
3127 | 3184 | ||
3128 | if (item.PermsGranter == UUID.Zero) | 3185 | if (item.PermsGranter == UUID.Zero) |
3129 | return; | 3186 | return; |
@@ -3196,10 +3253,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3196 | 3253 | ||
3197 | TaskInventoryItem item; | 3254 | TaskInventoryItem item; |
3198 | 3255 | ||
3199 | 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 | ||
3200 | { | 3264 | { |
3201 | item = m_host.TaskInventory[invItemID]; | 3265 | item = m_host.TaskInventory[invItemID]; |
3202 | } | 3266 | } |
3267 | m_host.TaskInventory.LockItemsForRead(false); | ||
3203 | 3268 | ||
3204 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3269 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3205 | { | 3270 | { |
@@ -3231,11 +3296,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3231 | 3296 | ||
3232 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3297 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3233 | { | 3298 | { |
3234 | lock (m_host.TaskInventory) | 3299 | m_host.TaskInventory.LockItemsForWrite(true); |
3235 | { | 3300 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3236 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3301 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3237 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3302 | m_host.TaskInventory.LockItemsForWrite(false); |
3238 | } | ||
3239 | 3303 | ||
3240 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3304 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3241 | "run_time_permissions", new Object[] { | 3305 | "run_time_permissions", new Object[] { |
@@ -3255,11 +3319,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3255 | 3319 | ||
3256 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3320 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3257 | { | 3321 | { |
3258 | lock (m_host.TaskInventory) | 3322 | m_host.TaskInventory.LockItemsForWrite(true); |
3259 | { | 3323 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3260 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3324 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3261 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3325 | m_host.TaskInventory.LockItemsForWrite(false); |
3262 | } | ||
3263 | 3326 | ||
3264 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3327 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3265 | "run_time_permissions", new Object[] { | 3328 | "run_time_permissions", new Object[] { |
@@ -3280,11 +3343,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3280 | 3343 | ||
3281 | if (!m_waitingForScriptAnswer) | 3344 | if (!m_waitingForScriptAnswer) |
3282 | { | 3345 | { |
3283 | lock (m_host.TaskInventory) | 3346 | m_host.TaskInventory.LockItemsForWrite(true); |
3284 | { | 3347 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3285 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3348 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3286 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3349 | m_host.TaskInventory.LockItemsForWrite(false); |
3287 | } | ||
3288 | 3350 | ||
3289 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3351 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3290 | m_waitingForScriptAnswer=true; | 3352 | m_waitingForScriptAnswer=true; |
@@ -3319,10 +3381,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3319 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3381 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3320 | llReleaseControls(); | 3382 | llReleaseControls(); |
3321 | 3383 | ||
3322 | lock (m_host.TaskInventory) | 3384 | |
3323 | { | 3385 | m_host.TaskInventory.LockItemsForWrite(true); |
3324 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3386 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3325 | } | 3387 | m_host.TaskInventory.LockItemsForWrite(false); |
3388 | |||
3326 | 3389 | ||
3327 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3390 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3328 | "run_time_permissions", new Object[] { | 3391 | "run_time_permissions", new Object[] { |
@@ -3334,16 +3397,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3334 | { | 3397 | { |
3335 | m_host.AddScriptLPS(1); | 3398 | m_host.AddScriptLPS(1); |
3336 | 3399 | ||
3337 | lock (m_host.TaskInventory) | 3400 | m_host.TaskInventory.LockItemsForRead(true); |
3401 | |||
3402 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3338 | { | 3403 | { |
3339 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3404 | if (item.Type == 10 && item.ItemID == m_itemID) |
3340 | { | 3405 | { |
3341 | if (item.Type == 10 && item.ItemID == m_itemID) | 3406 | m_host.TaskInventory.LockItemsForRead(false); |
3342 | { | 3407 | return item.PermsGranter.ToString(); |
3343 | return item.PermsGranter.ToString(); | ||
3344 | } | ||
3345 | } | 3408 | } |
3346 | } | 3409 | } |
3410 | m_host.TaskInventory.LockItemsForRead(false); | ||
3347 | 3411 | ||
3348 | return UUID.Zero.ToString(); | 3412 | return UUID.Zero.ToString(); |
3349 | } | 3413 | } |
@@ -3352,19 +3416,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3352 | { | 3416 | { |
3353 | m_host.AddScriptLPS(1); | 3417 | m_host.AddScriptLPS(1); |
3354 | 3418 | ||
3355 | lock (m_host.TaskInventory) | 3419 | m_host.TaskInventory.LockItemsForRead(true); |
3420 | |||
3421 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3356 | { | 3422 | { |
3357 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3423 | if (item.Type == 10 && item.ItemID == m_itemID) |
3358 | { | 3424 | { |
3359 | if (item.Type == 10 && item.ItemID == m_itemID) | 3425 | int perms = item.PermsMask; |
3360 | { | 3426 | if (m_automaticLinkPermission) |
3361 | int perms = item.PermsMask; | 3427 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3362 | if (m_automaticLinkPermission) | 3428 | m_host.TaskInventory.LockItemsForRead(false); |
3363 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3429 | return perms; |
3364 | return perms; | ||
3365 | } | ||
3366 | } | 3430 | } |
3367 | } | 3431 | } |
3432 | m_host.TaskInventory.LockItemsForRead(false); | ||
3368 | 3433 | ||
3369 | return 0; | 3434 | return 0; |
3370 | } | 3435 | } |
@@ -3397,11 +3462,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3397 | UUID invItemID = InventorySelf(); | 3462 | UUID invItemID = InventorySelf(); |
3398 | 3463 | ||
3399 | TaskInventoryItem item; | 3464 | TaskInventoryItem item; |
3400 | lock (m_host.TaskInventory) | 3465 | m_host.TaskInventory.LockItemsForRead(true); |
3401 | { | 3466 | item = m_host.TaskInventory[invItemID]; |
3402 | item = m_host.TaskInventory[invItemID]; | 3467 | m_host.TaskInventory.LockItemsForRead(false); |
3403 | } | 3468 | |
3404 | |||
3405 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3469 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3406 | && !m_automaticLinkPermission) | 3470 | && !m_automaticLinkPermission) |
3407 | { | 3471 | { |
@@ -3454,16 +3518,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3454 | m_host.AddScriptLPS(1); | 3518 | m_host.AddScriptLPS(1); |
3455 | UUID invItemID = InventorySelf(); | 3519 | UUID invItemID = InventorySelf(); |
3456 | 3520 | ||
3457 | lock (m_host.TaskInventory) | 3521 | m_host.TaskInventory.LockItemsForRead(true); |
3458 | { | ||
3459 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3522 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3460 | && !m_automaticLinkPermission) | 3523 | && !m_automaticLinkPermission) |
3461 | { | 3524 | { |
3462 | 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); | ||
3463 | return; | 3527 | return; |
3464 | } | 3528 | } |
3465 | } | 3529 | m_host.TaskInventory.LockItemsForRead(false); |
3466 | 3530 | ||
3467 | if (linknum < ScriptBaseClass.LINK_THIS) | 3531 | if (linknum < ScriptBaseClass.LINK_THIS) |
3468 | return; | 3532 | return; |
3469 | 3533 | ||
@@ -3632,17 +3696,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3632 | m_host.AddScriptLPS(1); | 3696 | m_host.AddScriptLPS(1); |
3633 | int count = 0; | 3697 | int count = 0; |
3634 | 3698 | ||
3635 | lock (m_host.TaskInventory) | 3699 | m_host.TaskInventory.LockItemsForRead(true); |
3700 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3636 | { | 3701 | { |
3637 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3702 | if (inv.Value.Type == type || type == -1) |
3638 | { | 3703 | { |
3639 | if (inv.Value.Type == type || type == -1) | 3704 | count = count + 1; |
3640 | { | ||
3641 | count = count + 1; | ||
3642 | } | ||
3643 | } | 3705 | } |
3644 | } | 3706 | } |
3645 | 3707 | ||
3708 | m_host.TaskInventory.LockItemsForRead(false); | ||
3646 | return count; | 3709 | return count; |
3647 | } | 3710 | } |
3648 | 3711 | ||
@@ -3651,16 +3714,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3651 | m_host.AddScriptLPS(1); | 3714 | m_host.AddScriptLPS(1); |
3652 | ArrayList keys = new ArrayList(); | 3715 | ArrayList keys = new ArrayList(); |
3653 | 3716 | ||
3654 | lock (m_host.TaskInventory) | 3717 | m_host.TaskInventory.LockItemsForRead(true); |
3718 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3655 | { | 3719 | { |
3656 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3720 | if (inv.Value.Type == type || type == -1) |
3657 | { | 3721 | { |
3658 | if (inv.Value.Type == type || type == -1) | 3722 | keys.Add(inv.Value.Name); |
3659 | { | ||
3660 | keys.Add(inv.Value.Name); | ||
3661 | } | ||
3662 | } | 3723 | } |
3663 | } | 3724 | } |
3725 | m_host.TaskInventory.LockItemsForRead(false); | ||
3664 | 3726 | ||
3665 | if (keys.Count == 0) | 3727 | if (keys.Count == 0) |
3666 | { | 3728 | { |
@@ -3697,20 +3759,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3697 | } | 3759 | } |
3698 | 3760 | ||
3699 | // move the first object found with this inventory name | 3761 | // move the first object found with this inventory name |
3700 | lock (m_host.TaskInventory) | 3762 | m_host.TaskInventory.LockItemsForRead(true); |
3763 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3701 | { | 3764 | { |
3702 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3765 | if (inv.Value.Name == inventory) |
3703 | { | 3766 | { |
3704 | if (inv.Value.Name == inventory) | 3767 | found = true; |
3705 | { | 3768 | objId = inv.Key; |
3706 | found = true; | 3769 | assetType = inv.Value.Type; |
3707 | objId = inv.Key; | 3770 | objName = inv.Value.Name; |
3708 | assetType = inv.Value.Type; | 3771 | break; |
3709 | objName = inv.Value.Name; | ||
3710 | break; | ||
3711 | } | ||
3712 | } | 3772 | } |
3713 | } | 3773 | } |
3774 | m_host.TaskInventory.LockItemsForRead(false); | ||
3714 | 3775 | ||
3715 | if (!found) | 3776 | if (!found) |
3716 | { | 3777 | { |
@@ -3755,24 +3816,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3755 | ScriptSleep(3000); | 3816 | ScriptSleep(3000); |
3756 | } | 3817 | } |
3757 | 3818 | ||
3819 | [DebuggerNonUserCode] | ||
3758 | public void llRemoveInventory(string name) | 3820 | public void llRemoveInventory(string name) |
3759 | { | 3821 | { |
3760 | m_host.AddScriptLPS(1); | 3822 | m_host.AddScriptLPS(1); |
3761 | 3823 | ||
3762 | lock (m_host.TaskInventory) | 3824 | m_host.TaskInventory.LockItemsForRead(true); |
3825 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3763 | { | 3826 | { |
3764 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3827 | if (item.Name == name) |
3765 | { | 3828 | { |
3766 | if (item.Name == name) | 3829 | if (item.ItemID == m_itemID) |
3767 | { | 3830 | throw new ScriptDeleteException(); |
3768 | if (item.ItemID == m_itemID) | 3831 | else |
3769 | throw new ScriptDeleteException(); | 3832 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3770 | else | 3833 | |
3771 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3834 | m_host.TaskInventory.LockItemsForRead(false); |
3772 | return; | 3835 | return; |
3773 | } | ||
3774 | } | 3836 | } |
3775 | } | 3837 | } |
3838 | m_host.TaskInventory.LockItemsForRead(false); | ||
3776 | } | 3839 | } |
3777 | 3840 | ||
3778 | public void llSetText(string text, LSL_Vector color, double alpha) | 3841 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3861,6 +3924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3861 | { | 3924 | { |
3862 | m_host.AddScriptLPS(1); | 3925 | m_host.AddScriptLPS(1); |
3863 | 3926 | ||
3927 | //Clone is thread safe | ||
3864 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3928 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3865 | 3929 | ||
3866 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3930 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3951,17 +4015,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3951 | UUID soundId = UUID.Zero; | 4015 | UUID soundId = UUID.Zero; |
3952 | if (!UUID.TryParse(impact_sound, out soundId)) | 4016 | if (!UUID.TryParse(impact_sound, out soundId)) |
3953 | { | 4017 | { |
3954 | lock (m_host.TaskInventory) | 4018 | m_host.TaskInventory.LockItemsForRead(true); |
4019 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3955 | { | 4020 | { |
3956 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4021 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3957 | { | 4022 | { |
3958 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4023 | soundId = item.AssetID; |
3959 | { | 4024 | break; |
3960 | soundId = item.AssetID; | ||
3961 | break; | ||
3962 | } | ||
3963 | } | 4025 | } |
3964 | } | 4026 | } |
4027 | m_host.TaskInventory.LockItemsForRead(false); | ||
3965 | } | 4028 | } |
3966 | m_host.CollisionSound = soundId; | 4029 | m_host.CollisionSound = soundId; |
3967 | m_host.CollisionSoundVolume = (float)impact_volume; | 4030 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4007,6 +4070,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4007 | UUID partItemID; | 4070 | UUID partItemID; |
4008 | foreach (SceneObjectPart part in parts) | 4071 | foreach (SceneObjectPart part in parts) |
4009 | { | 4072 | { |
4073 | //Clone is thread safe | ||
4010 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4074 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4011 | 4075 | ||
4012 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4076 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4214,17 +4278,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4214 | 4278 | ||
4215 | m_host.AddScriptLPS(1); | 4279 | m_host.AddScriptLPS(1); |
4216 | 4280 | ||
4217 | lock (m_host.TaskInventory) | 4281 | m_host.TaskInventory.LockItemsForRead(true); |
4282 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4218 | { | 4283 | { |
4219 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4284 | if (item.Type == 10 && item.ItemID == m_itemID) |
4220 | { | 4285 | { |
4221 | if (item.Type == 10 && item.ItemID == m_itemID) | 4286 | result = item.Name!=null?item.Name:String.Empty; |
4222 | { | 4287 | break; |
4223 | result = item.Name!=null?item.Name:String.Empty; | ||
4224 | break; | ||
4225 | } | ||
4226 | } | 4288 | } |
4227 | } | 4289 | } |
4290 | m_host.TaskInventory.LockItemsForRead(false); | ||
4228 | 4291 | ||
4229 | return result; | 4292 | return result; |
4230 | } | 4293 | } |
@@ -4482,23 +4545,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4482 | { | 4545 | { |
4483 | m_host.AddScriptLPS(1); | 4546 | m_host.AddScriptLPS(1); |
4484 | 4547 | ||
4485 | lock (m_host.TaskInventory) | 4548 | m_host.TaskInventory.LockItemsForRead(true); |
4549 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4486 | { | 4550 | { |
4487 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4551 | if (inv.Value.Name == name) |
4488 | { | 4552 | { |
4489 | if (inv.Value.Name == name) | 4553 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4490 | { | 4554 | { |
4491 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4555 | m_host.TaskInventory.LockItemsForRead(false); |
4492 | { | 4556 | return inv.Value.AssetID.ToString(); |
4493 | return inv.Value.AssetID.ToString(); | 4557 | } |
4494 | } | 4558 | else |
4495 | else | 4559 | { |
4496 | { | 4560 | m_host.TaskInventory.LockItemsForRead(false); |
4497 | return UUID.Zero.ToString(); | 4561 | return UUID.Zero.ToString(); |
4498 | } | ||
4499 | } | 4562 | } |
4500 | } | 4563 | } |
4501 | } | 4564 | } |
4565 | m_host.TaskInventory.LockItemsForRead(false); | ||
4502 | 4566 | ||
4503 | return UUID.Zero.ToString(); | 4567 | return UUID.Zero.ToString(); |
4504 | } | 4568 | } |
@@ -5776,6 +5840,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5776 | m_host.AddScriptLPS(1); | 5840 | m_host.AddScriptLPS(1); |
5777 | return World.SimulatorFPS; | 5841 | return World.SimulatorFPS; |
5778 | } | 5842 | } |
5843 | |||
5779 | 5844 | ||
5780 | /* particle system rules should be coming into this routine as doubles, that is | 5845 | /* particle system rules should be coming into this routine as doubles, that is |
5781 | rule[0] should be an integer from this list and rule[1] should be the arg | 5846 | rule[0] should be an integer from this list and rule[1] should be the arg |
@@ -5993,14 +6058,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5993 | 6058 | ||
5994 | protected UUID GetTaskInventoryItem(string name) | 6059 | protected UUID GetTaskInventoryItem(string name) |
5995 | { | 6060 | { |
5996 | lock (m_host.TaskInventory) | 6061 | m_host.TaskInventory.LockItemsForRead(true); |
6062 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
5997 | { | 6063 | { |
5998 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6064 | if (inv.Value.Name == name) |
5999 | { | 6065 | { |
6000 | if (inv.Value.Name == name) | 6066 | m_host.TaskInventory.LockItemsForRead(false); |
6001 | return inv.Key; | 6067 | return inv.Key; |
6002 | } | 6068 | } |
6003 | } | 6069 | } |
6070 | m_host.TaskInventory.LockItemsForRead(false); | ||
6004 | 6071 | ||
6005 | return UUID.Zero; | 6072 | return UUID.Zero; |
6006 | } | 6073 | } |
@@ -6311,22 +6378,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6311 | } | 6378 | } |
6312 | 6379 | ||
6313 | // copy the first script found with this inventory name | 6380 | // copy the first script found with this inventory name |
6314 | lock (m_host.TaskInventory) | 6381 | m_host.TaskInventory.LockItemsForRead(true); |
6382 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6315 | { | 6383 | { |
6316 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6384 | if (inv.Value.Name == name) |
6317 | { | 6385 | { |
6318 | if (inv.Value.Name == name) | 6386 | // make sure the object is a script |
6387 | if (10 == inv.Value.Type) | ||
6319 | { | 6388 | { |
6320 | // make sure the object is a script | 6389 | found = true; |
6321 | if (10 == inv.Value.Type) | 6390 | srcId = inv.Key; |
6322 | { | 6391 | break; |
6323 | found = true; | ||
6324 | srcId = inv.Key; | ||
6325 | break; | ||
6326 | } | ||
6327 | } | 6392 | } |
6328 | } | 6393 | } |
6329 | } | 6394 | } |
6395 | m_host.TaskInventory.LockItemsForRead(false); | ||
6330 | 6396 | ||
6331 | if (!found) | 6397 | if (!found) |
6332 | { | 6398 | { |
@@ -8129,28 +8195,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8129 | { | 8195 | { |
8130 | m_host.AddScriptLPS(1); | 8196 | m_host.AddScriptLPS(1); |
8131 | 8197 | ||
8132 | lock (m_host.TaskInventory) | 8198 | m_host.TaskInventory.LockItemsForRead(true); |
8199 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8133 | { | 8200 | { |
8134 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8201 | if (inv.Value.Name == item) |
8135 | { | 8202 | { |
8136 | if (inv.Value.Name == item) | 8203 | m_host.TaskInventory.LockItemsForRead(false); |
8204 | switch (mask) | ||
8137 | { | 8205 | { |
8138 | switch (mask) | 8206 | case 0: |
8139 | { | 8207 | return (int)inv.Value.BasePermissions; |
8140 | case 0: | 8208 | case 1: |
8141 | return (int)inv.Value.BasePermissions; | 8209 | return (int)inv.Value.CurrentPermissions; |
8142 | case 1: | 8210 | case 2: |
8143 | return (int)inv.Value.CurrentPermissions; | 8211 | return (int)inv.Value.GroupPermissions; |
8144 | case 2: | 8212 | case 3: |
8145 | return (int)inv.Value.GroupPermissions; | 8213 | return (int)inv.Value.EveryonePermissions; |
8146 | case 3: | 8214 | case 4: |
8147 | return (int)inv.Value.EveryonePermissions; | 8215 | return (int)inv.Value.NextPermissions; |
8148 | case 4: | ||
8149 | return (int)inv.Value.NextPermissions; | ||
8150 | } | ||
8151 | } | 8216 | } |
8152 | } | 8217 | } |
8153 | } | 8218 | } |
8219 | m_host.TaskInventory.LockItemsForRead(false); | ||
8154 | 8220 | ||
8155 | return -1; | 8221 | return -1; |
8156 | } | 8222 | } |
@@ -8165,16 +8231,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8165 | { | 8231 | { |
8166 | m_host.AddScriptLPS(1); | 8232 | m_host.AddScriptLPS(1); |
8167 | 8233 | ||
8168 | lock (m_host.TaskInventory) | 8234 | m_host.TaskInventory.LockItemsForRead(true); |
8235 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8169 | { | 8236 | { |
8170 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8237 | if (inv.Value.Name == item) |
8171 | { | 8238 | { |
8172 | if (inv.Value.Name == item) | 8239 | m_host.TaskInventory.LockItemsForRead(false); |
8173 | { | 8240 | return inv.Value.CreatorID.ToString(); |
8174 | return inv.Value.CreatorID.ToString(); | ||
8175 | } | ||
8176 | } | 8241 | } |
8177 | } | 8242 | } |
8243 | m_host.TaskInventory.LockItemsForRead(false); | ||
8178 | 8244 | ||
8179 | llSay(0, "No item name '" + item + "'"); | 8245 | llSay(0, "No item name '" + item + "'"); |
8180 | 8246 | ||
@@ -8698,16 +8764,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8698 | { | 8764 | { |
8699 | m_host.AddScriptLPS(1); | 8765 | m_host.AddScriptLPS(1); |
8700 | 8766 | ||
8701 | lock (m_host.TaskInventory) | 8767 | m_host.TaskInventory.LockItemsForRead(true); |
8768 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8702 | { | 8769 | { |
8703 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8770 | if (inv.Value.Name == name) |
8704 | { | 8771 | { |
8705 | if (inv.Value.Name == name) | 8772 | m_host.TaskInventory.LockItemsForRead(false); |
8706 | { | 8773 | return inv.Value.Type; |
8707 | return inv.Value.Type; | ||
8708 | } | ||
8709 | } | 8774 | } |
8710 | } | 8775 | } |
8776 | m_host.TaskInventory.LockItemsForRead(false); | ||
8711 | 8777 | ||
8712 | return -1; | 8778 | return -1; |
8713 | } | 8779 | } |
@@ -8738,17 +8804,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8738 | if (invItemID == UUID.Zero) | 8804 | if (invItemID == UUID.Zero) |
8739 | return new LSL_Vector(); | 8805 | return new LSL_Vector(); |
8740 | 8806 | ||
8741 | lock (m_host.TaskInventory) | 8807 | m_host.TaskInventory.LockItemsForRead(true); |
8808 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8742 | { | 8809 | { |
8743 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8810 | m_host.TaskInventory.LockItemsForRead(false); |
8744 | return new LSL_Vector(); | 8811 | return new LSL_Vector(); |
8812 | } | ||
8745 | 8813 | ||
8746 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8814 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8747 | { | 8815 | { |
8748 | ShoutError("No permissions to track the camera"); | 8816 | ShoutError("No permissions to track the camera"); |
8749 | return new LSL_Vector(); | 8817 | m_host.TaskInventory.LockItemsForRead(false); |
8750 | } | 8818 | return new LSL_Vector(); |
8751 | } | 8819 | } |
8820 | m_host.TaskInventory.LockItemsForRead(false); | ||
8752 | 8821 | ||
8753 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8822 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8754 | if (presence != null) | 8823 | if (presence != null) |
@@ -8766,17 +8835,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8766 | if (invItemID == UUID.Zero) | 8835 | if (invItemID == UUID.Zero) |
8767 | return new LSL_Rotation(); | 8836 | return new LSL_Rotation(); |
8768 | 8837 | ||
8769 | lock (m_host.TaskInventory) | 8838 | m_host.TaskInventory.LockItemsForRead(true); |
8839 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8770 | { | 8840 | { |
8771 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8841 | m_host.TaskInventory.LockItemsForRead(false); |
8772 | return new LSL_Rotation(); | 8842 | return new LSL_Rotation(); |
8773 | 8843 | } | |
8774 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8844 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8775 | { | 8845 | { |
8776 | ShoutError("No permissions to track the camera"); | 8846 | ShoutError("No permissions to track the camera"); |
8777 | return new LSL_Rotation(); | 8847 | m_host.TaskInventory.LockItemsForRead(false); |
8778 | } | 8848 | return new LSL_Rotation(); |
8779 | } | 8849 | } |
8850 | m_host.TaskInventory.LockItemsForRead(false); | ||
8780 | 8851 | ||
8781 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8852 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8782 | if (presence != null) | 8853 | if (presence != null) |
@@ -8926,14 +8997,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8926 | if (objectID == UUID.Zero) return; | 8997 | if (objectID == UUID.Zero) return; |
8927 | 8998 | ||
8928 | UUID agentID; | 8999 | UUID agentID; |
8929 | lock (m_host.TaskInventory) | 9000 | m_host.TaskInventory.LockItemsForRead(true); |
8930 | { | 9001 | // we need the permission first, to know which avatar we want to set the camera for |
8931 | // we need the permission first, to know which avatar we want to set the camera for | 9002 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8932 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8933 | 9003 | ||
8934 | if (agentID == UUID.Zero) return; | 9004 | if (agentID == UUID.Zero) |
8935 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9005 | { |
9006 | m_host.TaskInventory.LockItemsForRead(false); | ||
9007 | return; | ||
9008 | } | ||
9009 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9010 | { | ||
9011 | m_host.TaskInventory.LockItemsForRead(false); | ||
9012 | return; | ||
8936 | } | 9013 | } |
9014 | m_host.TaskInventory.LockItemsForRead(false); | ||
8937 | 9015 | ||
8938 | ScenePresence presence = World.GetScenePresence(agentID); | 9016 | ScenePresence presence = World.GetScenePresence(agentID); |
8939 | 9017 | ||
@@ -8983,12 +9061,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8983 | 9061 | ||
8984 | // 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 |
8985 | UUID agentID; | 9063 | UUID agentID; |
8986 | lock (m_host.TaskInventory) | 9064 | m_host.TaskInventory.LockItemsForRead(true); |
9065 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9066 | if (agentID == UUID.Zero) | ||
8987 | { | 9067 | { |
8988 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9068 | m_host.TaskInventory.LockItemsForRead(false); |
8989 | if (agentID == UUID.Zero) return; | 9069 | return; |
8990 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
8991 | } | 9070 | } |
9071 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9072 | { | ||
9073 | m_host.TaskInventory.LockItemsForRead(false); | ||
9074 | return; | ||
9075 | } | ||
9076 | m_host.TaskInventory.LockItemsForRead(false); | ||
8992 | 9077 | ||
8993 | ScenePresence presence = World.GetScenePresence(agentID); | 9078 | ScenePresence presence = World.GetScenePresence(agentID); |
8994 | 9079 | ||
@@ -9445,15 +9530,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9445 | 9530 | ||
9446 | internal UUID ScriptByName(string name) | 9531 | internal UUID ScriptByName(string name) |
9447 | { | 9532 | { |
9448 | lock (m_host.TaskInventory) | 9533 | m_host.TaskInventory.LockItemsForRead(true); |
9534 | |||
9535 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9449 | { | 9536 | { |
9450 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9537 | if (item.Type == 10 && item.Name == name) |
9451 | { | 9538 | { |
9452 | if (item.Type == 10 && item.Name == name) | 9539 | m_host.TaskInventory.LockItemsForRead(false); |
9453 | return item.ItemID; | 9540 | return item.ItemID; |
9454 | } | 9541 | } |
9455 | } | 9542 | } |
9456 | 9543 | ||
9544 | m_host.TaskInventory.LockItemsForRead(false); | ||
9545 | |||
9457 | return UUID.Zero; | 9546 | return UUID.Zero; |
9458 | } | 9547 | } |
9459 | 9548 | ||
@@ -9494,6 +9583,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9494 | { | 9583 | { |
9495 | m_host.AddScriptLPS(1); | 9584 | m_host.AddScriptLPS(1); |
9496 | 9585 | ||
9586 | //Clone is thread safe | ||
9497 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9587 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9498 | 9588 | ||
9499 | UUID assetID = UUID.Zero; | 9589 | UUID assetID = UUID.Zero; |
@@ -9556,6 +9646,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9556 | { | 9646 | { |
9557 | m_host.AddScriptLPS(1); | 9647 | m_host.AddScriptLPS(1); |
9558 | 9648 | ||
9649 | //Clone is thread safe | ||
9559 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9650 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9560 | 9651 | ||
9561 | 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 7fdbac8..7f739b1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
636 | } | 636 | } |
637 | 637 | ||
638 | // Teleport functions | 638 | // Teleport functions |
639 | public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 639 | public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |
640 | { | 640 | { |
641 | // High because there is no security check. High griefer potential | 641 | // High because there is no security check. High griefer potential |
642 | // | 642 | // |
643 | CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); | 643 | CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); |
644 | 644 | ||
645 | ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize)); | 645 | ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); |
646 | 646 | ||
647 | m_host.AddScriptLPS(1); | 647 | m_host.AddScriptLPS(1); |
648 | UUID agentId = new UUID(); | 648 | UUID agentId = new UUID(); |
@@ -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) |
@@ -1948,5 +1952,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1948 | 1952 | ||
1949 | return key.ToString(); | 1953 | return key.ToString(); |
1950 | } | 1954 | } |
1955 | |||
1956 | /// <summary> | ||
1957 | /// Return information regarding various simulator statistics (sim fps, physics fps, time | ||
1958 | /// dilation, total number of prims, total number of active scripts, script lps, various | ||
1959 | /// timing data, packets in/out, etc. Basically much the information that's shown in the | ||
1960 | /// client's Statistics Bar (Ctrl-Shift-1) | ||
1961 | /// </summary> | ||
1962 | /// <returns>List of floats</returns> | ||
1963 | public LSL_List osGetRegionStats() | ||
1964 | { | ||
1965 | CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats"); | ||
1966 | m_host.AddScriptLPS(1); | ||
1967 | LSL_List ret = new LSL_List(); | ||
1968 | float[] stats = World.SimulatorStats; | ||
1969 | |||
1970 | for (int i = 0; i < 21; i++) | ||
1971 | { | ||
1972 | ret.Add(new LSL_Float( stats[i] )); | ||
1973 | } | ||
1974 | return ret; | ||
1975 | } | ||
1976 | |||
1951 | } | 1977 | } |
1952 | } | 1978 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2a403bf..0b0dc00 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
86 | void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
87 | void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 87 | void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
88 | 88 | ||
89 | // Animation commands | 89 | // Animation commands |
@@ -162,5 +162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
162 | 162 | ||
163 | key osGetMapTexture(); | 163 | key osGetMapTexture(); |
164 | key osGetRegionMapTexture(string regionName); | 164 | key osGetRegionMapTexture(string regionName); |
165 | LSL_List osGetRegionStats(); | ||
165 | } | 166 | } |
166 | } | 167 | } |
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/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 753ca55..acff8fb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -515,6 +515,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
515 | public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f"; | 515 | public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f"; |
516 | public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"; | 516 | public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"; |
517 | public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"; | 517 | public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"; |
518 | |||
519 | // Constants for osGetRegionStats | ||
520 | public const int STATS_TIME_DILATION = 0; | ||
521 | public const int STATS_SIM_FPS = 1; | ||
522 | public const int STATS_PHYSICS_FPS = 2; | ||
523 | public const int STATS_AGENT_UPDATES = 3; | ||
524 | public const int STATS_ROOT_AGENTS = 4; | ||
525 | public const int STATS_CHILD_AGENTS = 5; | ||
526 | public const int STATS_TOTAL_PRIMS = 6; | ||
527 | public const int STATS_ACTIVE_PRIMS = 7; | ||
528 | public const int STATS_FRAME_MS = 8; | ||
529 | public const int STATS_NET_MS = 9; | ||
530 | public const int STATS_PHYSICS_MS = 10; | ||
531 | public const int STATS_IMAGE_MS = 11; | ||
532 | public const int STATS_OTHER_MS = 12; | ||
533 | public const int STATS_IN_PACKETS_PER_SECOND = 13; | ||
534 | public const int STATS_OUT_PACKETS_PER_SECOND = 14; | ||
535 | public const int STATS_UNACKED_BYTES = 15; | ||
536 | public const int STATS_AGENT_MS = 16; | ||
537 | public const int STATS_PENDING_DOWNLOADS = 17; | ||
538 | public const int STATS_PENDING_UPLOADS = 18; | ||
539 | public const int STATS_ACTIVE_SCRIPTS = 19; | ||
540 | public const int STATS_SCRIPT_LPS = 20; | ||
518 | 541 | ||
519 | } | 542 | } |
520 | } | 543 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4928e90..519463e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
201 | m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat); | 201 | m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat); |
202 | } | 202 | } |
203 | 203 | ||
204 | public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat) | 204 | public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat) |
205 | { | 205 | { |
206 | m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat); | 206 | m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat); |
207 | } | 207 | } |
208 | 208 | ||
209 | public void osTeleportAgent(string agent, vector position, vector lookat) | 209 | public void osTeleportAgent(string agent, vector position, vector lookat) |
@@ -632,5 +632,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
632 | { | 632 | { |
633 | return m_OSSL_Functions.osGetRegionMapTexture(regionName); | 633 | return m_OSSL_Functions.osGetRegionMapTexture(regionName); |
634 | } | 634 | } |
635 | |||
636 | public LSL_List osGetRegionStats() | ||
637 | { | ||
638 | return m_OSSL_Functions.osGetRegionStats(); | ||
639 | } | ||
635 | } | 640 | } |
636 | } | 641 | } |
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 41b5d49..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 | |||
674 | m_DetectParams = data.DetectParams; | ||
675 | 663 | ||
676 | if (data.EventName == "state") // Hardcoded state change | 664 | if (data.EventName == "timer") |
665 | m_TimerQueued = false; | ||
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 | { | ||
777 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
778 | } | ||
779 | else | ||
780 | { | ||
781 | m_CurrentResult = null; | ||
782 | } | ||
783 | } | 784 | } |
785 | else | ||
786 | { | ||
787 | m_CurrentResult = null; | ||
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; |
@@ -1011,10 +1018,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1011 | { | 1018 | { |
1012 | get { return m_RegionID; } | 1019 | get { return m_RegionID; } |
1013 | } | 1020 | } |
1014 | |||
1015 | public bool CanBeDeleted() | ||
1016 | { | ||
1017 | return true; | ||
1018 | } | ||
1019 | } | 1021 | } |
1020 | } | 1022 | } |
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 { |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a60c0ba..2fc2ea1 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Reflection; |
@@ -1119,6 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1119 | return false; | 1120 | return false; |
1120 | } | 1121 | } |
1121 | 1122 | ||
1123 | [DebuggerNonUserCode] | ||
1122 | public void ApiResetScript(UUID itemID) | 1124 | public void ApiResetScript(UUID itemID) |
1123 | { | 1125 | { |
1124 | IScriptInstance instance = GetInstance(itemID); | 1126 | IScriptInstance instance = GetInstance(itemID); |
@@ -1170,6 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1170 | return UUID.Zero; | 1172 | return UUID.Zero; |
1171 | } | 1173 | } |
1172 | 1174 | ||
1175 | [DebuggerNonUserCode] | ||
1173 | public void SetState(UUID itemID, string newState) | 1176 | public void SetState(UUID itemID, string newState) |
1174 | { | 1177 | { |
1175 | IScriptInstance instance = GetInstance(itemID); | 1178 | IScriptInstance instance = GetInstance(itemID); |
@@ -1245,34 +1248,219 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1245 | } | 1248 | } |
1246 | } | 1249 | } |
1247 | 1250 | ||
1248 | public string GetAssemblyName(UUID itemID) | ||
1249 | { | ||
1250 | IScriptInstance instance = GetInstance(itemID); | ||
1251 | if (instance == null) | ||
1252 | return ""; | ||
1253 | return instance.GetAssemblyName(); | ||
1254 | } | ||
1255 | |||
1256 | public string GetXMLState(UUID itemID) | 1251 | public string GetXMLState(UUID itemID) |
1257 | { | 1252 | { |
1258 | IScriptInstance instance = GetInstance(itemID); | 1253 | IScriptInstance instance = GetInstance(itemID); |
1259 | if (instance == null) | 1254 | if (instance == null) |
1260 | return ""; | 1255 | return ""; |
1261 | return instance.GetXMLState(); | 1256 | string xml = instance.GetXMLState(); |
1262 | } | ||
1263 | 1257 | ||
1264 | public bool CanBeDeleted(UUID itemID) | 1258 | XmlDocument sdoc = new XmlDocument(); |
1265 | { | 1259 | sdoc.LoadXml(xml); |
1266 | IScriptInstance instance = GetInstance(itemID); | 1260 | XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); |
1267 | if (instance == null) | 1261 | XmlNode rootNode = rootL[0]; |
1268 | return true; | 1262 | |
1263 | // Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"> | ||
1264 | XmlDocument doc = new XmlDocument(); | ||
1265 | XmlElement stateData = doc.CreateElement("", "State", ""); | ||
1266 | XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); | ||
1267 | stateID.Value = itemID.ToString(); | ||
1268 | stateData.Attributes.Append(stateID); | ||
1269 | XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); | ||
1270 | assetID.Value = instance.AssetID.ToString(); | ||
1271 | stateData.Attributes.Append(assetID); | ||
1272 | doc.AppendChild(stateData); | ||
1273 | |||
1274 | // Add <ScriptState>...</ScriptState> | ||
1275 | XmlNode xmlstate = doc.ImportNode(rootNode, true); | ||
1276 | stateData.AppendChild(xmlstate); | ||
1277 | |||
1278 | string assemName = instance.GetAssemblyName(); | ||
1279 | |||
1280 | string fn = Path.GetFileName(assemName); | ||
1281 | |||
1282 | string assem = String.Empty; | ||
1283 | |||
1284 | if (File.Exists(assemName + ".text")) | ||
1285 | { | ||
1286 | FileInfo tfi = new FileInfo(assemName + ".text"); | ||
1287 | |||
1288 | if (tfi != null) | ||
1289 | { | ||
1290 | Byte[] tdata = new Byte[tfi.Length]; | ||
1291 | |||
1292 | try | ||
1293 | { | ||
1294 | FileStream tfs = File.Open(assemName + ".text", | ||
1295 | FileMode.Open, FileAccess.Read); | ||
1296 | tfs.Read(tdata, 0, tdata.Length); | ||
1297 | tfs.Close(); | ||
1298 | |||
1299 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | ||
1300 | } | ||
1301 | catch (Exception e) | ||
1302 | { | ||
1303 | m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); | ||
1304 | } | ||
1305 | } | ||
1306 | } | ||
1307 | else | ||
1308 | { | ||
1309 | FileInfo fi = new FileInfo(assemName); | ||
1310 | |||
1311 | if (fi != null) | ||
1312 | { | ||
1313 | Byte[] data = new Byte[fi.Length]; | ||
1314 | |||
1315 | try | ||
1316 | { | ||
1317 | FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); | ||
1318 | fs.Read(data, 0, data.Length); | ||
1319 | fs.Close(); | ||
1320 | |||
1321 | assem = System.Convert.ToBase64String(data); | ||
1322 | } | ||
1323 | catch (Exception e) | ||
1324 | { | ||
1325 | m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); | ||
1326 | } | ||
1327 | |||
1328 | } | ||
1329 | } | ||
1330 | |||
1331 | string map = String.Empty; | ||
1332 | |||
1333 | if (File.Exists(fn + ".map")) | ||
1334 | { | ||
1335 | FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); | ||
1336 | StreamReader msr = new StreamReader(mfs); | ||
1337 | |||
1338 | map = msr.ReadToEnd(); | ||
1339 | |||
1340 | msr.Close(); | ||
1341 | mfs.Close(); | ||
1342 | } | ||
1343 | |||
1344 | XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); | ||
1345 | XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); | ||
1346 | |||
1347 | assemblyName.Value = fn; | ||
1348 | assemblyData.Attributes.Append(assemblyName); | ||
1349 | |||
1350 | assemblyData.InnerText = assem; | ||
1351 | |||
1352 | stateData.AppendChild(assemblyData); | ||
1269 | 1353 | ||
1270 | return instance.CanBeDeleted(); | 1354 | XmlElement mapData = doc.CreateElement("", "LineMap", ""); |
1355 | XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); | ||
1356 | |||
1357 | mapName.Value = fn + ".map"; | ||
1358 | mapData.Attributes.Append(mapName); | ||
1359 | |||
1360 | mapData.InnerText = map; | ||
1361 | |||
1362 | stateData.AppendChild(mapData); | ||
1363 | return doc.InnerXml; | ||
1271 | } | 1364 | } |
1272 | 1365 | ||
1273 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) | 1366 | private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) |
1274 | { | 1367 | { |
1275 | return false; | 1368 | return false; |
1276 | } | 1369 | } |
1370 | |||
1371 | public void SetXMLState(UUID itemID, string xml) | ||
1372 | { | ||
1373 | if (xml == String.Empty) | ||
1374 | return; | ||
1375 | |||
1376 | XmlDocument doc = new XmlDocument(); | ||
1377 | |||
1378 | try | ||
1379 | { | ||
1380 | doc.LoadXml(xml); | ||
1381 | } | ||
1382 | catch (Exception) | ||
1383 | { | ||
1384 | m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); | ||
1385 | return; | ||
1386 | } | ||
1387 | |||
1388 | XmlNodeList rootL = doc.GetElementsByTagName("State"); | ||
1389 | if (rootL.Count < 1) | ||
1390 | return; | ||
1391 | |||
1392 | XmlElement rootE = (XmlElement)rootL[0]; | ||
1393 | |||
1394 | if (rootE.GetAttribute("UUID") != itemID.ToString()) | ||
1395 | return; | ||
1396 | |||
1397 | string assetID = rootE.GetAttribute("Asset"); | ||
1398 | |||
1399 | XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); | ||
1400 | |||
1401 | if (stateL.Count != 1) | ||
1402 | return; | ||
1403 | |||
1404 | XmlElement stateE = (XmlElement)stateL[0]; | ||
1405 | |||
1406 | if (World.m_trustBinaries) | ||
1407 | { | ||
1408 | XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); | ||
1409 | |||
1410 | if (assemL.Count != 1) | ||
1411 | return; | ||
1412 | |||
1413 | XmlElement assemE = (XmlElement)assemL[0]; | ||
1414 | |||
1415 | string fn = assemE.GetAttribute("Filename"); | ||
1416 | string base64 = assemE.InnerText; | ||
1417 | |||
1418 | string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1419 | path = Path.Combine(path, fn); | ||
1420 | |||
1421 | if (!File.Exists(path)) | ||
1422 | { | ||
1423 | Byte[] filedata = Convert.FromBase64String(base64); | ||
1424 | |||
1425 | FileStream fs = File.Create(path); | ||
1426 | fs.Write(filedata, 0, filedata.Length); | ||
1427 | fs.Close(); | ||
1428 | |||
1429 | fs = File.Create(path + ".text"); | ||
1430 | StreamWriter sw = new StreamWriter(fs); | ||
1431 | |||
1432 | sw.Write(base64); | ||
1433 | |||
1434 | sw.Close(); | ||
1435 | fs.Close(); | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1439 | string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1440 | statepath = Path.Combine(statepath, itemID.ToString() + ".state"); | ||
1441 | |||
1442 | FileStream sfs = File.Create(statepath); | ||
1443 | StreamWriter ssw = new StreamWriter(sfs); | ||
1444 | |||
1445 | ssw.Write(stateE.OuterXml); | ||
1446 | |||
1447 | ssw.Close(); | ||
1448 | sfs.Close(); | ||
1449 | |||
1450 | XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); | ||
1451 | |||
1452 | XmlElement mapE = (XmlElement)mapL[0]; | ||
1453 | |||
1454 | string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); | ||
1455 | mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); | ||
1456 | |||
1457 | FileStream mfs = File.Create(mappath); | ||
1458 | StreamWriter msw = new StreamWriter(mfs); | ||
1459 | |||
1460 | msw.Write(mapE.InnerText); | ||
1461 | |||
1462 | msw.Close(); | ||
1463 | mfs.Close(); | ||
1464 | } | ||
1277 | } | 1465 | } |
1278 | } | 1466 | } |