mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Move map related settings from [Startup] to a new [Map] section in OpenSim.ini
Existing map settings in [Startup] will continue to work, and if present will override anything in [Map] However, the proper place for such settings would now be [Map] This is to reduce the use of [Startup] as a bag for non-generic settings which should really go in sections, in common with other settings. This commit also extends Diva's previous work to allow a default setting to be given when looking at multiple sections for settings.
This commit is contained in:
@@ -917,7 +917,25 @@ namespace OpenSim.Framework
|
||||
/// <returns></returns>
|
||||
public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections)
|
||||
{
|
||||
object val = default(T);
|
||||
return GetConfigVarFromSections<T>(config, varname, sections, default(T));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of a configuration variable by looking into
|
||||
/// multiple sections in order. The latter sections overwrite
|
||||
/// any values previously found.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If no value is found then the given default value is returned
|
||||
/// </remarks>
|
||||
/// <typeparam name="T">Type of the variable</typeparam>
|
||||
/// <param name="config">The configuration object</param>
|
||||
/// <param name="varname">The configuration variable</param>
|
||||
/// <param name="sections">Ordered sequence of sections to look at</param>
|
||||
/// <param name="val">Default value</param>
|
||||
/// <returns></returns>
|
||||
public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val)
|
||||
{
|
||||
foreach (string section in sections)
|
||||
{
|
||||
IConfig cnf = config.Configs[section];
|
||||
@@ -925,11 +943,7 @@ namespace OpenSim.Framework
|
||||
continue;
|
||||
|
||||
if (typeof(T) == typeof(String))
|
||||
{
|
||||
if (val == null) // no null strings, please
|
||||
val = string.Empty;
|
||||
val = cnf.GetString(varname, (string)val);
|
||||
}
|
||||
else if (typeof(T) == typeof(Boolean))
|
||||
val = cnf.GetBoolean(varname, (bool)val);
|
||||
else if (typeof(T) == typeof(Int32))
|
||||
@@ -937,8 +951,9 @@ namespace OpenSim.Framework
|
||||
else if (typeof(T) == typeof(float))
|
||||
val = cnf.GetFloat(varname, (int)val);
|
||||
else
|
||||
m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T));
|
||||
m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T));
|
||||
}
|
||||
|
||||
return (T)val;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user