diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 86 |
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 f1abd4b..8d92ba5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using System.Runtime.Remoting; | 35 | using System.Runtime.Remoting; |
35 | using System.Runtime.Remoting.Lifetime; | 36 | using System.Runtime.Remoting.Lifetime; |
@@ -222,13 +223,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
222 | 223 | ||
223 | if (part != null) | 224 | if (part != null) |
224 | { | 225 | { |
225 | lock (part.TaskInventory) | 226 | part.TaskInventory.LockItemsForRead(true); |
227 | if (part.TaskInventory.ContainsKey(ItemID)) | ||
226 | { | 228 | { |
227 | if (part.TaskInventory.ContainsKey(ItemID)) | 229 | ScriptTask = part.TaskInventory[ItemID]; |
228 | { | ||
229 | ScriptTask = part.TaskInventory[ItemID]; | ||
230 | } | ||
231 | } | 230 | } |
231 | part.TaskInventory.LockItemsForRead(false); | ||
232 | } | 232 | } |
233 | 233 | ||
234 | ApiManager am = new ApiManager(); | 234 | ApiManager am = new ApiManager(); |
@@ -424,14 +424,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
424 | { | 424 | { |
425 | int permsMask; | 425 | int permsMask; |
426 | UUID permsGranter; | 426 | UUID permsGranter; |
427 | lock (part.TaskInventory) | 427 | part.TaskInventory.LockItemsForRead(true); |
428 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
428 | { | 429 | { |
429 | if (!part.TaskInventory.ContainsKey(ItemID)) | 430 | part.TaskInventory.LockItemsForRead(false); |
430 | return; | 431 | return; |
431 | |||
432 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
433 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
434 | } | 432 | } |
433 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
434 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
435 | part.TaskInventory.LockItemsForRead(false); | ||
435 | 436 | ||
436 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 437 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
437 | { | 438 | { |
@@ -559,6 +560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
559 | return true; | 560 | return true; |
560 | } | 561 | } |
561 | 562 | ||
563 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
562 | public void SetState(string state) | 564 | public void SetState(string state) |
563 | { | 565 | { |
564 | if (state == State) | 566 | if (state == State) |
@@ -570,7 +572,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
570 | new DetectParams[0])); | 572 | new DetectParams[0])); |
571 | PostEvent(new EventParams("state_entry", new Object[0], | 573 | PostEvent(new EventParams("state_entry", new Object[0], |
572 | new DetectParams[0])); | 574 | new DetectParams[0])); |
573 | 575 | ||
574 | throw new EventAbortException(); | 576 | throw new EventAbortException(); |
575 | } | 577 | } |
576 | 578 | ||
@@ -660,45 +662,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
660 | /// <returns></returns> | 662 | /// <returns></returns> |
661 | public object EventProcessor() | 663 | public object EventProcessor() |
662 | { | 664 | { |
665 | EventParams data = null; | ||
663 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 666 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
664 | if (!Running) | 667 | if (!Running) |
665 | return 0; | 668 | return 0; |
666 | 669 | ||
667 | lock (m_Script) | ||
668 | { | ||
669 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 670 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
670 | 671 | ||
671 | if (Suspended) | 672 | if (Suspended) |
672 | return 0; | 673 | return 0; |
673 | |||
674 | EventParams data = null; | ||
675 | 674 | ||
676 | lock (EventQueue) | 675 | lock (EventQueue) |
676 | { | ||
677 | data = (EventParams) EventQueue.Dequeue(); | ||
678 | if (data == null) // Shouldn't happen | ||
677 | { | 679 | { |
678 | data = (EventParams)EventQueue.Dequeue(); | 680 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
679 | if (data == null) // Shouldn't happen | ||
680 | { | 681 | { |
681 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 682 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
682 | { | ||
683 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | ||
684 | } | ||
685 | else | ||
686 | { | ||
687 | m_CurrentWorkItem = null; | ||
688 | } | ||
689 | return 0; | ||
690 | } | 683 | } |
691 | 684 | else | |
692 | if (data.EventName == "timer") | ||
693 | m_TimerQueued = false; | ||
694 | if (data.EventName == "control") | ||
695 | { | 685 | { |
696 | if (m_ControlEventsInQueue > 0) | 686 | m_CurrentWorkItem = null; |
697 | m_ControlEventsInQueue--; | ||
698 | } | 687 | } |
699 | if (data.EventName == "collision") | 688 | return 0; |
700 | m_CollisionInQueue = false; | ||
701 | } | 689 | } |
690 | |||
691 | if (data.EventName == "timer") | ||
692 | m_TimerQueued = false; | ||
693 | if (data.EventName == "control") | ||
694 | { | ||
695 | if (m_ControlEventsInQueue > 0) | ||
696 | m_ControlEventsInQueue--; | ||
697 | } | ||
698 | if (data.EventName == "collision") | ||
699 | m_CollisionInQueue = false; | ||
700 | } | ||
701 | |||
702 | lock(m_Script) | ||
703 | { | ||
702 | 704 | ||
703 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 705 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
704 | 706 | ||
@@ -853,6 +855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
853 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 855 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
854 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 856 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
855 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 857 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
858 | part.CollisionSound = UUID.Zero; | ||
856 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 859 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
857 | EventQueue.Clear(); | 860 | EventQueue.Clear(); |
858 | m_Script.ResetVars(); | 861 | m_Script.ResetVars(); |
@@ -867,6 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
867 | new Object[0], new DetectParams[0])); | 870 | new Object[0], new DetectParams[0])); |
868 | } | 871 | } |
869 | 872 | ||
873 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
870 | public void ApiResetScript() | 874 | public void ApiResetScript() |
871 | { | 875 | { |
872 | // bool running = Running; | 876 | // bool running = Running; |
@@ -878,6 +882,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
878 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 882 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
879 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 883 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
880 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 884 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
885 | part.CollisionSound = UUID.Zero; | ||
881 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 886 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
882 | 887 | ||
883 | EventQueue.Clear(); | 888 | EventQueue.Clear(); |
@@ -898,10 +903,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
898 | 903 | ||
899 | public Dictionary<string, object> GetVars() | 904 | public Dictionary<string, object> GetVars() |
900 | { | 905 | { |
901 | if (m_Script != null) | 906 | return m_Script.GetVars(); |
902 | return m_Script.GetVars(); | ||
903 | else | ||
904 | return new Dictionary<string, object>(); | ||
905 | } | 907 | } |
906 | 908 | ||
907 | public void SetVars(Dictionary<string, object> vars) | 909 | public void SetVars(Dictionary<string, object> vars) |