aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs48
1 files changed, 40 insertions, 8 deletions
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
251 /// <param name='dom'></param> 251 /// <param name='dom'></param>
252 /// <param name='assembly'></param> 252 /// <param name='assembly'></param>
253 /// <param name='stateSource'></param> 253 /// <param name='stateSource'></param>
254 public void Load(AppDomain dom, string assembly, StateSource stateSource) 254 /// <returns>false if load failed, true if suceeded</returns>
255 public bool Load(AppDomain dom, string assembly, StateSource stateSource)
255 { 256 {
256 m_Assembly = assembly; 257 m_Assembly = assembly;
257 m_stateSource = stateSource; 258 m_stateSource = stateSource;
@@ -266,26 +267,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
266 267
267 try 268 try
268 { 269 {
270 object[] constructorParams;
271
272 Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly));
273 Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript");
274
275 if (scriptType != null)
276 {
277 constructorParams = new object[] { m_coopSleepHandle };
278 }
279 else if (!m_coopTermination)
280 {
281 scriptType = scriptAssembly.GetType("SecondLife.Script");
282 constructorParams = null;
283 }
284 else
285 {
286 m_log.ErrorFormat(
287 "[SCRIPT INSTANCE]: You must remove all existing script DLLs before using enabling co-op termination"
288 + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run"
289 + " or by deleting all *.dll* files in the relevant bin/ScriptEngines/<region-id>/ directory");
290
291 return false;
292 }
293
294// m_log.DebugFormat(
295// "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}",
296// scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name);
297
269 if (dom != System.AppDomain.CurrentDomain) 298 if (dom != System.AppDomain.CurrentDomain)
270 m_Script 299 m_Script
271 = (IScript)dom.CreateInstanceAndUnwrap( 300 = (IScript)dom.CreateInstanceAndUnwrap(
272 Path.GetFileNameWithoutExtension(assembly), 301 Path.GetFileNameWithoutExtension(assembly),
273 "SecondLife.Script", 302 scriptType.FullName,
274 false, 303 false,
275 BindingFlags.Default, 304 BindingFlags.Default,
276 null, 305 null,
277 new object[] { m_coopSleepHandle }, 306 constructorParams,
278 null,
279 null, 307 null,
280 null); 308 null);
281 else 309 else
282 m_Script 310 m_Script
283 = (IScript)Assembly.Load(Path.GetFileNameWithoutExtension(assembly)).CreateInstance( 311 = (IScript)scriptAssembly.CreateInstance(
284 "SecondLife.Script", 312 scriptType.FullName,
285 false, 313 false,
286 BindingFlags.Default, 314 BindingFlags.Default,
287 null, 315 null,
288 new object[] { m_coopSleepHandle }, 316 constructorParams,
289 null, 317 null,
290 null); 318 null);
291 319
@@ -298,6 +326,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
298 m_log.ErrorFormat( 326 m_log.ErrorFormat(
299 "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", 327 "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}",
300 assembly, e.Message, e.StackTrace); 328 assembly, e.Message, e.StackTrace);
329
330 return false;
301 } 331 }
302 332
303 try 333 try
@@ -318,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
318 "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", 348 "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}",
319 assembly, e.Message, e.StackTrace); 349 assembly, e.Message, e.StackTrace);
320 350
321 return; 351 return false;
322 } 352 }
323 353
324 m_SaveState = true; 354 m_SaveState = true;
@@ -390,6 +420,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
390// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); 420// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
391 421
392// } 422// }
423
424 return true;
393 } 425 }
394 426
395 public void Init() 427 public void Init()