diff options
author | Justin Clark-Casey (justincc) | 2013-02-25 23:04:38 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-02-25 23:04:38 +0000 |
commit | d0cb4fc3262df2afe2ef34396c7960f7afee6b89 (patch) | |
tree | 2037829f95d30302b82536dc10cf5985a2b5df59 /OpenSim/Framework/Util.cs | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-d0cb4fc3262df2afe2ef34396c7960f7afee6b89.zip opensim-SC_OLD-d0cb4fc3262df2afe2ef34396c7960f7afee6b89.tar.gz opensim-SC_OLD-d0cb4fc3262df2afe2ef34396c7960f7afee6b89.tar.bz2 opensim-SC_OLD-d0cb4fc3262df2afe2ef34396c7960f7afee6b89.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 8b8e507..0fa54b2 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -917,7 +917,25 @@ namespace OpenSim.Framework | |||
917 | /// <returns></returns> | 917 | /// <returns></returns> |
918 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections) | 918 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections) |
919 | { | 919 | { |
920 | object val = default(T); | 920 | return GetConfigVarFromSections<T>(config, varname, sections, default(T)); |
921 | } | ||
922 | |||
923 | /// <summary> | ||
924 | /// Gets the value of a configuration variable by looking into | ||
925 | /// multiple sections in order. The latter sections overwrite | ||
926 | /// any values previously found. | ||
927 | /// </summary> | ||
928 | /// <remarks> | ||
929 | /// If no value is found then the given default value is returned | ||
930 | /// </remarks> | ||
931 | /// <typeparam name="T">Type of the variable</typeparam> | ||
932 | /// <param name="config">The configuration object</param> | ||
933 | /// <param name="varname">The configuration variable</param> | ||
934 | /// <param name="sections">Ordered sequence of sections to look at</param> | ||
935 | /// <param name="val">Default value</param> | ||
936 | /// <returns></returns> | ||
937 | public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val) | ||
938 | { | ||
921 | foreach (string section in sections) | 939 | foreach (string section in sections) |
922 | { | 940 | { |
923 | IConfig cnf = config.Configs[section]; | 941 | IConfig cnf = config.Configs[section]; |
@@ -925,11 +943,7 @@ namespace OpenSim.Framework | |||
925 | continue; | 943 | continue; |
926 | 944 | ||
927 | if (typeof(T) == typeof(String)) | 945 | if (typeof(T) == typeof(String)) |
928 | { | ||
929 | if (val == null) // no null strings, please | ||
930 | val = string.Empty; | ||
931 | val = cnf.GetString(varname, (string)val); | 946 | val = cnf.GetString(varname, (string)val); |
932 | } | ||
933 | else if (typeof(T) == typeof(Boolean)) | 947 | else if (typeof(T) == typeof(Boolean)) |
934 | val = cnf.GetBoolean(varname, (bool)val); | 948 | val = cnf.GetBoolean(varname, (bool)val); |
935 | else if (typeof(T) == typeof(Int32)) | 949 | else if (typeof(T) == typeof(Int32)) |
@@ -937,8 +951,9 @@ namespace OpenSim.Framework | |||
937 | else if (typeof(T) == typeof(float)) | 951 | else if (typeof(T) == typeof(float)) |
938 | val = cnf.GetFloat(varname, (int)val); | 952 | val = cnf.GetFloat(varname, (int)val); |
939 | else | 953 | else |
940 | m_log.WarnFormat("[UTIL]: Unhandled type {0}", typeof(T)); | 954 | m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); |
941 | } | 955 | } |
956 | |||
942 | return (T)val; | 957 | return (T)val; |
943 | } | 958 | } |
944 | 959 | ||