diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index eee078e870..eb10facee1 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -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"); diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index aef0b91258..3babe72e23 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -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 "); 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 "); + return; + } } private void HandleLoginEnable(string module, string[] cmd)