Compare commits

...

6 Commits

Author SHA1 Message Date
UbitUmarov
a87969840c fix m_regionSizeY change 2026-08-07 11:25:44 +01:00
UbitUmarov
460ed81f41 a few changes on the local maptiles folder code 2026-08-07 11:21:34 +01:00
UbitUmarov
b4b0d1773a Merge branch 'master' of https://github.com/opensim/opensim 2026-08-07 10:50:33 +01:00
UbitUmarov
46dd8c03bb missing commit ops 2026-08-07 10:49:45 +01:00
Ubit Umarov
3463388772 Merge pull request #51 from typhartez/maptiles-path
Add MapTilesDirectory setting to configure map tile location
2026-08-07 10:46:23 +01:00
Typhaine Artez
68b42d860a Add MapTilesDirectory setting to configure map tile location
Introduce a new MapTilesDirectory option in the [Map] config section
that controls where the MAP-<region uuid>.png tile images are saved and
loaded from. Previously these were always written to and read from the
current working directory.

- Warp3DImageModule saves the tile into the configured directory,
  creating it if needed.
- WorldMapModule loads the local tile from the configured directory when
  exporting the world map.
- Document the option in OpenSimDefaults.ini.

When left empty the current working directory is used, preserving the
previous behaviour.
2026-08-06 00:02:50 +02:00
4 changed files with 53 additions and 3 deletions

View File

@@ -84,6 +84,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
private float m_renderMinHeight = -100f; private float m_renderMinHeight = -100f;
private float m_renderMaxHeight = 4096f; private float m_renderMaxHeight = 4096f;
private string m_mapTilesDirectory = string.Empty; // directory to load/save map tile images
private bool m_Enabled = false; private bool m_Enabled = false;
#region Region Module interface #region Region Module interface
@@ -132,6 +134,21 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
m_renderMinHeight = -100f; m_renderMinHeight = -100f;
else if (m_renderMinHeight > m_renderMaxHeight - 10f) else if (m_renderMinHeight > m_renderMaxHeight - 10f)
m_renderMinHeight = m_renderMaxHeight - 10f; m_renderMinHeight = m_renderMaxHeight - 10f;
m_mapTilesDirectory =
Util.GetConfigVarFromSections<string>(source, "MapTilesDirectory", configSections, m_mapTilesDirectory);
if(!string.IsNullOrEmpty(m_mapTilesDirectory))
{
try
{
Directory.CreateDirectory(m_mapTilesDirectory);
}
catch(Exception e)
{
m_log.Error($"[MAPTILE]: failed to create folder {m_mapTilesDirectory} for local map tiles {e.Message}");
m_mapTilesDirectory = null;
}
}
} }
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
@@ -209,6 +226,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
Bitmap tile = GenImage(); Bitmap tile = GenImage();
// image may be reloaded elsewhere, so no compression format // image may be reloaded elsewhere, so no compression format
string filename = "MAP-" + m_scene.RegionInfo.RegionID.ToString() + ".png"; string filename = "MAP-" + m_scene.RegionInfo.RegionID.ToString() + ".png";
if (!string.IsNullOrEmpty(m_mapTilesDirectory))
filename = System.IO.Path.Combine(m_mapTilesDirectory, filename);
tile.Save(filename,ImageFormat.Png); tile.Save(filename,ImageFormat.Png);
m_primMesher = null; m_primMesher = null;
return tile; return tile;

View File

@@ -130,10 +130,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
//m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
MapBlockData data;
if (regionInfos != null && regionInfos.Count > 0) if (regionInfos != null && regionInfos.Count > 0)
{ {
foreach (GridRegion info in regionInfos) foreach (GridRegion info in regionInfos)
{ {
data = new MapBlockData();
data.Agents = 0;
data.Access = info.Access;
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
MapBlockFromGridRegion(block, info, flags); MapBlockFromGridRegion(block, info, flags);

View File

@@ -27,7 +27,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
@@ -100,6 +99,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
protected bool m_exportPrintScale = false; // prints the scale of map in meters on exported map protected bool m_exportPrintScale = false; // prints the scale of map in meters on exported map
protected bool m_exportPrintRegionName = false; // prints the region name exported map protected bool m_exportPrintRegionName = false; // prints the region name exported map
protected bool m_localV1MapAssets = false; // keep V1 map assets only on local cache protected bool m_localV1MapAssets = false; // keep V1 map assets only on local cache
protected string m_mapTilesDirectory = string.Empty; // directory to load/save map tile images
private readonly object m_sceneLock = new object(); private readonly object m_sceneLock = new object();
public WorldMapModule() public WorldMapModule()
@@ -158,6 +158,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Util.GetConfigVarFromSections<bool>(config, "ExportMapAddRegionName", configSections, m_exportPrintRegionName); Util.GetConfigVarFromSections<bool>(config, "ExportMapAddRegionName", configSections, m_exportPrintRegionName);
m_localV1MapAssets = m_localV1MapAssets =
Util.GetConfigVarFromSections<bool>(config, "LocalV1MapAssets", configSections, m_localV1MapAssets); Util.GetConfigVarFromSections<bool>(config, "LocalV1MapAssets", configSections, m_localV1MapAssets);
m_mapTilesDirectory =
Util.GetConfigVarFromSections<string>(config, "MapTilesDirectory", configSections, m_mapTilesDirectory);
if(!string.IsNullOrEmpty(m_mapTilesDirectory))
{
try
{
Directory.CreateDirectory(m_mapTilesDirectory);
}
catch(Exception e)
{
m_log.Error($"[WORLD MAP]: failed to create folder {m_mapTilesDirectory} for local map tiles {e.Message}");
m_mapTilesDirectory = null;
}
}
} }
public virtual void AddRegion(Scene scene) public virtual void AddRegion(Scene scene)
@@ -1337,10 +1352,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
startX--; startX--;
startY--; startY--;
bool doneLocal = false; bool doneLocal;
string filename = "MAP-" + m_scene.RegionInfo.RegionID.ToString() + ".png"; string filename = "MAP-" + m_scene.RegionInfo.RegionID.ToString() + ".png";
try try
{ {
if (!string.IsNullOrEmpty(m_mapTilesDirectory))
filename = Path.Combine(m_mapTilesDirectory, filename);
using(Image localMap = Bitmap.FromFile(filename)) using(Image localMap = Bitmap.FromFile(filename))
{ {
int x = regionX - startX; int x = regionX - startX;
@@ -1359,7 +1376,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
doneLocal = true; doneLocal = true;
} }
catch {} catch(Exception ex)
{
m_log.Error($"[WORLD MAP]: failed Export map file {ex.Message}");
return;
}
if(regions.Count > 0) if(regions.Count > 0)
{ {

View File

@@ -467,6 +467,11 @@
; generate better images. ; generate better images.
;MapImageModule = "MapImageModule" ;MapImageModule = "MapImageModule"
; Directory used to load and save the generated MAP-<region uuid>.png tile images.
; If left empty the current working directory is used (default behaviour).
; The directory is created automatically if it does not exist.
;MapTilesDirectory = "./localmaptiles"
; World map blacklist timeout in seconds ; World map blacklist timeout in seconds
;BlacklistTimeout = 600 ;BlacklistTimeout = 600