From 7cc69ac97fb577807329ad71a8204985862c1757 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 25 Jun 2009 23:31:55 +0000 Subject: 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. --- OpenSim/Framework/RegionInfo.cs | 12 +++++++++-- OpenSim/Region/Application/OpenSim.cs | 38 ++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index eee078e..eb10fac 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 aef0b91..3babe72 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]; + + 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, cmd[2]), true, out scene); + } + else { m_log.Error("Usage: create region "); return; } - - 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); } private void HandleLoginEnable(string module, string[] cmd) -- cgit v1.1