diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 968351b..f40da01 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; |
@@ -204,13 +205,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
204 | 205 | ||
205 | if (part != null) | 206 | if (part != null) |
206 | { | 207 | { |
207 | lock (part.TaskInventory) | 208 | part.TaskInventory.LockItemsForRead(true); |
209 | if (part.TaskInventory.ContainsKey(ItemID)) | ||
208 | { | 210 | { |
209 | if (part.TaskInventory.ContainsKey(ItemID)) | 211 | ScriptTask = part.TaskInventory[ItemID]; |
210 | { | ||
211 | ScriptTask = part.TaskInventory[ItemID]; | ||
212 | } | ||
213 | } | 212 | } |
213 | part.TaskInventory.LockItemsForRead(false); | ||
214 | } | 214 | } |
215 | 215 | ||
216 | ApiManager am = new ApiManager(); | 216 | ApiManager am = new ApiManager(); |
@@ -402,14 +402,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
402 | { | 402 | { |
403 | int permsMask; | 403 | int permsMask; |
404 | UUID permsGranter; | 404 | UUID permsGranter; |
405 | lock (part.TaskInventory) | 405 | part.TaskInventory.LockItemsForRead(true); |
406 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
406 | { | 407 | { |
407 | if (!part.TaskInventory.ContainsKey(ItemID)) | 408 | part.TaskInventory.LockItemsForRead(false); |
408 | return; | 409 | return; |
409 | |||
410 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
411 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
412 | } | 410 | } |
411 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
412 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
413 | part.TaskInventory.LockItemsForRead(false); | ||
413 | 414 | ||
414 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 415 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
415 | { | 416 | { |
@@ -533,6 +534,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
533 | return true; | 534 | return true; |
534 | } | 535 | } |
535 | 536 | ||
537 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
536 | public void SetState(string state) | 538 | public void SetState(string state) |
537 | { | 539 | { |
538 | if (state == State) | 540 | if (state == State) |
@@ -544,7 +546,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
544 | new DetectParams[0])); | 546 | new DetectParams[0])); |
545 | PostEvent(new EventParams("state_entry", new Object[0], | 547 | PostEvent(new EventParams("state_entry", new Object[0], |
546 | new DetectParams[0])); | 548 | new DetectParams[0])); |
547 | 549 | ||
548 | throw new EventAbortException(); | 550 | throw new EventAbortException(); |
549 | } | 551 | } |
550 | 552 | ||
@@ -634,45 +636,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
634 | /// <returns></returns> | 636 | /// <returns></returns> |
635 | public object EventProcessor() | 637 | public object EventProcessor() |
636 | { | 638 | { |
639 | EventParams data = null; | ||
637 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 640 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
638 | if (!Running) | 641 | if (!Running) |
639 | return 0; | 642 | return 0; |
640 | 643 | ||
641 | lock (m_Script) | ||
642 | { | ||
643 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 644 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
644 | 645 | ||
645 | if (Suspended) | 646 | if (Suspended) |
646 | return 0; | 647 | return 0; |
647 | |||
648 | EventParams data = null; | ||
649 | 648 | ||
650 | lock (EventQueue) | 649 | lock (EventQueue) |
650 | { | ||
651 | data = (EventParams) EventQueue.Dequeue(); | ||
652 | if (data == null) // Shouldn't happen | ||
651 | { | 653 | { |
652 | data = (EventParams)EventQueue.Dequeue(); | 654 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
653 | if (data == null) // Shouldn't happen | ||
654 | { | 655 | { |
655 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 656 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
656 | { | ||
657 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | ||
658 | } | ||
659 | else | ||
660 | { | ||
661 | m_CurrentWorkItem = null; | ||
662 | } | ||
663 | return 0; | ||
664 | } | 657 | } |
665 | 658 | else | |
666 | if (data.EventName == "timer") | ||
667 | m_TimerQueued = false; | ||
668 | if (data.EventName == "control") | ||
669 | { | 659 | { |
670 | if (m_ControlEventsInQueue > 0) | 660 | m_CurrentWorkItem = null; |
671 | m_ControlEventsInQueue--; | ||
672 | } | 661 | } |
673 | if (data.EventName == "collision") | 662 | return 0; |
674 | m_CollisionInQueue = false; | ||
675 | } | 663 | } |
664 | |||
665 | if (data.EventName == "timer") | ||
666 | m_TimerQueued = false; | ||
667 | if (data.EventName == "control") | ||
668 | { | ||
669 | if (m_ControlEventsInQueue > 0) | ||
670 | m_ControlEventsInQueue--; | ||
671 | } | ||
672 | if (data.EventName == "collision") | ||
673 | m_CollisionInQueue = false; | ||
674 | } | ||
675 | |||
676 | lock(m_Script) | ||
677 | { | ||
676 | 678 | ||
677 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 679 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
678 | 680 | ||
@@ -834,6 +836,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
834 | new Object[0], new DetectParams[0])); | 836 | new Object[0], new DetectParams[0])); |
835 | } | 837 | } |
836 | 838 | ||
839 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
837 | public void ApiResetScript() | 840 | public void ApiResetScript() |
838 | { | 841 | { |
839 | // bool running = Running; | 842 | // bool running = Running; |
@@ -865,10 +868,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
865 | 868 | ||
866 | public Dictionary<string, object> GetVars() | 869 | public Dictionary<string, object> GetVars() |
867 | { | 870 | { |
868 | if (m_Script != null) | 871 | return m_Script.GetVars(); |
869 | return m_Script.GetVars(); | ||
870 | else | ||
871 | return new Dictionary<string, object>(); | ||
872 | } | 872 | } |
873 | 873 | ||
874 | public void SetVars(Dictionary<string, object> vars) | 874 | public void SetVars(Dictionary<string, object> vars) |