aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMarck2010-08-14 12:46:17 +0200
committerJustin Clark-Casey (justincc)2010-08-20 19:35:52 +0100
commit7aad5af49850b3938282426dd1ecf160d7053032 (patch)
treed16c0b7080eaf22803cbdf1f30cc3b7f657b97ab /OpenSim/Region
parentOpenSim.ini.example FreeSwitch section improvements, move of XML-RPC section ... (diff)
downloadopensim-SC-7aad5af49850b3938282426dd1ecf160d7053032.zip
opensim-SC-7aad5af49850b3938282426dd1ecf160d7053032.tar.gz
opensim-SC-7aad5af49850b3938282426dd1ecf160d7053032.tar.bz2
opensim-SC-7aad5af49850b3938282426dd1ecf160d7053032.tar.xz
Some code cleanup for console command "create region".
Make region name an optional command parameter. Avoid question for region name if it has already been specified. Extend help text.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSim.cs65
1 files changed, 35 insertions, 30 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index d9ec287..6834606 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -308,8 +308,13 @@ namespace OpenSim
308 "Persist objects to the database now", RunCommand); 308 "Persist objects to the database now", RunCommand);
309 309
310 m_console.Commands.AddCommand("region", false, "create region", 310 m_console.Commands.AddCommand("region", false, "create region",
311 "create region", 311 "create region [\"region name\"] <region_file.ini>",
312 "Create a new region", HandleCreateRegion); 312 "Create a new region.",
313 "The settings for \"region name\" are read from <region_file.ini>."
314 + " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine
315 + "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine
316 + "If <region_file.ini> does not exist, it will be created.",
317 HandleCreateRegion);
313 318
314 m_console.Commands.AddCommand("region", false, "restart", 319 m_console.Commands.AddCommand("region", false, "restart",
315 "restart", 320 "restart",
@@ -513,47 +518,47 @@ namespace OpenSim
513 /// Creates a new region based on the parameters specified. This will ask the user questions on the console 518 /// Creates a new region based on the parameters specified. This will ask the user questions on the console
514 /// </summary> 519 /// </summary>
515 /// <param name="module"></param> 520 /// <param name="module"></param>
516 /// <param name="cmd">0,1,region name, region XML file</param> 521 /// <param name="cmd">0,1,region name, region ini or XML file</param>
517 private void HandleCreateRegion(string module, string[] cmd) 522 private void HandleCreateRegion(string module, string[] cmd)
518 { 523 {
519 if (cmd.Length < 4) 524 string regionName = string.Empty;
525 string regionFile = string.Empty;
526 if (cmd.Length == 3)
520 { 527 {
521 MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>"); 528 regionFile = cmd[2];
529 }
530 else if (cmd.Length > 3)
531 {
532 regionName = cmd[2];
533 regionFile = cmd[3];
534 }
535 string extension = Path.GetExtension(regionFile).ToLower();
536 bool isXml = extension.Equals(".xml");
537 bool isIni = extension.Equals(".ini");
538 if (!isXml && !isIni)
539 {
540 MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>");
522 return; 541 return;
523 } 542 }
524 if (cmd[3].EndsWith(".xml")) 543 if (!Path.IsPathRooted(regionFile))
525 { 544 {
526 string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); 545 string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
527 string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]); 546 regionFile = Path.Combine(regionsDir, regionFile);
528 // Allow absolute and relative specifiers
529 if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
530 regionFile = cmd[3];
531
532 IScene scene;
533 RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source);
534 PopulateRegionEstateInfo(regInfo);
535 CreateRegion(regInfo, true, out scene);
536 regInfo.EstateSettings.Save();
537 } 547 }
538 else if (cmd[3].EndsWith(".ini")) 548
549 RegionInfo regInfo;
550 if (isXml)
539 { 551 {
540 string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); 552 regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source);
541 string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
542 // Allow absolute and relative specifiers
543 if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
544 regionFile = cmd[3];
545
546 IScene scene;
547 RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]);
548 PopulateRegionEstateInfo(regInfo);
549 CreateRegion(regInfo, true, out scene);
550 regInfo.EstateSettings.Save();
551 } 553 }
552 else 554 else
553 { 555 {
554 MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>"); 556 regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
555 return;
556 } 557 }
558 IScene scene;
559 PopulateRegionEstateInfo(regInfo);
560 CreateRegion(regInfo, true, out scene);
561 regInfo.EstateSettings.Save();
557 } 562 }
558 563
559 /// <summary> 564 /// <summary>