From d0cb4fc3262df2afe2ef34396c7960f7afee6b89 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 25 Feb 2013 23:04:38 +0000 Subject: 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. --- OpenSim/Framework/Util.cs | 27 ++++++++--- .../CoreModules/Hypergrid/HGWorldMapModule.cs | 4 +- .../CoreModules/World/LegacyMap/MapImageModule.cs | 24 ++++------ .../World/Warp3DMap/Warp3DImageModule.cs | 20 ++++---- .../CoreModules/World/WorldMap/WorldMapModule.cs | 9 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 11 ++++- bin/OpenSim.ini.example | 55 ++++++++++++---------- bin/OpenSimDefaults.ini | 50 ++++++++++---------- 8 files changed, 109 insertions(+), 91 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 /// public static T GetConfigVarFromSections(IConfigSource config, string varname, string[] sections) { - object val = default(T); + return GetConfigVarFromSections(config, varname, sections, default(T)); + } + + /// + /// Gets the value of a configuration variable by looking into + /// multiple sections in order. The latter sections overwrite + /// any values previously found. + /// + /// + /// If no value is found then the given default value is returned + /// + /// Type of the variable + /// The configuration object + /// The configuration variable + /// Ordered sequence of sections to look at + /// Default value + /// + public static T GetConfigVarFromSections(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; } diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index e0921ad..c4255b9 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs @@ -52,8 +52,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid public override void Initialise(IConfigSource config) { - IConfig startupConfig = config.Configs["Startup"]; - if (startupConfig.GetString("WorldMapModule", "WorldMap") == "HGWorldMap") + if (Util.GetConfigVarFromSections( + config, "WorldMapModule", new string[] { "Map", "Startup" }, "WorldMap") == "HGWorldMap") m_Enabled = true; } diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index e7065dc..40638f8 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs @@ -80,17 +80,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap bool generateMaptiles = true; Bitmap mapbmp; - try - { - IConfig startupConfig = m_config.Configs["Startup"]; - drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume); - textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain); - generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", generateMaptiles); - } - catch - { - m_log.Warn("[MAPTILE]: Failed to load StartupConfig"); - } + string[] configSections = new string[] { "Map", "Startup" }; + + drawPrimVolume + = Util.GetConfigVarFromSections(m_config, "DrawPrimOnMapTile", configSections, drawPrimVolume); + textureTerrain + = Util.GetConfigVarFromSections(m_config, "TextureOnMapTile", configSections, textureTerrain); + generateMaptiles + = Util.GetConfigVarFromSections(m_config, "GenerateMaptiles", configSections, generateMaptiles); if (generateMaptiles) { @@ -148,9 +145,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap { m_config = source; - IConfig startupConfig = m_config.Configs["Startup"]; - if (startupConfig.GetString("MapImageModule", "MapImageModule") != - "MapImageModule") + if (Util.GetConfigVarFromSections( + m_config, "MapImageModule", new string[] { "Startup", "Map" }, "MapImageModule") != "MapImageModule") return; m_Enabled = true; diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 5e0dfa7..ed2b06a 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs @@ -71,8 +71,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap { m_config = source; - IConfig startupConfig = m_config.Configs["Startup"]; - if (startupConfig.GetString("MapImageModule", "MapImageModule") != "Warp3DImageModule") + if (Util.GetConfigVarFromSections( + m_config, "MapImageModule", new string[] { "Startup", "Map" }, "MapImageModule") != "Warp3DImageModule") return; m_Enabled = true; @@ -143,16 +143,12 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap bool drawPrimVolume = true; bool textureTerrain = true; - try - { - IConfig startupConfig = m_config.Configs["Startup"]; - drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume); - textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain); - } - catch - { - m_log.Warn("[WARP 3D IMAGE MODULE]: Failed to load StartupConfig"); - } + string[] configSections = new string[] { "Map", "Startup" }; + + drawPrimVolume + = Util.GetConfigVarFromSections(m_config, "DrawPrimOnMapTile", configSections, drawPrimVolume); + textureTerrain + = Util.GetConfigVarFromSections(m_config, "TextureOnMapTile", configSections, textureTerrain); m_colors.Clear(); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index e2f525c..912d50a 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -86,11 +86,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap #region INonSharedRegionModule Members public virtual void Initialise (IConfigSource config) { - IConfig startupConfig = config.Configs["Startup"]; - if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap") + string[] configSections = new string[] { "Map", "Startup" }; + + if (Util.GetConfigVarFromSections( + config, "WorldMapModule", configSections, "WorldMap") == "WorldMap") m_Enabled = true; - blacklistTimeout = startupConfig.GetInt("BlacklistTimeout", 10*60) * 1000; + blacklistTimeout + = Util.GetConfigVarFromSections(config, "BlacklistTimeout", configSections, 10 * 60) * 1000; } public virtual void AddRegion (Scene scene) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9b17b7f..5b61538 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -897,7 +897,11 @@ namespace OpenSim.Region.Framework.Scenes m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); - m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); + string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; + + m_generateMaptiles + = Util.GetConfigVarFromSections(config, "GenerateMaptiles", possibleMapConfigSections, true); + if (m_generateMaptiles) { int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); @@ -911,7 +915,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); + string tile + = Util.GetConfigVarFromSections( + config, "MaptileStaticUUID", possibleMapConfigSections, UUID.Zero.ToString()); + UUID tileID; if (tile != UUID.Zero.ToString() && UUID.TryParse(tile, out tileID)) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 5aeae8a..2756b32 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -268,32 +268,6 @@ ;; Default script engine to use. Currently, we only have XEngine ; DefaultScriptEngine = "XEngine" - ;# {GenerateMaptiles} {} {Generate map tiles?} {true false} true - ;; Map tile options. You can choose to generate normal maptiles or nominate an uploaded texture to - ;; be the map tile using the MaptileStaticUUID parameter in this section or for individual regions in - ;; the regions config file(s). If you do not want to upload map tiles at all, then you will need - ;; to disable the MapImageServiceModule entirely. - ; GenerateMaptiles = true - - ;# {MaptileRefresh} {GenerateMaptiles} {Maptile refresh period?} {} 0 - ;; If desired, a running region can update the map tiles periodically - ;; to reflect building activity. This names no sense of you don't have - ;; prims on maptiles. Value is in seconds. - ; MaptileRefresh = 0 - - ;# {MaptileStaticUUID} {} {Asset ID for static map texture} {} 00000000-0000-0000-0000-000000000000 - ;; If not generating maptiles, use this static texture asset ID - ; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" - - ;# {TextureOnMapTile} {} {Use terrain textures for map tiles?} {true false} true - ;; Use terrain texture for maptiles if true, use shaded green if false - ; TextureOnMapTile = true - - ;# {DrawPrimOnMapTile} {} {Draw prim shapes on map tiles?} {true false} false - ;; Draw objects on maptile. This step might take a long time if you've - ;; got a large number of objects, so you can turn it off here if you'd like. - ; DrawPrimOnMapTile = true - ;# {HttpProxy} {} {Proxy URL for llHTTPRequest and dynamic texture loading} {} http://proxy.com:8080 ;; Http proxy setting for llHTTPRequest and dynamic texture loading, if ;; required @@ -362,6 +336,35 @@ ;; This is a default that can be overwritten in some sections. ; GatekeeperURI = "http://127.0.0.1:9000" + +[Map] + ;# {GenerateMaptiles} {} {Generate map tiles?} {true false} true + ;; Map tile options. You can choose to generate normal maptiles or nominate an uploaded texture to + ;; be the map tile using the MaptileStaticUUID parameter in this section or for individual regions in + ;; the regions config file(s). If you do not want to upload map tiles at all, then you will need + ;; to disable the MapImageServiceModule entirely. + ; GenerateMaptiles = true + + ;# {MaptileRefresh} {GenerateMaptiles} {Maptile refresh period?} {} 0 + ;; If desired, a running region can update the map tiles periodically + ;; to reflect building activity. This names no sense of you don't have + ;; prims on maptiles. Value is in seconds. + ; MaptileRefresh = 0 + + ;# {MaptileStaticUUID} {} {Asset ID for static map texture} {} 00000000-0000-0000-0000-000000000000 + ;; If not generating maptiles, use this static texture asset ID + ; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" + + ;# {TextureOnMapTile} {} {Use terrain textures for map tiles?} {true false} true + ;; Use terrain texture for maptiles if true, use shaded green if false + ; TextureOnMapTile = true + + ;# {DrawPrimOnMapTile} {} {Draw prim shapes on map tiles?} {true false} false + ;; Draw objects on maptile. This step might take a long time if you've + ;; got a large number of objects, so you can turn it off here if you'd like. + ; DrawPrimOnMapTile = true + + [Estates] ; If these values are commented out then the user will be asked for estate details when required (this is the normal case). ; If these values are uncommented then they will be used to create a default estate as necessary. diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 2512428..6ecb5df 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -285,32 +285,6 @@ DefaultScriptEngine = "XEngine" ; ## - ; ## WORLD MAP - ; ## - - ;WorldMapModule = "WorldMap" - ;MapImageModule = "MapImageModule" - - ; World map blacklist timeout in seconds - ;BlacklistTimeout = 600 - - ; Set to false to not generate any maptiles - ;GenerateMaptiles = true - - ; Refresh (in seconds) the map tile periodically - ;MaptileRefresh = 0 - - ; If not generating maptiles, use this static texture asset ID - ;MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" - - ; Draw objects on maptile. This step might take a long time if you've got a large number of - ; objects, so you can turn it off here if you'd like. - DrawPrimOnMapTile = true - - ; Use terrain texture for maptiles if true, use shaded green if false - TextureOnMapTile = true - - ; ## ; ## EMAIL MODULE ; ## @@ -347,6 +321,30 @@ UseTrashOnDelete = True +[Map] + ;WorldMapModule = "WorldMap" + ;MapImageModule = "MapImageModule" + + ; World map blacklist timeout in seconds + ;BlacklistTimeout = 600 + + ; Set to false to not generate any maptiles + ;GenerateMaptiles = true + + ; Refresh (in seconds) the map tile periodically + ;MaptileRefresh = 0 + + ; If not generating maptiles, use this static texture asset ID + ;MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" + + ; Draw objects on maptile. This step might take a long time if you've got a large number of + ; objects, so you can turn it off here if you'd like. + DrawPrimOnMapTile = true + + ; Use terrain texture for maptiles if true, use shaded green if false + TextureOnMapTile = true + + [RegionReady] ; Enable this module to get notified once all items and scripts in the region have been completely loaded and compiled enabled = true -- cgit v1.1