aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
diff options
context:
space:
mode:
authorMelanie2011-10-25 03:16:40 +0100
committerMelanie2011-10-25 03:16:40 +0100
commit635b1bf18ef46f82257baa16fb1e3b068013ffc9 (patch)
tree50cba60ef9c3e604399a87bbf5d5d7f23a6724da /OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
parentMerge commit '5607fd3af828846291de3358067bb1214619489e' into bigmerge (diff)
parentExtend scripts stop/start/suspend/resume console commands to allow action on ... (diff)
downloadopensim-SC-635b1bf18ef46f82257baa16fb1e3b068013ffc9.zip
opensim-SC-635b1bf18ef46f82257baa16fb1e3b068013ffc9.tar.gz
opensim-SC-635b1bf18ef46f82257baa16fb1e3b068013ffc9.tar.bz2
opensim-SC-635b1bf18ef46f82257baa16fb1e3b068013ffc9.tar.xz
Merge commit '601dabb1b73a894e4f2f61abe6e9053d380008cd' into bigmerge
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs145
1 files changed, 109 insertions, 36 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index aa11eca..3ebeb75 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -344,14 +344,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine
344 "Synonym for scripts show command", HandleShowScripts); 344 "Synonym for scripts show command", HandleShowScripts);
345 345
346 MainConsole.Instance.Commands.AddCommand( 346 MainConsole.Instance.Commands.AddCommand(
347 "scripts", false, "scripts suspend", "scripts suspend", "Suspend all scripts", 347 "scripts", false, "scripts suspend", "scripts suspend [<script-item-uuid>]", "Suspends all running scripts",
348 "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" 348 "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a"
349 + " script that is currently processing an event.", 349 + " script that is currently processing an event.\n"
350 HandleSuspendScripts); 350 + "Suspended scripts will continue to accumulate events but won't process them.\n"
351 + "If a <script-item-uuid> is given then only that script will be suspended. Otherwise, all suitable scripts are suspended.",
352 (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript));
351 353
352 MainConsole.Instance.Commands.AddCommand( 354 MainConsole.Instance.Commands.AddCommand(
353 "scripts", false, "scripts resume", "scripts resume", "Resume all scripts", 355 "scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts",
354 "Resumes all currently suspended scripts", HandleResumeScripts); 356 "Resumes all currently suspended scripts.\n"
357 + "Resumed scripts will process all events accumulated whilst suspended."
358 + "If a <script-item-uuid> is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.",
359 (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript));
360
361 MainConsole.Instance.Commands.AddCommand(
362 "scripts", false, "scripts stop", "scripts stop [<script-item-uuid>]", "Stops all running scripts",
363 "Stops all running scripts."
364 + "If a <script-item-uuid> is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.",
365 (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript));
366
367 MainConsole.Instance.Commands.AddCommand(
368 "scripts", false, "scripts start", "scripts start [<script-item-uuid>]", "Starts all stopped scripts",
369 "Starts all stopped scripts."
370 + "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.",
371 (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
355 } 372 }
356 373
357 public void HandleShowScripts(string module, string[] cmdparams) 374 public void HandleShowScripts(string module, string[] cmdparams)
@@ -391,41 +408,101 @@ namespace OpenSim.Region.ScriptEngine.XEngine
391 } 408 }
392 } 409 }
393 410
394 public void HandleSuspendScripts(string module, string[] cmdparams) 411 /// <summary>
412 /// Parse the raw item id into a script instance from the command params if it's present.
413 /// </summary>
414 /// <param name="cmdparams"></param>
415 /// <param name="instance"></param>
416 /// <returns>true if we're okay to proceed, false if not.</returns>
417 private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action)
395 { 418 {
396 lock (m_Scripts) 419 lock (m_Scripts)
397 { 420 {
398 foreach (IScriptInstance instance in m_Scripts.Values) 421 string rawItemId;
422 UUID itemId = UUID.Zero;
423
424 if (cmdparams.Length == 2)
399 { 425 {
400 if (!instance.Suspended) 426 foreach (IScriptInstance instance in m_Scripts.Values)
401 { 427 action(instance);
402 instance.Suspend();
403 428
404 SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); 429 return;
405 MainConsole.Instance.OutputFormat( 430 }
406 "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", 431
407 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); 432 rawItemId = cmdparams[2];
433
434 if (!UUID.TryParse(rawItemId, out itemId))
435 {
436 MainConsole.Instance.OutputFormat("Error - {0} is not a valid UUID", rawItemId);
437 return;
438 }
439
440 if (itemId != UUID.Zero)
441 {
442 IScriptInstance instance = GetInstance(itemId);
443 if (instance == null)
444 {
445 MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId);
446 return;
447 }
448 else
449 {
450 action(instance);
451 return;
408 } 452 }
409 } 453 }
410 } 454 }
411 } 455 }
412 456
413 public void HandleResumeScripts(string module, string[] cmdparams) 457 private void HandleSuspendScript(IScriptInstance instance)
414 { 458 {
415 lock (m_Scripts) 459 if (!instance.Suspended)
416 { 460 {
417 foreach (IScriptInstance instance in m_Scripts.Values) 461 instance.Suspend();
418 {
419 if (instance.Suspended)
420 {
421 instance.Resume();
422 462
423 SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); 463 SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
424 MainConsole.Instance.OutputFormat( 464 MainConsole.Instance.OutputFormat(
425 "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", 465 "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
426 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); 466 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
427 } 467 }
428 } 468 }
469
470 private void HandleResumeScript(IScriptInstance instance)
471 {
472 if (instance.Suspended)
473 {
474 instance.Resume();
475
476 SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
477 MainConsole.Instance.OutputFormat(
478 "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
479 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
480 }
481 }
482
483 private void HandleStartScript(IScriptInstance instance)
484 {
485 if (!instance.Running)
486 {
487 instance.Start();
488
489 SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
490 MainConsole.Instance.OutputFormat(
491 "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
492 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
493 }
494 }
495
496 private void HandleStopScript(IScriptInstance instance)
497 {
498 if (instance.Running)
499 {
500 instance.Stop(0);
501
502 SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
503 MainConsole.Instance.OutputFormat(
504 "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
505 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
429 } 506 }
430 } 507 }
431 508
@@ -1804,19 +1881,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1804 public void SuspendScript(UUID itemID) 1881 public void SuspendScript(UUID itemID)
1805 { 1882 {
1806 IScriptInstance instance = GetInstance(itemID); 1883 IScriptInstance instance = GetInstance(itemID);
1807 if (instance == null) 1884 if (instance != null)
1808 return; 1885 instance.Suspend();
1809
1810 instance.Suspend();
1811 } 1886 }
1812 1887
1813 public void ResumeScript(UUID itemID) 1888 public void ResumeScript(UUID itemID)
1814 { 1889 {
1815 IScriptInstance instance = GetInstance(itemID); 1890 IScriptInstance instance = GetInstance(itemID);
1816 if (instance == null) 1891 if (instance != null)
1817 return; 1892 instance.Resume();
1818
1819 instance.Resume();
1820 } 1893 }
1821 1894
1822 public bool HasScript(UUID itemID, out bool running) 1895 public bool HasScript(UUID itemID, out bool running)
@@ -1831,4 +1904,4 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1831 return true; 1904 return true;
1832 } 1905 }
1833 } 1906 }
1834} 1907} \ No newline at end of file