From 8d7464d0de47f105d335e58183b4de658d580b34 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 8 Sep 2020 21:27:36 +1000 Subject: Don't read .ini region files, use .xml instead. Add [Region] .ini block. Coz OpenSim can get confused, and I have a better idea - For including actual region definition in the normal .ini stack. Same as the usual Region.ini format, except we add a RegionName parameter. --- .../LoadRegions/RegionLoaderFileSystem.cs | 23 +++++++++++++++++----- OpenSim/Framework/RegionInfo.cs | 21 ++++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs index 976714c..77a2c27 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderFileSystem.cs @@ -70,11 +70,11 @@ namespace OpenSim.ApplicationPlugins.LoadRegions string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); - // Create an empty Regions.ini if there are no existing config files. - if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0) + // Create an empty Regions.xml if there are no existing config files. + if (!allowRegionless && configFiles.Length == 0 /*&& iniFiles.Length == 0*/) { - new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); - iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); + new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.xml"), false, m_configSource); + configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); } m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath); @@ -82,6 +82,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions List regionInfos = new List(); int i = 0; + + IConfig regionConfig = (IConfig)m_configSource.Configs["Region"]; + string name = regionConfig.GetString("RegionName", string.Empty).Trim(); + if (string.Empty != name) + { + RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), string.Empty, false, m_configSource, name); + regionInfos.Add(regionInfo); + + m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName); + i++; + } + foreach (string file in iniFiles) { m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file); @@ -114,4 +126,5 @@ namespace OpenSim.ApplicationPlugins.LoadRegions return regionInfos.ToArray(); } } -} \ No newline at end of file +} + diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 5a3b814..b88d31f 100755 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -198,6 +198,11 @@ namespace OpenSim.Framework { // m_configSource = configSource; CacheID = UUID.Random(); + if (string.Empty == filename) + { + ReadNiniConfig(configSource, "Region", configName); + return; + } if (filename.ToLower().EndsWith(".ini")) { @@ -425,7 +430,7 @@ namespace OpenSim.Framework set { m_remotingPort = value; } } - + /// /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. /// @@ -514,6 +519,10 @@ namespace OpenSim.Framework private void ReadNiniConfig(IConfigSource source, string name) { + ReadNiniConfig(source, name, name); + } + private void ReadNiniConfig(IConfigSource source, string section, string name) + { bool creatingNew = false; if (source.Configs.Count == 0) @@ -549,8 +558,7 @@ namespace OpenSim.Framework source.AddConfig(name); } - RegionName = name; - IConfig config = source.Configs[name]; + IConfig config = source.Configs[section]; // Track all of the keys in this config and remove as they are processed // The remaining keys will be added to generic key-value storage for @@ -561,6 +569,11 @@ namespace OpenSim.Framework allKeys.Add(s); } + // RegionName + // + allKeys.Remove("RegionName"); + RegionName = config.GetString("RegionName", name); + // RegionUUID // allKeys.Remove("RegionUUID"); @@ -675,7 +688,7 @@ namespace OpenSim.Framework m_externalHostName = Util.GetLocalHost().ToString(); m_log.InfoFormat( "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}", - m_externalHostName, name); + m_externalHostName, RegionName); } else if (!m_resolveAddress) { -- cgit v1.1