diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 69 |
1 files changed, 57 insertions, 12 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 771db0c..ff4d130 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -94,6 +94,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
94 | private UUID m_CurrentStateHash; | 94 | private UUID m_CurrentStateHash; |
95 | private UUID m_RegionID; | 95 | private UUID m_RegionID; |
96 | 96 | ||
97 | public int DebugLevel { get; set; } | ||
98 | |||
97 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; } | 99 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; } |
98 | 100 | ||
99 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); | 101 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); |
@@ -174,6 +176,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
174 | 176 | ||
175 | public Queue EventQueue { get; private set; } | 177 | public Queue EventQueue { get; private set; } |
176 | 178 | ||
179 | public long EventsQueued | ||
180 | { | ||
181 | get | ||
182 | { | ||
183 | lock (EventQueue) | ||
184 | return EventQueue.Count; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | public long EventsProcessed { get; private set; } | ||
189 | |||
177 | public int StartParam { get; set; } | 190 | public int StartParam { get; set; } |
178 | 191 | ||
179 | public TaskInventoryItem ScriptTask { get; private set; } | 192 | public TaskInventoryItem ScriptTask { get; private set; } |
@@ -538,9 +551,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
538 | // forcibly abort the work item (this aborts the underlying thread). | 551 | // forcibly abort the work item (this aborts the underlying thread). |
539 | if (!m_InSelfDelete) | 552 | if (!m_InSelfDelete) |
540 | { | 553 | { |
541 | // m_log.ErrorFormat( | 554 | m_log.DebugFormat( |
542 | // "[SCRIPT INSTANCE]: Aborting script {0} {1} in prim {2} {3} {4} {5}", | 555 | "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", |
543 | // ScriptName, ItemID, PrimName, ObjectID, m_InSelfDelete, DateTime.Now.Ticks); | 556 | ScriptName, ItemID, PrimName, LocalID, timeout); |
544 | 557 | ||
545 | workItem.Abort(); | 558 | workItem.Abort(); |
546 | } | 559 | } |
@@ -696,19 +709,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
696 | { | 709 | { |
697 | 710 | ||
698 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); | 711 | // m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); |
712 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | ||
713 | |||
714 | if (DebugLevel >= 2) | ||
715 | m_log.DebugFormat( | ||
716 | "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | ||
717 | data.EventName, | ||
718 | ScriptName, | ||
719 | part.Name, | ||
720 | part.LocalId, | ||
721 | part.ParentGroup.Name, | ||
722 | part.ParentGroup.UUID, | ||
723 | part.AbsolutePosition, | ||
724 | part.ParentGroup.Scene.Name); | ||
699 | 725 | ||
700 | m_DetectParams = data.DetectParams; | 726 | m_DetectParams = data.DetectParams; |
701 | 727 | ||
702 | if (data.EventName == "state") // Hardcoded state change | 728 | if (data.EventName == "state") // Hardcoded state change |
703 | { | 729 | { |
704 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | ||
705 | // PrimName, ScriptName, data.Params[0].ToString()); | ||
706 | State = data.Params[0].ToString(); | 730 | State = data.Params[0].ToString(); |
731 | |||
732 | if (DebugLevel >= 1) | ||
733 | m_log.DebugFormat( | ||
734 | "[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", | ||
735 | State, | ||
736 | ScriptName, | ||
737 | part.Name, | ||
738 | part.LocalId, | ||
739 | part.ParentGroup.Name, | ||
740 | part.ParentGroup.UUID, | ||
741 | part.AbsolutePosition, | ||
742 | part.ParentGroup.Scene.Name); | ||
743 | |||
707 | AsyncCommandManager.RemoveScript(Engine, | 744 | AsyncCommandManager.RemoveScript(Engine, |
708 | LocalID, ItemID); | 745 | LocalID, ItemID); |
709 | 746 | ||
710 | SceneObjectPart part = Engine.World.GetSceneObjectPart( | ||
711 | LocalID); | ||
712 | if (part != null) | 747 | if (part != null) |
713 | { | 748 | { |
714 | part.SetScriptEvents(ItemID, | 749 | part.SetScriptEvents(ItemID, |
@@ -720,8 +755,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
720 | if (Engine.World.PipeEventsForScript(LocalID) || | 755 | if (Engine.World.PipeEventsForScript(LocalID) || |
721 | data.EventName == "control") // Don't freeze avies! | 756 | data.EventName == "control") // Don't freeze avies! |
722 | { | 757 | { |
723 | SceneObjectPart part = Engine.World.GetSceneObjectPart( | ||
724 | LocalID); | ||
725 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | 758 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
726 | // PrimName, ScriptName, data.EventName, State); | 759 | // PrimName, ScriptName, data.EventName, State); |
727 | 760 | ||
@@ -776,6 +809,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
776 | ChatTypeEnum.DebugChannel, 2147483647, | 809 | ChatTypeEnum.DebugChannel, 2147483647, |
777 | part.AbsolutePosition, | 810 | part.AbsolutePosition, |
778 | part.Name, part.UUID, false); | 811 | part.Name, part.UUID, false); |
812 | |||
813 | |||
814 | m_log.DebugFormat( | ||
815 | "[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}", | ||
816 | ScriptName, | ||
817 | PrimName, | ||
818 | part.UUID, | ||
819 | part.AbsolutePosition, | ||
820 | part.ParentGroup.Scene.Name, | ||
821 | text.Replace("\n", "\\n"), | ||
822 | e.InnerException); | ||
779 | } | 823 | } |
780 | catch (Exception) | 824 | catch (Exception) |
781 | { | 825 | { |
@@ -810,6 +854,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
810 | // script engine to run the next event. | 854 | // script engine to run the next event. |
811 | lock (EventQueue) | 855 | lock (EventQueue) |
812 | { | 856 | { |
857 | EventsProcessed++; | ||
858 | |||
813 | if (EventQueue.Count > 0 && Running && !ShuttingDown) | 859 | if (EventQueue.Count > 0 && Running && !ShuttingDown) |
814 | { | 860 | { |
815 | m_CurrentWorkItem = Engine.QueueEventHandler(this); | 861 | m_CurrentWorkItem = Engine.QueueEventHandler(this); |
@@ -834,7 +880,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
834 | return (DateTime.Now - m_EventStart).Seconds; | 880 | return (DateTime.Now - m_EventStart).Seconds; |
835 | } | 881 | } |
836 | 882 | ||
837 | public void ResetScript() | 883 | public void ResetScript(int timeout) |
838 | { | 884 | { |
839 | if (m_Script == null) | 885 | if (m_Script == null) |
840 | return; | 886 | return; |
@@ -844,7 +890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
844 | RemoveState(); | 890 | RemoveState(); |
845 | ReleaseControls(); | 891 | ReleaseControls(); |
846 | 892 | ||
847 | Stop(0); | 893 | Stop(timeout); |
848 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); | 894 | SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); |
849 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; | 895 | part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; |
850 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; | 896 | part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; |
@@ -1015,7 +1061,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
1015 | "({0}): {1}", scriptLine - 1, | 1061 | "({0}): {1}", scriptLine - 1, |
1016 | e.InnerException.Message); | 1062 | e.InnerException.Message); |
1017 | 1063 | ||
1018 | System.Console.WriteLine(e.ToString()+"\n"); | ||
1019 | return message; | 1064 | return message; |
1020 | } | 1065 | } |
1021 | } | 1066 | } |