aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs85
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 bc1902b..da2ef7b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Runtime.Remoting; 31using System.Runtime.Remoting;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Threading; 33using 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 {
@@ -588,6 +589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
588 return true; 589 return true;
589 } 590 }
590 591
592 [DebuggerNonUserCode] //Prevents the debugger from farting in this function
591 public void SetState(string state) 593 public void SetState(string state)
592 { 594 {
593 if (state == State) 595 if (state == State)
@@ -599,7 +601,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
599 new DetectParams[0])); 601 new DetectParams[0]));
600 PostEvent(new EventParams("state_entry", new Object[0], 602 PostEvent(new EventParams("state_entry", new Object[0],
601 new DetectParams[0])); 603 new DetectParams[0]));
602 604
603 throw new EventAbortException(); 605 throw new EventAbortException();
604 } 606 }
605 607
@@ -682,41 +684,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
682 /// <returns></returns> 684 /// <returns></returns>
683 public object EventProcessor() 685 public object EventProcessor()
684 { 686 {
685 lock (m_Script) 687 EventParams data = null;
686 {
687// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
688 688
689 if (Suspended) 689// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
690 return 0;
691 690
692 EventParams data = null; 691 if (Suspended)
692 return 0;
693 693
694 lock (m_EventQueue) 694 lock (m_EventQueue)
695 {
696 data = (EventParams) m_EventQueue.Dequeue();
697 if (data == null) // Shouldn't happen
695 { 698 {
696 data = (EventParams) m_EventQueue.Dequeue(); 699 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
697 if (data == null) // Shouldn't happen
698 { 700 {
699 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) 701 m_CurrentResult = m_Engine.QueueEventHandler(this);
700 {
701 m_CurrentResult = m_Engine.QueueEventHandler(this);
702 }
703 else
704 {
705 m_CurrentResult = null;
706 }
707 return 0;
708 } 702 }
709 703 else
710 if (data.EventName == "timer")
711 m_TimerQueued = false;
712 if (data.EventName == "control")
713 { 704 {
714 if (m_ControlEventsInQueue > 0) 705 m_CurrentResult = null;
715 m_ControlEventsInQueue--;
716 } 706 }
717 if (data.EventName == "collision") 707 return 0;
718 m_CollisionInQueue = false; 708 }
709
710 if (data.EventName == "timer")
711 m_TimerQueued = false;
712 if (data.EventName == "control")
713 {
714 if (m_ControlEventsInQueue > 0)
715 m_ControlEventsInQueue--;
719 } 716 }
717 if (data.EventName == "collision")
718 m_CollisionInQueue = false;
719 }
720
721 lock(m_Script)
722 {
720 723
721// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); 724// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this);
722 725
@@ -876,6 +879,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
876 new Object[0], new DetectParams[0])); 879 new Object[0], new DetectParams[0]));
877 } 880 }
878 881
882 [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
879 public void ApiResetScript() 883 public void ApiResetScript()
880 { 884 {
881 // bool running = Running; 885 // bool running = Running;
@@ -907,10 +911,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
907 911
908 public Dictionary<string, object> GetVars() 912 public Dictionary<string, object> GetVars()
909 { 913 {
910 if (m_Script != null) 914 return m_Script.GetVars();
911 return m_Script.GetVars();
912 else
913 return new Dictionary<string, object>();
914 } 915 }
915 916
916 public void SetVars(Dictionary<string, object> vars) 917 public void SetVars(Dictionary<string, object> vars)