diff options
author | Justin Clark-Casey (justincc) | 2013-01-10 23:49:48 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-25 23:50:15 +0000 |
commit | 0ba0ac4669e6bc1061ab024d23c1c2db3059a871 (patch) | |
tree | d2b4b3768e1d233f91388bf20c46456291c6ef25 | |
parent | minor: Capitalize GroupsModule command category (diff) | |
download | opensim-SC_OLD-0ba0ac4669e6bc1061ab024d23c1c2db3059a871.zip opensim-SC_OLD-0ba0ac4669e6bc1061ab024d23c1c2db3059a871.tar.gz opensim-SC_OLD-0ba0ac4669e6bc1061ab024d23c1c2db3059a871.tar.bz2 opensim-SC_OLD-0ba0ac4669e6bc1061ab024d23c1c2db3059a871.tar.xz |
Move scene debug commands into separate module. Command changes from "debug scene <key> <value>" to "debug scene set <key> <value>" to accomodate future settings
5 files changed, 350 insertions, 138 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 603cfbc..c4731a3 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -236,18 +236,6 @@ namespace OpenSim | |||
236 | + "If an avatar name is given then only packets from that avatar are logged", | 236 | + "If an avatar name is given then only packets from that avatar are logged", |
237 | Debug); | 237 | Debug); |
238 | 238 | ||
239 | m_console.Commands.AddCommand("Debug", false, "debug scene", | ||
240 | "debug scene active|collisions|pbackup|physics|scripting|teleport|updates true|false", | ||
241 | "Turn on scene debugging options.", | ||
242 | "If active is false then main scene update and maintenance loops are suspended.\n" | ||
243 | + "If collisions is false then collisions with other objects are turned off.\n" | ||
244 | + "If pbackup is false then periodic scene backup is turned off.\n" | ||
245 | + "If physics is false then all physics objects are non-physical.\n" | ||
246 | + "If scripting is false then no scripting operations happen.\n" | ||
247 | + "If teleport is true then some extra teleport debug information is logged.\n" | ||
248 | + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", | ||
249 | Debug); | ||
250 | |||
251 | m_console.Commands.AddCommand("General", false, "change region", | 239 | m_console.Commands.AddCommand("General", false, "change region", |
252 | "change region <region name>", | 240 | "change region <region name>", |
253 | "Change current console region", ChangeSelectedRegion); | 241 | "Change current console region", ChangeSelectedRegion); |
@@ -744,31 +732,6 @@ namespace OpenSim | |||
744 | 732 | ||
745 | break; | 733 | break; |
746 | 734 | ||
747 | case "scene": | ||
748 | if (args.Length == 4) | ||
749 | { | ||
750 | if (SceneManager.CurrentScene == null) | ||
751 | { | ||
752 | MainConsole.Instance.Output("Please use 'change region <regioname>' first"); | ||
753 | } | ||
754 | else | ||
755 | { | ||
756 | string key = args[2]; | ||
757 | string value = args[3]; | ||
758 | SceneManager.CurrentScene.SetSceneCoreDebug( | ||
759 | new Dictionary<string, string>() { { key, value } }); | ||
760 | |||
761 | MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value); | ||
762 | } | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | MainConsole.Instance.Output( | ||
767 | "Usage: debug scene active|collisions|pbackup|physics|scripting|teleport|updates true|false"); | ||
768 | } | ||
769 | |||
770 | break; | ||
771 | |||
772 | default: | 735 | default: |
773 | MainConsole.Instance.Output("Unknown debug command"); | 736 | MainConsole.Instance.Output("Unknown debug command"); |
774 | break; | 737 | break; |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index eb06fcc..311707b 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -753,13 +753,18 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
753 | Scene.RegionInfo.RegionSettings.Save(); | 753 | Scene.RegionInfo.RegionSettings.Save(); |
754 | TriggerRegionInfoChange(); | 754 | TriggerRegionInfoChange(); |
755 | 755 | ||
756 | Scene.SetSceneCoreDebug( | 756 | ISceneCommandsModule scm = Scene.RequestModuleInterface<ISceneCommandsModule>(); |
757 | new Dictionary<string, string>() { | 757 | |
758 | { "scripting", (!disableScripts).ToString() }, | 758 | if (scm != null) |
759 | { "collisions", (!disableCollisions).ToString() }, | 759 | { |
760 | { "physics", (!disablePhysics).ToString() } | 760 | scm.SetSceneDebugOptions( |
761 | } | 761 | new Dictionary<string, string>() { |
762 | ); | 762 | { "scripting", (!disableScripts).ToString() }, |
763 | { "collisions", (!disableCollisions).ToString() }, | ||
764 | { "physics", (!disablePhysics).ToString() } | ||
765 | } | ||
766 | ); | ||
767 | } | ||
763 | } | 768 | } |
764 | 769 | ||
765 | private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey) | 770 | private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey) |
diff --git a/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs b/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs new file mode 100644 index 0000000..c5e678b --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | |||
34 | namespace OpenSim.Region.Framework.Interfaces | ||
35 | { | ||
36 | public interface ISceneCommandsModule | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Sets the scene debug options. | ||
40 | /// </summary> | ||
41 | void SetSceneDebugOptions(Dictionary<string, string> options); | ||
42 | } | ||
43 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5c3521c..0c8aa6c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -70,12 +70,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Show debug information about teleports. | 71 | /// Show debug information about teleports. |
72 | /// </summary> | 72 | /// </summary> |
73 | public bool DebugTeleporting { get; private set; } | 73 | public bool DebugTeleporting { get; set; } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Show debug information about the scene loop. | 76 | /// Show debug information about the scene loop. |
77 | /// </summary> | 77 | /// </summary> |
78 | public bool DebugUpdates { get; private set; } | 78 | public bool DebugUpdates { get; set; } |
79 | 79 | ||
80 | /// <summary> | 80 | /// <summary> |
81 | /// If true then the scene is saved to persistent storage periodically, every m_update_backup frames and | 81 | /// If true then the scene is saved to persistent storage periodically, every m_update_backup frames and |
@@ -86,13 +86,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
86 | /// FIXME: Currently, setting this to false will mean that objects are not periodically returned from parcels. | 86 | /// FIXME: Currently, setting this to false will mean that objects are not periodically returned from parcels. |
87 | /// This needs to be fixed. | 87 | /// This needs to be fixed. |
88 | /// </remarks> | 88 | /// </remarks> |
89 | public bool PeriodicBackup { get; private set; } | 89 | public bool PeriodicBackup { get; set; } |
90 | 90 | ||
91 | /// <summary> | 91 | /// <summary> |
92 | /// If false then the scene is never saved to persistence storage even if PeriodicBackup == true and even | 92 | /// If false then the scene is never saved to persistence storage even if PeriodicBackup == true and even |
93 | /// if the scene is being shut down for the final time. | 93 | /// if the scene is being shut down for the final time. |
94 | /// </summary> | 94 | /// </summary> |
95 | public bool UseBackup { get; private set; } | 95 | public bool UseBackup { get; set; } |
96 | |||
97 | /// <summary> | ||
98 | /// If false then physical objects are disabled, though collisions will continue as normal. | ||
99 | /// </summary> | ||
100 | public bool PhysicsEnabled { get; set; } | ||
101 | |||
102 | /// <summary> | ||
103 | /// If false then scripts are not enabled on the smiulator | ||
104 | /// </summary> | ||
105 | public bool ScriptsEnabled | ||
106 | { | ||
107 | get { return m_scripts_enabled; } | ||
108 | set | ||
109 | { | ||
110 | if (m_scripts_enabled != value) | ||
111 | { | ||
112 | if (!value) | ||
113 | { | ||
114 | m_log.Info("Stopping all Scripts in Scene"); | ||
115 | |||
116 | EntityBase[] entities = Entities.GetEntities(); | ||
117 | foreach (EntityBase ent in entities) | ||
118 | { | ||
119 | if (ent is SceneObjectGroup) | ||
120 | ((SceneObjectGroup)ent).RemoveScriptInstances(false); | ||
121 | } | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | m_log.Info("Starting all Scripts in Scene"); | ||
126 | |||
127 | EntityBase[] entities = Entities.GetEntities(); | ||
128 | foreach (EntityBase ent in entities) | ||
129 | { | ||
130 | if (ent is SceneObjectGroup) | ||
131 | { | ||
132 | SceneObjectGroup sog = (SceneObjectGroup)ent; | ||
133 | sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0); | ||
134 | sog.ResumeScripts(); | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | |||
139 | m_scripts_enabled = value; | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | private bool m_scripts_enabled; | ||
96 | 144 | ||
97 | public SynchronizeSceneHandler SynchronizeScene; | 145 | public SynchronizeSceneHandler SynchronizeScene; |
98 | 146 | ||
@@ -299,8 +347,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
299 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 347 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
300 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 348 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); |
301 | 349 | ||
302 | private bool m_physics_enabled = true; | ||
303 | private bool m_scripts_enabled = true; | ||
304 | private string m_defaultScriptEngine; | 350 | private string m_defaultScriptEngine; |
305 | 351 | ||
306 | /// <summary> | 352 | /// <summary> |
@@ -762,9 +808,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
762 | 808 | ||
763 | DumpAssetsToFile = dumpAssetsToFile; | 809 | DumpAssetsToFile = dumpAssetsToFile; |
764 | 810 | ||
811 | // XXX: Don't set the public property since we don't want to activate here. This needs to be handled | ||
812 | // better in the future. | ||
765 | m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; | 813 | m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; |
766 | 814 | ||
767 | m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; | 815 | PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics; |
768 | 816 | ||
769 | m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; | 817 | m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; |
770 | 818 | ||
@@ -948,6 +996,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
948 | { | 996 | { |
949 | PhysicalPrims = true; | 997 | PhysicalPrims = true; |
950 | CollidablePrims = true; | 998 | CollidablePrims = true; |
999 | PhysicsEnabled = true; | ||
1000 | |||
951 | PeriodicBackup = true; | 1001 | PeriodicBackup = true; |
952 | UseBackup = true; | 1002 | UseBackup = true; |
953 | 1003 | ||
@@ -1192,91 +1242,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1192 | } | 1242 | } |
1193 | } | 1243 | } |
1194 | 1244 | ||
1195 | public void SetSceneCoreDebug(Dictionary<string, string> options) | ||
1196 | { | ||
1197 | if (options.ContainsKey("active")) | ||
1198 | { | ||
1199 | bool active; | ||
1200 | |||
1201 | if (bool.TryParse(options["active"], out active)) | ||
1202 | Active = active; | ||
1203 | } | ||
1204 | |||
1205 | if (options.ContainsKey("pbackup")) | ||
1206 | { | ||
1207 | bool active; | ||
1208 | |||
1209 | if (bool.TryParse(options["pbackup"], out active)) | ||
1210 | PeriodicBackup = active; | ||
1211 | } | ||
1212 | |||
1213 | if (options.ContainsKey("scripting")) | ||
1214 | { | ||
1215 | bool enableScripts = true; | ||
1216 | if (bool.TryParse(options["scripting"], out enableScripts) && m_scripts_enabled != enableScripts) | ||
1217 | { | ||
1218 | if (!enableScripts) | ||
1219 | { | ||
1220 | m_log.Info("Stopping all Scripts in Scene"); | ||
1221 | |||
1222 | EntityBase[] entities = Entities.GetEntities(); | ||
1223 | foreach (EntityBase ent in entities) | ||
1224 | { | ||
1225 | if (ent is SceneObjectGroup) | ||
1226 | ((SceneObjectGroup)ent).RemoveScriptInstances(false); | ||
1227 | } | ||
1228 | } | ||
1229 | else | ||
1230 | { | ||
1231 | m_log.Info("Starting all Scripts in Scene"); | ||
1232 | |||
1233 | EntityBase[] entities = Entities.GetEntities(); | ||
1234 | foreach (EntityBase ent in entities) | ||
1235 | { | ||
1236 | if (ent is SceneObjectGroup) | ||
1237 | { | ||
1238 | SceneObjectGroup sog = (SceneObjectGroup)ent; | ||
1239 | sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0); | ||
1240 | sog.ResumeScripts(); | ||
1241 | } | ||
1242 | } | ||
1243 | } | ||
1244 | |||
1245 | m_scripts_enabled = enableScripts; | ||
1246 | } | ||
1247 | } | ||
1248 | |||
1249 | if (options.ContainsKey("physics")) | ||
1250 | { | ||
1251 | bool enablePhysics; | ||
1252 | if (bool.TryParse(options["physics"], out enablePhysics)) | ||
1253 | m_physics_enabled = enablePhysics; | ||
1254 | } | ||
1255 | |||
1256 | // if (options.ContainsKey("collisions")) | ||
1257 | // { | ||
1258 | // // TODO: Implement. If false, should stop objects colliding, though possibly should still allow | ||
1259 | // // the avatar themselves to collide with the ground. | ||
1260 | // } | ||
1261 | |||
1262 | if (options.ContainsKey("teleport")) | ||
1263 | { | ||
1264 | bool enableTeleportDebugging; | ||
1265 | if (bool.TryParse(options["teleport"], out enableTeleportDebugging)) | ||
1266 | DebugTeleporting = enableTeleportDebugging; | ||
1267 | } | ||
1268 | |||
1269 | if (options.ContainsKey("updates")) | ||
1270 | { | ||
1271 | bool enableUpdateDebugging; | ||
1272 | if (bool.TryParse(options["updates"], out enableUpdateDebugging)) | ||
1273 | { | ||
1274 | DebugUpdates = enableUpdateDebugging; | ||
1275 | GcNotify.Enabled = DebugUpdates; | ||
1276 | } | ||
1277 | } | ||
1278 | } | ||
1279 | |||
1280 | public int GetInaccurateNeighborCount() | 1245 | public int GetInaccurateNeighborCount() |
1281 | { | 1246 | { |
1282 | return m_neighbours.Count; | 1247 | return m_neighbours.Count; |
@@ -1535,7 +1500,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1535 | } | 1500 | } |
1536 | 1501 | ||
1537 | tmpMS = Util.EnvironmentTickCount(); | 1502 | tmpMS = Util.EnvironmentTickCount(); |
1538 | if ((Frame % m_update_physics == 0) && m_physics_enabled) | 1503 | if (PhysicsEnabled && Frame % m_update_physics == 0) |
1539 | m_sceneGraph.UpdatePreparePhysics(); | 1504 | m_sceneGraph.UpdatePreparePhysics(); |
1540 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); | 1505 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); |
1541 | 1506 | ||
@@ -1550,7 +1515,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1550 | tmpMS = Util.EnvironmentTickCount(); | 1515 | tmpMS = Util.EnvironmentTickCount(); |
1551 | if (Frame % m_update_physics == 0) | 1516 | if (Frame % m_update_physics == 0) |
1552 | { | 1517 | { |
1553 | if (m_physics_enabled) | 1518 | if (PhysicsEnabled) |
1554 | physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); | 1519 | physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); |
1555 | 1520 | ||
1556 | if (SynchronizeScene != null) | 1521 | if (SynchronizeScene != null) |
diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs new file mode 100644 index 0000000..5dbf207 --- /dev/null +++ b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs | |||
@@ -0,0 +1,236 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Console; | ||
39 | using OpenSim.Framework.Monitoring; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | |||
43 | namespace OpenSim.Region.OptionalModules.Avatar.Attachments | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// A module that just holds commands for inspecting avatar appearance. | ||
47 | /// </summary> | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SceneCommandsModule")] | ||
49 | public class SceneCommandsModule : ISceneCommandsModule, INonSharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private Scene m_scene; | ||
54 | // private IAvatarFactoryModule m_avatarFactory; | ||
55 | |||
56 | public string Name { get { return "Scene Commands Module"; } } | ||
57 | |||
58 | public Type ReplaceableInterface { get { return null; } } | ||
59 | |||
60 | public void Initialise(IConfigSource source) | ||
61 | { | ||
62 | // m_log.DebugFormat("[SCENE COMMANDS MODULE]: INITIALIZED MODULE"); | ||
63 | } | ||
64 | |||
65 | public void PostInitialise() | ||
66 | { | ||
67 | // m_log.DebugFormat("[SCENE COMMANDS MODULE]: POST INITIALIZED MODULE"); | ||
68 | } | ||
69 | |||
70 | public void Close() | ||
71 | { | ||
72 | // m_log.DebugFormat("[SCENE COMMANDS MODULE]: CLOSED MODULE"); | ||
73 | } | ||
74 | |||
75 | public void AddRegion(Scene scene) | ||
76 | { | ||
77 | // m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
78 | |||
79 | m_scene = scene; | ||
80 | } | ||
81 | |||
82 | public void RemoveRegion(Scene scene) | ||
83 | { | ||
84 | // m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
85 | } | ||
86 | |||
87 | public void RegionLoaded(Scene scene) | ||
88 | { | ||
89 | // m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
90 | |||
91 | scene.AddCommand( | ||
92 | "Debug", this, "debug scene set", | ||
93 | "debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false", | ||
94 | "Turn on scene debugging options.", | ||
95 | "If active is false then main scene update and maintenance loops are suspended.\n" | ||
96 | + "If collisions is false then collisions with other objects are turned off.\n" | ||
97 | + "If pbackup is false then periodic scene backup is turned off.\n" | ||
98 | + "If physics is false then all physics objects are non-physical.\n" | ||
99 | + "If scripting is false then no scripting operations happen.\n" | ||
100 | + "If teleport is true then some extra teleport debug information is logged.\n" | ||
101 | + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.", | ||
102 | HandleDebugSceneCommand); | ||
103 | } | ||
104 | |||
105 | private void HandleDebugSceneCommand(string module, string[] args) | ||
106 | { | ||
107 | if (args.Length == 5) | ||
108 | { | ||
109 | if (MainConsole.Instance.ConsoleScene == null) | ||
110 | { | ||
111 | MainConsole.Instance.Output("Please use 'change region <regioname>' first"); | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | string key = args[3]; | ||
116 | string value = args[4]; | ||
117 | SetSceneDebugOptions(new Dictionary<string, string>() { { key, value } }); | ||
118 | |||
119 | MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value); | ||
120 | } | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | MainConsole.Instance.Output( | ||
125 | "Usage: debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false"); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | public void SetSceneDebugOptions(Dictionary<string, string> options) | ||
130 | { | ||
131 | if (options.ContainsKey("active")) | ||
132 | { | ||
133 | bool active; | ||
134 | |||
135 | if (bool.TryParse(options["active"], out active)) | ||
136 | m_scene.Active = active; | ||
137 | } | ||
138 | |||
139 | if (options.ContainsKey("pbackup")) | ||
140 | { | ||
141 | bool active; | ||
142 | |||
143 | if (bool.TryParse(options["pbackup"], out active)) | ||
144 | m_scene.PeriodicBackup = active; | ||
145 | } | ||
146 | |||
147 | if (options.ContainsKey("scripting")) | ||
148 | { | ||
149 | bool enableScripts = true; | ||
150 | if (bool.TryParse(options["scripting"], out enableScripts)) | ||
151 | m_scene.ScriptsEnabled = enableScripts; | ||
152 | } | ||
153 | |||
154 | if (options.ContainsKey("physics")) | ||
155 | { | ||
156 | bool enablePhysics; | ||
157 | if (bool.TryParse(options["physics"], out enablePhysics)) | ||
158 | m_scene.PhysicsEnabled = enablePhysics; | ||
159 | } | ||
160 | |||
161 | // if (options.ContainsKey("collisions")) | ||
162 | // { | ||
163 | // // TODO: Implement. If false, should stop objects colliding, though possibly should still allow | ||
164 | // // the avatar themselves to collide with the ground. | ||
165 | // } | ||
166 | |||
167 | if (options.ContainsKey("teleport")) | ||
168 | { | ||
169 | bool enableTeleportDebugging; | ||
170 | if (bool.TryParse(options["teleport"], out enableTeleportDebugging)) | ||
171 | m_scene.DebugTeleporting = enableTeleportDebugging; | ||
172 | } | ||
173 | |||
174 | if (options.ContainsKey("updates")) | ||
175 | { | ||
176 | bool enableUpdateDebugging; | ||
177 | if (bool.TryParse(options["updates"], out enableUpdateDebugging)) | ||
178 | { | ||
179 | m_scene.DebugUpdates = enableUpdateDebugging; | ||
180 | GcNotify.Enabled = enableUpdateDebugging; | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | |||
185 | private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb) | ||
186 | { | ||
187 | sb.AppendFormat("Attachments for {0}\n", sp.Name); | ||
188 | |||
189 | ConsoleDisplayTable ct = new ConsoleDisplayTable() { Indent = 2 }; | ||
190 | ct.Columns.Add(new ConsoleDisplayTableColumn("Attachment Name", 50)); | ||
191 | ct.Columns.Add(new ConsoleDisplayTableColumn("Local ID", 10)); | ||
192 | ct.Columns.Add(new ConsoleDisplayTableColumn("Item ID", 36)); | ||
193 | ct.Columns.Add(new ConsoleDisplayTableColumn("Attach Point", 14)); | ||
194 | ct.Columns.Add(new ConsoleDisplayTableColumn("Position", 15)); | ||
195 | |||
196 | // sb.AppendFormat( | ||
197 | // " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", | ||
198 | // "Attachment Name", "Local ID", "Item ID", "Attach Point", "Position"); | ||
199 | |||
200 | List<SceneObjectGroup> attachmentObjects = sp.GetAttachments(); | ||
201 | foreach (SceneObjectGroup attachmentObject in attachmentObjects) | ||
202 | { | ||
203 | // InventoryItemBase attachmentItem | ||
204 | // = m_scenes[0].InventoryService.GetItem(new InventoryItemBase(attachmentObject.FromItemID)); | ||
205 | |||
206 | // if (attachmentItem == null) | ||
207 | // { | ||
208 | // sb.AppendFormat( | ||
209 | // "WARNING: Couldn't find attachment for item {0} at point {1}\n", | ||
210 | // attachmentData.ItemID, (AttachmentPoint)attachmentData.AttachPoint); | ||
211 | // continue; | ||
212 | // } | ||
213 | // else | ||
214 | // { | ||
215 | // sb.AppendFormat( | ||
216 | // " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", | ||
217 | // attachmentObject.Name, attachmentObject.LocalId, attachmentObject.FromItemID, | ||
218 | // (AttachmentPoint)attachmentObject.AttachmentPoint, attachmentObject.RootPart.AttachedPos); | ||
219 | ct.Rows.Add( | ||
220 | new ConsoleDisplayTableRow( | ||
221 | new List<string>() | ||
222 | { | ||
223 | attachmentObject.Name, | ||
224 | attachmentObject.LocalId.ToString(), | ||
225 | attachmentObject.FromItemID.ToString(), | ||
226 | ((AttachmentPoint)attachmentObject.AttachmentPoint).ToString(), | ||
227 | attachmentObject.RootPart.AttachedPos.ToString() | ||
228 | })); | ||
229 | // } | ||
230 | } | ||
231 | |||
232 | ct.AddToStringBuilder(sb); | ||
233 | sb.Append("\n"); | ||
234 | } | ||
235 | } | ||
236 | } \ No newline at end of file | ||