OpenSim.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  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. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Reflection;
  32. using System.Timers;
  33. using log4net;
  34. using Nini.Config;
  35. using OpenMetaverse;
  36. using OpenSim.Framework;
  37. using OpenSim.Framework.Console;
  38. using OpenSim.Framework.Statistics;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Region.Framework.Scenes;
  41. namespace OpenSim
  42. {
  43. /// <summary>
  44. /// Interactive OpenSim region server
  45. /// </summary>
  46. public class OpenSim : OpenSimBase
  47. {
  48. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  49. protected string m_startupCommandsFile;
  50. protected string m_shutdownCommandsFile;
  51. protected bool m_gui = false;
  52. protected string m_consoleType = "local";
  53. protected uint m_consolePort = 0;
  54. private string m_timedScript = "disabled";
  55. private Timer m_scriptTimer;
  56. public OpenSim(IConfigSource configSource) : base(configSource)
  57. {
  58. }
  59. protected override void ReadExtraConfigSettings()
  60. {
  61. base.ReadExtraConfigSettings();
  62. IConfig startupConfig = m_config.Source.Configs["Startup"];
  63. IConfig networkConfig = m_config.Source.Configs["Network"];
  64. int stpMaxThreads = 15;
  65. if (startupConfig != null)
  66. {
  67. m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", "startup_commands.txt");
  68. m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", "shutdown_commands.txt");
  69. if (startupConfig.GetString("console", String.Empty) == String.Empty)
  70. m_gui = startupConfig.GetBoolean("gui", false);
  71. else
  72. m_consoleType= startupConfig.GetString("console", String.Empty);
  73. if (networkConfig != null)
  74. m_consolePort = (uint)networkConfig.GetInt("console_port", 0);
  75. m_timedScript = startupConfig.GetString("timer_Script", "disabled");
  76. if (m_logFileAppender != null)
  77. {
  78. if (m_logFileAppender is log4net.Appender.FileAppender)
  79. {
  80. log4net.Appender.FileAppender appender =
  81. (log4net.Appender.FileAppender)m_logFileAppender;
  82. string fileName = startupConfig.GetString("LogFile", String.Empty);
  83. if (fileName != String.Empty)
  84. {
  85. appender.File = fileName;
  86. appender.ActivateOptions();
  87. }
  88. m_log.InfoFormat("[LOGGING]: Logging started to file {0}", appender.File);
  89. }
  90. }
  91. string asyncCallMethodStr = startupConfig.GetString("async_call_method", String.Empty);
  92. FireAndForgetMethod asyncCallMethod;
  93. if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
  94. Util.FireAndForgetMethod = asyncCallMethod;
  95. stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15);
  96. }
  97. if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
  98. Util.InitThreadPool(stpMaxThreads);
  99. m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
  100. }
  101. /// <summary>
  102. /// Performs initialisation of the scene, such as loading configuration from disk.
  103. /// </summary>
  104. protected override void StartupSpecific()
  105. {
  106. m_log.Info("====================================================================");
  107. m_log.Info("========================= STARTING OPENSIM =========================");
  108. m_log.Info("====================================================================");
  109. m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode",
  110. (ConfigurationSettings.Standalone ? "sandbox" : "grid"));
  111. //m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString());
  112. // http://msdn.microsoft.com/en-us/library/bb384202.aspx
  113. //GCSettings.LatencyMode = GCLatencyMode.Batch;
  114. //m_log.InfoFormat("[OPENSIM MAIN]: GC Latency Mode: {0}", GCSettings.LatencyMode.ToString());
  115. if (m_gui) // Driven by external GUI
  116. m_console = new CommandConsole("Region");
  117. else
  118. {
  119. switch (m_consoleType)
  120. {
  121. case "basic":
  122. m_console = new CommandConsole("Region");
  123. break;
  124. case "rest":
  125. m_console = new RemoteConsole("Region");
  126. ((RemoteConsole)m_console).ReadConfig(m_config.Source);
  127. break;
  128. default:
  129. m_console = new LocalConsole("Region");
  130. break;
  131. }
  132. }
  133. MainConsole.Instance = m_console;
  134. RegisterConsoleCommands();
  135. base.StartupSpecific();
  136. if (m_console is RemoteConsole)
  137. {
  138. if (m_consolePort == 0)
  139. {
  140. ((RemoteConsole)m_console).SetServer(m_httpServer);
  141. }
  142. else
  143. {
  144. ((RemoteConsole)m_console).SetServer(MainServer.GetHttpServer(m_consolePort));
  145. }
  146. }
  147. //Run Startup Commands
  148. if (String.IsNullOrEmpty(m_startupCommandsFile))
  149. {
  150. m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
  151. }
  152. else
  153. {
  154. RunCommandScript(m_startupCommandsFile);
  155. }
  156. // Start timer script (run a script every xx seconds)
  157. if (m_timedScript != "disabled")
  158. {
  159. m_scriptTimer = new Timer();
  160. m_scriptTimer.Enabled = true;
  161. m_scriptTimer.Interval = 1200*1000;
  162. m_scriptTimer.Elapsed += RunAutoTimerScript;
  163. }
  164. // Hook up to the watchdog timer
  165. Watchdog.OnWatchdogTimeout += WatchdogTimeoutHandler;
  166. PrintFileToConsole("startuplogo.txt");
  167. // For now, start at the 'root' level by default
  168. if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
  169. ChangeSelectedRegion("region",
  170. new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
  171. else
  172. ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
  173. }
  174. /// <summary>
  175. /// Register standard set of region console commands
  176. /// </summary>
  177. private void RegisterConsoleCommands()
  178. {
  179. m_console.Commands.AddCommand("region", false, "clear assets",
  180. "clear assets",
  181. "Clear the asset cache", HandleClearAssets);
  182. m_console.Commands.AddCommand("region", false, "force update",
  183. "force update",
  184. "Force the update of all objects on clients",
  185. HandleForceUpdate);
  186. m_console.Commands.AddCommand("region", false, "debug packet",
  187. "debug packet <level>",
  188. "Turn on packet debugging", Debug);
  189. m_console.Commands.AddCommand("region", false, "debug scene",
  190. "debug scene <cripting> <collisions> <physics>",
  191. "Turn on scene debugging", Debug);
  192. m_console.Commands.AddCommand("region", false, "change region",
  193. "change region <region name>",
  194. "Change current console region", ChangeSelectedRegion);
  195. m_console.Commands.AddCommand("region", false, "save xml",
  196. "save xml",
  197. "Save a region's data in XML format", SaveXml);
  198. m_console.Commands.AddCommand("region", false, "save xml2",
  199. "save xml2",
  200. "Save a region's data in XML2 format", SaveXml2);
  201. m_console.Commands.AddCommand("region", false, "load xml",
  202. "load xml [-newIDs [<x> <y> <z>]]",
  203. "Load a region's data from XML format", LoadXml);
  204. m_console.Commands.AddCommand("region", false, "load xml2",
  205. "load xml2",
  206. "Load a region's data from XML2 format", LoadXml2);
  207. m_console.Commands.AddCommand("region", false, "save prims xml2",
  208. "save prims xml2 [<prim name> <file name>]",
  209. "Save named prim to XML2", SavePrimsXml2);
  210. m_console.Commands.AddCommand("region", false, "load oar",
  211. "load oar [--merge] <oar name>",
  212. "Load a region's data from OAR archive", LoadOar);
  213. m_console.Commands.AddCommand("region", false, "save oar",
  214. "save oar <oar name>",
  215. "Save a region's data to an OAR archive",
  216. "More information on forthcoming options here soon", SaveOar);
  217. m_console.Commands.AddCommand("region", false, "edit scale",
  218. "edit scale <name> <x> <y> <z>",
  219. "Change the scale of a named prim", HandleEditScale);
  220. m_console.Commands.AddCommand("region", false, "kick user",
  221. "kick user <first> <last> [message]",
  222. "Kick a user off the simulator", KickUserCommand);
  223. m_console.Commands.AddCommand("region", false, "show assets",
  224. "show assets",
  225. "Show asset data", HandleShow);
  226. m_console.Commands.AddCommand("region", false, "show users",
  227. "show users [full]",
  228. "Show user data", HandleShow);
  229. m_console.Commands.AddCommand("region", false, "show connections",
  230. "show connections",
  231. "Show connection data", HandleShow);
  232. m_console.Commands.AddCommand("region", false, "show users full",
  233. "show users full",
  234. String.Empty, HandleShow);
  235. m_console.Commands.AddCommand("region", false, "show modules",
  236. "show modules",
  237. "Show module data", HandleShow);
  238. m_console.Commands.AddCommand("region", false, "show regions",
  239. "show regions",
  240. "Show region data", HandleShow);
  241. m_console.Commands.AddCommand("region", false, "show queues",
  242. "show queues",
  243. "Show queue data", HandleShow);
  244. m_console.Commands.AddCommand("region", false, "show ratings",
  245. "show ratings",
  246. "Show rating data", HandleShow);
  247. m_console.Commands.AddCommand("region", false, "backup",
  248. "backup",
  249. "Persist objects to the database now", RunCommand);
  250. m_console.Commands.AddCommand("region", false, "create region",
  251. "create region",
  252. "Create a new region", HandleCreateRegion);
  253. m_console.Commands.AddCommand("region", false, "restart",
  254. "restart",
  255. "Restart all sims in this instance", RunCommand);
  256. m_console.Commands.AddCommand("region", false, "config set",
  257. "config set <section> <field> <value>",
  258. "Set a config option", HandleConfig);
  259. m_console.Commands.AddCommand("region", false, "config get",
  260. "config get <section> <field>",
  261. "Read a config option", HandleConfig);
  262. m_console.Commands.AddCommand("region", false, "config save",
  263. "config save",
  264. "Save current configuration", HandleConfig);
  265. m_console.Commands.AddCommand("region", false, "command-script",
  266. "command-script <script>",
  267. "Run a command script from file", RunCommand);
  268. m_console.Commands.AddCommand("region", false, "remove-region",
  269. "remove-region <name>",
  270. "Remove a region from this simulator", RunCommand);
  271. m_console.Commands.AddCommand("region", false, "delete-region",
  272. "delete-region <name>",
  273. "Delete a region from disk", RunCommand);
  274. m_console.Commands.AddCommand("region", false, "modules list",
  275. "modules list",
  276. "List modules", HandleModules);
  277. m_console.Commands.AddCommand("region", false, "modules load",
  278. "modules load <name>",
  279. "Load a module", HandleModules);
  280. m_console.Commands.AddCommand("region", false, "modules unload",
  281. "modules unload <name>",
  282. "Unload a module", HandleModules);
  283. m_console.Commands.AddCommand("region", false, "Add-InventoryHost",
  284. "Add-InventoryHost <host>",
  285. String.Empty, RunCommand);
  286. m_console.Commands.AddCommand("region", false, "kill uuid",
  287. "kill uuid <UUID>",
  288. "Kill an object by UUID", KillUUID);
  289. if (ConfigurationSettings.Standalone)
  290. {
  291. m_console.Commands.AddCommand("region", false, "create user",
  292. "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
  293. "Create a new user", HandleCreateUser);
  294. m_console.Commands.AddCommand("region", false, "reset user password",
  295. "reset user password [<first> [<last> [<password>]]]",
  296. "Reset a user password", HandleResetUserPassword);
  297. }
  298. m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
  299. "Set local coordinate to map HG regions to", RunCommand);
  300. m_console.Commands.AddCommand("hypergrid", false, "link-region",
  301. "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
  302. "Link a hypergrid region", RunCommand);
  303. m_console.Commands.AddCommand("hypergrid", false, "unlink-region",
  304. "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
  305. "Unlink a hypergrid region", RunCommand);
  306. }
  307. public override void ShutdownSpecific()
  308. {
  309. if (m_shutdownCommandsFile != String.Empty)
  310. {
  311. RunCommandScript(m_shutdownCommandsFile);
  312. }
  313. base.ShutdownSpecific();
  314. }
  315. /// <summary>
  316. /// Timer to run a specific text file as console commands. Configured in in the main ini file
  317. /// </summary>
  318. /// <param name="sender"></param>
  319. /// <param name="e"></param>
  320. private void RunAutoTimerScript(object sender, EventArgs e)
  321. {
  322. if (m_timedScript != "disabled")
  323. {
  324. RunCommandScript(m_timedScript);
  325. }
  326. }
  327. private void WatchdogTimeoutHandler(System.Threading.Thread thread, int lastTick)
  328. {
  329. int now = Environment.TickCount & Int32.MaxValue;
  330. m_log.ErrorFormat("[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago",
  331. thread.Name, thread.ThreadState, now - lastTick);
  332. }
  333. #region Console Commands
  334. /// <summary>
  335. /// Kicks users off the region
  336. /// </summary>
  337. /// <param name="module"></param>
  338. /// <param name="cmdparams">name of avatar to kick</param>
  339. private void KickUserCommand(string module, string[] cmdparams)
  340. {
  341. if (cmdparams.Length < 4)
  342. return;
  343. string alert = null;
  344. if (cmdparams.Length > 4)
  345. alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
  346. IList agents = m_sceneManager.GetCurrentSceneAvatars();
  347. foreach (ScenePresence presence in agents)
  348. {
  349. RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
  350. if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) &&
  351. presence.Lastname.ToLower().Contains(cmdparams[3].ToLower()))
  352. {
  353. m_log.Info(
  354. String.Format(
  355. "Kicking user: {0,-16}{1,-16}{2,-37} in region: {3,-16}",
  356. presence.Firstname, presence.Lastname, presence.UUID, regionInfo.RegionName));
  357. // kick client...
  358. if (alert != null)
  359. presence.ControllingClient.Kick(alert);
  360. else
  361. presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n");
  362. // ...and close on our side
  363. presence.Scene.IncomingCloseAgent(presence.UUID);
  364. }
  365. }
  366. m_log.Info("");
  367. }
  368. /// <summary>
  369. /// Run an optional startup list of commands
  370. /// </summary>
  371. /// <param name="fileName"></param>
  372. private void RunCommandScript(string fileName)
  373. {
  374. if (File.Exists(fileName))
  375. {
  376. m_log.Info("[COMMANDFILE]: Running " + fileName);
  377. using (StreamReader readFile = File.OpenText(fileName))
  378. {
  379. string currentCommand;
  380. while ((currentCommand = readFile.ReadLine()) != null)
  381. {
  382. if (currentCommand != String.Empty)
  383. {
  384. m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
  385. m_console.RunCommand(currentCommand);
  386. }
  387. }
  388. }
  389. }
  390. }
  391. /// <summary>
  392. /// Opens a file and uses it as input to the console command parser.
  393. /// </summary>
  394. /// <param name="fileName">name of file to use as input to the console</param>
  395. private static void PrintFileToConsole(string fileName)
  396. {
  397. if (File.Exists(fileName))
  398. {
  399. StreamReader readFile = File.OpenText(fileName);
  400. string currentLine;
  401. while ((currentLine = readFile.ReadLine()) != null)
  402. {
  403. m_log.Info("[!]" + currentLine);
  404. }
  405. }
  406. }
  407. private void HandleClearAssets(string module, string[] args)
  408. {
  409. m_log.Info("Not implemented.");
  410. }
  411. /// <summary>
  412. /// Force resending of all updates to all clients in active region(s)
  413. /// </summary>
  414. /// <param name="module"></param>
  415. /// <param name="args"></param>
  416. private void HandleForceUpdate(string module, string[] args)
  417. {
  418. m_log.Info("Updating all clients");
  419. m_sceneManager.ForceCurrentSceneClientUpdate();
  420. }
  421. /// <summary>
  422. /// Edits the scale of a primative with the name specified
  423. /// </summary>
  424. /// <param name="module"></param>
  425. /// <param name="args">0,1, name, x, y, z</param>
  426. private void HandleEditScale(string module, string[] args)
  427. {
  428. if (args.Length == 6)
  429. {
  430. m_sceneManager.HandleEditCommandOnCurrentScene(args);
  431. }
  432. else
  433. {
  434. m_log.Info("Argument error: edit scale <prim name> <x> <y> <z>");
  435. }
  436. }
  437. /// <summary>
  438. /// Creates a new region based on the parameters specified. This will ask the user questions on the console
  439. /// </summary>
  440. /// <param name="module"></param>
  441. /// <param name="cmd">0,1,region name, region XML file</param>
  442. private void HandleCreateRegion(string module, string[] cmd)
  443. {
  444. if (cmd.Length < 4)
  445. {
  446. m_log.Error("Usage: create region <region name> <region_file.ini>");
  447. return;
  448. }
  449. if (cmd[3].EndsWith(".xml"))
  450. {
  451. string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
  452. string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
  453. // Allow absolute and relative specifiers
  454. if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
  455. regionFile = cmd[3];
  456. IScene scene;
  457. CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene);
  458. }
  459. else if (cmd[3].EndsWith(".ini"))
  460. {
  461. string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
  462. string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
  463. // Allow absolute and relative specifiers
  464. if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
  465. regionFile = cmd[3];
  466. IScene scene;
  467. CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]), true, out scene);
  468. }
  469. else
  470. {
  471. m_log.Error("Usage: create region <region name> <region_file.ini>");
  472. return;
  473. }
  474. }
  475. /// <summary>
  476. /// Change and load configuration file data.
  477. /// </summary>
  478. /// <param name="module"></param>
  479. /// <param name="cmd"></param>
  480. private void HandleConfig(string module, string[] cmd)
  481. {
  482. List<string> args = new List<string>(cmd);
  483. args.RemoveAt(0);
  484. string[] cmdparams = args.ToArray();
  485. string n = "CONFIG";
  486. if (cmdparams.Length > 0)
  487. {
  488. switch (cmdparams[0].ToLower())
  489. {
  490. case "set":
  491. if (cmdparams.Length < 4)
  492. {
  493. m_log.Error("SYNTAX: " + n + " SET SECTION KEY VALUE");
  494. m_log.Error("EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
  495. }
  496. else
  497. {
  498. IConfig c;
  499. IConfigSource source = new IniConfigSource();
  500. c = source.AddConfig(cmdparams[1]);
  501. if (c != null)
  502. {
  503. string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
  504. c.Set(cmdparams[2], _value);
  505. m_config.Source.Merge(source);
  506. m_log.Error(n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
  507. _value);
  508. }
  509. }
  510. break;
  511. case "get":
  512. if (cmdparams.Length < 3)
  513. {
  514. m_log.Error("SYNTAX: " + n + " GET SECTION KEY");
  515. m_log.Error("EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
  516. }
  517. else
  518. {
  519. IConfig c = m_config.Source.Configs[cmdparams[1]];
  520. if (c == null)
  521. {
  522. m_log.Info("Section \"" + cmdparams[1] + "\" does not exist.");
  523. break;
  524. }
  525. else
  526. {
  527. m_log.Info(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
  528. c.GetString(cmdparams[2]));
  529. }
  530. }
  531. break;
  532. case "save":
  533. if (cmdparams.Length < 2)
  534. {
  535. m_log.Error("SYNTAX: " + n + " SAVE FILE");
  536. return;
  537. }
  538. if (Application.iniFilePath == cmdparams[1])
  539. {
  540. m_log.Error("FILE can not be "+Application.iniFilePath);
  541. return;
  542. }
  543. m_log.Info("Saving configuration file: " + cmdparams[1]);
  544. m_config.Save(cmdparams[1]);
  545. break;
  546. }
  547. }
  548. }
  549. /// <summary>
  550. /// Load, Unload, and list Region modules in use
  551. /// </summary>
  552. /// <param name="module"></param>
  553. /// <param name="cmd"></param>
  554. private void HandleModules(string module, string[] cmd)
  555. {
  556. List<string> args = new List<string>(cmd);
  557. args.RemoveAt(0);
  558. string[] cmdparams = args.ToArray();
  559. if (cmdparams.Length > 0)
  560. {
  561. switch (cmdparams[0].ToLower())
  562. {
  563. case "list":
  564. foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules)
  565. {
  566. m_log.Info("Shared region module: " + irm.Name);
  567. }
  568. break;
  569. case "unload":
  570. if (cmdparams.Length > 1)
  571. {
  572. foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules))
  573. {
  574. if (rm.Name.ToLower() == cmdparams[1].ToLower())
  575. {
  576. m_log.Info("Unloading module: " + rm.Name);
  577. m_moduleLoader.UnloadModule(rm);
  578. }
  579. }
  580. }
  581. break;
  582. case "load":
  583. if (cmdparams.Length > 1)
  584. {
  585. foreach (Scene s in new ArrayList(m_sceneManager.Scenes))
  586. {
  587. m_log.Info("Loading module: " + cmdparams[1]);
  588. m_moduleLoader.LoadRegionModules(cmdparams[1], s);
  589. }
  590. }
  591. break;
  592. }
  593. }
  594. }
  595. /// <summary>
  596. /// Runs commands issued by the server console from the operator
  597. /// </summary>
  598. /// <param name="command">The first argument of the parameter (the command)</param>
  599. /// <param name="cmdparams">Additional arguments passed to the command</param>
  600. public void RunCommand(string module, string[] cmdparams)
  601. {
  602. List<string> args = new List<string>(cmdparams);
  603. if (args.Count < 1)
  604. return;
  605. string command = args[0];
  606. args.RemoveAt(0);
  607. cmdparams = args.ToArray();
  608. switch (command)
  609. {
  610. case "command-script":
  611. if (cmdparams.Length > 0)
  612. {
  613. RunCommandScript(cmdparams[0]);
  614. }
  615. break;
  616. case "backup":
  617. m_sceneManager.BackupCurrentScene();
  618. break;
  619. case "remove-region":
  620. string regRemoveName = CombineParams(cmdparams, 0);
  621. Scene removeScene;
  622. if (m_sceneManager.TryGetScene(regRemoveName, out removeScene))
  623. RemoveRegion(removeScene, false);
  624. else
  625. m_log.Error("no region with that name");
  626. break;
  627. case "delete-region":
  628. string regDeleteName = CombineParams(cmdparams, 0);
  629. Scene killScene;
  630. if (m_sceneManager.TryGetScene(regDeleteName, out killScene))
  631. RemoveRegion(killScene, true);
  632. else
  633. m_log.Error("no region with that name");
  634. break;
  635. case "restart":
  636. m_sceneManager.RestartCurrentScene();
  637. break;
  638. case "Add-InventoryHost":
  639. if (cmdparams.Length > 0)
  640. {
  641. m_log.Info("Not implemented.");
  642. }
  643. break;
  644. }
  645. }
  646. /// <summary>
  647. /// Change the currently selected region. The selected region is that operated upon by single region commands.
  648. /// </summary>
  649. /// <param name="cmdParams"></param>
  650. protected void ChangeSelectedRegion(string module, string[] cmdparams)
  651. {
  652. if (cmdparams.Length > 2)
  653. {
  654. string newRegionName = CombineParams(cmdparams, 2);
  655. if (!m_sceneManager.TrySetCurrentScene(newRegionName))
  656. m_log.Error("Couldn't select region " + newRegionName);
  657. }
  658. else
  659. {
  660. m_log.Error("Usage: change region <region name>");
  661. }
  662. string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName);
  663. m_log.Info(String.Format("Currently selected region is {0}", regionName));
  664. m_console.DefaultPrompt = String.Format("Region ({0}) ", regionName);
  665. m_console.ConsoleScene = m_sceneManager.CurrentScene;
  666. }
  667. /// <summary>
  668. /// Execute switch for some of the create commands
  669. /// </summary>
  670. /// <param name="args"></param>
  671. private void HandleCreateUser(string module, string[] cmd)
  672. {
  673. if (ConfigurationSettings.Standalone)
  674. {
  675. CreateUser(cmd);
  676. }
  677. else
  678. {
  679. m_log.Info("Create user is not available in grid mode, use the user server.");
  680. }
  681. }
  682. /// <summary>
  683. /// Execute switch for some of the reset commands
  684. /// </summary>
  685. /// <param name="args"></param>
  686. protected void HandleResetUserPassword(string module, string[] cmd)
  687. {
  688. if (ConfigurationSettings.Standalone)
  689. {
  690. ResetUserPassword(cmd);
  691. }
  692. else
  693. {
  694. m_log.Info("Reset user password is not available in grid mode, use the user-server.");
  695. }
  696. }
  697. /// <summary>
  698. /// Turn on some debugging values for OpenSim.
  699. /// </summary>
  700. /// <param name="args"></param>
  701. protected void Debug(string module, string[] args)
  702. {
  703. if (args.Length == 1)
  704. return;
  705. switch (args[1])
  706. {
  707. case "packet":
  708. if (args.Length > 2)
  709. {
  710. int newDebug;
  711. if (int.TryParse(args[2], out newDebug))
  712. {
  713. m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug);
  714. }
  715. else
  716. {
  717. m_log.Error("packet debug should be 0..255");
  718. }
  719. m_log.Info("New packet debug: " + newDebug.ToString());
  720. }
  721. break;
  722. case "scene":
  723. if (args.Length == 5)
  724. {
  725. if (m_sceneManager.CurrentScene == null)
  726. {
  727. m_log.Info("Please use 'change region <regioname>' first");
  728. }
  729. else
  730. {
  731. bool scriptingOn = !Convert.ToBoolean(args[2]);
  732. bool collisionsOn = !Convert.ToBoolean(args[3]);
  733. bool physicsOn = !Convert.ToBoolean(args[4]);
  734. m_sceneManager.CurrentScene.SetSceneCoreDebug(scriptingOn, collisionsOn, physicsOn);
  735. m_log.Info(
  736. String.Format(
  737. "Set debug scene scripting = {0}, collisions = {1}, physics = {2}",
  738. !scriptingOn, !collisionsOn, !physicsOn));
  739. }
  740. }
  741. else
  742. {
  743. m_log.Error("debug scene <scripting> <collisions> <physics> (where inside <> is true/false)");
  744. }
  745. break;
  746. default:
  747. m_log.Error("Unknown debug");
  748. break;
  749. }
  750. }
  751. // see BaseOpenSimServer
  752. /// <summary>
  753. /// Many commands list objects for debugging. Some of the types are listed here
  754. /// </summary>
  755. /// <param name="mod"></param>
  756. /// <param name="cmd"></param>
  757. public override void HandleShow(string mod, string[] cmd)
  758. {
  759. base.HandleShow(mod, cmd);
  760. List<string> args = new List<string>(cmd);
  761. args.RemoveAt(0);
  762. string[] showParams = args.ToArray();
  763. switch (showParams[0])
  764. {
  765. case "assets":
  766. m_log.Info("Not implemented.");
  767. break;
  768. case "users":
  769. IList agents;
  770. if (showParams.Length > 1 && showParams[1] == "full")
  771. {
  772. agents = m_sceneManager.GetCurrentScenePresences();
  773. }
  774. else
  775. {
  776. agents = m_sceneManager.GetCurrentSceneAvatars();
  777. }
  778. m_log.Info(String.Format("\nAgents connected: {0}\n", agents.Count));
  779. m_log.Info(
  780. String.Format("{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}", "Firstname", "Lastname",
  781. "Agent ID", "Root/Child", "Region", "Position"));
  782. foreach (ScenePresence presence in agents)
  783. {
  784. RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
  785. string regionName;
  786. if (regionInfo == null)
  787. {
  788. regionName = "Unresolvable";
  789. }
  790. else
  791. {
  792. regionName = regionInfo.RegionName;
  793. }
  794. m_log.Info(
  795. String.Format(
  796. "{0,-16}{1,-16}{2,-37}{3,-11}{4,-16}{5,-30}",
  797. presence.Firstname,
  798. presence.Lastname,
  799. presence.UUID,
  800. presence.IsChildAgent ? "Child" : "Root",
  801. regionName,
  802. presence.AbsolutePosition.ToString()));
  803. }
  804. m_log.Info(String.Empty);
  805. break;
  806. case "connections":
  807. System.Text.StringBuilder connections = new System.Text.StringBuilder("Connections:\n");
  808. m_sceneManager.ForEachScene(
  809. delegate(Scene scene)
  810. {
  811. scene.ForEachClient(
  812. delegate(IClientAPI client)
  813. {
  814. connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n",
  815. scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode);
  816. }, false
  817. );
  818. }
  819. );
  820. m_log.Info(connections.ToString());
  821. break;
  822. case "modules":
  823. m_log.Info("The currently loaded shared modules are:");
  824. foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
  825. {
  826. m_log.Info("Shared Module: " + module.Name);
  827. }
  828. break;
  829. case "regions":
  830. m_sceneManager.ForEachScene(
  831. delegate(Scene scene)
  832. {
  833. m_log.Info("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " +
  834. scene.RegionInfo.RegionLocX + " , Region YLoc: " +
  835. scene.RegionInfo.RegionLocY + " , Region Port: " +
  836. scene.RegionInfo.InternalEndPoint.Port.ToString());
  837. });
  838. break;
  839. case "queues":
  840. Notice(GetQueuesReport());
  841. break;
  842. case "ratings":
  843. m_sceneManager.ForEachScene(
  844. delegate(Scene scene)
  845. {
  846. string rating = "";
  847. if (scene.RegionInfo.RegionSettings.Maturity == 1)
  848. {
  849. rating = "MATURE";
  850. }
  851. else if (scene.RegionInfo.RegionSettings.Maturity == 2)
  852. {
  853. rating = "ADULT";
  854. }
  855. else
  856. {
  857. rating = "PG";
  858. }
  859. m_log.Info("Region Name: " + scene.RegionInfo.RegionName + " , Region Rating: " +
  860. rating);
  861. });
  862. break;
  863. }
  864. }
  865. /// <summary>
  866. /// print UDP Queue data for each client
  867. /// </summary>
  868. /// <returns></returns>
  869. private string GetQueuesReport()
  870. {
  871. string report = String.Empty;
  872. m_sceneManager.ForEachScene(delegate(Scene scene)
  873. {
  874. scene.ForEachClient(delegate(IClientAPI client)
  875. {
  876. if (client is IStatsCollector)
  877. {
  878. report = report + client.FirstName +
  879. " " + client.LastName + "\n";
  880. IStatsCollector stats =
  881. (IStatsCollector) client;
  882. report = report + string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}\n",
  883. "Send",
  884. "In",
  885. "Out",
  886. "Resend",
  887. "Land",
  888. "Wind",
  889. "Cloud",
  890. "Task",
  891. "Texture",
  892. "Asset");
  893. report = report + stats.Report() +
  894. "\n\n";
  895. }
  896. });
  897. });
  898. return report;
  899. }
  900. /// <summary>
  901. /// Create a new user
  902. /// </summary>
  903. /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
  904. protected void CreateUser(string[] cmdparams)
  905. {
  906. string firstName;
  907. string lastName;
  908. string password;
  909. string email;
  910. uint regX = 1000;
  911. uint regY = 1000;
  912. IConfig standalone;
  913. if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
  914. {
  915. regX = (uint)standalone.GetInt("default_location_x", (int)regX);
  916. regY = (uint)standalone.GetInt("default_location_y", (int)regY);
  917. }
  918. if (cmdparams.Length < 3)
  919. firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
  920. else firstName = cmdparams[2];
  921. if (cmdparams.Length < 4)
  922. lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
  923. else lastName = cmdparams[3];
  924. if (cmdparams.Length < 5)
  925. password = MainConsole.Instance.PasswdPrompt("Password");
  926. else password = cmdparams[4];
  927. if (cmdparams.Length < 6)
  928. regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
  929. else regX = Convert.ToUInt32(cmdparams[5]);
  930. if (cmdparams.Length < 7)
  931. regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
  932. else regY = Convert.ToUInt32(cmdparams[6]);
  933. if (cmdparams.Length < 8)
  934. email = MainConsole.Instance.CmdPrompt("Email", "");
  935. else email = cmdparams[7];
  936. if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
  937. {
  938. m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
  939. }
  940. else
  941. {
  942. m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
  943. }
  944. }
  945. /// <summary>
  946. /// Reset a user password.
  947. /// </summary>
  948. /// <param name="cmdparams"></param>
  949. private void ResetUserPassword(string[] cmdparams)
  950. {
  951. string firstName;
  952. string lastName;
  953. string newPassword;
  954. if (cmdparams.Length < 4)
  955. firstName = MainConsole.Instance.CmdPrompt("First name");
  956. else firstName = cmdparams[3];
  957. if (cmdparams.Length < 5)
  958. lastName = MainConsole.Instance.CmdPrompt("Last name");
  959. else lastName = cmdparams[4];
  960. if (cmdparams.Length < 6)
  961. newPassword = MainConsole.Instance.PasswdPrompt("New password");
  962. else newPassword = cmdparams[5];
  963. m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
  964. }
  965. /// <summary>
  966. /// Use XML2 format to serialize data to a file
  967. /// </summary>
  968. /// <param name="module"></param>
  969. /// <param name="cmdparams"></param>
  970. protected void SavePrimsXml2(string module, string[] cmdparams)
  971. {
  972. if (cmdparams.Length > 5)
  973. {
  974. m_sceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]);
  975. }
  976. else
  977. {
  978. m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
  979. }
  980. }
  981. /// <summary>
  982. /// Use XML format to serialize data to a file
  983. /// </summary>
  984. /// <param name="module"></param>
  985. /// <param name="cmdparams"></param>
  986. protected void SaveXml(string module, string[] cmdparams)
  987. {
  988. 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.");
  989. if (cmdparams.Length > 0)
  990. {
  991. m_sceneManager.SaveCurrentSceneToXml(cmdparams[2]);
  992. }
  993. else
  994. {
  995. m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
  996. }
  997. }
  998. /// <summary>
  999. /// Loads data and region objects from XML format.
  1000. /// </summary>
  1001. /// <param name="module"></param>
  1002. /// <param name="cmdparams"></param>
  1003. protected void LoadXml(string module, string[] cmdparams)
  1004. {
  1005. 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.");
  1006. Vector3 loadOffset = new Vector3(0, 0, 0);
  1007. if (cmdparams.Length > 2)
  1008. {
  1009. bool generateNewIDS = false;
  1010. if (cmdparams.Length > 3)
  1011. {
  1012. if (cmdparams[3] == "-newUID")
  1013. {
  1014. generateNewIDS = true;
  1015. }
  1016. if (cmdparams.Length > 4)
  1017. {
  1018. loadOffset.X = (float) Convert.ToDecimal(cmdparams[4]);
  1019. if (cmdparams.Length > 5)
  1020. {
  1021. loadOffset.Y = (float) Convert.ToDecimal(cmdparams[5]);
  1022. }
  1023. if (cmdparams.Length > 6)
  1024. {
  1025. loadOffset.Z = (float) Convert.ToDecimal(cmdparams[6]);
  1026. }
  1027. m_log.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," +
  1028. loadOffset.Z + ">");
  1029. }
  1030. }
  1031. m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset);
  1032. }
  1033. else
  1034. {
  1035. try
  1036. {
  1037. m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
  1038. }
  1039. catch (FileNotFoundException)
  1040. {
  1041. m_log.Error("Default xml not found. Usage: load-xml <filename>");
  1042. }
  1043. }
  1044. }
  1045. /// <summary>
  1046. /// Serialize region data to XML2Format
  1047. /// </summary>
  1048. /// <param name="module"></param>
  1049. /// <param name="cmdparams"></param>
  1050. protected void SaveXml2(string module, string[] cmdparams)
  1051. {
  1052. if (cmdparams.Length > 2)
  1053. {
  1054. m_sceneManager.SaveCurrentSceneToXml2(cmdparams[2]);
  1055. }
  1056. else
  1057. {
  1058. m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
  1059. }
  1060. }
  1061. /// <summary>
  1062. /// Load region data from Xml2Format
  1063. /// </summary>
  1064. /// <param name="module"></param>
  1065. /// <param name="cmdparams"></param>
  1066. protected void LoadXml2(string module, string[] cmdparams)
  1067. {
  1068. if (cmdparams.Length > 2)
  1069. {
  1070. try
  1071. {
  1072. m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[2]);
  1073. }
  1074. catch (FileNotFoundException)
  1075. {
  1076. m_log.Error("Specified xml not found. Usage: load xml2 <filename>");
  1077. }
  1078. }
  1079. else
  1080. {
  1081. try
  1082. {
  1083. m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
  1084. }
  1085. catch (FileNotFoundException)
  1086. {
  1087. m_log.Error("Default xml not found. Usage: load xml2 <filename>");
  1088. }
  1089. }
  1090. }
  1091. /// <summary>
  1092. /// Load a whole region from an opensimulator archive.
  1093. /// </summary>
  1094. /// <param name="cmdparams"></param>
  1095. protected void LoadOar(string module, string[] cmdparams)
  1096. {
  1097. try
  1098. {
  1099. m_sceneManager.LoadArchiveToCurrentScene(cmdparams);
  1100. }
  1101. catch (Exception e)
  1102. {
  1103. m_log.Error(e.Message);
  1104. }
  1105. }
  1106. /// <summary>
  1107. /// Save a region to a file, including all the assets needed to restore it.
  1108. /// </summary>
  1109. /// <param name="cmdparams"></param>
  1110. protected void SaveOar(string module, string[] cmdparams)
  1111. {
  1112. m_sceneManager.SaveCurrentSceneToArchive(cmdparams);
  1113. }
  1114. private static string CombineParams(string[] commandParams, int pos)
  1115. {
  1116. string result = String.Empty;
  1117. for (int i = pos; i < commandParams.Length; i++)
  1118. {
  1119. result += commandParams[i] + " ";
  1120. }
  1121. result = result.TrimEnd(' ');
  1122. return result;
  1123. }
  1124. /// <summary>
  1125. /// Kill an object given its UUID.
  1126. /// </summary>
  1127. /// <param name="cmdparams"></param>
  1128. protected void KillUUID(string module, string[] cmdparams)
  1129. {
  1130. if (cmdparams.Length > 2)
  1131. {
  1132. UUID id = UUID.Zero;
  1133. SceneObjectGroup grp = null;
  1134. Scene sc = null;
  1135. if (!UUID.TryParse(cmdparams[2], out id))
  1136. {
  1137. MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!");
  1138. return;
  1139. }
  1140. m_sceneManager.ForEachScene(
  1141. delegate(Scene scene)
  1142. {
  1143. SceneObjectPart part = scene.GetSceneObjectPart(id);
  1144. if (part == null)
  1145. return;
  1146. grp = part.ParentGroup;
  1147. sc = scene;
  1148. });
  1149. if (grp == null)
  1150. {
  1151. MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id));
  1152. }
  1153. else
  1154. {
  1155. MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName));
  1156. try
  1157. {
  1158. sc.DeleteSceneObject(grp, false);
  1159. }
  1160. catch (Exception e)
  1161. {
  1162. m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e);
  1163. }
  1164. }
  1165. }
  1166. else
  1167. {
  1168. MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid <UUID>");
  1169. }
  1170. }
  1171. #endregion
  1172. }
  1173. }