diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index 641453e..d47cab8 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs | |||
@@ -67,6 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
67 | private Queue<LUStruct> LUQueue = new Queue<LUStruct>(); | 67 | private Queue<LUStruct> LUQueue = new Queue<LUStruct>(); |
68 | private static bool PrivateThread; | 68 | private static bool PrivateThread; |
69 | private int LoadUnloadMaxQueueSize; | 69 | private int LoadUnloadMaxQueueSize; |
70 | private Object scriptLock = new Object(); | ||
70 | 71 | ||
71 | // Load/Unload structure | 72 | // Load/Unload structure |
72 | private struct LUStruct | 73 | private struct LUStruct |
@@ -304,7 +305,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
304 | //ScriptBaseInterface Script = (ScriptBaseInterface)GetScript(localID, itemID); | 305 | //ScriptBaseInterface Script = (ScriptBaseInterface)GetScript(localID, itemID); |
305 | IScript Script = GetScript(localID, itemID); | 306 | IScript Script = GetScript(localID, itemID); |
306 | if (Script == null) | 307 | if (Script == null) |
308 | { | ||
307 | return; | 309 | return; |
310 | } | ||
308 | //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined | 311 | //cfk 2-7-08 dont need this right now and the default Linux build has DEBUG defined |
309 | ///#if DEBUG | 312 | ///#if DEBUG |
310 | /// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); | 313 | /// Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); |
@@ -331,37 +334,42 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase | |||
331 | 334 | ||
332 | public IScript GetScript(uint localID, LLUUID itemID) | 335 | public IScript GetScript(uint localID, LLUUID itemID) |
333 | { | 336 | { |
334 | if (Scripts.ContainsKey(localID) == false) | 337 | lock (scriptLock) |
335 | return null; | 338 | { |
336 | 339 | if (Scripts.ContainsKey(localID) == false) | |
337 | Dictionary<LLUUID, IScript> Obj; | 340 | return null; |
338 | Scripts.TryGetValue(localID, out Obj); | 341 | |
339 | if (Obj.ContainsKey(itemID) == false) | 342 | Dictionary<LLUUID, IScript> Obj; |
340 | return null; | 343 | Scripts.TryGetValue(localID, out Obj); |
341 | 344 | if (Obj.ContainsKey(itemID) == false) | |
342 | // Get script | 345 | return null; |
343 | IScript Script; | 346 | |
344 | Obj.TryGetValue(itemID, out Script); | 347 | // Get script |
345 | 348 | IScript Script; | |
346 | return Script; | 349 | Obj.TryGetValue(itemID, out Script); |
350 | return Script; | ||
351 | } | ||
347 | } | 352 | } |
348 | 353 | ||
349 | public void SetScript(uint localID, LLUUID itemID, IScript Script) | 354 | public void SetScript(uint localID, LLUUID itemID, IScript Script) |
350 | { | 355 | { |
351 | // Create object if it doesn't exist | 356 | lock (scriptLock) |
352 | if (Scripts.ContainsKey(localID) == false) | ||
353 | { | 357 | { |
354 | Scripts.Add(localID, new Dictionary<LLUUID, IScript>()); | 358 | // Create object if it doesn't exist |
355 | } | 359 | if (Scripts.ContainsKey(localID) == false) |
360 | { | ||
361 | Scripts.Add(localID, new Dictionary<LLUUID, IScript>()); | ||
362 | } | ||
356 | 363 | ||
357 | // Delete script if it exists | 364 | // Delete script if it exists |
358 | Dictionary<LLUUID, IScript> Obj; | 365 | Dictionary<LLUUID, IScript> Obj; |
359 | Scripts.TryGetValue(localID, out Obj); | 366 | Scripts.TryGetValue(localID, out Obj); |
360 | if (Obj.ContainsKey(itemID) == true) | 367 | if (Obj.ContainsKey(itemID) == true) |
361 | Obj.Remove(itemID); | 368 | Obj.Remove(itemID); |
362 | 369 | ||
363 | // Add to object | 370 | // Add to object |
364 | Obj.Add(itemID, Script); | 371 | Obj.Add(itemID, Script); |
372 | } | ||
365 | } | 373 | } |
366 | 374 | ||
367 | public void RemoveScript(uint localID, LLUUID itemID) | 375 | public void RemoveScript(uint localID, LLUUID itemID) |