OpenSimMainConsole.cs 30 KB

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