diff options
author | Justin Clarke Casey | 2008-06-01 01:01:16 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-06-01 01:01:16 +0000 |
commit | 8e1d3386561f263646c10c875aa00af4b3c9f815 (patch) | |
tree | 3fc89893ecdd75b0be7283dd0b4a2b9376b59964 /OpenSim/Region/Application/OpenSimMainConsole.cs | |
parent | * Updates permission module so that GenericCommunicationPermission returns tr... (diff) | |
download | opensim-SC-8e1d3386561f263646c10c875aa00af4b3c9f815.zip opensim-SC-8e1d3386561f263646c10c875aa00af4b3c9f815.tar.gz opensim-SC-8e1d3386561f263646c10c875aa00af4b3c9f815.tar.bz2 opensim-SC-8e1d3386561f263646c10c875aa00af4b3c9f815.tar.xz |
* Refactor: Split opensim background server into a separate class
Diffstat (limited to 'OpenSim/Region/Application/OpenSimMainConsole.cs')
-rw-r--r-- | OpenSim/Region/Application/OpenSimMainConsole.cs | 679 |
1 files changed, 0 insertions, 679 deletions
diff --git a/OpenSim/Region/Application/OpenSimMainConsole.cs b/OpenSim/Region/Application/OpenSimMainConsole.cs deleted file mode 100644 index 467db14..0000000 --- a/OpenSim/Region/Application/OpenSimMainConsole.cs +++ /dev/null | |||
@@ -1,679 +0,0 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using System.Net; | ||
33 | using System.Reflection; | ||
34 | using System.Threading; | ||
35 | using libsecondlife; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Console; | ||
40 | using OpenSim.Framework.Statistics; | ||
41 | using OpenSim.Region.Environment.Interfaces; | ||
42 | using OpenSim.Region.Environment.Scenes; | ||
43 | using Timer=System.Timers.Timer; | ||
44 | |||
45 | namespace OpenSim | ||
46 | { | ||
47 | public delegate void ConsoleCommand(string[] comParams); | ||
48 | |||
49 | public class OpenSimMainConsole : OpenSimMain, conscmd_callback | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | protected string m_startupCommandsFile; | ||
54 | protected string m_shutdownCommandsFile; | ||
55 | |||
56 | private string m_timedScript = "disabled"; | ||
57 | private Timer m_scriptTimer; | ||
58 | |||
59 | public OpenSimMainConsole(IConfigSource configSource) | ||
60 | : base(configSource) | ||
61 | { | ||
62 | } | ||
63 | |||
64 | protected override void ReadConfigSettings() | ||
65 | { | ||
66 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
67 | |||
68 | if (startupConfig != null) | ||
69 | { | ||
70 | m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", String.Empty); | ||
71 | m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", String.Empty); | ||
72 | |||
73 | m_timedScript = startupConfig.GetString("timer_Script", "disabled"); | ||
74 | } | ||
75 | base.ReadConfigSettings(); | ||
76 | } | ||
77 | |||
78 | /// <summary> | ||
79 | /// Performs initialisation of the scene, such as loading configuration from disk. | ||
80 | /// </summary> | ||
81 | public override void StartUp() | ||
82 | { | ||
83 | // | ||
84 | // Called from app startup (OpenSim.Application) | ||
85 | // | ||
86 | |||
87 | m_log.Info("===================================================================="); | ||
88 | m_log.Info("========================= STARTING OPENSIM ========================="); | ||
89 | m_log.Info("===================================================================="); | ||
90 | m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid")); | ||
91 | |||
92 | m_console = CreateConsole(); | ||
93 | MainConsole.Instance = m_console; | ||
94 | InternalStartUp(); | ||
95 | |||
96 | //Run Startup Commands | ||
97 | if (m_startupCommandsFile != String.Empty) | ||
98 | { | ||
99 | RunCommandScript(m_startupCommandsFile); | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | m_log.Info("[STARTUP]: No startup command script specified. Moving on..."); | ||
104 | } | ||
105 | |||
106 | // Start timer script (run a script every xx seconds) | ||
107 | if (m_timedScript != "disabled") | ||
108 | { | ||
109 | m_scriptTimer = new Timer(); | ||
110 | m_scriptTimer.Enabled = true; | ||
111 | m_scriptTimer.Interval = 1200 * 1000; | ||
112 | m_scriptTimer.Elapsed += RunAutoTimerScript; | ||
113 | } | ||
114 | |||
115 | PrintFileToConsole("startuplogo.txt"); | ||
116 | } | ||
117 | |||
118 | protected ConsoleBase CreateConsole() | ||
119 | { | ||
120 | return new ConsoleBase("Region", this); | ||
121 | } | ||
122 | |||
123 | private void RunAutoTimerScript(object sender, EventArgs e) | ||
124 | { | ||
125 | if (m_timedScript != "disabled") | ||
126 | { | ||
127 | RunCommandScript(m_timedScript); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | #region Console Commands | ||
132 | |||
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | /// <param name="fileName"></param> | ||
137 | private void RunCommandScript(string fileName) | ||
138 | { | ||
139 | m_log.Info("[COMMANDFILE]: Running " + fileName); | ||
140 | if (File.Exists(fileName)) | ||
141 | { | ||
142 | StreamReader readFile = File.OpenText(fileName); | ||
143 | string currentCommand; | ||
144 | while ((currentCommand = readFile.ReadLine()) != null) | ||
145 | { | ||
146 | if (currentCommand != String.Empty) | ||
147 | { | ||
148 | m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); | ||
149 | m_console.RunCommand(currentCommand); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | m_log.Error("[COMMANDFILE]: Command script missing. Can not run commands"); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | private static void PrintFileToConsole(string fileName) | ||
160 | { | ||
161 | if (File.Exists(fileName)) | ||
162 | { | ||
163 | StreamReader readFile = File.OpenText(fileName); | ||
164 | string currentLine; | ||
165 | while ((currentLine = readFile.ReadLine()) != null) | ||
166 | { | ||
167 | m_log.Info("[!]" + currentLine); | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | |||
172 | |||
173 | /// <summary> | ||
174 | /// Runs commands issued by the server console from the operator | ||
175 | /// </summary> | ||
176 | /// <param name="command">The first argument of the parameter (the command)</param> | ||
177 | /// <param name="cmdparams">Additional arguments passed to the command</param> | ||
178 | public override void RunCmd(string command, string[] cmdparams) | ||
179 | { | ||
180 | base.RunCmd(command, cmdparams); | ||
181 | |||
182 | switch (command) | ||
183 | { | ||
184 | case "clear-assets": | ||
185 | m_assetCache.Clear(); | ||
186 | break; | ||
187 | |||
188 | case "set-time": | ||
189 | m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0])); | ||
190 | break; | ||
191 | |||
192 | case "force-update": | ||
193 | m_console.Notice("Updating all clients"); | ||
194 | m_sceneManager.ForceCurrentSceneClientUpdate(); | ||
195 | break; | ||
196 | |||
197 | case "edit-scale": | ||
198 | if (cmdparams.Length == 4) | ||
199 | { | ||
200 | m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams); | ||
201 | } | ||
202 | break; | ||
203 | |||
204 | case "debug": | ||
205 | if (cmdparams.Length > 0) | ||
206 | { | ||
207 | Debug(cmdparams); | ||
208 | } | ||
209 | break; | ||
210 | |||
211 | case "scene-debug": | ||
212 | if (cmdparams.Length == 3) | ||
213 | { | ||
214 | if (m_sceneManager.CurrentScene == null) | ||
215 | { | ||
216 | m_console.Error("CONSOLE", "Please use 'change-region <regioname>' first"); | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | m_sceneManager.CurrentScene.SetSceneCoreDebug(!Convert.ToBoolean(cmdparams[0]), !Convert.ToBoolean(cmdparams[1]), !Convert.ToBoolean(cmdparams[2])); | ||
221 | } | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | m_console.Error("scene-debug <scripting> <collisions> <physics> (where inside <> is true/false)"); | ||
226 | } | ||
227 | break; | ||
228 | |||
229 | case "help": | ||
230 | m_console.Notice("alert - send alert to a designated user or all users."); | ||
231 | m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); | ||
232 | m_console.Notice(" alert general [Message] - send an alert to all users."); | ||
233 | m_console.Notice("backup - trigger a simulator backup"); | ||
234 | m_console.Notice("clear-assets - clear asset cache"); | ||
235 | m_console.Notice("create-region <name> <regionfile.xml> - creates a new region"); | ||
236 | m_console.Notice("create user - adds a new user."); | ||
237 | m_console.Notice("change-region [name] - sets the region that many of these commands affect."); | ||
238 | m_console.Notice("command-script [filename] - Execute command in a file."); | ||
239 | m_console.Notice("debug - debugging commands"); | ||
240 | m_console.Notice(" packet 0..255 - print incoming/outgoing packets (0=off)"); | ||
241 | m_console.Notice("scene-debug [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False"); | ||
242 | m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim"); | ||
243 | m_console.Notice("export-map [filename] - save image of world map"); | ||
244 | m_console.Notice("force-update - force an update of prims in the scene"); | ||
245 | m_console.Notice("load-xml [filename] - load prims from XML (DEPRECATED)"); | ||
246 | m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format"); | ||
247 | m_console.Notice("restart - disconnects all clients and restarts the sims in the instance."); | ||
248 | m_console.Notice("remove-region [name] - remove a region"); | ||
249 | m_console.Notice("save-xml [filename] - save prims to XML (DEPRECATED)"); | ||
250 | m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); | ||
251 | m_console.Notice("script - manually trigger scripts? or script commands?"); | ||
252 | m_console.Notice("set-time [x] - set the current scene time phase"); | ||
253 | m_console.Notice("show assets - show state of asset cache."); | ||
254 | m_console.Notice("show users - show info about connected users."); | ||
255 | m_console.Notice("show modules - shows info about loaded modules."); | ||
256 | m_console.Notice("show regions - show running region information."); | ||
257 | m_console.Notice("threads - list threads"); | ||
258 | m_console.Notice("config set section field value - set a config value"); | ||
259 | m_console.Notice("config get section field - get a config value"); | ||
260 | m_console.Notice("config save - save OpenSim.ini"); | ||
261 | m_console.Notice("terrain help - show help for terrain commands."); | ||
262 | break; | ||
263 | |||
264 | case "threads": | ||
265 | // m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:"); | ||
266 | // int _tc = 0; | ||
267 | |||
268 | // foreach (ProcessThread pt in Process.GetCurrentProcess().Threads) | ||
269 | // { | ||
270 | // _tc++; | ||
271 | // m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString()); | ||
272 | // } | ||
273 | |||
274 | List<Thread> threads = ThreadTracker.GetThreads(); | ||
275 | if (threads == null) | ||
276 | { | ||
277 | m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode."); | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | int _tc = 0; | ||
282 | m_console.Notice("THREAD", threads.Count + " threads are being tracked:"); | ||
283 | foreach (Thread t in threads) | ||
284 | { | ||
285 | _tc++; | ||
286 | m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString()); | ||
287 | } | ||
288 | } | ||
289 | |||
290 | break; | ||
291 | case "save-xml": | ||
292 | m_log.Error("[CONSOLE]: PLEASE NOTE, save-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use save-xml2, please file a mantis detailing the reason."); | ||
293 | |||
294 | if (cmdparams.Length > 0) | ||
295 | { | ||
296 | m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]); | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME); | ||
301 | } | ||
302 | break; | ||
303 | |||
304 | case "load-xml": | ||
305 | m_log.Error("[CONSOLE]: PLEASE NOTE, load-xml is DEPRECATED and may be REMOVED soon. If you are using this and there is some reason you can't use load-xml2, please file a mantis detailing the reason."); | ||
306 | |||
307 | LLVector3 loadOffset = new LLVector3(0, 0, 0); | ||
308 | if (cmdparams.Length > 0) | ||
309 | { | ||
310 | bool generateNewIDS = false; | ||
311 | if (cmdparams.Length > 1) | ||
312 | { | ||
313 | if (cmdparams[1] == "-newUID") | ||
314 | { | ||
315 | generateNewIDS = true; | ||
316 | } | ||
317 | if (cmdparams.Length > 2) | ||
318 | { | ||
319 | loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); | ||
320 | if (cmdparams.Length > 3) | ||
321 | { | ||
322 | loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); | ||
323 | } | ||
324 | if (cmdparams.Length > 4) | ||
325 | { | ||
326 | loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); | ||
327 | } | ||
328 | m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + | ||
329 | loadOffset.Z + ">"); | ||
330 | } | ||
331 | } | ||
332 | m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); | ||
333 | } | ||
334 | else | ||
335 | { | ||
336 | m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); | ||
337 | } | ||
338 | break; | ||
339 | |||
340 | case "save-xml2": | ||
341 | if (cmdparams.Length > 0) | ||
342 | { | ||
343 | m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]); | ||
344 | } | ||
345 | else | ||
346 | { | ||
347 | m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME); | ||
348 | } | ||
349 | break; | ||
350 | |||
351 | case "load-xml2": | ||
352 | if (cmdparams.Length > 0) | ||
353 | { | ||
354 | m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]); | ||
355 | } | ||
356 | else | ||
357 | { | ||
358 | m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); | ||
359 | } | ||
360 | break; | ||
361 | |||
362 | case "load-oar": | ||
363 | m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); | ||
364 | |||
365 | if (cmdparams.Length > 0) | ||
366 | { | ||
367 | m_sceneManager.LoadArchiveToCurrentScene(cmdparams[0]); | ||
368 | } | ||
369 | else | ||
370 | { | ||
371 | m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME); | ||
372 | } | ||
373 | break; | ||
374 | |||
375 | case "save-oar": | ||
376 | m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); | ||
377 | |||
378 | if (cmdparams.Length > 0) | ||
379 | { | ||
380 | m_sceneManager.SaveCurrentSceneToArchive(cmdparams[0]); | ||
381 | } | ||
382 | else | ||
383 | { | ||
384 | m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME); | ||
385 | } | ||
386 | break; | ||
387 | |||
388 | case "plugin": | ||
389 | m_sceneManager.SendCommandToPluginModules(cmdparams); | ||
390 | break; | ||
391 | |||
392 | case "command-script": | ||
393 | if (cmdparams.Length > 0) | ||
394 | { | ||
395 | RunCommandScript(cmdparams[0]); | ||
396 | } | ||
397 | break; | ||
398 | |||
399 | case "backup": | ||
400 | m_sceneManager.BackupCurrentScene(); | ||
401 | break; | ||
402 | |||
403 | case "alert": | ||
404 | m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams); | ||
405 | break; | ||
406 | |||
407 | case "create": | ||
408 | CreateAccount(cmdparams); | ||
409 | break; | ||
410 | |||
411 | case "create-region": | ||
412 | CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true); | ||
413 | break; | ||
414 | case "remove-region": | ||
415 | string regName = CombineParams(cmdparams, 0); | ||
416 | |||
417 | Scene killScene; | ||
418 | if (m_sceneManager.TryGetScene(regName, out killScene)) | ||
419 | { | ||
420 | // only need to check this if we are not at the | ||
421 | // root level | ||
422 | if ((m_sceneManager.CurrentScene != null) && | ||
423 | (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID)) | ||
424 | { | ||
425 | m_sceneManager.TrySetCurrentScene(".."); | ||
426 | } | ||
427 | m_regionData.Remove(killScene.RegionInfo); | ||
428 | m_sceneManager.CloseScene(killScene); | ||
429 | } | ||
430 | break; | ||
431 | |||
432 | case "restart": | ||
433 | m_sceneManager.RestartCurrentScene(); | ||
434 | break; | ||
435 | |||
436 | case "change-region": | ||
437 | if (cmdparams.Length > 0) | ||
438 | { | ||
439 | string regionName = CombineParams(cmdparams, 0); | ||
440 | |||
441 | if (!m_sceneManager.TrySetCurrentScene(regionName)) | ||
442 | { | ||
443 | m_console.Error("Couldn't set current region to: " + regionName); | ||
444 | } | ||
445 | } | ||
446 | |||
447 | if (m_sceneManager.CurrentScene == null) | ||
448 | { | ||
449 | m_console.Error("CONSOLE", "Currently at Root level. To change region please use 'change-region <regioname>'"); | ||
450 | } | ||
451 | else | ||
452 | { | ||
453 | m_console.Error("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + | ||
454 | ". To change region please use 'change-region <regioname>'"); | ||
455 | } | ||
456 | |||
457 | break; | ||
458 | |||
459 | case "export-map": | ||
460 | if (cmdparams.Length > 0) | ||
461 | { | ||
462 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]); | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg"); | ||
467 | } | ||
468 | break; | ||
469 | |||
470 | case "config": | ||
471 | string n = command.ToUpper(); | ||
472 | if (cmdparams.Length > 0) | ||
473 | { | ||
474 | switch (cmdparams[0].ToLower()) | ||
475 | { | ||
476 | case "set": | ||
477 | if (cmdparams.Length < 4) | ||
478 | { | ||
479 | m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); | ||
480 | m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | IConfig c = DefaultConfig().Configs[cmdparams[1]]; | ||
485 | if (c == null) | ||
486 | c = DefaultConfig().AddConfig(cmdparams[1]); | ||
487 | string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); | ||
488 | c.Set(cmdparams[2], _value); | ||
489 | m_config.Merge(c.ConfigSource); | ||
490 | |||
491 | m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + | ||
492 | _value); | ||
493 | } | ||
494 | break; | ||
495 | case "get": | ||
496 | if (cmdparams.Length < 3) | ||
497 | { | ||
498 | m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY"); | ||
499 | m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | IConfig c = DefaultConfig().Configs[cmdparams[1]]; | ||
504 | if (c == null) | ||
505 | { | ||
506 | m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); | ||
507 | break; | ||
508 | } | ||
509 | else | ||
510 | { | ||
511 | m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + | ||
512 | c.GetString(cmdparams[2])); | ||
513 | } | ||
514 | } | ||
515 | |||
516 | break; | ||
517 | case "save": | ||
518 | m_console.Notice("Saving configuration file: " + Application.iniFilePath); | ||
519 | m_config.Save(Application.iniFilePath); | ||
520 | break; | ||
521 | } | ||
522 | } | ||
523 | break; | ||
524 | case "modules": | ||
525 | if (cmdparams.Length > 0) | ||
526 | { | ||
527 | switch (cmdparams[0].ToLower()) | ||
528 | { | ||
529 | case "list": | ||
530 | foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) | ||
531 | { | ||
532 | m_console.Notice("Shared region module: " + irm.Name); | ||
533 | } | ||
534 | break; | ||
535 | case "unload": | ||
536 | if (cmdparams.Length > 1) | ||
537 | { | ||
538 | foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules)) | ||
539 | { | ||
540 | if (rm.Name.ToLower() == cmdparams[1].ToLower()) | ||
541 | { | ||
542 | m_console.Notice("Unloading module: " + rm.Name); | ||
543 | m_moduleLoader.UnloadModule(rm); | ||
544 | } | ||
545 | } | ||
546 | } | ||
547 | break; | ||
548 | case "load": | ||
549 | if (cmdparams.Length > 1) | ||
550 | { | ||
551 | foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) | ||
552 | { | ||
553 | |||
554 | m_console.Notice("Loading module: " + cmdparams[1]); | ||
555 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); | ||
556 | } | ||
557 | } | ||
558 | break; | ||
559 | } | ||
560 | } | ||
561 | |||
562 | break; | ||
563 | default: | ||
564 | string[] tmpPluginArgs = new string[cmdparams.Length + 1]; | ||
565 | cmdparams.CopyTo(tmpPluginArgs, 1); | ||
566 | tmpPluginArgs[0] = command; | ||
567 | |||
568 | m_sceneManager.SendCommandToPluginModules(tmpPluginArgs); | ||
569 | break; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | public void Debug(string[] args) | ||
574 | { | ||
575 | switch (args[0]) | ||
576 | { | ||
577 | case "packet": | ||
578 | if (args.Length > 1) | ||
579 | { | ||
580 | int newDebug; | ||
581 | if (int.TryParse(args[1], out newDebug)) | ||
582 | { | ||
583 | m_sceneManager.SetDebugPacketOnCurrentScene(newDebug); | ||
584 | } | ||
585 | else | ||
586 | { | ||
587 | m_console.Error("packet debug should be 0..2"); | ||
588 | } | ||
589 | m_console.Notice("New packet debug: " + newDebug.ToString()); | ||
590 | } | ||
591 | |||
592 | break; | ||
593 | default: | ||
594 | m_console.Error("Unknown debug"); | ||
595 | break; | ||
596 | } | ||
597 | } | ||
598 | |||
599 | // see BaseOpenSimServer | ||
600 | public override void Show(string ShowWhat) | ||
601 | { | ||
602 | base.Show(ShowWhat); | ||
603 | |||
604 | switch (ShowWhat) | ||
605 | { | ||
606 | case "assets": | ||
607 | m_assetCache.ShowState(); | ||
608 | break; | ||
609 | |||
610 | case "users": | ||
611 | IList agents = m_sceneManager.GetCurrentSceneAvatars(); | ||
612 | |||
613 | m_console.Notice(String.Format("\nAgents connected: {0}\n", agents.Count)); | ||
614 | |||
615 | m_console.Notice( | ||
616 | String.Format("{0,-16}{1,-16}{2,-37}{3,-16}", "Firstname", "Lastname", | ||
617 | "Agent ID","Region")); | ||
618 | |||
619 | foreach (ScenePresence presence in agents) | ||
620 | { | ||
621 | RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle); | ||
622 | string regionName; | ||
623 | System.Net.EndPoint ep = null; | ||
624 | |||
625 | if (regionInfo == null) | ||
626 | { | ||
627 | regionName = "Unresolvable"; | ||
628 | } | ||
629 | else | ||
630 | { | ||
631 | regionName = regionInfo.RegionName; | ||
632 | } | ||
633 | |||
634 | m_console.Notice( | ||
635 | String.Format( | ||
636 | "{0,-16}{1,-16}{2,-37}{3,-16}", | ||
637 | presence.Firstname, | ||
638 | presence.Lastname, | ||
639 | presence.UUID, | ||
640 | regionName)); | ||
641 | } | ||
642 | |||
643 | m_console.Notice(""); | ||
644 | break; | ||
645 | |||
646 | case "modules": | ||
647 | m_console.Notice("The currently loaded shared modules are:"); | ||
648 | foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) | ||
649 | { | ||
650 | m_console.Notice("Shared Module: " + module.Name); | ||
651 | } | ||
652 | break; | ||
653 | |||
654 | case "regions": | ||
655 | m_sceneManager.ForEachScene( | ||
656 | delegate(Scene scene) | ||
657 | { | ||
658 | m_console.Notice("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + | ||
659 | scene.RegionInfo.RegionLocX + " , Region YLoc: " + | ||
660 | scene.RegionInfo.RegionLocY); | ||
661 | }); | ||
662 | break; | ||
663 | } | ||
664 | } | ||
665 | |||
666 | private static string CombineParams(string[] commandParams, int pos) | ||
667 | { | ||
668 | string result = String.Empty; | ||
669 | for (int i = pos; i < commandParams.Length; i++) | ||
670 | { | ||
671 | result += commandParams[i] + " "; | ||
672 | } | ||
673 | result = result.TrimEnd(' '); | ||
674 | return result; | ||
675 | } | ||
676 | |||
677 | #endregion | ||
678 | } | ||
679 | } | ||