From e3e38e34c5f58a3c466d1b651b41faf834ff5259 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 22:21:10 +0000 Subject: [PATCH 01/16] If a particular region is selected in the console, only try to delete objects in that region, rather than in every region on the simulator The old wrong behaviour was in place before the command was extracted to a module. --- .../Objects/Commands/ObjectCommandsModule.cs | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 57c109e581..42eeb6cf33 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private ICommandConsole m_console; public string Name { get { return "Object Commands Module"; } } @@ -75,6 +76,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands // m_log.DebugFormat("[OBJECT COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); m_scene = scene; + m_console = MainConsole.Instance; + + m_console.Commands.AddCommand("region", false, "delete object owner", + "delete object owner ", + "Delete object by owner", HandleDeleteObject); + m_console.Commands.AddCommand("region", false, "delete object creator", + "delete object creator ", + "Delete object by creator", HandleDeleteObject); + m_console.Commands.AddCommand("region", false, "delete object uuid", + "delete object uuid ", + "Delete object by uuid", HandleDeleteObject); + m_console.Commands.AddCommand("region", false, "delete object name", + "delete object name ", + "Delete object by name", HandleDeleteObject); + m_console.Commands.AddCommand("region", false, "delete object outside", + "delete object outside", + "Delete all objects outside boundaries", HandleDeleteObject); } public void RemoveRegion(Scene scene) @@ -85,26 +103,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands public void RegionLoaded(Scene scene) { // m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); - - MainConsole.Instance.Commands.AddCommand("region", false, "delete object owner", - "delete object owner ", - "Delete object by owner", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object creator", - "delete object creator ", - "Delete object by creator", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object uuid", - "delete object uuid ", - "Delete object by uuid", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object name", - "delete object name ", - "Delete object by name", HandleDeleteObject); - MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", - "delete object outside", - "Delete all objects outside boundaries", HandleDeleteObject); } private void HandleDeleteObject(string module, string[] cmd) { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + if (cmd.Length < 3) return; @@ -198,7 +203,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectGroup g in deletes) { - MainConsole.Instance.OutputFormat("Deleting object {0}", g.UUID); + m_console.OutputFormat("Deleting object {0}", g.UUID); m_scene.DeleteSceneObject(g, false); } } From 77b032549ee8a12202a6aa974c6fd07761515d51 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 22:22:32 +0000 Subject: [PATCH 02/16] Add the name of a deleted object to the console output --- .../CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 42eeb6cf33..3e0f622a5e 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectGroup g in deletes) { - m_console.OutputFormat("Deleting object {0}", g.UUID); + m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); m_scene.DeleteSceneObject(g, false); } } From 647b326edcd5f80e31ebbff8bd6501c0919c267b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 22:27:05 +0000 Subject: [PATCH 03/16] Add more user feedback if an object isn't found for which delete was requested. --- .../Objects/Commands/ObjectCommandsModule.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 3e0f622a5e..78f86ccb85 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -140,6 +140,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with owner {0}", match); + break; case "creator": @@ -152,6 +155,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with creator {0}", match); + break; case "uuid": @@ -164,6 +170,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with uuid {0}", match); + break; case "name": @@ -173,6 +182,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found with name {0}", o); + break; case "outside": @@ -198,6 +210,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); + if (deletes.Count == 0) + m_console.OutputFormat("No objects were found outside region bounds"); + break; } From ab89adfaefb7c2858cb2f90f783c010157d980a7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 23:03:39 +0000 Subject: [PATCH 04/16] Implement "show object uuid " console command. This will show details about a part with the given uuid if it's found. --- .../Objects/Commands/ObjectCommandsModule.cs | 61 +++++++++++++++++-- .../Framework/Scenes/SceneObjectGroup.cs | 6 ++ 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 78f86ccb85..b378f7a5cd 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -80,19 +80,33 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands m_console.Commands.AddCommand("region", false, "delete object owner", "delete object owner ", - "Delete object by owner", HandleDeleteObject); + "Delete a scene object by owner", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object creator", "delete object creator ", - "Delete object by creator", HandleDeleteObject); + "Delete a scene object by creator", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object uuid", "delete object uuid ", - "Delete object by uuid", HandleDeleteObject); + "Delete a scene object by uuid", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object name", "delete object name ", - "Delete object by name", HandleDeleteObject); + "Delete a scene object by name", HandleDeleteObject); m_console.Commands.AddCommand("region", false, "delete object outside", "delete object outside", - "Delete all objects outside boundaries", HandleDeleteObject); + "Delete all scene objects outside region boundaries", HandleDeleteObject); + + m_console.Commands.AddCommand( + "region", + false, + "show object uuid", + "show object uuid ", + "Show details of a scene object with the given UUID", HandleShowObjectByUuid); + +// m_console.Commands.AddCommand( +// "region", +// false, +// "show object name ", +// "show object name ", +// "Show details of scene objects with the given name", HandleShowObjectName); } public void RemoveRegion(Scene scene) @@ -105,6 +119,43 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands // m_log.DebugFormat("[OBJECTS COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); } + private void HandleShowObjectByUuid(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show object uuid "); + return; + } + + UUID objectUuid; + if (!UUID.TryParse(cmd[3], out objectUuid)) + { + m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); + return; + } + + SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); + + if (sop == null) + { + m_console.OutputFormat("No object found with uuid {0}", objectUuid); + return; + } + + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("Name: {0}\n", sop.Name); + sb.AppendFormat("Description: {0}\n", sop.Description); + sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); + sb.AppendFormat("Parent: {0}", + sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); + sb.AppendFormat("Parts: {0}", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString()); + + m_console.OutputFormat(sb.ToString()); + } + private void HandleDeleteObject(string module, string[] cmd) { if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 739c5fa12c..e7f2fdbd7f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -264,6 +264,12 @@ namespace OpenSim.Region.Framework.Scenes set { RootPart.Name = value; } } + public string Description + { + get { return RootPart.Description; } + set { RootPart.Description = value; } + } + /// /// Added because the Parcel code seems to use it /// but not sure a object should have this From ac7cded080ff4db606c42f81b4d1f798fe7fa624 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 23:06:48 +0000 Subject: [PATCH 05/16] Get rid of the "no objects found" feedback for now - this doesn't work well if a command is executed over multiple scenes. --- .../Objects/Commands/ObjectCommandsModule.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index b378f7a5cd..d5a3e77ca2 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands if (sop == null) { - m_console.OutputFormat("No object found with uuid {0}", objectUuid); +// m_console.OutputFormat("No object found with uuid {0}", objectUuid); return; } @@ -191,8 +191,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with owner {0}", match); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with owner {0}", match); break; @@ -206,8 +206,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with creator {0}", match); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with creator {0}", match); break; @@ -221,8 +221,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with uuid {0}", match); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with uuid {0}", match); break; @@ -233,8 +233,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found with name {0}", o); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found with name {0}", o); break; @@ -261,12 +261,14 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands deletes.Add(g); }); - if (deletes.Count == 0) - m_console.OutputFormat("No objects were found outside region bounds"); +// if (deletes.Count == 0) +// m_console.OutputFormat("No objects were found outside region bounds"); break; } + m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName); + foreach (SceneObjectGroup g in deletes) { m_console.OutputFormat("Deleting object {0} {1}", g.UUID, g.Name); From 996cc6097e7d5bbccd1a0b85a1d901686037e19b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 23:21:02 +0000 Subject: [PATCH 06/16] Implement "show object name " console command to show details of an object with the given name --- .../Objects/Commands/ObjectCommandsModule.cs | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index d5a3e77ca2..d1ae4dc870 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -101,12 +101,12 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object uuid ", "Show details of a scene object with the given UUID", HandleShowObjectByUuid); -// m_console.Commands.AddCommand( -// "region", -// false, -// "show object name ", -// "show object name ", -// "Show details of scene objects with the given name", HandleShowObjectName); + m_console.Commands.AddCommand( + "region", + false, + "show object name", + "show object name ", + "Show details of scene objects with the given name", HandleShowObjectByName); } public void RemoveRegion(Scene scene) @@ -146,14 +146,55 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands } StringBuilder sb = new StringBuilder(); + AddPartReport(sb, sop); + + m_console.OutputFormat(sb.ToString()); + } + + private void HandleShowObjectByName(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show object name "); + return; + } + + string name = cmd[3]; + + List parts = new List(); + + m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); + + if (parts.Count == 0) + { + m_console.OutputFormat("No parts with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); + return; + } + + StringBuilder sb = new StringBuilder(); + + foreach (SceneObjectPart part in parts) + { + AddPartReport(sb, part); + sb.Append("\n"); + } + + m_console.OutputFormat(sb.ToString()); + } + + private StringBuilder AddPartReport(StringBuilder sb, SceneObjectPart sop) + { sb.AppendFormat("Name: {0}\n", sop.Name); sb.AppendFormat("Description: {0}\n", sop.Description); sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); sb.AppendFormat("Parent: {0}", sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); - sb.AppendFormat("Parts: {0}", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString()); + sb.AppendFormat("Parts: {0}\n", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; - m_console.OutputFormat(sb.ToString()); + return sb; } private void HandleDeleteObject(string module, string[] cmd) From f028dca711c7ebcda32e4b035eb667455e3bc29d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 31 Jan 2012 23:35:13 +0000 Subject: [PATCH 07/16] Add "show part uuid" and "show part name" console commands. These commands will display part/prim details for a given uuid or name The "show object uuid" and "show object name" commands will now only display details for objects (i.e. not child parts in a linkset). This is for consistency with the "delete object" commands which only delete objects, not parts. --- .../Objects/Commands/ObjectCommandsModule.cs | 104 ++++++++++++++++-- 1 file changed, 97 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index d1ae4dc870..e3d04cd669 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -107,6 +107,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands "show object name", "show object name ", "Show details of scene objects with the given name", HandleShowObjectByName); + + m_console.Commands.AddCommand( + "region", + false, + "show part uuid", + "show part uuid ", + "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); + + m_console.Commands.AddCommand( + "region", + false, + "show part name", + "show part name ", + "Show details of scene object parts with the given name", HandleShowPartByName); } public void RemoveRegion(Scene scene) @@ -137,16 +151,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands return; } - SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); + SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid); - if (sop == null) + if (so == null) { -// m_console.OutputFormat("No object found with uuid {0}", objectUuid); +// m_console.OutputFormat("No part found with uuid {0}", objectUuid); return; } StringBuilder sb = new StringBuilder(); - AddPartReport(sb, sop); + AddSceneObjectReport(sb, so); m_console.OutputFormat(sb.ToString()); } @@ -164,6 +178,72 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands string name = cmd[3]; + List sceneObjects = new List(); + + m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }}); + + if (sceneObjects.Count == 0) + { + m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName); + return; + } + + StringBuilder sb = new StringBuilder(); + + foreach (SceneObjectGroup so in sceneObjects) + { + AddSceneObjectReport(sb, so); + sb.Append("\n"); + } + + m_console.OutputFormat(sb.ToString()); + } + + private void HandleShowPartByUuid(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show part uuid "); + return; + } + + UUID objectUuid; + if (!UUID.TryParse(cmd[3], out objectUuid)) + { + m_console.OutputFormat("{0} is not a valid uuid", cmd[3]); + return; + } + + SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); + + if (sop == null) + { +// m_console.OutputFormat("No part found with uuid {0}", objectUuid); + return; + } + + StringBuilder sb = new StringBuilder(); + AddScenePartReport(sb, sop); + + m_console.OutputFormat(sb.ToString()); + } + + private void HandleShowPartByName(string module, string[] cmd) + { + if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) + return; + + if (cmd.Length < 4) + { + m_console.OutputFormat("Usage: show part name "); + return; + } + + string name = cmd[3]; + List parts = new List(); m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } })); @@ -178,21 +258,31 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands foreach (SceneObjectPart part in parts) { - AddPartReport(sb, part); + AddScenePartReport(sb, part); sb.Append("\n"); } m_console.OutputFormat(sb.ToString()); } - private StringBuilder AddPartReport(StringBuilder sb, SceneObjectPart sop) + private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so) + { + sb.AppendFormat("Name: {0}\n", so.Name); + sb.AppendFormat("Description: {0}\n", so.Description); + sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName); + sb.AppendFormat("Parts: {0}\n", so.PrimCount); + + return sb; + } + + private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop) { sb.AppendFormat("Name: {0}\n", sop.Name); sb.AppendFormat("Description: {0}\n", sop.Description); sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); sb.AppendFormat("Parent: {0}", sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); - sb.AppendFormat("Parts: {0}\n", sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; + sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; return sb; } From 437de6743c98b9ab217ac56ca6646883ca44c240 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 1 Feb 2012 00:07:06 +0000 Subject: [PATCH 08/16] Implement "xengine status" console command to show various xengine stats --- .../Region/ScriptEngine/XEngine/XEngine.cs | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c9bbf0e0c0..c9fb7222f7 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -26,14 +26,15 @@ */ using System; -using System.IO; -using System.Threading; using System.Collections; using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Reflection; using System.Security; using System.Security.Policy; -using System.Reflection; -using System.Globalization; +using System.Text; +using System.Threading; using System.Xml; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -272,6 +273,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine OnObjectRemoved += m_XmlRpcRouter.ObjectRemoved; } + MainConsole.Instance.Commands.AddCommand( + "scripts", false, "xengine status", "xengine status", "Show status information", + "Show status information on the script engine.", + HandleShowStatus); + MainConsole.Instance.Commands.AddCommand( "scripts", false, "scripts show", "scripts show []", "Show script information", "Show information on all scripts known to the script engine." @@ -359,6 +365,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + private void HandleShowStatus(string module, string[] cmdparams) + { + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); + + lock (m_Scripts) + sb.AppendFormat("Scripts loaded : {0}\n", m_Scripts.Count); + + sb.AppendFormat("Unique scripts : {0}\n", m_uniqueScripts.Count); + sb.AppendFormat("Scripts waiting for load : {0}\n", m_CompileQueue.Count); + sb.AppendFormat("Allocated threads : {0}\n", m_ThreadPool.ActiveThreads); + sb.AppendFormat("In use threads : {0}\n", m_ThreadPool.InUseThreads); + sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); +// sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); + + MainConsole.Instance.OutputFormat(sb.ToString()); + } + public void HandleShowScripts(string module, string[] cmdparams) { if (cmdparams.Length == 2) From 8b3da1bff4344d4dc7738f97e5aaa6d024db8f7e Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 1 Feb 2012 00:10:07 +0000 Subject: [PATCH 09/16] Make script console commands only show for selected region. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c9fb7222f7..459821bcb6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -324,6 +324,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine /// true if we're okay to proceed, false if not. private void HandleScriptsAction(string[] cmdparams, Action action) { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + lock (m_Scripts) { string rawItemId; @@ -367,6 +370,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine private void HandleShowStatus(string module, string[] cmdparams) { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + StringBuilder sb = new StringBuilder(); sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); @@ -385,6 +391,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void HandleShowScripts(string module, string[] cmdparams) { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + if (cmdparams.Length == 2) { lock (m_Scripts) From e3680f216eeb631cd8955a708b1eee492566fa5c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 1 Feb 2012 00:17:02 +0000 Subject: [PATCH 10/16] Add count of events queued for a particular script in "scripts show" console command --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 459821bcb6..13c5cd959d 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -428,10 +428,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine status = "running"; } - MainConsole.Instance.OutputFormat( - "{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})", - instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); + Queue eq = instance.EventQueue; + + lock (eq) + { + MainConsole.Instance.OutputFormat( + "{0}.{1}, queued events = {2}, item UUID {3}, prim UUID {4} @ {5} ({6})", + instance.PrimName, instance.ScriptName, eq.Count, instance.ItemID, instance.ObjectID, + sop.AbsolutePosition, status); + } } private void HandleSuspendScript(IScriptInstance instance) From 99e71222f05345d7c4e1658bf52b90087cad7ab7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 1 Feb 2012 00:27:42 +0000 Subject: [PATCH 11/16] Lay out script status in property per row format, since getting too long for console lines. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 13c5cd959d..f11987eede 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -428,15 +428,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine status = "running"; } + StringBuilder sb = new StringBuilder(); Queue eq = instance.EventQueue; + sb.AppendFormat("Script name : {0}\n", instance.ScriptName); + sb.AppendFormat("Status : {0}\n", status); + lock (eq) - { - MainConsole.Instance.OutputFormat( - "{0}.{1}, queued events = {2}, item UUID {3}, prim UUID {4} @ {5} ({6})", - instance.PrimName, instance.ScriptName, eq.Count, instance.ItemID, instance.ObjectID, - sop.AbsolutePosition, status); - } + sb.AppendFormat("Queued events : {0}\n", eq.Count); + + sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); + sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); + sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); + sb.AppendFormat("Position : {0}\n", sop.AbsolutePosition); + + MainConsole.Instance.OutputFormat(sb.ToString()); } private void HandleSuspendScript(IScriptInstance instance) From 3d7b5e5e93b4d9f8c2ad3be8241ee0a484fe222b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 31 Jan 2012 22:00:59 -0800 Subject: [PATCH 12/16] HG: This hopefully fixes the HG teleports back home to OSGrid. Looks like Uri.ToString() drops the port when it's port 80. --- .../Framework/EntityTransfer/HGEntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 8d41728880..38a7805b3d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer region.ExternalHostName = uri.Host; region.HttpPort = (uint)uri.Port; - region.ServerURI = uri.ToString(); + region.ServerURI = aCircuit.ServiceURLs["HomeURI"].ToString(); region.RegionName = string.Empty; region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); return region; From fcc1fa2c32af3df8962e470150b641dda036a8ab Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:36:14 +0000 Subject: [PATCH 13/16] Straighten out some attachment mess. Don't save attachment states for HG visitors at all. On Leaving a sim, save only the changed ones. Don't save all scripted stuff when leaving a sim. --- .../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++----------- OpenSim/Region/Framework/Scenes/Scene.cs | 12 +++++++++++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2142d0216a..65ba730168 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void SaveChangedAttachments(IScenePresence sp) + public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted) { // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); @@ -157,13 +157,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments foreach (SceneObjectGroup grp in sp.GetAttachments()) { -// if (grp.HasGroupChanged) // Resizer scripts? -// { - grp.IsAttachment = false; - grp.AbsolutePosition = grp.RootPart.AttachedPos; - UpdateKnownItem(sp, grp); - grp.IsAttachment = true; -// } + grp.IsAttachment = false; + grp.AbsolutePosition = grp.RootPart.AttachedPos; + UpdateKnownItem(sp, grp, saveAllScripted); + grp.IsAttachment = true; } } @@ -460,7 +457,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp) + private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted) { // Saving attachments for NPCs messes them up for the real owner! INPCModule module = m_scene.RequestModuleInterface(); @@ -470,7 +467,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return; } - if (grp.HasGroupChanged || grp.ContainsScripts()) + if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) { m_log.DebugFormat( "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", @@ -696,7 +693,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments group.IsAttachment = false; group.AbsolutePosition = group.RootPart.AttachedPos; - UpdateKnownItem(sp, group); + UpdateKnownItem(sp, group, true); m_scene.DeleteSceneObject(group, false); return; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index df6c88fb6d..34d1151dbc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3104,7 +3104,17 @@ namespace OpenSim.Region.Framework.Scenes m_eventManager.TriggerOnRemovePresence(agentID); if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) - AttachmentsModule.SaveChangedAttachments(avatar); + { + IUserManagement uMan = m_aScene.RequestModuleInterface(); + // Don't save attachments for HG visitors, it + // messes up their inventory. When a HG visitor logs + // out on a foreign grid, their attachments will be + // reloaded in the state they were in when they left + // the home grid. This is best anyway as the visited + // grid may use an incompatible script engine. + if (uMan == null || uMan.IsLocalGridUser(id)) + AttachmentsModule.SaveChangedAttachments(avatar, false); + } ForEachClient( delegate(IClientAPI client) From c08d6df7e13abde2905ece634cd6770b3804554c Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:38:20 +0000 Subject: [PATCH 14/16] Prevent a changed attachment that has been saved from being saved again. --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 65ba730168..7086e6c331 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -500,6 +500,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (sp.ControllingClient != null) sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0); } + grp.HasGroupChanged = false; // Prevent it being saved over and over } else { From 241ddd031f36eda9f1339398ae30d52c1b9e83e5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:45:15 +0000 Subject: [PATCH 15/16] Fix copy/paste errors --- OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index e668daebe8..eb071650bc 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Save the attachments that have change on this presence. /// /// - void SaveChangedAttachments(IScenePresence sp); + void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted); /// /// Delete all the presence's attachments from the scene diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 34d1151dbc..2af4a1c457 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3105,14 +3105,14 @@ namespace OpenSim.Region.Framework.Scenes if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) { - IUserManagement uMan = m_aScene.RequestModuleInterface(); + IUserManagement uMan = RequestModuleInterface(); // Don't save attachments for HG visitors, it // messes up their inventory. When a HG visitor logs // out on a foreign grid, their attachments will be // reloaded in the state they were in when they left // the home grid. This is best anyway as the visited // grid may use an incompatible script engine. - if (uMan == null || uMan.IsLocalGridUser(id)) + if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) AttachmentsModule.SaveChangedAttachments(avatar, false); } From 003bd9f1b3a774141d53282d3b3c13a7e121f0a4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 10:05:04 +0000 Subject: [PATCH 16/16] Small optimization to last commit --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2af4a1c457..23fee4e2d8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3056,11 +3056,11 @@ namespace OpenSim.Region.Framework.Scenes public override void RemoveClient(UUID agentID, bool closeChildAgents) { CheckHeartbeat(); - bool childagentYN = false; + bool isChildAgent = false; ScenePresence avatar = GetScenePresence(agentID); if (avatar != null) { - childagentYN = avatar.IsChildAgent; + isChildAgent = avatar.IsChildAgent; if (avatar.ParentID != 0) { @@ -3071,9 +3071,9 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat( "[SCENE]: Removing {0} agent {1} from region {2}", - (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); + (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); - m_sceneGraph.removeUserCount(!childagentYN); + m_sceneGraph.removeUserCount(!isChildAgent); // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI @@ -3103,7 +3103,7 @@ namespace OpenSim.Region.Framework.Scenes { m_eventManager.TriggerOnRemovePresence(agentID); - if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) + if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc) { IUserManagement uMan = RequestModuleInterface(); // Don't save attachments for HG visitors, it