diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 816d8ba..6e04e79 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -47,13 +47,15 @@ using OpenSim.Framework; | |||
47 | using OpenSim.Framework.Console; | 47 | using OpenSim.Framework.Console; |
48 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Interfaces; | 49 | using OpenSim.Region.Framework.Interfaces; |
50 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
50 | using OpenSim.Region.ScriptEngine.Shared; | 51 | using OpenSim.Region.ScriptEngine.Shared; |
51 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 52 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
52 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; | 53 | using OpenSim.Region.ScriptEngine.Shared.CodeTools; |
53 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 54 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
54 | using OpenSim.Region.ScriptEngine.Shared.Api; | 55 | using OpenSim.Region.ScriptEngine.Shared.Api; |
55 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | 56 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
56 | using OpenSim.Region.ScriptEngine.Interfaces; | 57 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
58 | using OpenSim.Region.ScriptEngine.XEngine.ScriptBase; | ||
57 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; | 59 | using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; |
58 | 60 | ||
59 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | 61 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; |
@@ -244,6 +246,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
244 | get { return "XEngine"; } | 246 | get { return "XEngine"; } |
245 | } | 247 | } |
246 | 248 | ||
249 | public string ScriptClassName { get; private set; } | ||
250 | |||
251 | public string ScriptBaseClassName { get; private set; } | ||
252 | |||
253 | public ParameterInfo[] ScriptBaseClassParameters { get; private set; } | ||
254 | |||
255 | public string[] ScriptReferencedAssemblies { get; private set; } | ||
256 | |||
247 | public Scene World | 257 | public Scene World |
248 | { | 258 | { |
249 | get { return m_Scene; } | 259 | get { return m_Scene; } |
@@ -298,21 +308,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
298 | 308 | ||
299 | m_ScriptConfig = configSource.Configs["XEngine"]; | 309 | m_ScriptConfig = configSource.Configs["XEngine"]; |
300 | m_ConfigSource = configSource; | 310 | m_ConfigSource = configSource; |
311 | |||
312 | string rawScriptStopStrategy = m_ScriptConfig.GetString("ScriptStopStrategy", "abort"); | ||
313 | |||
314 | m_log.InfoFormat("[XEngine]: Script stop strategy is {0}", rawScriptStopStrategy); | ||
315 | |||
316 | if (rawScriptStopStrategy == "co-op") | ||
317 | { | ||
318 | ScriptClassName = "XEngineScript"; | ||
319 | ScriptBaseClassName = typeof(XEngineScriptBase).FullName; | ||
320 | ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); | ||
321 | ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) }; | ||
322 | } | ||
323 | else | ||
324 | { | ||
325 | ScriptClassName = "Script"; | ||
326 | ScriptBaseClassName = typeof(ScriptBaseClass).FullName; | ||
327 | } | ||
328 | |||
329 | // Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]); | ||
301 | } | 330 | } |
302 | 331 | ||
303 | public void AddRegion(Scene scene) | 332 | public void AddRegion(Scene scene) |
304 | { | 333 | { |
305 | if (m_ScriptConfig == null) | 334 | if (m_ScriptConfig == null) |
306 | return; | 335 | return; |
336 | |||
307 | m_ScriptFailCount = 0; | 337 | m_ScriptFailCount = 0; |
308 | m_ScriptErrorMessage = String.Empty; | 338 | m_ScriptErrorMessage = String.Empty; |
309 | 339 | ||
310 | if (m_ScriptConfig == null) | ||
311 | { | ||
312 | // m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled"); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true); | 340 | m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true); |
317 | 341 | ||
318 | if (!m_Enabled) | 342 | if (!m_Enabled) |
@@ -1180,7 +1204,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1180 | } | 1204 | } |
1181 | 1205 | ||
1182 | m_log.DebugFormat( | 1206 | m_log.DebugFormat( |
1183 | "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | 1207 | "[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", |
1184 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | 1208 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, |
1185 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | 1209 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); |
1186 | 1210 | ||
@@ -1201,6 +1225,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1201 | lock (m_AddingAssemblies) | 1225 | lock (m_AddingAssemblies) |
1202 | { | 1226 | { |
1203 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); | 1227 | m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); |
1228 | |||
1204 | if (!m_AddingAssemblies.ContainsKey(assembly)) { | 1229 | if (!m_AddingAssemblies.ContainsKey(assembly)) { |
1205 | m_AddingAssemblies[assembly] = 1; | 1230 | m_AddingAssemblies[assembly] = 1; |
1206 | } else { | 1231 | } else { |
@@ -1250,7 +1275,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1250 | } | 1275 | } |
1251 | catch (Exception e) | 1276 | catch (Exception e) |
1252 | { | 1277 | { |
1253 | // m_log.ErrorFormat("[XEngine]: Exception when rezzing script {0}{1}", e.Message, e.StackTrace); | 1278 | // m_log.ErrorFormat( |
1279 | // "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}", | ||
1280 | // itemID, e.Message, e.StackTrace); | ||
1254 | 1281 | ||
1255 | // try | 1282 | // try |
1256 | // { | 1283 | // { |
@@ -1329,13 +1356,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1329 | sandbox = AppDomain.CurrentDomain; | 1356 | sandbox = AppDomain.CurrentDomain; |
1330 | } | 1357 | } |
1331 | 1358 | ||
1332 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 1359 | if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource)) |
1333 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 1360 | return false; |
1334 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | ||
1335 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | ||
1336 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | ||
1337 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | ||
1338 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | ||
1339 | 1361 | ||
1340 | m_AppDomains[appDomain] = sandbox; | 1362 | m_AppDomains[appDomain] = sandbox; |
1341 | 1363 | ||