1
0

OpenSim.cs 57 KB

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