From 61353dde80a3912e26959c612a1d8d46ec1bc826 Mon Sep 17 00:00:00 2001 From: Jak Daniels Date: Mon, 17 Mar 2014 20:39:36 +0000 Subject: Allow Region specific static maptiles to be loaded from file. --- OpenSim/Framework/RegionInfo.cs | 21 +++++++++ .../CoreModules/World/LegacyMap/MapImageModule.cs | 53 ++++++++++++++-------- OpenSim/Region/Framework/Scenes/Scene.cs | 3 +- 3 files changed, 58 insertions(+), 19 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 1de30af..f71ee86 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -143,6 +143,7 @@ namespace OpenSim.Framework public string RemotingAddress; public UUID ScopeID = UUID.Zero; private UUID m_maptileStaticUUID = UUID.Zero; + public string m_maptileStaticFile; public uint WorldLocX = 0; public uint WorldLocY = 0; @@ -349,6 +350,11 @@ namespace OpenSim.Framework { get { return m_maptileStaticUUID; } } + + public string MaptileStaticFile + { + get { return m_maptileStaticFile; } + } /// /// The port by which http communication occurs with the region (most noticeably, CAPS communication) @@ -716,6 +722,9 @@ namespace OpenSim.Framework { config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); } + + m_maptileStaticFile = config.GetString("MaptileStaticFile", String.Empty); + allKeys.Remove("MaptileStaticFile"); #endregion @@ -843,6 +852,9 @@ namespace OpenSim.Framework if (m_maptileStaticUUID != UUID.Zero) config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); + + if (m_maptileStaticFile != String.Empty) + config.Set("MaptileStaticFile", m_maptileStaticFile); } public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result) @@ -952,6 +964,9 @@ namespace OpenSim.Framework configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true); + + configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Filename of a texture to use as the map for this region", m_maptileStaticFile, true); } public void loadConfigurationOptions() @@ -1016,6 +1031,9 @@ namespace OpenSim.Framework configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, "UUID of a texture to use as the map for this region", String.Empty, true); + + configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Filename of a texture to use as the map for this region", String.Empty, true); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -1097,6 +1115,9 @@ namespace OpenSim.Framework case "region_static_maptile": m_maptileStaticUUID = (UUID)configuration_result; break; + case "region_static_mapfile": + m_maptileStaticFile = (string)configuration_result; + break; } return true; diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index 1dad8ba..0bd6ae4 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs @@ -91,29 +91,46 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap if (generateMaptiles) { - if (textureTerrain) + if (String.IsNullOrEmpty(m_scene.RegionInfo.m_maptileStaticFile)) { - terrainRenderer = new TexturedMapTileRenderer(); - } - else - { - terrainRenderer = new ShadedMapTileRenderer(); - } + if (textureTerrain) + { + terrainRenderer = new TexturedMapTileRenderer(); + } + else + { + terrainRenderer = new ShadedMapTileRenderer(); + } - terrainRenderer.Initialise(m_scene, m_config); + terrainRenderer.Initialise(m_scene, m_config); - mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, - System.Drawing.Imaging.PixelFormat.Format24bppRgb); - //long t = System.Environment.TickCount; - //for (int i = 0; i < 10; ++i) { - terrainRenderer.TerrainToBitmap(mapbmp); - //} - //t = System.Environment.TickCount - t; - //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t); + mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, + System.Drawing.Imaging.PixelFormat.Format24bppRgb); + //long t = System.Environment.TickCount; + //for (int i = 0; i < 10; ++i) { + terrainRenderer.TerrainToBitmap(mapbmp); + //} + //t = System.Environment.TickCount - t; + //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t); - if (drawPrimVolume) + if (drawPrimVolume) + { + DrawObjectVolume(m_scene, mapbmp); + } + } + else { - DrawObjectVolume(m_scene, mapbmp); + try + { + mapbmp = new Bitmap("maptiles/" + m_scene.RegionInfo.m_maptileStaticFile); + } + catch (Exception e) + { + m_log.ErrorFormat("[MAPTILE]: Failed to load Static map image texture file: {0} for {1}", "maptiles/" + m_scene.RegionInfo.m_maptileStaticFile, m_scene.Name); + //mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + mapbmp = null; + } + if (mapbmp != null) m_log.DebugFormat("[MAPTILE]: Static map image texture file {0} found for {1}", "maptiles/" + m_scene.RegionInfo.m_maptileStaticFile, m_scene.Name); } } else diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fa90ef4..d16b73b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -903,7 +903,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_generateMaptiles) { - int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); + int maptileRefresh = Util.GetConfigVarFromSections(config, "MaptileRefresh", possibleMapConfigSections, 0); + m_log.InfoFormat("[SCENE]: Region {0}, WORLD MAP refresh time set to {1} seconds", RegionInfo.RegionName, maptileRefresh); if (maptileRefresh != 0) { m_mapGenerationTimer.Interval = maptileRefresh * 1000; -- cgit v1.1