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.prebuild-update
parent
c41ff51bd3
commit
7aad5af498
|
@ -393,7 +393,7 @@ namespace OpenSim.Framework
|
||||||
if (!File.Exists(filename)) // New region config request
|
if (!File.Exists(filename)) // New region config request
|
||||||
{
|
{
|
||||||
IniConfigSource newFile = new IniConfigSource();
|
IniConfigSource newFile = new IniConfigSource();
|
||||||
ReadNiniConfig(newFile, String.Empty);
|
ReadNiniConfig(newFile, configName);
|
||||||
|
|
||||||
newFile.Save(filename);
|
newFile.Save(filename);
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,13 @@ namespace OpenSim
|
||||||
"Persist objects to the database now", RunCommand);
|
"Persist objects to the database now", RunCommand);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "create region",
|
m_console.Commands.AddCommand("region", false, "create region",
|
||||||
"create region",
|
"create region [\"region name\"] <region_file.ini>",
|
||||||
"Create a new region", HandleCreateRegion);
|
"Create a new region.",
|
||||||
|
"The settings for \"region name\" are read from <region_file.ini>."
|
||||||
|
+ " If \"region name\" does not exist in <region_file.ini>, it will be added." + Environment.NewLine
|
||||||
|
+ "Without \"region name\", the first region found in <region_file.ini> will be created." + Environment.NewLine
|
||||||
|
+ "If <region_file.ini> does not exist, it will be created.",
|
||||||
|
HandleCreateRegion);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "restart",
|
m_console.Commands.AddCommand("region", false, "restart",
|
||||||
"restart",
|
"restart",
|
||||||
|
@ -513,47 +518,47 @@ namespace OpenSim
|
||||||
/// Creates a new region based on the parameters specified. This will ask the user questions on the console
|
/// Creates a new region based on the parameters specified. This will ask the user questions on the console
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="module"></param>
|
/// <param name="module"></param>
|
||||||
/// <param name="cmd">0,1,region name, region XML file</param>
|
/// <param name="cmd">0,1,region name, region ini or XML file</param>
|
||||||
private void HandleCreateRegion(string module, string[] cmd)
|
private void HandleCreateRegion(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
if (cmd.Length < 4)
|
string regionName = string.Empty;
|
||||||
|
string regionFile = string.Empty;
|
||||||
|
if (cmd.Length == 3)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>");
|
regionFile = cmd[2];
|
||||||
|
}
|
||||||
|
else if (cmd.Length > 3)
|
||||||
|
{
|
||||||
|
regionName = cmd[2];
|
||||||
|
regionFile = cmd[3];
|
||||||
|
}
|
||||||
|
string extension = Path.GetExtension(regionFile).ToLower();
|
||||||
|
bool isXml = extension.Equals(".xml");
|
||||||
|
bool isIni = extension.Equals(".ini");
|
||||||
|
if (!isXml && !isIni)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Usage: create region [\"region name\"] <region_file.ini>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmd[3].EndsWith(".xml"))
|
if (!Path.IsPathRooted(regionFile))
|
||||||
{
|
{
|
||||||
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
|
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
|
||||||
string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
|
regionFile = Path.Combine(regionsDir, regionFile);
|
||||||
// Allow absolute and relative specifiers
|
|
||||||
if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
|
|
||||||
regionFile = cmd[3];
|
|
||||||
|
|
||||||
IScene scene;
|
|
||||||
RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source);
|
|
||||||
PopulateRegionEstateInfo(regInfo);
|
|
||||||
CreateRegion(regInfo, true, out scene);
|
|
||||||
regInfo.EstateSettings.Save();
|
|
||||||
}
|
}
|
||||||
else if (cmd[3].EndsWith(".ini"))
|
|
||||||
{
|
|
||||||
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
|
|
||||||
string regionFile = String.Format("{0}/{1}", regionsDir, cmd[3]);
|
|
||||||
// Allow absolute and relative specifiers
|
|
||||||
if (cmd[3].StartsWith("/") || cmd[3].StartsWith("\\") || cmd[3].StartsWith(".."))
|
|
||||||
regionFile = cmd[3];
|
|
||||||
|
|
||||||
IScene scene;
|
RegionInfo regInfo;
|
||||||
RegionInfo regInfo = new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]);
|
if (isXml)
|
||||||
PopulateRegionEstateInfo(regInfo);
|
{
|
||||||
CreateRegion(regInfo, true, out scene);
|
regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source);
|
||||||
regInfo.EstateSettings.Save();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output("Usage: create region <region name> <region_file.ini>");
|
regInfo = new RegionInfo(regionName, regionFile, false, ConfigSource.Source, regionName);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
IScene scene;
|
||||||
|
PopulateRegionEstateInfo(regInfo);
|
||||||
|
CreateRegion(regInfo, true, out scene);
|
||||||
|
regInfo.EstateSettings.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue