diff options
author | Dan Lake | 2011-10-19 14:43:16 -0700 |
---|---|---|
committer | Dan Lake | 2011-10-19 14:43:16 -0700 |
commit | 8b20faf06c4850df800945c8135aa90c2eebe034 (patch) | |
tree | d4ea07158630904c24c1de9bbd704aa4f72f9277 /OpenSim | |
parent | Renamed and rearranged AvatarFactoryModule to eliminate redundant lookups of ... (diff) | |
parent | Extend scripts stop/start/suspend/resume console commands to allow action on ... (diff) | |
download | opensim-SC-8b20faf06c4850df800945c8135aa90c2eebe034.zip opensim-SC-8b20faf06c4850df800945c8135aa90c2eebe034.tar.gz opensim-SC-8b20faf06c4850df800945c8135aa90c2eebe034.tar.bz2 opensim-SC-8b20faf06c4850df800945c8135aa90c2eebe034.tar.xz |
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/IScriptModule.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 158 |
2 files changed, 100 insertions, 72 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index b27b7da..950e4b0 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -41,12 +41,16 @@ namespace OpenSim.Region.Framework.Interfaces | |||
41 | bool PostScriptEvent(UUID itemID, string name, Object[] args); | 41 | bool PostScriptEvent(UUID itemID, string name, Object[] args); |
42 | bool PostObjectEvent(UUID itemID, string name, Object[] args); | 42 | bool PostObjectEvent(UUID itemID, string name, Object[] args); |
43 | 43 | ||
44 | // Suspend ALL scripts in a given scene object. The item ID | 44 | /// <summary> |
45 | // is the UUID of a SOG, and the method acts on all contained | 45 | /// Suspends a script. |
46 | // scripts. This is different from the suspend/resume that | 46 | /// </summary> |
47 | // can be issued by a client. | 47 | /// <param name="itemID">The item ID of the script.</param> |
48 | // | ||
49 | void SuspendScript(UUID itemID); | 48 | void SuspendScript(UUID itemID); |
49 | |||
50 | /// <summary> | ||
51 | /// Resumes a script. | ||
52 | /// </summary> | ||
53 | /// <param name="itemID">The item ID of the script.</param> | ||
50 | void ResumeScript(UUID itemID); | 54 | void ResumeScript(UUID itemID); |
51 | 55 | ||
52 | ArrayList GetScriptErrors(UUID itemID); | 56 | ArrayList GetScriptErrors(UUID itemID); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 003e735..240e36f 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -276,25 +276,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
276 | "Synonym for scripts show command", HandleShowScripts); | 276 | "Synonym for scripts show command", HandleShowScripts); |
277 | 277 | ||
278 | MainConsole.Instance.Commands.AddCommand( | 278 | MainConsole.Instance.Commands.AddCommand( |
279 | "scripts", false, "scripts suspend", "scripts suspend", "Suspends all running scripts", | 279 | "scripts", false, "scripts suspend", "scripts suspend [<script-item-uuid>]", "Suspends all running scripts", |
280 | "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" | 280 | "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" |
281 | + " script that is currently processing an event.\n" | 281 | + " script that is currently processing an event.\n" |
282 | + "Suspended scripts will continue to accumulate events but won't process them.", | 282 | + "Suspended scripts will continue to accumulate events but won't process them.\n" |
283 | HandleSuspendScripts); | 283 | + "If a <script-item-uuid> is given then only that script will be suspended. Otherwise, all suitable scripts are suspended.", |
284 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript)); | ||
284 | 285 | ||
285 | MainConsole.Instance.Commands.AddCommand( | 286 | MainConsole.Instance.Commands.AddCommand( |
286 | "scripts", false, "scripts resume", "scripts resume", "Resumes all suspended scripts", | 287 | "scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts", |
287 | "Resumes all currently suspended scripts.\n" | 288 | "Resumes all currently suspended scripts.\n" |
288 | + "Resumed scripts will process all events accumulated whilst suspended.", | 289 | + "Resumed scripts will process all events accumulated whilst suspended." |
289 | HandleResumeScripts); | 290 | + "If a <script-item-uuid> is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", |
291 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript)); | ||
290 | 292 | ||
291 | MainConsole.Instance.Commands.AddCommand( | 293 | MainConsole.Instance.Commands.AddCommand( |
292 | "scripts", false, "scripts stop", "scripts stop", "Stops all running scripts", | 294 | "scripts", false, "scripts stop", "scripts stop [<script-item-uuid>]", "Stops all running scripts", |
293 | HandleStopScripts); | 295 | "Stops all running scripts." |
296 | + "If a <script-item-uuid> is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", | ||
297 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript)); | ||
294 | 298 | ||
295 | MainConsole.Instance.Commands.AddCommand( | 299 | MainConsole.Instance.Commands.AddCommand( |
296 | "scripts", false, "scripts start", "scripts start", "Starts all stopped scripts", | 300 | "scripts", false, "scripts start", "scripts start [<script-item-uuid>]", "Starts all stopped scripts", |
297 | HandleStartScripts); | 301 | "Starts all stopped scripts." |
302 | + "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.", | ||
303 | (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); | ||
298 | } | 304 | } |
299 | 305 | ||
300 | public void HandleShowScripts(string module, string[] cmdparams) | 306 | public void HandleShowScripts(string module, string[] cmdparams) |
@@ -334,79 +340,101 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
334 | } | 340 | } |
335 | } | 341 | } |
336 | 342 | ||
337 | public void HandleSuspendScripts(string module, string[] cmdparams) | 343 | /// <summary> |
344 | /// Parse the raw item id into a script instance from the command params if it's present. | ||
345 | /// </summary> | ||
346 | /// <param name="cmdparams"></param> | ||
347 | /// <param name="instance"></param> | ||
348 | /// <returns>true if we're okay to proceed, false if not.</returns> | ||
349 | private void HandleScriptsAction(string[] cmdparams, Action<IScriptInstance> action) | ||
338 | { | 350 | { |
339 | lock (m_Scripts) | 351 | lock (m_Scripts) |
340 | { | 352 | { |
341 | foreach (IScriptInstance instance in m_Scripts.Values) | 353 | string rawItemId; |
354 | UUID itemId = UUID.Zero; | ||
355 | |||
356 | if (cmdparams.Length == 2) | ||
342 | { | 357 | { |
343 | if (!instance.Suspended) | 358 | foreach (IScriptInstance instance in m_Scripts.Values) |
344 | { | 359 | action(instance); |
345 | instance.Suspend(); | ||
346 | 360 | ||
347 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | 361 | return; |
348 | MainConsole.Instance.OutputFormat( | 362 | } |
349 | "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", | 363 | |
350 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); | 364 | rawItemId = cmdparams[2]; |
365 | |||
366 | if (!UUID.TryParse(rawItemId, out itemId)) | ||
367 | { | ||
368 | MainConsole.Instance.OutputFormat("Error - {0} is not a valid UUID", rawItemId); | ||
369 | return; | ||
370 | } | ||
371 | |||
372 | if (itemId != UUID.Zero) | ||
373 | { | ||
374 | IScriptInstance instance = GetInstance(itemId); | ||
375 | if (instance == null) | ||
376 | { | ||
377 | MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId); | ||
378 | return; | ||
379 | } | ||
380 | else | ||
381 | { | ||
382 | action(instance); | ||
383 | return; | ||
351 | } | 384 | } |
352 | } | 385 | } |
353 | } | 386 | } |
354 | } | 387 | } |
355 | 388 | ||
356 | public void HandleResumeScripts(string module, string[] cmdparams) | 389 | private void HandleSuspendScript(IScriptInstance instance) |
357 | { | 390 | { |
358 | lock (m_Scripts) | 391 | if (!instance.Suspended) |
359 | { | 392 | { |
360 | foreach (IScriptInstance instance in m_Scripts.Values) | 393 | instance.Suspend(); |
361 | { | ||
362 | if (instance.Suspended) | ||
363 | { | ||
364 | instance.Resume(); | ||
365 | 394 | ||
366 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | 395 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); |
367 | MainConsole.Instance.OutputFormat( | 396 | MainConsole.Instance.OutputFormat( |
368 | "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", | 397 | "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", |
369 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); | 398 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); |
370 | } | ||
371 | } | ||
372 | } | 399 | } |
373 | } | 400 | } |
374 | 401 | ||
375 | public void HandleStartScripts(string module, string[] cmdparams) | 402 | private void HandleResumeScript(IScriptInstance instance) |
376 | { | 403 | { |
377 | lock (m_Scripts) | 404 | if (instance.Suspended) |
378 | { | 405 | { |
379 | foreach (IScriptInstance instance in m_Scripts.Values) | 406 | instance.Resume(); |
380 | { | ||
381 | if (!instance.Running) | ||
382 | { | ||
383 | instance.Start(); | ||
384 | 407 | ||
385 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | 408 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); |
386 | MainConsole.Instance.OutputFormat( | 409 | MainConsole.Instance.OutputFormat( |
387 | "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", | 410 | "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", |
388 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); | 411 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); |
389 | } | ||
390 | } | ||
391 | } | 412 | } |
392 | } | 413 | } |
393 | 414 | ||
394 | public void HandleStopScripts(string module, string[] cmdparams) | 415 | private void HandleStartScript(IScriptInstance instance) |
395 | { | 416 | { |
396 | lock (m_Scripts) | 417 | if (!instance.Running) |
397 | { | 418 | { |
398 | foreach (IScriptInstance instance in m_Scripts.Values) | 419 | instance.Start(); |
399 | { | ||
400 | if (instance.Running) | ||
401 | { | ||
402 | instance.Stop(0); | ||
403 | 420 | ||
404 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | 421 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); |
405 | MainConsole.Instance.OutputFormat( | 422 | MainConsole.Instance.OutputFormat( |
406 | "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", | 423 | "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", |
407 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); | 424 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); |
408 | } | 425 | } |
409 | } | 426 | } |
427 | |||
428 | private void HandleStopScript(IScriptInstance instance) | ||
429 | { | ||
430 | if (instance.Running) | ||
431 | { | ||
432 | instance.Stop(0); | ||
433 | |||
434 | SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID); | ||
435 | MainConsole.Instance.OutputFormat( | ||
436 | "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}", | ||
437 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition); | ||
410 | } | 438 | } |
411 | } | 439 | } |
412 | 440 | ||
@@ -1770,19 +1798,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1770 | public void SuspendScript(UUID itemID) | 1798 | public void SuspendScript(UUID itemID) |
1771 | { | 1799 | { |
1772 | IScriptInstance instance = GetInstance(itemID); | 1800 | IScriptInstance instance = GetInstance(itemID); |
1773 | if (instance == null) | 1801 | if (instance != null) |
1774 | return; | 1802 | instance.Suspend(); |
1775 | |||
1776 | instance.Suspend(); | ||
1777 | } | 1803 | } |
1778 | 1804 | ||
1779 | public void ResumeScript(UUID itemID) | 1805 | public void ResumeScript(UUID itemID) |
1780 | { | 1806 | { |
1781 | IScriptInstance instance = GetInstance(itemID); | 1807 | IScriptInstance instance = GetInstance(itemID); |
1782 | if (instance == null) | 1808 | if (instance != null) |
1783 | return; | 1809 | instance.Resume(); |
1784 | |||
1785 | instance.Resume(); | ||
1786 | } | 1810 | } |
1787 | } | 1811 | } |
1788 | } | 1812 | } \ No newline at end of file |