aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs86
1 files changed, 44 insertions, 42 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 306090e..3797683 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;
@@ -221,13 +222,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
221 222
222 if (part != null) 223 if (part != null)
223 { 224 {
224 lock (part.TaskInventory) 225 part.TaskInventory.LockItemsForRead(true);
226 if (part.TaskInventory.ContainsKey(ItemID))
225 { 227 {
226 if (part.TaskInventory.ContainsKey(ItemID)) 228 ScriptTask = part.TaskInventory[ItemID];
227 {
228 ScriptTask = part.TaskInventory[ItemID];
229 }
230 } 229 }
230 part.TaskInventory.LockItemsForRead(false);
231 } 231 }
232 232
233 ApiManager am = new ApiManager(); 233 ApiManager am = new ApiManager();
@@ -426,14 +426,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
426 { 426 {
427 int permsMask; 427 int permsMask;
428 UUID permsGranter; 428 UUID permsGranter;
429 lock (part.TaskInventory) 429 part.TaskInventory.LockItemsForRead(true);
430 if (!part.TaskInventory.ContainsKey(ItemID))
430 { 431 {
431 if (!part.TaskInventory.ContainsKey(ItemID)) 432 part.TaskInventory.LockItemsForRead(false);
432 return; 433 return;
433
434 permsGranter = part.TaskInventory[ItemID].PermsGranter;
435 permsMask = part.TaskInventory[ItemID].PermsMask;
436 } 434 }
435 permsGranter = part.TaskInventory[ItemID].PermsGranter;
436 permsMask = part.TaskInventory[ItemID].PermsMask;
437 part.TaskInventory.LockItemsForRead(false);
437 438
438 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 439 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
439 { 440 {
@@ -561,6 +562,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
561 return true; 562 return true;
562 } 563 }
563 564
565 [DebuggerNonUserCode] //Prevents the debugger from farting in this function
564 public void SetState(string state) 566 public void SetState(string state)
565 { 567 {
566 if (state == State) 568 if (state == State)
@@ -572,7 +574,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
572 new DetectParams[0])); 574 new DetectParams[0]));
573 PostEvent(new EventParams("state_entry", new Object[0], 575 PostEvent(new EventParams("state_entry", new Object[0],
574 new DetectParams[0])); 576 new DetectParams[0]));
575 577
576 throw new EventAbortException(); 578 throw new EventAbortException();
577 } 579 }
578 580
@@ -662,45 +664,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
662 /// <returns></returns> 664 /// <returns></returns>
663 public object EventProcessor() 665 public object EventProcessor()
664 { 666 {
667 EventParams data = null;
665 // We check here as the thread stopping this instance from running may itself hold the m_Script lock. 668 // We check here as the thread stopping this instance from running may itself hold the m_Script lock.
666 if (!Running) 669 if (!Running)
667 return 0; 670 return 0;
668 671
669 lock (m_Script)
670 {
671// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); 672// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
672 673
673 if (Suspended) 674 if (Suspended)
674 return 0; 675 return 0;
675
676 EventParams data = null;
677 676
678 lock (EventQueue) 677 lock (EventQueue)
678 {
679 data = (EventParams) EventQueue.Dequeue();
680 if (data == null) // Shouldn't happen
679 { 681 {
680 data = (EventParams)EventQueue.Dequeue(); 682 if (EventQueue.Count > 0 && Running && !ShuttingDown)
681 if (data == null) // Shouldn't happen
682 { 683 {
683 if (EventQueue.Count > 0 && Running && !ShuttingDown) 684 m_CurrentWorkItem = Engine.QueueEventHandler(this);
684 {
685 m_CurrentWorkItem = Engine.QueueEventHandler(this);
686 }
687 else
688 {
689 m_CurrentWorkItem = null;
690 }
691 return 0;
692 } 685 }
693 686 else
694 if (data.EventName == "timer")
695 m_TimerQueued = false;
696 if (data.EventName == "control")
697 { 687 {
698 if (m_ControlEventsInQueue > 0) 688 m_CurrentWorkItem = null;
699 m_ControlEventsInQueue--;
700 } 689 }
701 if (data.EventName == "collision") 690 return 0;
702 m_CollisionInQueue = false;
703 } 691 }
692
693 if (data.EventName == "timer")
694 m_TimerQueued = false;
695 if (data.EventName == "control")
696 {
697 if (m_ControlEventsInQueue > 0)
698 m_ControlEventsInQueue--;
699 }
700 if (data.EventName == "collision")
701 m_CollisionInQueue = false;
702 }
703
704 lock(m_Script)
705 {
704 706
705// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); 707// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this);
706 708
@@ -855,6 +857,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
855 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); 857 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
856 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; 858 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
857 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; 859 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
860 part.CollisionSound = UUID.Zero;
858 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); 861 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
859 EventQueue.Clear(); 862 EventQueue.Clear();
860 m_Script.ResetVars(); 863 m_Script.ResetVars();
@@ -869,6 +872,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
869 new Object[0], new DetectParams[0])); 872 new Object[0], new DetectParams[0]));
870 } 873 }
871 874
875 [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
872 public void ApiResetScript() 876 public void ApiResetScript()
873 { 877 {
874 // bool running = Running; 878 // bool running = Running;
@@ -880,6 +884,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
880 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); 884 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
881 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; 885 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
882 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; 886 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
887 part.CollisionSound = UUID.Zero;
883 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); 888 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
884 889
885 EventQueue.Clear(); 890 EventQueue.Clear();
@@ -900,10 +905,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
900 905
901 public Dictionary<string, object> GetVars() 906 public Dictionary<string, object> GetVars()
902 { 907 {
903 if (m_Script != null) 908 return m_Script.GetVars();
904 return m_Script.GetVars();
905 else
906 return new Dictionary<string, object>();
907 } 909 }
908 910
909 public void SetVars(Dictionary<string, object> vars) 911 public void SetVars(Dictionary<string, object> vars)