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.cs87
1 files changed, 45 insertions, 42 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index dfe8386..68f701c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization; 31using System.Globalization;
32using System.IO; 32using System.IO;
33using System.Diagnostics; //for [DebuggerNonUserCode]
33using System.Reflection; 34using System.Reflection;
34using System.Runtime.Remoting; 35using System.Runtime.Remoting;
35using System.Runtime.Remoting.Lifetime; 36using System.Runtime.Remoting.Lifetime;
@@ -232,13 +233,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
232 233
233 if (part != null) 234 if (part != null)
234 { 235 {
235 lock (part.TaskInventory) 236 part.TaskInventory.LockItemsForRead(true);
237 if (part.TaskInventory.ContainsKey(ItemID))
236 { 238 {
237 if (part.TaskInventory.ContainsKey(ItemID)) 239 ScriptTask = part.TaskInventory[ItemID];
238 {
239 ScriptTask = part.TaskInventory[ItemID];
240 }
241 } 240 }
241 part.TaskInventory.LockItemsForRead(false);
242 } 242 }
243 243
244 ApiManager am = new ApiManager(); 244 ApiManager am = new ApiManager();
@@ -430,14 +430,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
430 { 430 {
431 int permsMask; 431 int permsMask;
432 UUID permsGranter; 432 UUID permsGranter;
433 lock (part.TaskInventory) 433 part.TaskInventory.LockItemsForRead(true);
434 if (!part.TaskInventory.ContainsKey(ItemID))
434 { 435 {
435 if (!part.TaskInventory.ContainsKey(ItemID)) 436 part.TaskInventory.LockItemsForRead(false);
436 return; 437 return;
437
438 permsGranter = part.TaskInventory[ItemID].PermsGranter;
439 permsMask = part.TaskInventory[ItemID].PermsMask;
440 } 438 }
439 permsGranter = part.TaskInventory[ItemID].PermsGranter;
440 permsMask = part.TaskInventory[ItemID].PermsMask;
441 part.TaskInventory.LockItemsForRead(false);
441 442
442 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 443 if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
443 { 444 {
@@ -565,6 +566,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
565 return true; 566 return true;
566 } 567 }
567 568
569 [DebuggerNonUserCode] //Prevents the debugger from farting in this function
568 public void SetState(string state) 570 public void SetState(string state)
569 { 571 {
570 if (state == State) 572 if (state == State)
@@ -576,7 +578,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
576 new DetectParams[0])); 578 new DetectParams[0]));
577 PostEvent(new EventParams("state_entry", new Object[0], 579 PostEvent(new EventParams("state_entry", new Object[0],
578 new DetectParams[0])); 580 new DetectParams[0]));
579 581
580 throw new EventAbortException(); 582 throw new EventAbortException();
581 } 583 }
582 584
@@ -666,46 +668,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
666 /// <returns></returns> 668 /// <returns></returns>
667 public object EventProcessor() 669 public object EventProcessor()
668 { 670 {
671 EventParams data = null;
669 // We check here as the thread stopping this instance from running may itself hold the m_Script lock. 672 // We check here as the thread stopping this instance from running may itself hold the m_Script lock.
670 if (!Running) 673 if (!Running)
671 return 0; 674 return 0;
672 675
673 lock (m_Script)
674 {
675// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); 676// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
676 677
677 if (Suspended) 678 if (Suspended)
678 return 0; 679 return 0;
679
680 EventParams data = null;
681 680
682 lock (EventQueue) 681 lock (EventQueue)
682 {
683 data = (EventParams) EventQueue.Dequeue();
684 if (data == null) // Shouldn't happen
683 { 685 {
684 data = (EventParams)EventQueue.Dequeue(); 686 if (EventQueue.Count > 0 && Running && !ShuttingDown)
685 if (data == null) // Shouldn't happen
686 { 687 {
687 if (EventQueue.Count > 0 && Running && !ShuttingDown) 688 m_CurrentWorkItem = Engine.QueueEventHandler(this);
688 {
689 m_CurrentWorkItem = Engine.QueueEventHandler(this);
690 }
691 else
692 {
693 m_CurrentWorkItem = null;
694 }
695 return 0;
696 } 689 }
697 690 else
698 if (data.EventName == "timer")
699 m_TimerQueued = false;
700 if (data.EventName == "control")
701 { 691 {
702 if (m_ControlEventsInQueue > 0) 692 m_CurrentWorkItem = null;
703 m_ControlEventsInQueue--;
704 } 693 }
705 if (data.EventName == "collision") 694 return 0;
706 m_CollisionInQueue = false; 695 }
696
697 if (data.EventName == "timer")
698 m_TimerQueued = false;
699 if (data.EventName == "control")
700 {
701 if (m_ControlEventsInQueue > 0)
702 m_ControlEventsInQueue--;
707 } 703 }
704 if (data.EventName == "collision")
705 m_CollisionInQueue = false;
706 }
708 707
708 lock(m_Script)
709 {
710
711// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this);
709 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); 712 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
710 713
711 if (DebugLevel >= 2) 714 if (DebugLevel >= 2)
@@ -891,6 +894,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
891 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); 894 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
892 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; 895 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
893 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; 896 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
897 part.CollisionSound = UUID.Zero;
894 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); 898 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
895 EventQueue.Clear(); 899 EventQueue.Clear();
896 m_Script.ResetVars(); 900 m_Script.ResetVars();
@@ -905,6 +909,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
905 new Object[0], new DetectParams[0])); 909 new Object[0], new DetectParams[0]));
906 } 910 }
907 911
912 [DebuggerNonUserCode] //Stops the VS debugger from farting in this function
908 public void ApiResetScript() 913 public void ApiResetScript()
909 { 914 {
910 // bool running = Running; 915 // bool running = Running;
@@ -916,6 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
916 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); 921 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
917 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; 922 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
918 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; 923 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
924 part.CollisionSound = UUID.Zero;
919 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); 925 AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
920 926
921 EventQueue.Clear(); 927 EventQueue.Clear();
@@ -936,10 +942,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
936 942
937 public Dictionary<string, object> GetVars() 943 public Dictionary<string, object> GetVars()
938 { 944 {
939 if (m_Script != null) 945 return m_Script.GetVars();
940 return m_Script.GetVars();
941 else
942 return new Dictionary<string, object>();
943 } 946 }
944 947
945 public void SetVars(Dictionary<string, object> vars) 948 public void SetVars(Dictionary<string, object> vars)