diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/Executor.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/Executor.cs | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index cadd55c..363d81e 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs | |||
@@ -23,7 +23,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
23 | // Object never expires | 23 | // Object never expires |
24 | public override Object InitializeLifetimeService() | 24 | public override Object InitializeLifetimeService() |
25 | { | 25 | { |
26 | Console.WriteLine("Executor: InitializeLifetimeService()"); | 26 | //Console.WriteLine("Executor: InitializeLifetimeService()"); |
27 | // return null; | 27 | // return null; |
28 | ILease lease = (ILease)base.InitializeLifetimeService(); | 28 | ILease lease = (ILease)base.InitializeLifetimeService(); |
29 | 29 | ||
@@ -45,54 +45,60 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
45 | { | 45 | { |
46 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 46 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
47 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! | 47 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! |
48 | 48 | try | |
49 | if (m_Running == false) | ||
50 | { | 49 | { |
51 | // Script is inactive, do not execute! | 50 | if (m_Running == false) |
52 | return; | 51 | { |
53 | } | 52 | // Script is inactive, do not execute! |
53 | return; | ||
54 | } | ||
54 | 55 | ||
55 | string EventName = m_Script.State() + "_event_" + FunctionName; | 56 | string EventName = m_Script.State() + "_event_" + FunctionName; |
56 | 57 | ||
57 | //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); | 58 | //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); |
58 | 59 | ||
59 | Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); | 60 | Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); |
60 | 61 | ||
61 | if (Events.ContainsKey(EventName) == false) | 62 | if (Events.ContainsKey(EventName) == false) |
62 | { | ||
63 | // Not found, create | ||
64 | Type type = m_Script.GetType(); | ||
65 | try | ||
66 | { | ||
67 | MethodInfo mi = type.GetMethod(EventName); | ||
68 | Events.Add(EventName, mi); | ||
69 | } | ||
70 | catch (Exception e) | ||
71 | { | 63 | { |
72 | // Event name not found, cache it as not found | 64 | // Not found, create |
73 | Events.Add(EventName, null); | 65 | Type type = m_Script.GetType(); |
66 | try | ||
67 | { | ||
68 | MethodInfo mi = type.GetMethod(EventName); | ||
69 | Events.Add(EventName, mi); | ||
70 | } | ||
71 | catch (Exception e) | ||
72 | { | ||
73 | // Event name not found, cache it as not found | ||
74 | Events.Add(EventName, null); | ||
75 | } | ||
74 | } | 76 | } |
75 | } | ||
76 | 77 | ||
77 | // Get event | 78 | // Get event |
78 | MethodInfo ev = null; | 79 | MethodInfo ev = null; |
79 | Events.TryGetValue(EventName, out ev); | 80 | Events.TryGetValue(EventName, out ev); |
80 | 81 | ||
81 | if (ev == null) // No event by that name! | 82 | if (ev == null) // No event by that name! |
82 | return; | 83 | { |
84 | Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); | ||
85 | return; | ||
86 | } | ||
83 | 87 | ||
84 | // Found | 88 | // Found |
85 | try | 89 | try |
86 | { | 90 | { |
87 | // Invoke it | 91 | // Invoke it |
88 | ev.Invoke(m_Script, args); | 92 | ev.Invoke(m_Script, args); |
89 | 93 | ||
94 | } | ||
95 | catch (Exception e) | ||
96 | { | ||
97 | // TODO: Send to correct place | ||
98 | Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); | ||
99 | } | ||
90 | } | 100 | } |
91 | catch (Exception e) | 101 | catch { } |
92 | { | ||
93 | // TODO: Send to correct place | ||
94 | Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); | ||
95 | } | ||
96 | } | 102 | } |
97 | 103 | ||
98 | 104 | ||