diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs | 61 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs (renamed from OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 48 |
4 files changed, 101 insertions, 12 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs b/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs new file mode 100644 index 0000000..f4211c8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/Api/Runtime/XEngineScriptBase.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting; | ||
30 | using System.Runtime.Remoting.Lifetime; | ||
31 | using System.Security.Permissions; | ||
32 | using System.Threading; | ||
33 | using System.Reflection; | ||
34 | using System.Collections; | ||
35 | using System.Collections.Generic; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared; | ||
38 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
39 | |||
40 | namespace OpenSim.Region.ScriptEngine.XEngine.ScriptBase | ||
41 | { | ||
42 | public class XEngineScriptBase : ScriptBaseClass | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Used for script sleeps when we are using co-operative script termination. | ||
46 | /// </summary> | ||
47 | /// <remarks>null if co-operative script termination is not active</remarks> | ||
48 | WaitHandle m_coopSleepHandle; | ||
49 | |||
50 | public XEngineScriptBase(WaitHandle coopSleepHandle) : base() | ||
51 | { | ||
52 | m_coopSleepHandle = coopSleepHandle; | ||
53 | } | ||
54 | |||
55 | public void opensim_reserved_CheckForCoopTermination() | ||
56 | { | ||
57 | if (m_coopSleepHandle != null && m_coopSleepHandle.WaitOne(0)) | ||
58 | throw new ScriptCoopStopException(); | ||
59 | } | ||
60 | } | ||
61 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 9405075..afde685 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
52 | { | 52 | { |
53 | myScriptEngine = _ScriptEngine; | 53 | myScriptEngine = _ScriptEngine; |
54 | 54 | ||
55 | m_log.Info("[XEngine] Hooking up to server events"); | 55 | // m_log.Info("[XEngine] Hooking up to server events"); |
56 | myScriptEngine.World.EventManager.OnAttach += attach; | 56 | myScriptEngine.World.EventManager.OnAttach += attach; |
57 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; | 57 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; |
58 | myScriptEngine.World.EventManager.OnObjectGrabbing += touch; | 58 | myScriptEngine.World.EventManager.OnObjectGrabbing += touch; |
@@ -69,7 +69,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
69 | myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start; | 69 | myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start; |
70 | myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision; | 70 | myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision; |
71 | myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end; | 71 | myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end; |
72 | IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>(); | 72 | IMoneyModule money = myScriptEngine.World.RequestModuleInterface<IMoneyModule>(); |
73 | if (money != null) | 73 | if (money != null) |
74 | { | 74 | { |
75 | money.OnObjectPaid+=HandleObjectPaid; | 75 | money.OnObjectPaid+=HandleObjectPaid; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs index 5abfe9a..5abfe9a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineBasicTests.cs | |||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 72646f6..d483219 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -46,13 +46,15 @@ using OpenSim.Framework; | |||
46 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Scenes; | 47 | using OpenSim.Region.Framework.Scenes; |
48 | using OpenSim.Region.Framework.Interfaces; | 48 | using OpenSim.Region.Framework.Interfaces; |
49 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
49 | using OpenSim.Region.ScriptEngine.Shared; | 50 | using OpenSim.Region.ScriptEngine.Shared; |
50 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 51 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
51 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 52 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
52 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 53 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
53 | using OpenSim.Region.ScriptEngine.Shared.Api; | 54 | using OpenSim.Region.ScriptEngine.Shared.Api; |
54 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 55 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
55 | using OpenSim.Region.ScriptEngine.Interfaces; | 56 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
57 | using OpenSim.Region.ScriptEngine.XEngine.ScriptBase; | ||
56 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; | 58 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; |
57 | 59 | ||
58 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | 60 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; |
@@ -176,6 +178,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
176 | get { return "XEngine"; } | 178 | get { return "XEngine"; } |
177 | } | 179 | } |
178 | 180 | ||
181 | public string ScriptClassName { get; private set; } | ||
182 | |||
183 | public string ScriptBaseClassName { get; private set; } | ||
184 | |||
185 | public ParameterInfo[] ScriptBaseClassParameters { get; private set; } | ||
186 | |||
187 | public string[] ScriptReferencedAssemblies { get; private set; } | ||
188 | |||
179 | public Scene World | 189 | public Scene World |
180 | { | 190 | { |
181 | get { return m_Scene; } | 191 | get { return m_Scene; } |
@@ -230,21 +240,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
230 | 240 | ||
231 | m_ScriptConfig = configSource.Configs["XEngine"]; | 241 | m_ScriptConfig = configSource.Configs["XEngine"]; |
232 | m_ConfigSource = configSource; | 242 | m_ConfigSource = configSource; |
243 | |||
244 | string rawScriptStopStrategy = m_ScriptConfig.GetString("ScriptStopStrategy", "abort"); | ||
245 | |||
246 | m_log.InfoFormat("[XEngine]: Script stop strategy is {0}", rawScriptStopStrategy); | ||
247 | |||
248 | if (rawScriptStopStrategy == "co-op") | ||
249 | { | ||
250 | ScriptClassName = "XEngineScript"; | ||
251 | ScriptBaseClassName = typeof(XEngineScriptBase).FullName; | ||
252 | ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); | ||
253 | ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) }; | ||
254 | } | ||
255 | else | ||
256 | { | ||
257 | ScriptClassName = "Script"; | ||
258 | ScriptBaseClassName = typeof(ScriptBaseClass).FullName; | ||
259 | } | ||
260 | |||
261 | // Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]); | ||
233 | } | 262 | } |
234 | 263 | ||
235 | public void AddRegion(Scene scene) | 264 | public void AddRegion(Scene scene) |
236 | { | 265 | { |
237 | if (m_ScriptConfig == null) | 266 | if (m_ScriptConfig == null) |
238 | return; | 267 | return; |
268 | |||
239 | m_ScriptFailCount = 0; | 269 | m_ScriptFailCount = 0; |
240 | m_ScriptErrorMessage = String.Empty; | 270 | m_ScriptErrorMessage = String.Empty; |
241 | 271 | ||
242 | if (m_ScriptConfig == null) | ||
243 | { | ||
244 | // m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled"); | ||
245 | return; | ||
246 | } | ||
247 | |||
248 | m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true); | 272 | m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true); |
249 | 273 | ||
250 | if (!m_Enabled) | 274 | if (!m_Enabled) |
@@ -1109,7 +1133,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1109 | } | 1133 | } |
1110 | 1134 | ||
1111 | m_log.DebugFormat( | 1135 | m_log.DebugFormat( |
1112 | "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | 1136 | "[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", |
1113 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | 1137 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, |
1114 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | 1138 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); |
1115 | 1139 | ||
@@ -1130,6 +1154,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1130 | lock (m_AddingAssemblies) | 1154 | lock (m_AddingAssemblies) |
1131 | { | 1155 | { |
1132 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); | 1156 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); |
1157 | |||
1133 | if (!m_AddingAssemblies.ContainsKey(assembly)) { | 1158 | if (!m_AddingAssemblies.ContainsKey(assembly)) { |
1134 | m_AddingAssemblies[assembly] = 1; | 1159 | m_AddingAssemblies[assembly] = 1; |
1135 | } else { | 1160 | } else { |
@@ -1179,7 +1204,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1179 | } | 1204 | } |
1180 | catch (Exception e) | 1205 | catch (Exception e) |
1181 | { | 1206 | { |
1182 | // m_log.ErrorFormat("[XEngine]: Exception when rezzing script {0}{1}", e.Message, e.StackTrace); | 1207 | // m_log.ErrorFormat( |
1208 | // "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}", | ||
1209 | // itemID, e.Message, e.StackTrace); | ||
1183 | 1210 | ||
1184 | // try | 1211 | // try |
1185 | // { | 1212 | // { |
@@ -1288,7 +1315,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1288 | startParam, postOnRez, | 1315 | startParam, postOnRez, |
1289 | m_MaxScriptQueue); | 1316 | m_MaxScriptQueue); |
1290 | 1317 | ||
1291 | instance.Load(m_AppDomains[appDomain], assembly, stateSource); | 1318 | if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) |
1319 | return false; | ||
1292 | 1320 | ||
1293 | // if (DebugLevel >= 1) | 1321 | // if (DebugLevel >= 1) |
1294 | // m_log.DebugFormat( | 1322 | // m_log.DebugFormat( |