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