diff options
author | lbsa71 | 2008-06-24 21:09:49 +0000 |
---|---|---|
committer | lbsa71 | 2008-06-24 21:09:49 +0000 |
commit | 6b7930104bdb845d3b9c085dc04f52b6446f23b1 (patch) | |
tree | 05ee45781a455817fa400bb99f30f4d19d4eb1f8 /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |
parent | based on positive feedback on performance of making keys fixed length (diff) | |
download | opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.zip opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.gz opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.bz2 opensim-SC_OLD-6b7930104bdb845d3b9c085dc04f52b6446f23b1.tar.xz |
* Applied patch from Melanie, mantis issue #1581 - "Refactor LSL language, api and compiler out of XEngine"
"First stage in a major Script Engine refactor, that will result in the LSL implementaions ebing reconverged. Not there yet, but one major part is done."
Thank you, Melanie!
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 234 |
1 files changed, 77 insertions, 157 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0b0ff3d..709e3ee 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -14,11 +14,15 @@ using OpenSim.Framework; | |||
14 | using OpenSim.Region.Environment; | 14 | using OpenSim.Region.Environment; |
15 | using OpenSim.Region.Environment.Scenes; | 15 | using OpenSim.Region.Environment.Scenes; |
16 | using OpenSim.Region.Environment.Interfaces; | 16 | using OpenSim.Region.Environment.Interfaces; |
17 | using OpenSim.Region.ScriptEngine.XEngine.Script; | 17 | using OpenSim.Region.ScriptEngine.Shared; |
18 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
19 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
20 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | ||
21 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
18 | 22 | ||
19 | namespace OpenSim.Region.ScriptEngine.XEngine | 23 | namespace OpenSim.Region.ScriptEngine.XEngine |
20 | { | 24 | { |
21 | public class XEngine : IRegionModule | 25 | public class XEngine : IRegionModule, IScriptEngine |
22 | { | 26 | { |
23 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 27 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
24 | 28 | ||
@@ -30,10 +34,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
30 | private EventManager m_EventManager; | 34 | private EventManager m_EventManager; |
31 | private int m_EventLimit; | 35 | private int m_EventLimit; |
32 | private bool m_KillTimedOutScripts; | 36 | private bool m_KillTimedOutScripts; |
37 | public AsyncCommandManager m_AsyncCommands; | ||
33 | 38 | ||
34 | private static List<XEngine> m_ScriptEngines = | 39 | private static List<XEngine> m_ScriptEngines = |
35 | new List<XEngine>(); | 40 | new List<XEngine>(); |
36 | public AsyncCommandManager m_ASYNCLSLCommandManager; | ||
37 | 41 | ||
38 | // Maps the local id to the script inventory items in it | 42 | // Maps the local id to the script inventory items in it |
39 | 43 | ||
@@ -87,11 +91,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
87 | string Script; | 91 | string Script; |
88 | } | 92 | } |
89 | 93 | ||
90 | public IConfig ScriptConfigSource | 94 | public IConfig Config |
91 | { | 95 | { |
92 | get { return m_ScriptConfig; } | 96 | get { return m_ScriptConfig; } |
93 | } | 97 | } |
94 | 98 | ||
99 | public Object AsyncCommands | ||
100 | { | ||
101 | get { return (Object)m_AsyncCommands; } | ||
102 | } | ||
103 | |||
95 | // | 104 | // |
96 | // IRegionModule functions | 105 | // IRegionModule functions |
97 | // | 106 | // |
@@ -155,7 +164,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
155 | } | 164 | } |
156 | 165 | ||
157 | m_EventManager = new EventManager(this); | 166 | m_EventManager = new EventManager(this); |
158 | m_ASYNCLSLCommandManager = new AsyncCommandManager(this); | ||
159 | 167 | ||
160 | StartEngine(minThreads, maxThreads, idleTimeout, prio, | 168 | StartEngine(minThreads, maxThreads, idleTimeout, prio, |
161 | maxScriptQueue, stackSize); | 169 | maxScriptQueue, stackSize); |
@@ -166,6 +174,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
166 | m_Scene.EventManager.OnRemoveScript += OnRemoveScript; | 174 | m_Scene.EventManager.OnRemoveScript += OnRemoveScript; |
167 | m_Scene.EventManager.OnScriptReset += OnScriptReset; | 175 | m_Scene.EventManager.OnScriptReset += OnScriptReset; |
168 | 176 | ||
177 | m_AsyncCommands = new AsyncCommandManager(this); | ||
178 | |||
169 | if (sleepTime > 0) | 179 | if (sleepTime > 0) |
170 | { | 180 | { |
171 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( | 181 | m_ThreadPool.QueueWorkItem(new WorkItemCallback( |
@@ -418,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
418 | if (!m_Scripts.ContainsKey(itemID)) | 428 | if (!m_Scripts.ContainsKey(itemID)) |
419 | return; | 429 | return; |
420 | 430 | ||
421 | m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); | 431 | m_AsyncCommands.RemoveScript(localID, itemID); |
422 | 432 | ||
423 | XScriptInstance instance=m_Scripts[itemID]; | 433 | XScriptInstance instance=m_Scripts[itemID]; |
424 | m_Scripts.Remove(itemID); | 434 | m_Scripts.Remove(itemID); |
@@ -552,7 +562,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
552 | // | 562 | // |
553 | // Post event to an entire prim | 563 | // Post event to an entire prim |
554 | // | 564 | // |
555 | public bool PostObjectEvent(uint localID, XEventParams p) | 565 | public bool PostObjectEvent(uint localID, EventParams p) |
556 | { | 566 | { |
557 | bool result = false; | 567 | bool result = false; |
558 | 568 | ||
@@ -577,7 +587,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
577 | // | 587 | // |
578 | // Post an event to a single script | 588 | // Post an event to a single script |
579 | // | 589 | // |
580 | public bool PostScriptEvent(LLUUID itemID, XEventParams p) | 590 | public bool PostScriptEvent(LLUUID itemID, EventParams p) |
581 | { | 591 | { |
582 | if (m_Scripts.ContainsKey(itemID)) | 592 | if (m_Scripts.ContainsKey(itemID)) |
583 | { | 593 | { |
@@ -654,7 +664,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
654 | instance.ResetScript(); | 664 | instance.ResetScript(); |
655 | } | 665 | } |
656 | 666 | ||
657 | public XDetectParams GetDetectParams(LLUUID itemID, int idx) | 667 | public DetectParams GetDetectParams(LLUUID itemID, int idx) |
658 | { | 668 | { |
659 | XScriptInstance instance = GetInstance(itemID); | 669 | XScriptInstance instance = GetInstance(itemID); |
660 | if (instance != null) | 670 | if (instance != null) |
@@ -669,115 +679,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
669 | return instance.GetDetectID(idx); | 679 | return instance.GetDetectID(idx); |
670 | return LLUUID.Zero; | 680 | return LLUUID.Zero; |
671 | } | 681 | } |
672 | } | ||
673 | |||
674 | public class XDetectParams | ||
675 | { | ||
676 | public XDetectParams() | ||
677 | { | ||
678 | Key = LLUUID.Zero; | ||
679 | OffsetPos = new LSL_Types.Vector3(); | ||
680 | LinkNum = 0; | ||
681 | Group = LLUUID.Zero; | ||
682 | Name = String.Empty; | ||
683 | Owner = LLUUID.Zero; | ||
684 | Position = new LSL_Types.Vector3(); | ||
685 | Rotation = new LSL_Types.Quaternion(); | ||
686 | Type = 0; | ||
687 | Velocity = new LSL_Types.Vector3(); | ||
688 | } | ||
689 | |||
690 | public LLUUID Key; | ||
691 | public LSL_Types.Vector3 OffsetPos; | ||
692 | public int LinkNum; | ||
693 | public LLUUID Group; | ||
694 | public string Name; | ||
695 | public LLUUID Owner; | ||
696 | public LSL_Types.Vector3 Position; | ||
697 | public LSL_Types.Quaternion Rotation; | ||
698 | public int Type; | ||
699 | public LSL_Types.Vector3 Velocity; | ||
700 | |||
701 | public void Populate(Scene scene) | ||
702 | { | ||
703 | SceneObjectPart part = scene.GetSceneObjectPart(Key); | ||
704 | if (part == null) // Avatar, maybe? | ||
705 | { | ||
706 | ScenePresence presence = scene.GetScenePresence(Key); | ||
707 | if (presence == null) | ||
708 | return; | ||
709 | |||
710 | Name = presence.Firstname + " " + presence.Lastname; | ||
711 | Owner = Key; | ||
712 | Position = new LSL_Types.Vector3( | ||
713 | presence.AbsolutePosition.X, | ||
714 | presence.AbsolutePosition.X, | ||
715 | presence.AbsolutePosition.Z); | ||
716 | Rotation = new LSL_Types.Quaternion( | ||
717 | presence.Rotation.x, | ||
718 | presence.Rotation.y, | ||
719 | presence.Rotation.z, | ||
720 | presence.Rotation.w); | ||
721 | Velocity = new LSL_Types.Vector3( | ||
722 | presence.Velocity.X, | ||
723 | presence.Velocity.X, | ||
724 | presence.Velocity.Z); | ||
725 | |||
726 | Type = 0x01; // Avatar | ||
727 | if (presence.Velocity != LLVector3.Zero) | ||
728 | Type |= 0x02; // Active | ||
729 | |||
730 | Group = presence.ControllingClient.ActiveGroupId; | ||
731 | 682 | ||
683 | public void SetState(LLUUID itemID, string newState) | ||
684 | { | ||
685 | XScriptInstance instance = GetInstance(itemID); | ||
686 | if (instance == null) | ||
732 | return; | 687 | return; |
733 | } | 688 | instance.SetState(newState); |
734 | |||
735 | part=part.ParentGroup.RootPart; // We detect objects only | ||
736 | |||
737 | LinkNum = 0; // Not relevant | ||
738 | |||
739 | Group = part.GroupID; | ||
740 | Name = part.Name; | ||
741 | Owner = part.OwnerID; | ||
742 | if (part.Velocity == LLVector3.Zero) | ||
743 | Type = 0x04; // Passive | ||
744 | else | ||
745 | Type = 0x02; // Passive | ||
746 | |||
747 | foreach (SceneObjectPart p in part.ParentGroup.Children.Values) | ||
748 | { | ||
749 | if (part.ContainsScripts()) | ||
750 | { | ||
751 | Type |= 0x08; // Scripted | ||
752 | break; | ||
753 | } | ||
754 | } | ||
755 | |||
756 | Position = new LSL_Types.Vector3(part.AbsolutePosition.X, | ||
757 | part.AbsolutePosition.Y, | ||
758 | part.AbsolutePosition.Z); | ||
759 | |||
760 | LLQuaternion wr = part.GetWorldRotation(); | ||
761 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); | ||
762 | |||
763 | Velocity = new LSL_Types.Vector3(part.Velocity.X, | ||
764 | part.Velocity.Y, | ||
765 | part.Velocity.Z); | ||
766 | } | 689 | } |
767 | } | 690 | public string GetState(LLUUID itemID) |
768 | |||
769 | public class XEventParams | ||
770 | { | ||
771 | public XEventParams(string eventName, Object[] eventParams, XDetectParams[] detectParams) | ||
772 | { | 691 | { |
773 | EventName=eventName; | 692 | XScriptInstance instance = GetInstance(itemID); |
774 | Params=eventParams; | 693 | if (instance == null) |
775 | DetectParams=detectParams; | 694 | return "default"; |
695 | return instance.State; | ||
776 | } | 696 | } |
777 | |||
778 | public string EventName; | ||
779 | public Object[] Params; | ||
780 | public XDetectParams[] DetectParams; | ||
781 | } | 697 | } |
782 | 698 | ||
783 | public class XScriptInstance | 699 | public class XScriptInstance |
@@ -791,17 +707,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
791 | private LLUUID m_ObjectID; | 707 | private LLUUID m_ObjectID; |
792 | private LLUUID m_AssetID; | 708 | private LLUUID m_AssetID; |
793 | private IScript m_Script; | 709 | private IScript m_Script; |
794 | private LSL_ScriptCommands m_LSLCommands; | ||
795 | private OSSL_ScriptCommands m_OSSLCommands; | ||
796 | private Executor m_Executor; | 710 | private Executor m_Executor; |
797 | private LLUUID m_AppDomain; | 711 | private LLUUID m_AppDomain; |
798 | private XDetectParams[] m_DetectParams; | 712 | private DetectParams[] m_DetectParams; |
799 | private bool m_TimerQueued; | 713 | private bool m_TimerQueued; |
800 | private DateTime m_EventStart; | 714 | private DateTime m_EventStart; |
801 | private bool m_InEvent; | 715 | private bool m_InEvent; |
802 | private string m_PrimName; | 716 | private string m_PrimName; |
803 | private string m_ScriptName; | 717 | private string m_ScriptName; |
804 | private string m_Assembly; | 718 | private string m_Assembly; |
719 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); | ||
805 | 720 | ||
806 | public enum StateSource | 721 | public enum StateSource |
807 | { | 722 | { |
@@ -893,6 +808,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
893 | m_ScriptName = scriptName; | 808 | m_ScriptName = scriptName; |
894 | m_Assembly = assembly; | 809 | m_Assembly = assembly; |
895 | 810 | ||
811 | ApiManager am = new ApiManager(); | ||
812 | |||
896 | SceneObjectPart part=engine.World.GetSceneObjectPart(localID); | 813 | SceneObjectPart part=engine.World.GetSceneObjectPart(localID); |
897 | if (part == null) | 814 | if (part == null) |
898 | { | 815 | { |
@@ -900,10 +817,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
900 | return; | 817 | return; |
901 | } | 818 | } |
902 | 819 | ||
903 | m_LSLCommands = new LSL_ScriptCommands(engine, this, part, localID, | 820 | foreach (string api in am.GetApis()) |
904 | itemID); | 821 | { |
905 | m_OSSLCommands = new OSSL_ScriptCommands(engine, this, part, | 822 | m_Apis[api] = am.CreateApi(api); |
906 | localID, itemID); | 823 | m_Apis[api].Initialize(engine, part, localID, itemID); |
824 | } | ||
907 | 825 | ||
908 | try | 826 | try |
909 | { | 827 | { |
@@ -918,14 +836,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
918 | 836 | ||
919 | try | 837 | try |
920 | { | 838 | { |
921 | m_Script.Start(m_LSLCommands, m_OSSLCommands); | 839 | foreach (KeyValuePair<string,IScriptApi> kv in m_Apis) |
840 | { | ||
841 | m_Script.InitApi(kv.Key, kv.Value); | ||
842 | } | ||
922 | 843 | ||
923 | m_Executor = new Executor(m_Script); | 844 | m_Executor = new Executor(m_Script); |
924 | 845 | ||
925 | // m_Engine.Log.Debug("[XEngine] Script instance created"); | 846 | // m_Engine.Log.Debug("[XEngine] Script instance created"); |
926 | 847 | ||
927 | part.SetScriptEvents(m_ItemID, | 848 | part.SetScriptEvents(m_ItemID, |
928 | (int)m_Executor.GetStateEventFlags()); | 849 | (int)m_Executor.GetStateEventFlags(State)); |
929 | } | 850 | } |
930 | catch (Exception e) | 851 | catch (Exception e) |
931 | { | 852 | { |
@@ -958,7 +879,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
958 | 879 | ||
959 | ScriptSerializer.Deserialize(xml, this); | 880 | ScriptSerializer.Deserialize(xml, this); |
960 | 881 | ||
961 | m_Engine.m_ASYNCLSLCommandManager.CreateFromData( | 882 | m_Engine.m_AsyncCommands.CreateFromData( |
962 | m_LocalID, m_ItemID, m_ObjectID, | 883 | m_LocalID, m_ItemID, m_ObjectID, |
963 | PluginData); | 884 | PluginData); |
964 | 885 | ||
@@ -976,32 +897,32 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
976 | if (stateSource == StateSource.NewRez) | 897 | if (stateSource == StateSource.NewRez) |
977 | { | 898 | { |
978 | // m_Engine.Log.Debug("[XEngine] Posted changed(CHANGED_REGION_RESTART) to script"); | 899 | // m_Engine.Log.Debug("[XEngine] Posted changed(CHANGED_REGION_RESTART) to script"); |
979 | PostEvent(new XEventParams("changed", | 900 | PostEvent(new EventParams("changed", |
980 | new Object[] {new LSL_Types.LSLInteger(256)}, new XDetectParams[0])); | 901 | new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0])); |
981 | } | 902 | } |
982 | } | 903 | } |
983 | } | 904 | } |
984 | else | 905 | else |
985 | { | 906 | { |
986 | m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); | 907 | m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); |
987 | PostEvent(new XEventParams("state_entry", | 908 | PostEvent(new EventParams("state_entry", |
988 | new Object[0], new XDetectParams[0])); | 909 | new Object[0], new DetectParams[0])); |
989 | Start(); | 910 | Start(); |
990 | } | 911 | } |
991 | } | 912 | } |
992 | catch (Exception e) | 913 | catch (Exception e) |
993 | { | 914 | { |
994 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); | 915 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); |
995 | PostEvent(new XEventParams("state_entry", | 916 | PostEvent(new EventParams("state_entry", |
996 | new Object[0], new XDetectParams[0])); | 917 | new Object[0], new DetectParams[0])); |
997 | Start(); | 918 | Start(); |
998 | } | 919 | } |
999 | } | 920 | } |
1000 | else | 921 | else |
1001 | { | 922 | { |
1002 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); | 923 | m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); |
1003 | PostEvent(new XEventParams("state_entry", | 924 | PostEvent(new EventParams("state_entry", |
1004 | new Object[0], new XDetectParams[0])); | 925 | new Object[0], new DetectParams[0])); |
1005 | Start(); | 926 | Start(); |
1006 | } | 927 | } |
1007 | } | 928 | } |
@@ -1100,15 +1021,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1100 | 1021 | ||
1101 | public void SetState(string state) | 1022 | public void SetState(string state) |
1102 | { | 1023 | { |
1103 | PostEvent(new XEventParams("state_exit", new Object[0], | 1024 | PostEvent(new EventParams("state_exit", new Object[0], |
1104 | new XDetectParams[0])); | 1025 | new DetectParams[0])); |
1105 | PostEvent(new XEventParams("state", new Object[] { state }, | 1026 | PostEvent(new EventParams("state", new Object[] { state }, |
1106 | new XDetectParams[0])); | 1027 | new DetectParams[0])); |
1107 | PostEvent(new XEventParams("state_entry", new Object[0], | 1028 | PostEvent(new EventParams("state_entry", new Object[0], |
1108 | new XDetectParams[0])); | 1029 | new DetectParams[0])); |
1109 | } | 1030 | } |
1110 | 1031 | ||
1111 | public void PostEvent(XEventParams data) | 1032 | public void PostEvent(EventParams data) |
1112 | { | 1033 | { |
1113 | // m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", | 1034 | // m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", |
1114 | // m_PrimName, m_ScriptName, data.EventName, m_State); | 1035 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
@@ -1137,11 +1058,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1137 | 1058 | ||
1138 | public object EventProcessor() | 1059 | public object EventProcessor() |
1139 | { | 1060 | { |
1140 | XEventParams data = null; | 1061 | EventParams data = null; |
1141 | 1062 | ||
1142 | lock (m_EventQueue) | 1063 | lock (m_EventQueue) |
1143 | { | 1064 | { |
1144 | data = (XEventParams) m_EventQueue.Dequeue(); | 1065 | data = (EventParams) m_EventQueue.Dequeue(); |
1145 | if (data == null) // Shouldn't happen | 1066 | if (data == null) // Shouldn't happen |
1146 | { | 1067 | { |
1147 | m_CurrentResult = null; | 1068 | m_CurrentResult = null; |
@@ -1158,7 +1079,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1158 | // m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}", | 1079 | // m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}", |
1159 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 1080 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); |
1160 | m_State=data.Params[0].ToString(); | 1081 | m_State=data.Params[0].ToString(); |
1161 | m_Engine.m_ASYNCLSLCommandManager.RemoveScript( | 1082 | m_Engine.m_AsyncCommands.RemoveScript( |
1162 | m_LocalID, m_ItemID); | 1083 | m_LocalID, m_ItemID); |
1163 | 1084 | ||
1164 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 1085 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
@@ -1166,7 +1087,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1166 | if (part != null) | 1087 | if (part != null) |
1167 | { | 1088 | { |
1168 | part.SetScriptEvents(m_ItemID, | 1089 | part.SetScriptEvents(m_ItemID, |
1169 | (int)m_Executor.GetStateEventFlags()); | 1090 | (int)m_Executor.GetStateEventFlags(State)); |
1170 | } | 1091 | } |
1171 | } | 1092 | } |
1172 | else | 1093 | else |
@@ -1181,7 +1102,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1181 | { | 1102 | { |
1182 | m_EventStart = DateTime.Now; | 1103 | m_EventStart = DateTime.Now; |
1183 | m_InEvent = true; | 1104 | m_InEvent = true; |
1184 | m_Executor.ExecuteEvent(data.EventName, data.Params); | 1105 | m_Executor.ExecuteEvent(State, data.EventName, data.Params); |
1185 | m_InEvent = false; | 1106 | m_InEvent = false; |
1186 | } | 1107 | } |
1187 | catch (Exception e) | 1108 | catch (Exception e) |
@@ -1259,14 +1180,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1259 | bool running = Running; | 1180 | bool running = Running; |
1260 | 1181 | ||
1261 | Stop(0); | 1182 | Stop(0); |
1262 | m_Engine.m_ASYNCLSLCommandManager.RemoveScript(m_LocalID, m_ItemID); | 1183 | m_Engine.m_AsyncCommands.RemoveScript(m_LocalID, m_ItemID); |
1263 | m_EventQueue.Clear(); | 1184 | m_EventQueue.Clear(); |
1264 | m_Script.ResetVars(); | 1185 | m_Script.ResetVars(); |
1265 | m_State = "default"; | 1186 | m_State = "default"; |
1266 | if (running) | 1187 | if (running) |
1267 | Start(); | 1188 | Start(); |
1268 | PostEvent(new XEventParams("state_entry", | 1189 | PostEvent(new EventParams("state_entry", |
1269 | new Object[0], new XDetectParams[0])); | 1190 | new Object[0], new DetectParams[0])); |
1270 | } | 1191 | } |
1271 | 1192 | ||
1272 | public Dictionary<string, object> GetVars() | 1193 | public Dictionary<string, object> GetVars() |
@@ -1279,7 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1279 | m_Script.SetVars(vars); | 1200 | m_Script.SetVars(vars); |
1280 | } | 1201 | } |
1281 | 1202 | ||
1282 | public XDetectParams GetDetectParams(int idx) | 1203 | public DetectParams GetDetectParams(int idx) |
1283 | { | 1204 | { |
1284 | if (idx < 0 || idx >= m_DetectParams.Length) | 1205 | if (idx < 0 || idx >= m_DetectParams.Length) |
1285 | return null; | 1206 | return null; |
@@ -1298,7 +1219,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1298 | public void SaveState(string assembly) | 1219 | public void SaveState(string assembly) |
1299 | { | 1220 | { |
1300 | PluginData = | 1221 | PluginData = |
1301 | m_Engine.m_ASYNCLSLCommandManager.GetSerializationData( | 1222 | m_Engine.m_AsyncCommands.GetSerializationData( |
1302 | m_ItemID); | 1223 | m_ItemID); |
1303 | 1224 | ||
1304 | string xml = ScriptSerializer.Serialize(this); | 1225 | string xml = ScriptSerializer.Serialize(this); |
@@ -1368,7 +1289,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1368 | 1289 | ||
1369 | while (count > 0) | 1290 | while (count > 0) |
1370 | { | 1291 | { |
1371 | XEventParams ep = (XEventParams)instance.EventQueue.Dequeue(); | 1292 | EventParams ep = (EventParams)instance.EventQueue.Dequeue(); |
1372 | instance.EventQueue.Enqueue(ep); | 1293 | instance.EventQueue.Enqueue(ep); |
1373 | count--; | 1294 | count--; |
1374 | 1295 | ||
@@ -1387,7 +1308,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1387 | 1308 | ||
1388 | XmlElement detect = xmldoc.CreateElement("", "Detected", ""); | 1309 | XmlElement detect = xmldoc.CreateElement("", "Detected", ""); |
1389 | 1310 | ||
1390 | foreach (XDetectParams det in ep.DetectParams) | 1311 | foreach (DetectParams det in ep.DetectParams) |
1391 | { | 1312 | { |
1392 | XmlElement objectElem = xmldoc.CreateElement("", "Object", | 1313 | XmlElement objectElem = xmldoc.CreateElement("", "Object", |
1393 | ""); | 1314 | ""); |
@@ -1449,9 +1370,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1449 | rootElement.AppendChild(queue); | 1370 | rootElement.AppendChild(queue); |
1450 | 1371 | ||
1451 | XmlNode plugins = xmldoc.CreateElement("", "Plugins", ""); | 1372 | XmlNode plugins = xmldoc.CreateElement("", "Plugins", ""); |
1452 | if (instance.PluginData.Length > 0) | 1373 | DumpList(xmldoc, plugins, |
1453 | DumpList(xmldoc, plugins, | 1374 | new LSL_Types.list(instance.PluginData)); |
1454 | new LSL_Types.list(instance.PluginData)); | ||
1455 | 1375 | ||
1456 | rootElement.AppendChild(plugins); | 1376 | rootElement.AppendChild(plugins); |
1457 | 1377 | ||
@@ -1510,8 +1430,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1510 | foreach (XmlNode item in itemL) | 1430 | foreach (XmlNode item in itemL) |
1511 | { | 1431 | { |
1512 | List<Object> parms = new List<Object>(); | 1432 | List<Object> parms = new List<Object>(); |
1513 | List<XDetectParams> detected = | 1433 | List<DetectParams> detected = |
1514 | new List<XDetectParams>(); | 1434 | new List<DetectParams>(); |
1515 | 1435 | ||
1516 | string eventName = | 1436 | string eventName = |
1517 | item.Attributes.GetNamedItem("event").Value; | 1437 | item.Attributes.GetNamedItem("event").Value; |
@@ -1595,7 +1515,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1595 | LLUUID.TryParse(det.InnerText, | 1515 | LLUUID.TryParse(det.InnerText, |
1596 | out uuid); | 1516 | out uuid); |
1597 | 1517 | ||
1598 | XDetectParams d = new XDetectParams(); | 1518 | DetectParams d = new DetectParams(); |
1599 | d.Key = uuid; | 1519 | d.Key = uuid; |
1600 | d.OffsetPos = v; | 1520 | d.OffsetPos = v; |
1601 | d.LinkNum = d_linkNum; | 1521 | d.LinkNum = d_linkNum; |
@@ -1612,7 +1532,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1612 | break; | 1532 | break; |
1613 | } | 1533 | } |
1614 | } | 1534 | } |
1615 | XEventParams ep = new XEventParams( | 1535 | EventParams ep = new EventParams( |
1616 | eventName, parms.ToArray(), | 1536 | eventName, parms.ToArray(), |
1617 | detected.ToArray()); | 1537 | detected.ToArray()); |
1618 | instance.EventQueue.Enqueue(ep); | 1538 | instance.EventQueue.Enqueue(ep); |