aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
-rw-r--r--OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs227
1 files changed, 227 insertions, 0 deletions
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