From fe8977564bda8ec2f328ebb2d2623c43073e9be5 Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 22 Aug 2019 12:01:47 +1000 Subject: When the generate map command is given, generate the map. The month check seems a bit dodgy, but I'll let it ride for now. --- .../CoreModules/World/LegacyMap/MapImageModule.cs | 4 ++++ .../World/Warp3DMap/Warp3DImageModule.cs | 13 +++++++++++- .../CoreModules/World/WorldMap/WorldMapModule.cs | 24 +++++++++++++++++++++- OpenSim/Region/Framework/Interfaces/ITerrain.cs | 1 + 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index b927cfa..1e63662 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs @@ -73,6 +73,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap #region IMapImageGenerator Members + public Bitmap CreateMapTileForce() + { + return CreateMapTile(); + } public Bitmap CreateMapTile() { bool drawPrimVolume = true; diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index fb94853..d094bee 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs @@ -245,10 +245,20 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap g.Flush(); } */ + public Bitmap CreateMapTileForce() + { + m_log.Info("[MAPTILE]: Forcing a map tile regenerate."); + File.Delete(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + ".bmp")); + return CreateMapTile(); + } public Bitmap CreateMapTile() { - if ((File.GetCreationTime(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + ".bmp")).Month != DateTime.Now.Month) && m_enable_refreshEveryMonth == true) + if ((File.GetCreationTime(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + ".bmp")).Month != DateTime.Now.Month) && (m_enable_refreshEveryMonth == true)) + { + m_log.InfoFormat("[MAPTILE]: Clearing old map tile out of cache {0} {1}.", + File.GetCreationTime(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + ".bmp")).Month, DateTime.Now.Month); File.Delete(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + ".bmp")); + } if(File.Exists(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + ".bmp"))) { @@ -256,6 +266,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap } else { + m_log.Info("[MAPTILE]: Actually generating a map tile."); /* this must be on all map, not just its image if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) { diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 03a4d34..94072a5 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1458,7 +1458,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (consoleScene != null && consoleScene != m_scene) return; - GenerateMaptile(); + GenerateMaptileForce(); } public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) @@ -1572,6 +1572,28 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return responsemap; } + private void GenerateMaptileForce() + { + // Cannot create a map for a nonexistent heightmap + if (m_scene.Heightmap == null) + return; + + if (m_mapImageGenerator == null) + { + Console.WriteLine("No map image generator available for {0}", m_scene.Name); + return; + } + m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.Name); + + using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTileForce()) + { + GenerateMaptile(mapbmp); + + if (m_mapImageServiceModule != null) + m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp); + } + } + public void GenerateMaptile() { // Cannot create a map for a nonexistent heightmap diff --git a/OpenSim/Region/Framework/Interfaces/ITerrain.cs b/OpenSim/Region/Framework/Interfaces/ITerrain.cs index 815a2d8..2fc954a 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrain.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrain.cs @@ -74,6 +74,7 @@ namespace OpenSim.Region.Framework.Interfaces public interface IMapImageGenerator { + System.Drawing.Bitmap CreateMapTileForce(); System.Drawing.Bitmap CreateMapTile(); System.Drawing.Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures); byte[] WriteJpeg2000Image(); -- cgit v1.1