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 329e361..1c59d45 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; |
@@ -218,13 +219,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
218 | 219 | ||
219 | if (part != null) | 220 | if (part != null) |
220 | { | 221 | { |
221 | lock (part.TaskInventory) | 222 | part.TaskInventory.LockItemsForRead(true); |
223 | if (part.TaskInventory.ContainsKey(ItemID)) | ||
222 | { | 224 | { |
223 | if (part.TaskInventory.ContainsKey(ItemID)) | 225 | ScriptTask = part.TaskInventory[ItemID]; |
224 | { | ||
225 | ScriptTask = part.TaskInventory[ItemID]; | ||
226 | } | ||
227 | } | 226 | } |
227 | part.TaskInventory.LockItemsForRead(false); | ||
228 | } | 228 | } |
229 | 229 | ||
230 | ApiManager am = new ApiManager(); | 230 | ApiManager am = new ApiManager(); |
@@ -416,14 +416,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
416 | { | 416 | { |
417 | int permsMask; | 417 | int permsMask; |
418 | UUID permsGranter; | 418 | UUID permsGranter; |
419 | lock (part.TaskInventory) | 419 | part.TaskInventory.LockItemsForRead(true); |
420 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
420 | { | 421 | { |
421 | if (!part.TaskInventory.ContainsKey(ItemID)) | 422 | part.TaskInventory.LockItemsForRead(false); |
422 | return; | 423 | return; |
423 | |||
424 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
425 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
426 | } | 424 | } |
425 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
426 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
427 | part.TaskInventory.LockItemsForRead(false); | ||
427 | 428 | ||
428 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 429 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
429 | { | 430 | { |
@@ -551,6 +552,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
551 | return true; | 552 | return true; |
552 | } | 553 | } |
553 | 554 | ||
555 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
554 | public void SetState(string state) | 556 | public void SetState(string state) |
555 | { | 557 | { |
556 | if (state == State) | 558 | if (state == State) |
@@ -562,7 +564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
562 | new DetectParams[0])); | 564 | new DetectParams[0])); |
563 | PostEvent(new EventParams("state_entry", new Object[0], | 565 | PostEvent(new EventParams("state_entry", new Object[0], |
564 | new DetectParams[0])); | 566 | new DetectParams[0])); |
565 | 567 | ||
566 | throw new EventAbortException(); | 568 | throw new EventAbortException(); |
567 | } | 569 | } |
568 | 570 | ||
@@ -652,45 +654,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
652 | /// <returns></returns> | 654 | /// <returns></returns> |
653 | public object EventProcessor() | 655 | public object EventProcessor() |
654 | { | 656 | { |
657 | EventParams data = null; | ||
655 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 658 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
656 | if (!Running) | 659 | if (!Running) |
657 | return 0; | 660 | return 0; |
658 | 661 | ||
659 | lock (m_Script) | ||
660 | { | ||
661 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 662 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
662 | 663 | ||
663 | if (Suspended) | 664 | if (Suspended) |
664 | return 0; | 665 | return 0; |
665 | |||
666 | EventParams data = null; | ||
667 | 666 | ||
668 | lock (EventQueue) | 667 | lock (EventQueue) |
668 | { | ||
669 | data = (EventParams) EventQueue.Dequeue(); | ||
670 | if (data == null) // Shouldn't happen | ||
669 | { | 671 | { |
670 | data = (EventParams)EventQueue.Dequeue(); | 672 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
671 | if (data == null) // Shouldn't happen | ||
672 | { | 673 | { |
673 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 674 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
674 | { | ||
675 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | ||
676 | } | ||
677 | else | ||
678 | { | ||
679 | m_CurrentWorkItem = null; | ||
680 | } | ||
681 | return 0; | ||
682 | } | 675 | } |
683 | 676 | else | |
684 | if (data.EventName == "timer") | ||
685 | m_TimerQueued = false; | ||
686 | if (data.EventName == "control") | ||
687 | { | 677 | { |
688 | if (m_ControlEventsInQueue > 0) | 678 | m_CurrentWorkItem = null; |
689 | m_ControlEventsInQueue--; | ||
690 | } | 679 | } |
691 | if (data.EventName == "collision") | 680 | return 0; |
692 | m_CollisionInQueue = false; | ||
693 | } | 681 | } |
682 | |||
683 | if (data.EventName == "timer") | ||
684 | m_TimerQueued = false; | ||
685 | if (data.EventName == "control") | ||
686 | { | ||
687 | if (m_ControlEventsInQueue > 0) | ||
688 | m_ControlEventsInQueue--; | ||
689 | } | ||
690 | if (data.EventName == "collision") | ||
691 | m_CollisionInQueue = false; | ||
692 | } | ||
693 | |||
694 | lock(m_Script) | ||
695 | { | ||
694 | 696 | ||
695 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 697 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
696 | 698 | ||
@@ -845,6 +847,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
845 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 847 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
846 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 848 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
847 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 849 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
850 | part.CollisionSound = UUID.Zero; | ||
848 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 851 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
849 | EventQueue.Clear(); | 852 | EventQueue.Clear(); |
850 | m_Script.ResetVars(); | 853 | m_Script.ResetVars(); |
@@ -859,6 +862,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
859 | new Object[0], new DetectParams[0])); | 862 | new Object[0], new DetectParams[0])); |
860 | } | 863 | } |
861 | 864 | ||
865 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
862 | public void ApiResetScript() | 866 | public void ApiResetScript() |
863 | { | 867 | { |
864 | // bool running = Running; | 868 | // bool running = Running; |
@@ -870,6 +874,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
870 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 874 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
871 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 875 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
872 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 876 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
877 | part.CollisionSound = UUID.Zero; | ||
873 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 878 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
874 | 879 | ||
875 | EventQueue.Clear(); | 880 | EventQueue.Clear(); |
@@ -890,10 +895,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
890 | 895 | ||
891 | public Dictionary<string, object> GetVars() | 896 | public Dictionary<string, object> GetVars() |
892 | { | 897 | { |
893 | if (m_Script != null) | 898 | return m_Script.GetVars(); |
894 | return m_Script.GetVars(); | ||
895 | else | ||
896 | return new Dictionary<string, object>(); | ||
897 | } | 899 | } |
898 | 900 | ||
899 | public void SetVars(Dictionary<string, object> vars) | 901 | public void SetVars(Dictionary<string, object> vars) |