30 using System.Collections.Generic;
32 using System.Reflection;
34 using OpenSim.Framework;
36 namespace OpenSim.ApplicationPlugins.LoadRegions
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 private IConfigSource m_configSource;
46 m_configSource = configSource;
51 string regionConfigPath = Path.Combine(Util.configDir(),
"Regions");
52 bool allowRegionless =
false;
56 IConfig startupConfig = (IConfig)m_configSource.Configs[
"Startup"];
57 regionConfigPath = startupConfig.GetString(
"regionload_regionsdir", regionConfigPath).Trim();
58 allowRegionless = startupConfig.GetBoolean(
"allow_regionless",
false);
65 if (!Directory.Exists(regionConfigPath))
67 Directory.CreateDirectory(regionConfigPath);
70 string[] configFiles = Directory.GetFiles(regionConfigPath,
"*.xml");
71 string[] iniFiles = Directory.GetFiles(regionConfigPath,
"*.ini");
74 if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0)
76 new RegionInfo(
"DEFAULT REGION CONFIG", Path.Combine(regionConfigPath,
"Regions.ini"),
false, m_configSource);
77 iniFiles = Directory.GetFiles(regionConfigPath,
"*.ini");
80 m_log.InfoFormat(
"[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath);
82 List<RegionInfo> regionInfos =
new List<RegionInfo>();
85 foreach (
string file
in iniFiles)
87 m_log.InfoFormat(
"[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
89 IConfigSource source =
new IniConfigSource(file);
91 foreach (IConfig config
in source.Configs)
93 RegionInfo regionInfo =
new RegionInfo(
"REGION CONFIG #" + (i + 1), file,
false, m_configSource, config.Name);
94 regionInfos.Add(regionInfo);
96 m_log.InfoFormat(
"[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
102 foreach (
string file
in configFiles)
104 m_log.InfoFormat(
"[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
106 RegionInfo regionInfo =
new RegionInfo(
"REGION CONFIG #" + (i + 1), file,
false, m_configSource);
107 regionInfos.Add(regionInfo);
109 m_log.InfoFormat(
"[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
114 return regionInfos.ToArray();
void SetIniConfigSource(IConfigSource configSource)
RegionInfo[] LoadRegions()
OpenSim.Framework.RegionInfo RegionInfo