Make create region save the new region to ini file format if the name

specifies an ini file.
If the ini file exists, the region will be added.
0.6.6-post-fixes
Melanie Thielker 2009-06-25 23:31:55 +00:00
parent 82305b0dea
commit 7cc69ac97f
2 changed files with 36 additions and 10 deletions

View File

@ -262,10 +262,17 @@ namespace OpenSim.Framework
return;
}
IConfigSource source = new IniConfigSource(filename);
IniConfigSource source = new IniConfigSource(filename);
bool saveFile = false;
if (source.Configs[configName] == null)
saveFile = true;
ReadNiniConfig(source, configName);
if (configName != String.Empty && saveFile)
source.Save(filename);
return;
}
@ -406,7 +413,8 @@ namespace OpenSim.Framework
if (source.Configs.Count == 0)
{
name = MainConsole.Instance.CmdPrompt("New region name", String.Empty);
if (name == String.Empty)
name = MainConsole.Instance.CmdPrompt("New region name", name);
if (name == String.Empty)
throw new Exception("Cannot interactively create region with no name");

View File

@ -443,20 +443,38 @@ namespace OpenSim
private void HandleCreateRegion(string module, string[] cmd)
{
if (cmd.Length < 4 || !cmd[3].EndsWith(".xml"))
if (cmd.Length < 4)
{
m_log.Error("Usage: create region <region name> <region_file.xml>");
return;
}
if (cmd[3].EndsWith(".xml"))
{
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];
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;
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene);
}
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;
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source), true, out scene);
IScene scene;
CreateRegion(new RegionInfo(cmd[2], regionFile, false, ConfigSource.Source, cmd[2]), true, out scene);
}
else
{
m_log.Error("Usage: create region <region name> <region_file.xml>");
return;
}
}
private void HandleLoginEnable(string module, string[] cmd)