From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../MapImage/MapImageServiceModule.cs | 52 ++++++++++++---------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 08d6bdd..9888c3b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -53,6 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] + public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule { private static readonly ILog m_log = @@ -67,11 +68,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage private int m_refreshtime = 0; private int m_lastrefresh = 0; private System.Timers.Timer m_refreshTimer; - + #region ISharedRegionModule - + public Type ReplaceableInterface { get { return null; } } - public string Name { get { return "MapImageServiceModule"; } } + public string Name { get { return "MapImageServiceModule"; } } public void RegionLoaded(Scene scene) { } public void Close() { } public void PostInitialise() { } @@ -94,8 +95,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage return; int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); - - // if refresh is less than zero, disable the module if (refreshminutes < 0) { m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled."); @@ -116,22 +115,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Unable to load LocalServiceModule from {0}. MapService module disabled. Please fix the configuration.", service); return; } - + // we don't want the timer if the interval is zero, but we still want this module enables if(refreshminutes > 0) { m_refreshtime = refreshminutes * 60 * 1000; // convert from minutes to ms - + m_refreshTimer = new System.Timers.Timer(); m_refreshTimer.Enabled = true; m_refreshTimer.AutoReset = true; m_refreshTimer.Interval = m_refreshtime; m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); + m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}", refreshminutes, service); } - else + else { m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with no refresh and service object {0}", service); } @@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage } #endregion ISharedRegionModule - + /// /// /// @@ -210,7 +210,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage return; } - m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name); // mapTile.Save( // DEBUG DEBUG // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY), @@ -218,12 +217,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage // If the region/maptile is legacy sized, just upload the one tile like it has always been done if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) { - ConvertAndUploadMaptile(mapTile, + m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name); + ConvertAndUploadMaptile(scene, mapTile, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, scene.RegionInfo.RegionName); } else { + m_log.DebugFormat("{0} Upload {1} maptiles for {2}", LogHeader, + (mapTile.Width * mapTile.Height) / (Constants.RegionSize * Constants.RegionSize), + scene.Name); + // For larger regions (varregion) we must cut the region image into legacy sized // pieces since that is how the maptile system works. // Note the assumption that varregions are always a multiple of legacy size. @@ -240,7 +244,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage (int)Constants.RegionSize, (int)Constants.RegionSize); using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) { - ConvertAndUploadMaptile(subMapTile, + ConvertAndUploadMaptile(scene, subMapTile, scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), scene.Name); @@ -253,8 +257,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage /// /// /// - private void UploadMapTile(IScene scene) + public void UploadMapTile(IScene scene) { + m_log.DebugFormat("{0}: upload maptile for {1}", LogHeader, scene.RegionInfo.RegionName); + // Create a JPG map tile and upload it to the AddMapTile API IMapImageGenerator tileGenerator = scene.RequestModuleInterface(); if (tileGenerator == null) @@ -265,18 +271,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage using (Bitmap mapTile = tileGenerator.CreateMapTile()) { - if (mapTile != null) - { - UploadMapTile(scene, mapTile); - } - else - { - m_log.WarnFormat("{0} Tile image generation failed", LogHeader); - } + // XXX: The MapImageModule will return a null if the user has chosen not to create map tiles and there + // is no static map tile. + if (mapTile == null) + return; + + UploadMapTile(scene, mapTile); } } - private void ConvertAndUploadMaptile(Image tileImage, uint locX, uint locY, string regionName) + private void ConvertAndUploadMaptile(IScene scene, Image tileImage, uint locX, uint locY, string regionName) { byte[] jpgData = Utils.EmptyBytes; @@ -288,7 +292,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage if (jpgData != Utils.EmptyBytes) { string reason = string.Empty; - if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason)) + if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) { m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, regionName, locX, locY, reason); @@ -300,4 +304,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage } } } -} \ No newline at end of file +} -- cgit v1.1