From bff0d75e0f369382d8f97c58bf8127ab53b4dc91 Mon Sep 17 00:00:00 2001 From: Fredo Chaplin Date: Fri, 23 Oct 2009 16:11:25 +0200 Subject: [PATCH 1/2] patch kill by UUID Signed-off-by: Melanie --- OpenSim/Region/Application/OpenSim.cs | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index b44818266a..e7ae7bd9b8 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -343,6 +343,10 @@ namespace OpenSim "Add-InventoryHost ", String.Empty, RunCommand); + m_console.Commands.AddCommand("region", false, "killuuid", + "killuuid ", + "kill an object by UUID", KillUUID); + if (ConfigurationSettings.Standalone) { m_console.Commands.AddCommand("region", false, "create user", @@ -1332,6 +1336,60 @@ namespace OpenSim return result; } + /// + /// Kill an object given its UUID. + /// + /// + protected void KillUUID(string module, string[] cmdparams) + { + if (cmdparams.Length > 1) + { + UUID id = UUID.Zero; + SceneObjectGroup grp = null; + Scene sc = null; + + try + { + Guid x = new Guid((string)cmdparams[1]); + id = (UUID)(string)cmdparams[1]; + } + catch (Exception) + { + m_log.Error("[KillUUID]: Error bad UUID formating !"); + return; + } + + m_sceneManager.ForEachScene( + delegate(Scene scene) + { + if (scene.Entities[id] != null) + { + grp = (SceneObjectGroup) scene.Entities[id]; + sc = scene; + } + }); + + if (grp == null) + m_log.ErrorFormat("[KillUUID]: Given UUID {0} not found !", id); + else + { + m_log.InfoFormat("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName); + try + { + sc.DeleteSceneObject(grp, false); + } + catch (Exception e) + { + m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e); + } + } + } + else + { + m_log.Error("[KillUUID]: Usage: killuuid "); + } + } + #endregion } } From c17359fea51bc6c2dbe610a8e790a463fb9b5e51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 28 Oct 2009 18:25:37 +0000 Subject: [PATCH 2/2] Adding changes to previous patch to make it fit into core better --- OpenSim/Region/Application/OpenSim.cs | 36 +++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index e7ae7bd9b8..60c34df8bd 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -343,9 +343,9 @@ namespace OpenSim "Add-InventoryHost ", String.Empty, RunCommand); - m_console.Commands.AddCommand("region", false, "killuuid", - "killuuid ", - "kill an object by UUID", KillUUID); + m_console.Commands.AddCommand("region", false, "kill uuid", + "kill uuid ", + "Kill an object by UUID", KillUUID); if (ConfigurationSettings.Standalone) { @@ -1342,38 +1342,36 @@ namespace OpenSim /// protected void KillUUID(string module, string[] cmdparams) { - if (cmdparams.Length > 1) + if (cmdparams.Length > 2) { UUID id = UUID.Zero; SceneObjectGroup grp = null; Scene sc = null; - try + if (!UUID.TryParse(cmdparams[2], out id)) { - Guid x = new Guid((string)cmdparams[1]); - id = (UUID)(string)cmdparams[1]; - } - catch (Exception) - { - m_log.Error("[KillUUID]: Error bad UUID formating !"); + MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!"); return; } m_sceneManager.ForEachScene( delegate(Scene scene) { - if (scene.Entities[id] != null) - { - grp = (SceneObjectGroup) scene.Entities[id]; - sc = scene; - } + SceneObjectPart part = scene.GetSceneObjectPart(id); + if (part == null) + return; + + grp = part.ParentGroup; + sc = scene; }); if (grp == null) - m_log.ErrorFormat("[KillUUID]: Given UUID {0} not found !", id); + { + MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id)); + } else { - m_log.InfoFormat("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName); + MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName)); try { sc.DeleteSceneObject(grp, false); @@ -1386,7 +1384,7 @@ namespace OpenSim } else { - m_log.Error("[KillUUID]: Usage: killuuid "); + MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid "); } }