diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 9b93135..34f2cc7 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; |
@@ -264,13 +265,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
264 | 265 | ||
265 | if (part != null) | 266 | if (part != null) |
266 | { | 267 | { |
267 | lock (part.TaskInventory) | 268 | part.TaskInventory.LockItemsForRead(true); |
269 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
268 | { | 270 | { |
269 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 271 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
270 | { | ||
271 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
272 | } | ||
273 | } | 272 | } |
273 | part.TaskInventory.LockItemsForRead(false); | ||
274 | } | 274 | } |
275 | 275 | ||
276 | ApiManager am = new ApiManager(); | 276 | ApiManager am = new ApiManager(); |
@@ -469,14 +469,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
469 | { | 469 | { |
470 | int permsMask; | 470 | int permsMask; |
471 | UUID permsGranter; | 471 | UUID permsGranter; |
472 | lock (part.TaskInventory) | 472 | part.TaskInventory.LockItemsForRead(true); |
473 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
473 | { | 474 | { |
474 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 475 | part.TaskInventory.LockItemsForRead(false); |
475 | return; | 476 | return; |
476 | |||
477 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
478 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
479 | } | 477 | } |
478 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
479 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
480 | part.TaskInventory.LockItemsForRead(false); | ||
480 | 481 | ||
481 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 482 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
482 | { | 483 | { |
@@ -585,6 +586,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
585 | return true; | 586 | return true; |
586 | } | 587 | } |
587 | 588 | ||
589 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
588 | public void SetState(string state) | 590 | public void SetState(string state) |
589 | { | 591 | { |
590 | if (state == State) | 592 | if (state == State) |
@@ -596,7 +598,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
596 | new DetectParams[0])); | 598 | new DetectParams[0])); |
597 | PostEvent(new EventParams("state_entry", new Object[0], | 599 | PostEvent(new EventParams("state_entry", new Object[0], |
598 | new DetectParams[0])); | 600 | new DetectParams[0])); |
599 | 601 | ||
600 | throw new EventAbortException(); | 602 | throw new EventAbortException(); |
601 | } | 603 | } |
602 | 604 | ||
@@ -679,41 +681,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
679 | /// <returns></returns> | 681 | /// <returns></returns> |
680 | public object EventProcessor() | 682 | public object EventProcessor() |
681 | { | 683 | { |
682 | lock (m_Script) | 684 | EventParams data = null; |
683 | { | ||
684 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | ||
685 | 685 | ||
686 | if (Suspended) | 686 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
687 | return 0; | ||
688 | 687 | ||
689 | EventParams data = null; | 688 | if (Suspended) |
689 | return 0; | ||
690 | 690 | ||
691 | lock (m_EventQueue) | 691 | lock (m_EventQueue) |
692 | { | ||
693 | data = (EventParams) m_EventQueue.Dequeue(); | ||
694 | if (data == null) // Shouldn't happen | ||
692 | { | 695 | { |
693 | data = (EventParams) m_EventQueue.Dequeue(); | 696 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) |
694 | if (data == null) // Shouldn't happen | ||
695 | { | 697 | { |
696 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 698 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
697 | { | ||
698 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
699 | } | ||
700 | else | ||
701 | { | ||
702 | m_CurrentResult = null; | ||
703 | } | ||
704 | return 0; | ||
705 | } | 699 | } |
706 | 700 | else | |
707 | if (data.EventName == "timer") | ||
708 | m_TimerQueued = false; | ||
709 | if (data.EventName == "control") | ||
710 | { | 701 | { |
711 | if (m_ControlEventsInQueue > 0) | 702 | m_CurrentResult = null; |
712 | m_ControlEventsInQueue--; | ||
713 | } | 703 | } |
714 | if (data.EventName == "collision") | 704 | return 0; |
715 | m_CollisionInQueue = false; | 705 | } |
706 | |||
707 | if (data.EventName == "timer") | ||
708 | m_TimerQueued = false; | ||
709 | if (data.EventName == "control") | ||
710 | { | ||
711 | if (m_ControlEventsInQueue > 0) | ||
712 | m_ControlEventsInQueue--; | ||
716 | } | 713 | } |
714 | if (data.EventName == "collision") | ||
715 | m_CollisionInQueue = false; | ||
716 | } | ||
717 | |||
718 | lock(m_Script) | ||
719 | { | ||
717 | 720 | ||
718 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 721 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
719 | 722 | ||
@@ -870,6 +873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
870 | new Object[0], new DetectParams[0])); | 873 | new Object[0], new DetectParams[0])); |
871 | } | 874 | } |
872 | 875 | ||
876 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
873 | public void ApiResetScript() | 877 | public void ApiResetScript() |
874 | { | 878 | { |
875 | // bool running = Running; | 879 | // bool running = Running; |
@@ -901,10 +905,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
901 | 905 | ||
902 | public Dictionary<string, object> GetVars() | 906 | public Dictionary<string, object> GetVars() |
903 | { | 907 | { |
904 | if (m_Script != null) | 908 | return m_Script.GetVars(); |
905 | return m_Script.GetVars(); | ||
906 | else | ||
907 | return new Dictionary<string, object>(); | ||
908 | } | 909 | } |
909 | 910 | ||
910 | public void SetVars(Dictionary<string, object> vars) | 911 | public void SetVars(Dictionary<string, object> vars) |