OpenSim.cs 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349
  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. m_log.InfoFormat("[NETWORK]: Using {0} as SYSTEMIP", Util.GetLocalHost().ToString());
  168. // For now, start at the 'root' level by default
  169. if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it
  170. ChangeSelectedRegion("region",
  171. new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName});
  172. else
  173. ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
  174. }
  175. /// <summary>
  176. /// Register standard set of region console commands
  177. /// </summary>
  178. private void RegisterConsoleCommands()
  179. {
  180. m_console.Commands.AddCommand("region", false, "clear assets",
  181. "clear assets",
  182. "Clear the asset cache", HandleClearAssets);
  183. m_console.Commands.AddCommand("region", false, "force update",
  184. "force update",
  185. "Force the update of all objects on clients",
  186. HandleForceUpdate);
  187. m_console.Commands.AddCommand("region", false, "debug packet",
  188. "debug packet <level>",
  189. "Turn on packet debugging", Debug);
  190. m_console.Commands.AddCommand("region", false, "debug scene",
  191. "debug scene <cripting> <collisions> <physics>",
  192. "Turn on scene debugging", Debug);
  193. m_console.Commands.AddCommand("region", false, "change region",
  194. "change region <region name>",
  195. "Change current console region", ChangeSelectedRegion);
  196. m_console.Commands.AddCommand("region", false, "save xml",
  197. "save xml",
  198. "Save a region's data in XML format", SaveXml);
  199. m_console.Commands.AddCommand("region", false, "save xml2",
  200. "save xml2",
  201. "Save a region's data in XML2 format", SaveXml2);
  202. m_console.Commands.AddCommand("region", false, "load xml",
  203. "load xml [-newIDs [<x> <y> <z>]]",
  204. "Load a region's data from XML format", LoadXml);
  205. m_console.Commands.AddCommand("region", false, "load xml2",
  206. "load xml2",
  207. "Load a region's data from XML2 format", LoadXml2);
  208. m_console.Commands.AddCommand("region", false, "save prims xml2",
  209. "save prims xml2 [<prim name> <file name>]",
  210. "Save named prim to XML2", SavePrimsXml2);
  211. m_console.Commands.AddCommand("region", false, "load oar",
  212. "load oar [--merge] <oar name>",
  213. "Load a region's data from OAR archive", LoadOar);
  214. m_console.Commands.AddCommand("region", false, "save oar",
  215. "save oar <oar name>",
  216. "Save a region's data to an OAR archive",
  217. "More information on forthcoming options here soon", SaveOar);
  218. m_console.Commands.AddCommand("region", false, "edit scale",
  219. "edit scale <name> <x> <y> <z>",
  220. "Change the scale of a named prim", HandleEditScale);
  221. m_console.Commands.AddCommand("region", false, "kick user",
  222. "kick user <first> <last> [message]",
  223. "Kick a user off the simulator", KickUserCommand);
  224. m_console.Commands.AddCommand("region", false, "show assets",
  225. "show assets",
  226. "Show asset data", HandleShow);
  227. m_console.Commands.AddCommand("region", false, "show users",
  228. "show users [full]",
  229. "Show user data", HandleShow);
  230. m_console.Commands.AddCommand("region", false, "show connections",
  231. "show connections",
  232. "Show connection data", HandleShow);
  233. m_console.Commands.AddCommand("region", false, "show users full",
  234. "show users full",
  235. String.Empty, HandleShow);
  236. m_console.Commands.AddCommand("region", false, "show modules",
  237. "show modules",
  238. "Show module data", HandleShow);
  239. m_console.Commands.AddCommand("region", false, "show regions",
  240. "show regions",
  241. "Show region data", HandleShow);
  242. m_console.Commands.AddCommand("region", false, "show queues",
  243. "show queues",
  244. "Show queue data", HandleShow);
  245. m_console.Commands.AddCommand("region", false, "show ratings",
  246. "show ratings",
  247. "Show rating data", HandleShow);
  248. m_console.Commands.AddCommand("region", false, "backup",
  249. "backup",
  250. "Persist objects to the database now", RunCommand);
  251. m_console.Commands.AddCommand("region", false, "create region",
  252. "create region",
  253. "Create a new region", HandleCreateRegion);
  254. m_console.Commands.AddCommand("region", false, "restart",
  255. "restart",
  256. "Restart all sims in this instance", RunCommand);
  257. m_console.Commands.AddCommand("region", false, "config set",
  258. "config set <section> <field> <value>",
  259. "Set a config option", HandleConfig);
  260. m_console.Commands.AddCommand("region", false, "config get",
  261. "config get <section> <field>",
  262. "Read a config option", HandleConfig);
  263. m_console.Commands.AddCommand("region", false, "config save",
  264. "config save",
  265. "Save current configuration", HandleConfig);
  266. m_console.Commands.AddCommand("region", false, "command-script",
  267. "command-script <script>",
  268. "Run a command script from file", RunCommand);
  269. m_console.Commands.AddCommand("region", false, "remove-region",
  270. "remove-region <name>",
  271. "Remove a region from this simulator", RunCommand);
  272. m_console.Commands.AddCommand("region", false, "delete-region",
  273. "delete-region <name>",
  274. "Delete a region from disk", RunCommand);
  275. m_console.Commands.AddCommand("region", false, "modules list",
  276. "modules list",
  277. "List modules", HandleModules);
  278. m_console.Commands.AddCommand("region", false, "modules load",
  279. "modules load <name>",
  280. "Load a module", HandleModules);
  281. m_console.Commands.AddCommand("region", false, "modules unload",
  282. "modules unload <name>",
  283. "Unload a module", HandleModules);
  284. m_console.Commands.AddCommand("region", false, "Add-InventoryHost",
  285. "Add-InventoryHost <host>",
  286. String.Empty, RunCommand);
  287. m_console.Commands.AddCommand("region", false, "kill uuid",
  288. "kill uuid <UUID>",
  289. "Kill an object by UUID", KillUUID);
  290. if (ConfigurationSettings.Standalone)
  291. {
  292. m_console.Commands.AddCommand("region", false, "create user",
  293. "create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
  294. "Create a new user", HandleCreateUser);
  295. m_console.Commands.AddCommand("region", false, "reset user password",
  296. "reset user password [<first> [<last> [<password>]]]",
  297. "Reset a user password", HandleResetUserPassword);
  298. }
  299. m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
  300. "Set local coordinate to map HG regions to", RunCommand);
  301. m_console.Commands.AddCommand("hypergrid", false, "link-region",
  302. "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
  303. "Link a hypergrid region", RunCommand);
  304. m_console.Commands.AddCommand("hypergrid", false, "unlink-region",
  305. "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
  306. "Unlink a hypergrid region", RunCommand);
  307. }
  308. public override void ShutdownSpecific()
  309. {
  310. if (m_shutdownCommandsFile != String.Empty)
  311. {
  312. RunCommandScript(m_shutdownCommandsFile);
  313. }
  314. base.ShutdownSpecific();
  315. }
  316. /// <summary>
  317. /// Timer to run a specific text file as console commands. Configured in in the main ini file
  318. /// </summary>
  319. /// <param name="sender"></param>
  320. /// <param name="e"></param>
  321. private void RunAutoTimerScript(object sender, EventArgs e)
  322. {
  323. if (m_timedScript != "disabled")
  324. {
  325. RunCommandScript(m_timedScript);
  326. }
  327. }
  328. private void WatchdogTimeoutHandler(System.Threading.Thread thread, int lastTick)
  329. {
  330. int now = Environment.TickCount & Int32.MaxValue;
  331. m_log.ErrorFormat("[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago",
  332. thread.Name, thread.ThreadState, now - lastTick);
  333. }
  334. #region Console Commands
  335. /// <summary>
  336. /// Kicks users off the region
  337. /// </summary>
  338. /// <param name="module"></param>
  339. /// <param name="cmdparams">name of avatar to kick</param>
  340. private void KickUserCommand(string module, string[] cmdparams)
  341. {
  342. if (cmdparams.Length < 4)
  343. return;
  344. string alert = null;
  345. if (cmdparams.Length > 4)
  346. alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
  347. IList agents = m_sceneManager.GetCurrentSceneAvatars();
  348. foreach (ScenePresence presence in agents)
  349. {
  350. RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
  351. if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) &&
  352. presence.Lastname.ToLower().Contains(cmdparams[3].ToLower()))
  353. {
  354. MainConsole.Instance.Output(
  355. String.Format(
  356. "Kicking user: {0,-16}{1,-16}{2,-37} in region: {3,-16}",
  357. presence.Firstname, presence.Lastname, presence.UUID, regionInfo.RegionName));
  358. // kick client...
  359. if (alert != null)
  360. presence.ControllingClient.Kick(alert);
  361. else
  362. presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n");
  363. // ...and close on our side
  364. presence.Scene.IncomingCloseAgent(presence.UUID);
  365. }
  366. }
  367. MainConsole.Instance.Output("");
  368. }
  369. /// <summary>
  370. /// Run an optional startup list of commands
  371. /// </summary>
  372. /// <param name="fileName"></param>
  373. private void RunCommandScript(string fileName)
  374. {
  375. if (File.Exists(fileName))
  376. {
  377. m_log.Info("[COMMANDFILE]: Running " + fileName);
  378. using (StreamReader readFile = File.OpenText(fileName))
  379. {
  380. string currentCommand;
  381. while ((currentCommand = readFile.ReadLine()) != null)
  382. {
  383. if (currentCommand != String.Empty)
  384. {
  385. m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
  386. m_console.RunCommand(currentCommand);
  387. }
  388. }
  389. }
  390. }
  391. }
  392. /// <summary>
  393. /// Opens a file and uses it as input to the console command parser.
  394. /// </summary>
  395. /// <param name="fileName">name of file to use as input to the console</param>
  396. private static void PrintFileToConsole(string fileName)
  397. {
  398. if (File.Exists(fileName))
  399. {
  400. StreamReader readFile = File.OpenText(fileName);
  401. string currentLine;
  402. while ((currentLine = readFile.ReadLine()) != null)
  403. {
  404. m_log.Info("[!]" + currentLine);
  405. }
  406. }
  407. }
  408. private void HandleClearAssets(string module, string[] args)
  409. {
  410. MainConsole.Instance.Output("Not implemented.");
  411. }
  412. /// <summary>
  413. /// Force resending of all updates to all clients in active region(s)
  414. /// </summary>
  415. /// <param name="module"></param>
  416. /// <param name="args"></param>
  417. private void HandleForceUpdate(string module, string[] args)
  418. {
  419. MainConsole.Instance.Output("Updating all clients");
  420. m_sceneManager.ForceCurrentSceneClientUpdate();
  421. }
  422. /// <summary>
  423. /// Edits the scale of a primative with the name specified
  424. /// </summary>
  425. /// <param name="module"></param>
  426. /// <param name="args">0,1, name, x, y, z</param>
  427. private void HandleEditScale(string module, string[] args)
  428. {
  429. if (args.Length == 6)
  430. {
  431. m_sceneManager.HandleEditCommandOnCurrentScene(args);
  432. }
  433. else
  434. {
  435. MainConsole.Instance.Output("Argument error: edit scale <prim name> <x> <y> <z>");
  436. }
  437. }
  438. /// <summary>
  439. /// Creates a new region based on the parameters specified. This will ask the user questions on the console
  440. /// </summary>
  441. /// <param name="module"></param>
  442. /// <param name="cmd">0,1,region name, region XML file</param>
  443. private void HandleCreateRegion(string module, string[] cmd)
  444. {
  445. if (cmd.Length < 4)
  446. {
  447. MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>");
  448. return;
  449. }
  450. if (cmd[3].EndsWith(".xml"))
  451. {
  452. string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
  453. string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
  454. // Allow absolute and relative specifiers
  455. if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
  456. regionFile = cmd[3];
  457. IScene scene;
  458. CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene);
  459. }
  460. else if (cmd[3].EndsWith(".ini"))
  461. {
  462. string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
  463. string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
  464. // Allow absolute and relative specifiers
  465. if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
  466. regionFile = cmd[3];
  467. IScene scene;
  468. CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]), true, out scene);
  469. }
  470. else
  471. {
  472. MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>");
  473. return;
  474. }
  475. }
  476. /// <summary>
  477. /// Change and load configuration file data.
  478. /// </summary>
  479. /// <param name="module"></param>
  480. /// <param name="cmd"></param>
  481. private void HandleConfig(string module, string[] cmd)
  482. {
  483. List<string> args = new List<string>(cmd);
  484. args.RemoveAt(0);
  485. string[] cmdparams = args.ToArray();
  486. string n = "CONFIG";
  487. if (cmdparams.Length > 0)
  488. {
  489. switch (cmdparams[0].ToLower())
  490. {
  491. case "set":
  492. if (cmdparams.Length < 4)
  493. {
  494. MainConsole.Instance.Output(String.Format("SYNTAX: {0} SET SECTION KEY VALUE",n));
  495. MainConsole.Instance.Output(String.Format("EXAMPLE: {0} SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5",n));
  496. }
  497. else
  498. {
  499. IConfig c;
  500. IConfigSource source = new IniConfigSource();
  501. c = source.AddConfig(cmdparams[1]);
  502. if (c != null)
  503. {
  504. string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
  505. c.Set(cmdparams[2], _value);
  506. m_config.Source.Merge(source);
  507. MainConsole.Instance.Output(String.Format("{0} {0} {1} {2} {3}",n,cmdparams[1],cmdparams[2],_value));
  508. }
  509. }
  510. break;
  511. case "get":
  512. if (cmdparams.Length < 3)
  513. {
  514. MainConsole.Instance.Output(String.Format("SYNTAX: {0} GET SECTION KEY",n));
  515. MainConsole.Instance.Output(String.Format("EXAMPLE: {0} GET ScriptEngine.DotNetEngine NumberOfScriptThreads",n));
  516. }
  517. else
  518. {
  519. IConfig c = m_config.Source.Configs[cmdparams[1]];
  520. if (c == null)
  521. {
  522. MainConsole.Instance.Output(String.Format("Section \"{0}\" does not exist.",cmdparams[1]));
  523. break;
  524. }
  525. else
  526. {
  527. MainConsole.Instance.Output(String.Format("{0} GET {1} {2} : {3}",n,cmdparams[1],cmdparams[2],
  528. c.GetString(cmdparams[2])));
  529. }
  530. }
  531. break;
  532. case "save":
  533. if (cmdparams.Length < 2)
  534. {
  535. MainConsole.Instance.Output("SYNTAX: " + n + " SAVE FILE");
  536. return;
  537. }
  538. if (Application.iniFilePath == cmdparams[1])
  539. {
  540. MainConsole.Instance.Output("FILE can not be " + Application.iniFilePath);
  541. return;
  542. }
  543. MainConsole.Instance.Output("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. MainConsole.Instance.Output(String.Format("Shared region module: {0}", 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. MainConsole.Instance.Output(String.Format("Unloading module: {0}", 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. MainConsole.Instance.Output(String.Format("Loading module: {0}", 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. MainConsole.Instance.Output("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. MainConsole.Instance.Output("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. MainConsole.Instance.Output("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. MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName));
  657. }
  658. else
  659. {
  660. MainConsole.Instance.Output("Usage: change region <region name>");
  661. }
  662. string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName);
  663. MainConsole.Instance.Output(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. MainConsole.Instance.Output("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. MainConsole.Instance.Output("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. MainConsole.Instance.Output("packet debug should be 0..255");
  718. }
  719. MainConsole.Instance.Output(String.Format("New packet debug: {0}", newDebug));
  720. }
  721. break;
  722. case "scene":
  723. if (args.Length == 5)
  724. {
  725. if (m_sceneManager.CurrentScene == null)
  726. {
  727. MainConsole.Instance.Output("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. MainConsole.Instance.Output(
  736. String.Format(
  737. "Set debug scene scripting = {0}, collisions = {1}, physics = {2}",
  738. !scriptingOn, !collisionsOn, !physicsOn));
  739. }
  740. }
  741. else
  742. {
  743. MainConsole.Instance.Output("debug scene <scripting> <collisions> <physics> (where inside <> is true/false)");
  744. }
  745. break;
  746. default:
  747. MainConsole.Instance.Output("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. MainConsole.Instance.Output("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. MainConsole.Instance.Output(String.Format("\nAgents connected: {0}\n", agents.Count));
  779. MainConsole.Instance.Output(
  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. MainConsole.Instance.Output(
  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. MainConsole.Instance.Output(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. MainConsole.Instance.Output(connections.ToString());
  821. break;
  822. case "modules":
  823. MainConsole.Instance.Output("The currently loaded shared modules are:");
  824. foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
  825. {
  826. MainConsole.Instance.Output("Shared Module: " + module.Name);
  827. }
  828. MainConsole.Instance.Output("");
  829. break;
  830. case "regions":
  831. m_sceneManager.ForEachScene(
  832. delegate(Scene scene)
  833. {
  834. MainConsole.Instance.Output(String.Format(
  835. "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}",
  836. scene.RegionInfo.RegionName,
  837. scene.RegionInfo.RegionLocX,
  838. scene.RegionInfo.RegionLocY,
  839. scene.RegionInfo.InternalEndPoint.Port));
  840. });
  841. break;
  842. case "queues":
  843. Notice(GetQueuesReport());
  844. break;
  845. case "ratings":
  846. m_sceneManager.ForEachScene(
  847. delegate(Scene scene)
  848. {
  849. string rating = "";
  850. if (scene.RegionInfo.RegionSettings.Maturity == 1)
  851. {
  852. rating = "MATURE";
  853. }
  854. else if (scene.RegionInfo.RegionSettings.Maturity == 2)
  855. {
  856. rating = "ADULT";
  857. }
  858. else
  859. {
  860. rating = "PG";
  861. }
  862. MainConsole.Instance.Output(String.Format(
  863. "Region Name: {0}, Region Rating {1}",
  864. scene.RegionInfo.RegionName,
  865. rating));
  866. });
  867. break;
  868. }
  869. }
  870. /// <summary>
  871. /// print UDP Queue data for each client
  872. /// </summary>
  873. /// <returns></returns>
  874. private string GetQueuesReport()
  875. {
  876. string report = String.Empty;
  877. m_sceneManager.ForEachScene(delegate(Scene scene)
  878. {
  879. scene.ForEachClient(delegate(IClientAPI client)
  880. {
  881. if (client is IStatsCollector)
  882. {
  883. report = report + client.FirstName +
  884. " " + client.LastName;
  885. IStatsCollector stats =
  886. (IStatsCollector) client;
  887. 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",
  888. "Send",
  889. "In",
  890. "Out",
  891. "Resend",
  892. "Land",
  893. "Wind",
  894. "Cloud",
  895. "Task",
  896. "Texture",
  897. "Asset");
  898. report = report + stats.Report() +
  899. "\n";
  900. }
  901. });
  902. });
  903. return report;
  904. }
  905. /// <summary>
  906. /// Create a new user
  907. /// </summary>
  908. /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
  909. protected void CreateUser(string[] cmdparams)
  910. {
  911. string firstName;
  912. string lastName;
  913. string password;
  914. string email;
  915. uint regX = 1000;
  916. uint regY = 1000;
  917. IConfig standalone;
  918. if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
  919. {
  920. regX = (uint)standalone.GetInt("default_location_x", (int)regX);
  921. regY = (uint)standalone.GetInt("default_location_y", (int)regY);
  922. }
  923. if (cmdparams.Length < 3)
  924. firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
  925. else firstName = cmdparams[2];
  926. if (cmdparams.Length < 4)
  927. lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
  928. else lastName = cmdparams[3];
  929. if (cmdparams.Length < 5)
  930. password = MainConsole.Instance.PasswdPrompt("Password");
  931. else password = cmdparams[4];
  932. if (cmdparams.Length < 6)
  933. regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
  934. else regX = Convert.ToUInt32(cmdparams[5]);
  935. if (cmdparams.Length < 7)
  936. regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
  937. else regY = Convert.ToUInt32(cmdparams[6]);
  938. if (cmdparams.Length < 8)
  939. email = MainConsole.Instance.CmdPrompt("Email", "");
  940. else email = cmdparams[7];
  941. if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
  942. {
  943. m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
  944. }
  945. else
  946. {
  947. MainConsole.Instance.Output(string.Format("A user with the name {0} {1} already exists!", firstName, lastName));
  948. }
  949. }
  950. /// <summary>
  951. /// Reset a user password.
  952. /// </summary>
  953. /// <param name="cmdparams"></param>
  954. private void ResetUserPassword(string[] cmdparams)
  955. {
  956. string firstName;
  957. string lastName;
  958. string newPassword;
  959. if (cmdparams.Length < 4)
  960. firstName = MainConsole.Instance.CmdPrompt("First name");
  961. else firstName = cmdparams[3];
  962. if (cmdparams.Length < 5)
  963. lastName = MainConsole.Instance.CmdPrompt("Last name");
  964. else lastName = cmdparams[4];
  965. if (cmdparams.Length < 6)
  966. newPassword = MainConsole.Instance.PasswdPrompt("New password");
  967. else newPassword = cmdparams[5];
  968. m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
  969. }
  970. /// <summary>
  971. /// Use XML2 format to serialize data to a file
  972. /// </summary>
  973. /// <param name="module"></param>
  974. /// <param name="cmdparams"></param>
  975. protected void SavePrimsXml2(string module, string[] cmdparams)
  976. {
  977. if (cmdparams.Length > 5)
  978. {
  979. m_sceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]);
  980. }
  981. else
  982. {
  983. m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
  984. }
  985. }
  986. /// <summary>
  987. /// Use XML format to serialize data to a file
  988. /// </summary>
  989. /// <param name="module"></param>
  990. /// <param name="cmdparams"></param>
  991. protected void SaveXml(string module, string[] cmdparams)
  992. {
  993. MainConsole.Instance.Output("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.");
  994. if (cmdparams.Length > 0)
  995. {
  996. m_sceneManager.SaveCurrentSceneToXml(cmdparams[2]);
  997. }
  998. else
  999. {
  1000. m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
  1001. }
  1002. }
  1003. /// <summary>
  1004. /// Loads data and region objects from XML format.
  1005. /// </summary>
  1006. /// <param name="module"></param>
  1007. /// <param name="cmdparams"></param>
  1008. protected void LoadXml(string module, string[] cmdparams)
  1009. {
  1010. MainConsole.Instance.Output("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.");
  1011. Vector3 loadOffset = new Vector3(0, 0, 0);
  1012. if (cmdparams.Length > 2)
  1013. {
  1014. bool generateNewIDS = false;
  1015. if (cmdparams.Length > 3)
  1016. {
  1017. if (cmdparams[3] == "-newUID")
  1018. {
  1019. generateNewIDS = true;
  1020. }
  1021. if (cmdparams.Length > 4)
  1022. {
  1023. loadOffset.X = (float)Convert.ToDecimal(cmdparams[4], Culture.NumberFormatInfo);
  1024. if (cmdparams.Length > 5)
  1025. {
  1026. loadOffset.Y = (float)Convert.ToDecimal(cmdparams[5], Culture.NumberFormatInfo);
  1027. }
  1028. if (cmdparams.Length > 6)
  1029. {
  1030. loadOffset.Z = (float)Convert.ToDecimal(cmdparams[6], Culture.NumberFormatInfo);
  1031. }
  1032. MainConsole.Instance.Output(String.Format("loadOffsets <X,Y,Z> = <{0},{1},{2}>",loadOffset.X,loadOffset.Y,loadOffset.Z));
  1033. }
  1034. }
  1035. m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset);
  1036. }
  1037. else
  1038. {
  1039. try
  1040. {
  1041. m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
  1042. }
  1043. catch (FileNotFoundException)
  1044. {
  1045. MainConsole.Instance.Output("Default xml not found. Usage: load-xml <filename>");
  1046. }
  1047. }
  1048. }
  1049. /// <summary>
  1050. /// Serialize region data to XML2Format
  1051. /// </summary>
  1052. /// <param name="module"></param>
  1053. /// <param name="cmdparams"></param>
  1054. protected void SaveXml2(string module, string[] cmdparams)
  1055. {
  1056. if (cmdparams.Length > 2)
  1057. {
  1058. m_sceneManager.SaveCurrentSceneToXml2(cmdparams[2]);
  1059. }
  1060. else
  1061. {
  1062. m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
  1063. }
  1064. }
  1065. /// <summary>
  1066. /// Load region data from Xml2Format
  1067. /// </summary>
  1068. /// <param name="module"></param>
  1069. /// <param name="cmdparams"></param>
  1070. protected void LoadXml2(string module, string[] cmdparams)
  1071. {
  1072. if (cmdparams.Length > 2)
  1073. {
  1074. try
  1075. {
  1076. m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[2]);
  1077. }
  1078. catch (FileNotFoundException)
  1079. {
  1080. MainConsole.Instance.Output("Specified xml not found. Usage: load xml2 <filename>");
  1081. }
  1082. }
  1083. else
  1084. {
  1085. try
  1086. {
  1087. m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
  1088. }
  1089. catch (FileNotFoundException)
  1090. {
  1091. MainConsole.Instance.Output("Default xml not found. Usage: load xml2 <filename>");
  1092. }
  1093. }
  1094. }
  1095. /// <summary>
  1096. /// Load a whole region from an opensimulator archive.
  1097. /// </summary>
  1098. /// <param name="cmdparams"></param>
  1099. protected void LoadOar(string module, string[] cmdparams)
  1100. {
  1101. try
  1102. {
  1103. m_sceneManager.LoadArchiveToCurrentScene(cmdparams);
  1104. }
  1105. catch (Exception e)
  1106. {
  1107. MainConsole.Instance.Output(e.Message);
  1108. }
  1109. }
  1110. /// <summary>
  1111. /// Save a region to a file, including all the assets needed to restore it.
  1112. /// </summary>
  1113. /// <param name="cmdparams"></param>
  1114. protected void SaveOar(string module, string[] cmdparams)
  1115. {
  1116. m_sceneManager.SaveCurrentSceneToArchive(cmdparams);
  1117. }
  1118. private static string CombineParams(string[] commandParams, int pos)
  1119. {
  1120. string result = String.Empty;
  1121. for (int i = pos; i < commandParams.Length; i++)
  1122. {
  1123. result += commandParams[i] + " ";
  1124. }
  1125. result = result.TrimEnd(' ');
  1126. return result;
  1127. }
  1128. /// <summary>
  1129. /// Kill an object given its UUID.
  1130. /// </summary>
  1131. /// <param name="cmdparams"></param>
  1132. protected void KillUUID(string module, string[] cmdparams)
  1133. {
  1134. if (cmdparams.Length > 2)
  1135. {
  1136. UUID id = UUID.Zero;
  1137. SceneObjectGroup grp = null;
  1138. Scene sc = null;
  1139. if (!UUID.TryParse(cmdparams[2], out id))
  1140. {
  1141. MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!");
  1142. return;
  1143. }
  1144. m_sceneManager.ForEachScene(
  1145. delegate(Scene scene)
  1146. {
  1147. SceneObjectPart part = scene.GetSceneObjectPart(id);
  1148. if (part == null)
  1149. return;
  1150. grp = part.ParentGroup;
  1151. sc = scene;
  1152. });
  1153. if (grp == null)
  1154. {
  1155. MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id));
  1156. }
  1157. else
  1158. {
  1159. MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName));
  1160. try
  1161. {
  1162. sc.DeleteSceneObject(grp, false);
  1163. }
  1164. catch (Exception e)
  1165. {
  1166. m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e);
  1167. }
  1168. }
  1169. }
  1170. else
  1171. {
  1172. MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid <UUID>");
  1173. }
  1174. }
  1175. #endregion
  1176. }
  1177. }