aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs37
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs19
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneCommandsModule.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs183
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs227
6 files changed, 363 insertions, 148 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 08e4023..e1cff69 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 teleport", "debug teleport", "Toggle teleport route debugging", Debug);
240
241 m_console.Commands.AddCommand("Debug", false, "debug scene",
242 "debug scene active|collisions|physics|scripting|teleport true|false",
243 "Turn on scene debugging.",
244 "If active is false then main scene update and maintenance loops are suspended.\n"
245 + "If collisions is false then collisions with other objects are turned off.\n"
246 + "If physics is false then all physics objects are non-physical.\n"
247 + "If scripting is false then no scripting operations happen.\n"
248 + "If teleport is true then some extra teleport debug information 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|scripting|collisions|physics|teleport 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 9aee491..a5f5749 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -780,13 +780,18 @@ namespace OpenSim.Region.CoreModules.World.Estate
780 Scene.RegionInfo.RegionSettings.Save(); 780 Scene.RegionInfo.RegionSettings.Save();
781 TriggerRegionInfoChange(); 781 TriggerRegionInfoChange();
782 782
783 Scene.SetSceneCoreDebug( 783 ISceneCommandsModule scm = Scene.RequestModuleInterface<ISceneCommandsModule>();
784 new Dictionary<string, string>() { 784
785 { "scripting", (!disableScripts).ToString() }, 785 if (scm != null)
786 { "collisions", (!disableCollisions).ToString() }, 786 {
787 { "physics", (!disablePhysics).ToString() } 787 scm.SetSceneDebugOptions(
788 } 788 new Dictionary<string, string>() {
789 ); 789 { "scripting", (!disableScripts).ToString() },
790 { "collisions", (!disableCollisions).ToString() },
791 { "physics", (!disablePhysics).ToString() }
792 }
793 );
794 }
790 } 795 }
791 796
792 private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey) 797 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
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33
34namespace 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 a5ef2b7..784fc91 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -70,12 +70,77 @@ 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
80 /// <summary>
81 /// If true then the scene is saved to persistent storage periodically, every m_update_backup frames and
82 /// if objects meet required conditions (m_dontPersistBefore and m_dontPersistAfter).
83 /// </summary>
84 /// <remarks>
85 /// Even if false, the scene will still be saved on clean shutdown.
86 /// FIXME: Currently, setting this to false will mean that objects are not periodically returned from parcels.
87 /// This needs to be fixed.
88 /// </remarks>
89 public bool PeriodicBackup { get; set; }
90
91 /// <summary>
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.
94 /// </summary>
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;
79 144
80 public SynchronizeSceneHandler SynchronizeScene; 145 public SynchronizeSceneHandler SynchronizeScene;
81 146
@@ -284,8 +349,6 @@ namespace OpenSim.Region.Framework.Scenes
284 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 349 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
285 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 350 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
286 351
287 private bool m_physics_enabled = true;
288 private bool m_scripts_enabled = true;
289 private string m_defaultScriptEngine; 352 private string m_defaultScriptEngine;
290 353
291 /// <summary> 354 /// <summary>
@@ -348,7 +411,6 @@ namespace OpenSim.Region.Framework.Scenes
348 411
349 private Timer m_mapGenerationTimer = new Timer(); 412 private Timer m_mapGenerationTimer = new Timer();
350 private bool m_generateMaptiles; 413 private bool m_generateMaptiles;
351 private bool m_useBackup = true;
352 414
353 #endregion Fields 415 #endregion Fields
354 416
@@ -614,11 +676,6 @@ namespace OpenSim.Region.Framework.Scenes
614 get { return m_authenticateHandler; } 676 get { return m_authenticateHandler; }
615 } 677 }
616 678
617 public bool UseBackup
618 {
619 get { return m_useBackup; }
620 }
621
622 // an instance to the physics plugin's Scene object. 679 // an instance to the physics plugin's Scene object.
623 public PhysicsScene PhysicsScene 680 public PhysicsScene PhysicsScene
624 { 681 {
@@ -773,9 +830,11 @@ namespace OpenSim.Region.Framework.Scenes
773 830
774 DumpAssetsToFile = dumpAssetsToFile; 831 DumpAssetsToFile = dumpAssetsToFile;
775 832
833 // XXX: Don't set the public property since we don't want to activate here. This needs to be handled
834 // better in the future.
776 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; 835 m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
777 836
778 m_physics_enabled = !RegionInfo.RegionSettings.DisablePhysics; 837 PhysicsEnabled = !RegionInfo.RegionSettings.DisablePhysics;
779 838
780 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")"; 839 m_simulatorVersion = simulatorVersion + " (" + Util.GetRuntimeInformation() + ")";
781 840
@@ -792,8 +851,8 @@ namespace OpenSim.Region.Framework.Scenes
792 StartDisabled = startupConfig.GetBoolean("StartDisabled", false); 851 StartDisabled = startupConfig.GetBoolean("StartDisabled", false);
793 852
794 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); 853 m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
795 m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); 854 UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
796 if (!m_useBackup) 855 if (!UseBackup)
797 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); 856 m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
798 857
799 //Animation states 858 //Animation states
@@ -970,6 +1029,10 @@ namespace OpenSim.Region.Framework.Scenes
970 { 1029 {
971 PhysicalPrims = true; 1030 PhysicalPrims = true;
972 CollidablePrims = true; 1031 CollidablePrims = true;
1032 PhysicsEnabled = true;
1033
1034 PeriodicBackup = true;
1035 UseBackup = true;
973 1036
974 BordersLocked = true; 1037 BordersLocked = true;
975 Border northBorder = new Border(); 1038 Border northBorder = new Border();
@@ -1212,83 +1275,6 @@ namespace OpenSim.Region.Framework.Scenes
1212 } 1275 }
1213 } 1276 }
1214 1277
1215 public void SetSceneCoreDebug(Dictionary<string, string> options)
1216 {
1217 if (options.ContainsKey("active"))
1218 {
1219 bool active;
1220
1221 if (bool.TryParse(options["active"], out active))
1222 Active = active;
1223 }
1224
1225 if (options.ContainsKey("scripting"))
1226 {
1227 bool enableScripts = true;
1228 if (bool.TryParse(options["scripting"], out enableScripts) && m_scripts_enabled != enableScripts)
1229 {
1230 if (!enableScripts)
1231 {
1232 m_log.Info("Stopping all Scripts in Scene");
1233
1234 EntityBase[] entities = Entities.GetEntities();
1235 foreach (EntityBase ent in entities)
1236 {
1237 if (ent is SceneObjectGroup)
1238 ((SceneObjectGroup)ent).RemoveScriptInstances(false);
1239 }
1240 }
1241 else
1242 {
1243 m_log.Info("Starting all Scripts in Scene");
1244
1245 EntityBase[] entities = Entities.GetEntities();
1246 foreach (EntityBase ent in entities)
1247 {
1248 if (ent is SceneObjectGroup)
1249 {
1250 SceneObjectGroup sog = (SceneObjectGroup)ent;
1251 sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
1252 sog.ResumeScripts();
1253 }
1254 }
1255 }
1256
1257 m_scripts_enabled = enableScripts;
1258 }
1259 }
1260
1261 if (options.ContainsKey("physics"))
1262 {
1263 bool enablePhysics;
1264 if (bool.TryParse(options["physics"], out enablePhysics))
1265 m_physics_enabled = enablePhysics;
1266 }
1267
1268// if (options.ContainsKey("collisions"))
1269// {
1270// // TODO: Implement. If false, should stop objects colliding, though possibly should still allow
1271// // the avatar themselves to collide with the ground.
1272// }
1273
1274 if (options.ContainsKey("teleport"))
1275 {
1276 bool enableTeleportDebugging;
1277 if (bool.TryParse(options["teleport"], out enableTeleportDebugging))
1278 DebugTeleporting = enableTeleportDebugging;
1279 }
1280
1281 if (options.ContainsKey("updates"))
1282 {
1283 bool enableUpdateDebugging;
1284 if (bool.TryParse(options["updates"], out enableUpdateDebugging))
1285 {
1286 DebugUpdates = enableUpdateDebugging;
1287 GcNotify.Enabled = DebugUpdates;
1288 }
1289 }
1290 }
1291
1292 public int GetInaccurateNeighborCount() 1278 public int GetInaccurateNeighborCount()
1293 { 1279 {
1294 return m_neighbours.Count; 1280 return m_neighbours.Count;
@@ -1337,16 +1323,7 @@ namespace OpenSim.Region.Framework.Scenes
1337 1323
1338 m_log.Debug("[SCENE]: Persisting changed objects"); 1324 m_log.Debug("[SCENE]: Persisting changed objects");
1339 1325
1340 EntityBase[] entities = GetEntities(); 1326 Backup(false);
1341 foreach (EntityBase entity in entities)
1342 {
1343 if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged)
1344 {
1345 ((SceneObjectGroup)entity).ProcessBackup(SimulationDataService, false);
1346 }
1347 }
1348
1349 m_log.Debug("[SCENE]: Graph close");
1350 m_sceneGraph.Close(); 1327 m_sceneGraph.Close();
1351 1328
1352 if (!GridService.DeregisterRegion(RegionInfo.RegionID)) 1329 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
@@ -1573,7 +1550,7 @@ namespace OpenSim.Region.Framework.Scenes
1573 } 1550 }
1574 1551
1575 tmpMS = Util.EnvironmentTickCount(); 1552 tmpMS = Util.EnvironmentTickCount();
1576 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1553 if (PhysicsEnabled && Frame % m_update_physics == 0)
1577 m_sceneGraph.UpdatePreparePhysics(); 1554 m_sceneGraph.UpdatePreparePhysics();
1578 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS); 1555 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1579 1556
@@ -1588,7 +1565,7 @@ namespace OpenSim.Region.Framework.Scenes
1588 tmpMS = Util.EnvironmentTickCount(); 1565 tmpMS = Util.EnvironmentTickCount();
1589 if (Frame % m_update_physics == 0) 1566 if (Frame % m_update_physics == 0)
1590 { 1567 {
1591 if (m_physics_enabled) 1568 if (PhysicsEnabled)
1592 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime); 1569 physicsFPS = m_sceneGraph.UpdatePhysics(MinFrameTime);
1593 1570
1594 if (SynchronizeScene != null) 1571 if (SynchronizeScene != null)
@@ -1630,7 +1607,7 @@ namespace OpenSim.Region.Framework.Scenes
1630 eventMS = Util.EnvironmentTickCountSubtract(tmpMS); 1607 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1631 } 1608 }
1632 1609
1633 if (Frame % m_update_backup == 0) 1610 if (PeriodicBackup && Frame % m_update_backup == 0)
1634 { 1611 {
1635 tmpMS = Util.EnvironmentTickCount(); 1612 tmpMS = Util.EnvironmentTickCount();
1636 UpdateStorageBackup(); 1613 UpdateStorageBackup();
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index ae0ad02..d764936 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
126 { 126 {
127 scene.RegisterModuleInterface<IGroupsModule>(this); 127 scene.RegisterModuleInterface<IGroupsModule>(this);
128 scene.AddCommand( 128 scene.AddCommand(
129 "debug", 129 "Debug",
130 this, 130 this,
131 "debug groups verbose", 131 "debug groups verbose",
132 "debug groups verbose <true|false>", 132 "debug groups verbose <true|false>",
diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs
new file mode 100644
index 0000000..8b8758e
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs
@@ -0,0 +1,227 @@
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
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Framework.Monitoring;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace 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
55 public string Name { get { return "Scene Commands Module"; } }
56
57 public Type ReplaceableInterface { get { return null; } }
58
59 public void Initialise(IConfigSource source)
60 {
61// m_log.DebugFormat("[SCENE COMMANDS MODULE]: INITIALIZED MODULE");
62 }
63
64 public void PostInitialise()
65 {
66// m_log.DebugFormat("[SCENE COMMANDS MODULE]: POST INITIALIZED MODULE");
67 }
68
69 public void Close()
70 {
71// m_log.DebugFormat("[SCENE COMMANDS MODULE]: CLOSED MODULE");
72 }
73
74 public void AddRegion(Scene scene)
75 {
76// m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
77
78 m_scene = scene;
79
80 m_scene.RegisterModuleInterface<ISceneCommandsModule>(this);
81 }
82
83 public void RemoveRegion(Scene scene)
84 {
85// m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
86 }
87
88 public void RegionLoaded(Scene scene)
89 {
90// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
91
92 scene.AddCommand(
93 "Debug", this, "debug scene get",
94 "debug scene get",
95 "List current scene options.",
96 "If active is false then main scene update and maintenance loops are suspended.\n"
97 + "If collisions is false then collisions with other objects are turned off.\n"
98 + "If pbackup is false then periodic scene backup is turned off.\n"
99 + "If physics is false then all physics objects are non-physical.\n"
100 + "If scripting is false then no scripting operations happen.\n"
101 + "If teleport is true then some extra teleport debug information is logged.\n"
102 + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.",
103 HandleDebugSceneGetCommand);
104
105 scene.AddCommand(
106 "Debug", this, "debug scene set",
107 "debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false",
108 "Turn on scene debugging options.",
109 "If active is false then main scene update and maintenance loops are suspended.\n"
110 + "If collisions is false then collisions with other objects are turned off.\n"
111 + "If pbackup is false then periodic scene backup is turned off.\n"
112 + "If physics is false then all physics objects are non-physical.\n"
113 + "If scripting is false then no scripting operations happen.\n"
114 + "If teleport is true then some extra teleport debug information is logged.\n"
115 + "If updates is true then any frame which exceeds double the maximum desired frame time is logged.",
116 HandleDebugSceneSetCommand);
117 }
118
119 private void HandleDebugSceneGetCommand(string module, string[] args)
120 {
121 if (args.Length == 3)
122 {
123 if (MainConsole.Instance.ConsoleScene == null)
124 MainConsole.Instance.Output("Please use 'change region <regioname>' first");
125 else
126 OutputSceneDebugOptions();
127 }
128 else
129 {
130 MainConsole.Instance.Output("Usage: debug scene get");
131 }
132 }
133
134 private void OutputSceneDebugOptions()
135 {
136 ConsoleDisplayList cdl = new ConsoleDisplayList();
137 cdl.AddRow("active", m_scene.Active);
138 cdl.AddRow("pbackup", m_scene.PeriodicBackup);
139 cdl.AddRow("physics", m_scene.PhysicsEnabled);
140 cdl.AddRow("scripting", m_scene.ScriptsEnabled);
141 cdl.AddRow("teleport", m_scene.DebugTeleporting);
142 cdl.AddRow("updates", m_scene.DebugUpdates);
143
144 MainConsole.Instance.Output(cdl.ToString());
145 }
146
147 private void HandleDebugSceneSetCommand(string module, string[] args)
148 {
149 if (args.Length == 5)
150 {
151 if (MainConsole.Instance.ConsoleScene == null)
152 {
153 MainConsole.Instance.Output("Please use 'change region <regioname>' first");
154 }
155 else
156 {
157 string key = args[3];
158 string value = args[4];
159 SetSceneDebugOptions(new Dictionary<string, string>() { { key, value } });
160
161 MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value);
162 }
163 }
164 else
165 {
166 MainConsole.Instance.Output(
167 "Usage: debug scene set active|collisions|pbackup|physics|scripting|teleport|updates true|false");
168 }
169 }
170
171 public void SetSceneDebugOptions(Dictionary<string, string> options)
172 {
173 if (options.ContainsKey("active"))
174 {
175 bool active;
176
177 if (bool.TryParse(options["active"], out active))
178 m_scene.Active = active;
179 }
180
181 if (options.ContainsKey("pbackup"))
182 {
183 bool active;
184
185 if (bool.TryParse(options["pbackup"], out active))
186 m_scene.PeriodicBackup = active;
187 }
188
189 if (options.ContainsKey("scripting"))
190 {
191 bool enableScripts = true;
192 if (bool.TryParse(options["scripting"], out enableScripts))
193 m_scene.ScriptsEnabled = enableScripts;
194 }
195
196 if (options.ContainsKey("physics"))
197 {
198 bool enablePhysics;
199 if (bool.TryParse(options["physics"], out enablePhysics))
200 m_scene.PhysicsEnabled = enablePhysics;
201 }
202
203// if (options.ContainsKey("collisions"))
204// {
205// // TODO: Implement. If false, should stop objects colliding, though possibly should still allow
206// // the avatar themselves to collide with the ground.
207// }
208
209 if (options.ContainsKey("teleport"))
210 {
211 bool enableTeleportDebugging;
212 if (bool.TryParse(options["teleport"], out enableTeleportDebugging))
213 m_scene.DebugTeleporting = enableTeleportDebugging;
214 }
215
216 if (options.ContainsKey("updates"))
217 {
218 bool enableUpdateDebugging;
219 if (bool.TryParse(options["updates"], out enableUpdateDebugging))
220 {
221 m_scene.DebugUpdates = enableUpdateDebugging;
222 GcNotify.Enabled = enableUpdateDebugging;
223 }
224 }
225 }
226 }
227} \ No newline at end of file