From cf168194e5968c1fab33266bdbb57465f303860b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Jan 2013 02:28:27 +0000 Subject: If ScriptStopStrategy hasn't been set to co-op in [XEngine] config, then continue to generate C# that is functionality identical to historical generation This is to eliminate disruption until co-op termination has been well-tested. In non co-op mode, XEngine will continue to load DLLs of the existing Script class and the new XEngineScript class. Moving to co-op mode still requires existing script DLL deletion to force recompilation, either manually or by setting DeleteScriptsOnStartup = true for one run. This change also means that scripts which fail to initialize do not still show up as running scripts. --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index e6ec0e1..4cfcb75 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -251,7 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// /// /// - public void Load(AppDomain dom, string assembly, StateSource stateSource) + /// false if load failed, true if suceeded + public bool Load(AppDomain dom, string assembly, StateSource stateSource) { m_Assembly = assembly; m_stateSource = stateSource; @@ -266,26 +267,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance try { + object[] constructorParams; + + Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly)); + Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript"); + + if (scriptType != null) + { + constructorParams = new object[] { m_coopSleepHandle }; + } + else if (!m_coopTermination) + { + scriptType = scriptAssembly.GetType("SecondLife.Script"); + constructorParams = null; + } + else + { + m_log.ErrorFormat( + "[SCRIPT INSTANCE]: You must remove all existing script DLLs before using enabling co-op termination" + + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run" + + " or by deleting all *.dll* files in the relevant bin/ScriptEngines// directory"); + + return false; + } + +// m_log.DebugFormat( +// "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}", +// scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name); + if (dom != System.AppDomain.CurrentDomain) m_Script = (IScript)dom.CreateInstanceAndUnwrap( Path.GetFileNameWithoutExtension(assembly), - "SecondLife.Script", + scriptType.FullName, false, BindingFlags.Default, null, - new object[] { m_coopSleepHandle }, - null, + constructorParams, null, null); else m_Script - = (IScript)Assembly.Load(Path.GetFileNameWithoutExtension(assembly)).CreateInstance( - "SecondLife.Script", + = (IScript)scriptAssembly.CreateInstance( + scriptType.FullName, false, BindingFlags.Default, null, - new object[] { m_coopSleepHandle }, + constructorParams, null, null); @@ -298,6 +326,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_log.ErrorFormat( "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", assembly, e.Message, e.StackTrace); + + return false; } try @@ -318,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", assembly, e.Message, e.StackTrace); - return; + return false; } m_SaveState = true; @@ -390,6 +420,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); // } + + return true; } public void Init() -- cgit v1.1