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 5ad6eeb..538cb8b 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; |
@@ -230,13 +231,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
230 | 231 | ||
231 | if (part != null) | 232 | if (part != null) |
232 | { | 233 | { |
233 | lock (part.TaskInventory) | 234 | part.TaskInventory.LockItemsForRead(true); |
235 | if (part.TaskInventory.ContainsKey(ItemID)) | ||
234 | { | 236 | { |
235 | if (part.TaskInventory.ContainsKey(ItemID)) | 237 | ScriptTask = part.TaskInventory[ItemID]; |
236 | { | ||
237 | ScriptTask = part.TaskInventory[ItemID]; | ||
238 | } | ||
239 | } | 238 | } |
239 | part.TaskInventory.LockItemsForRead(false); | ||
240 | } | 240 | } |
241 | 241 | ||
242 | ApiManager am = new ApiManager(); | 242 | ApiManager am = new ApiManager(); |
@@ -428,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
428 | { | 428 | { |
429 | int permsMask; | 429 | int permsMask; |
430 | UUID permsGranter; | 430 | UUID permsGranter; |
431 | lock (part.TaskInventory) | 431 | part.TaskInventory.LockItemsForRead(true); |
432 | if (!part.TaskInventory.ContainsKey(ItemID)) | ||
432 | { | 433 | { |
433 | if (!part.TaskInventory.ContainsKey(ItemID)) | 434 | part.TaskInventory.LockItemsForRead(false); |
434 | return; | 435 | return; |
435 | |||
436 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
437 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
438 | } | 436 | } |
437 | permsGranter = part.TaskInventory[ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[ItemID].PermsMask; | ||
439 | part.TaskInventory.LockItemsForRead(false); | ||
439 | 440 | ||
440 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
441 | { | 442 | { |
@@ -563,6 +564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
563 | return true; | 564 | return true; |
564 | } | 565 | } |
565 | 566 | ||
567 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
566 | public void SetState(string state) | 568 | public void SetState(string state) |
567 | { | 569 | { |
568 | if (state == State) | 570 | if (state == State) |
@@ -574,7 +576,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
574 | new DetectParams[0])); | 576 | new DetectParams[0])); |
575 | PostEvent(new EventParams("state_entry", new Object[0], | 577 | PostEvent(new EventParams("state_entry", new Object[0], |
576 | new DetectParams[0])); | 578 | new DetectParams[0])); |
577 | 579 | ||
578 | throw new EventAbortException(); | 580 | throw new EventAbortException(); |
579 | } | 581 | } |
580 | 582 | ||
@@ -664,45 +666,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
664 | /// <returns></returns> | 666 | /// <returns></returns> |
665 | public object EventProcessor() | 667 | public object EventProcessor() |
666 | { | 668 | { |
669 | EventParams data = null; | ||
667 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. | 670 | // We check here as the thread stopping this instance from running may itself hold the m_Script lock. |
668 | if (!Running) | 671 | if (!Running) |
669 | return 0; | 672 | return 0; |
670 | 673 | ||
671 | lock (m_Script) | ||
672 | { | ||
673 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); | 674 | // m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName); |
674 | 675 | ||
675 | if (Suspended) | 676 | if (Suspended) |
676 | return 0; | 677 | return 0; |
677 | |||
678 | EventParams data = null; | ||
679 | 678 | ||
680 | lock (EventQueue) | 679 | lock (EventQueue) |
680 | { | ||
681 | data = (EventParams) EventQueue.Dequeue(); | ||
682 | if (data == null) // Shouldn't happen | ||
681 | { | 683 | { |
682 | data = (EventParams)EventQueue.Dequeue(); | 684 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
683 | if (data == null) // Shouldn't happen | ||
684 | { | 685 | { |
685 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 686 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
686 | { | ||
687 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | ||
688 | } | ||
689 | else | ||
690 | { | ||
691 | m_CurrentWorkItem = null; | ||
692 | } | ||
693 | return 0; | ||
694 | } | 687 | } |
695 | 688 | else | |
696 | if (data.EventName == "timer") | ||
697 | m_TimerQueued = false; | ||
698 | if (data.EventName == "control") | ||
699 | { | 689 | { |
700 | if (m_ControlEventsInQueue > 0) | 690 | m_CurrentWorkItem = null; |
701 | m_ControlEventsInQueue--; | ||
702 | } | 691 | } |
703 | if (data.EventName == "collision") | 692 | return 0; |
704 | m_CollisionInQueue = false; | ||
705 | } | 693 | } |
694 | |||
695 | if (data.EventName == "timer") | ||
696 | m_TimerQueued = false; | ||
697 | if (data.EventName == "control") | ||
698 | { | ||
699 | if (m_ControlEventsInQueue > 0) | ||
700 | m_ControlEventsInQueue--; | ||
701 | } | ||
702 | if (data.EventName == "collision") | ||
703 | m_CollisionInQueue = false; | ||
704 | } | ||
705 | |||
706 | lock(m_Script) | ||
707 | { | ||
706 | 708 | ||
707 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 709 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
708 | 710 | ||
@@ -870,6 +872,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
870 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 872 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
871 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 873 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
872 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 874 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
875 | part.CollisionSound = UUID.Zero; | ||
873 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 876 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
874 | EventQueue.Clear(); | 877 | EventQueue.Clear(); |
875 | m_Script.ResetVars(); | 878 | m_Script.ResetVars(); |
@@ -884,6 +887,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
884 | new Object[0], new DetectParams[0])); | 887 | new Object[0], new DetectParams[0])); |
885 | } | 888 | } |
886 | 889 | ||
890 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
887 | public void ApiResetScript() | 891 | public void ApiResetScript() |
888 | { | 892 | { |
889 | // bool running = Running; | 893 | // bool running = Running; |
@@ -895,6 +899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
895 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 899 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
896 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 900 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
897 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 901 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
902 | part.CollisionSound = UUID.Zero; | ||
898 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); | 903 | AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); |
899 | 904 | ||
900 | EventQueue.Clear(); | 905 | EventQueue.Clear(); |
@@ -915,10 +920,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
915 | 920 | ||
916 | public Dictionary<string, object> GetVars() | 921 | public Dictionary<string, object> GetVars() |
917 | { | 922 | { |
918 | if (m_Script != null) | 923 | return m_Script.GetVars(); |
919 | return m_Script.GetVars(); | ||
920 | else | ||
921 | return new Dictionary<string, object>(); | ||
922 | } | 924 | } |
923 | 925 | ||
924 | public void SetVars(Dictionary<string, object> vars) | 926 | public void SetVars(Dictionary<string, object> vars) |