diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage | |
parent | Add a build script. (diff) | |
download | opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | 52 |
1 files changed, 28 insertions, 24 deletions
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 | |||
53 | /// </remarks> | 53 | /// </remarks> |
54 | 54 | ||
55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] | 55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] |
56 | |||
56 | public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule | 57 | public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule |
57 | { | 58 | { |
58 | private static readonly ILog m_log = | 59 | private static readonly ILog m_log = |
@@ -67,11 +68,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
67 | private int m_refreshtime = 0; | 68 | private int m_refreshtime = 0; |
68 | private int m_lastrefresh = 0; | 69 | private int m_lastrefresh = 0; |
69 | private System.Timers.Timer m_refreshTimer; | 70 | private System.Timers.Timer m_refreshTimer; |
70 | 71 | ||
71 | #region ISharedRegionModule | 72 | #region ISharedRegionModule |
72 | 73 | ||
73 | public Type ReplaceableInterface { get { return null; } } | 74 | public Type ReplaceableInterface { get { return null; } } |
74 | public string Name { get { return "MapImageServiceModule"; } } | 75 | public string Name { get { return "MapImageServiceModule"; } } |
75 | public void RegionLoaded(Scene scene) { } | 76 | public void RegionLoaded(Scene scene) { } |
76 | public void Close() { } | 77 | public void Close() { } |
77 | public void PostInitialise() { } | 78 | public void PostInitialise() { } |
@@ -94,8 +95,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
94 | return; | 95 | return; |
95 | 96 | ||
96 | int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); | 97 | int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); |
97 | |||
98 | // if refresh is less than zero, disable the module | ||
99 | if (refreshminutes < 0) | 98 | if (refreshminutes < 0) |
100 | { | 99 | { |
101 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Negative refresh time given in config. Module disabled."); | 100 | 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 | |||
116 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Unable to load LocalServiceModule from {0}. MapService module disabled. Please fix the configuration.", service); | 115 | m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Unable to load LocalServiceModule from {0}. MapService module disabled. Please fix the configuration.", service); |
117 | return; | 116 | return; |
118 | } | 117 | } |
119 | 118 | ||
120 | // we don't want the timer if the interval is zero, but we still want this module enables | 119 | // we don't want the timer if the interval is zero, but we still want this module enables |
121 | if(refreshminutes > 0) | 120 | if(refreshminutes > 0) |
122 | { | 121 | { |
123 | m_refreshtime = refreshminutes * 60 * 1000; // convert from minutes to ms | 122 | m_refreshtime = refreshminutes * 60 * 1000; // convert from minutes to ms |
124 | 123 | ||
125 | m_refreshTimer = new System.Timers.Timer(); | 124 | m_refreshTimer = new System.Timers.Timer(); |
126 | m_refreshTimer.Enabled = true; | 125 | m_refreshTimer.Enabled = true; |
127 | m_refreshTimer.AutoReset = true; | 126 | m_refreshTimer.AutoReset = true; |
128 | m_refreshTimer.Interval = m_refreshtime; | 127 | m_refreshTimer.Interval = m_refreshtime; |
129 | m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); | 128 | m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); |
130 | 129 | ||
130 | |||
131 | m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}", | 131 | m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}", |
132 | refreshminutes, service); | 132 | refreshminutes, service); |
133 | } | 133 | } |
134 | else | 134 | else |
135 | { | 135 | { |
136 | m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with no refresh and service object {0}", service); | 136 | m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with no refresh and service object {0}", service); |
137 | } | 137 | } |
@@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
171 | } | 171 | } |
172 | 172 | ||
173 | #endregion ISharedRegionModule | 173 | #endregion ISharedRegionModule |
174 | 174 | ||
175 | ///<summary> | 175 | ///<summary> |
176 | /// | 176 | /// |
177 | ///</summary> | 177 | ///</summary> |
@@ -210,7 +210,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name); | ||
214 | 213 | ||
215 | // mapTile.Save( // DEBUG DEBUG | 214 | // mapTile.Save( // DEBUG DEBUG |
216 | // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY), | 215 | // 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 | |||
218 | // If the region/maptile is legacy sized, just upload the one tile like it has always been done | 217 | // If the region/maptile is legacy sized, just upload the one tile like it has always been done |
219 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) | 218 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) |
220 | { | 219 | { |
221 | ConvertAndUploadMaptile(mapTile, | 220 | m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name); |
221 | ConvertAndUploadMaptile(scene, mapTile, | ||
222 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, | 222 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, |
223 | scene.RegionInfo.RegionName); | 223 | scene.RegionInfo.RegionName); |
224 | } | 224 | } |
225 | else | 225 | else |
226 | { | 226 | { |
227 | m_log.DebugFormat("{0} Upload {1} maptiles for {2}", LogHeader, | ||
228 | (mapTile.Width * mapTile.Height) / (Constants.RegionSize * Constants.RegionSize), | ||
229 | scene.Name); | ||
230 | |||
227 | // For larger regions (varregion) we must cut the region image into legacy sized | 231 | // For larger regions (varregion) we must cut the region image into legacy sized |
228 | // pieces since that is how the maptile system works. | 232 | // pieces since that is how the maptile system works. |
229 | // Note the assumption that varregions are always a multiple of legacy size. | 233 | // Note the assumption that varregions are always a multiple of legacy size. |
@@ -240,7 +244,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
240 | (int)Constants.RegionSize, (int)Constants.RegionSize); | 244 | (int)Constants.RegionSize, (int)Constants.RegionSize); |
241 | using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) | 245 | using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) |
242 | { | 246 | { |
243 | ConvertAndUploadMaptile(subMapTile, | 247 | ConvertAndUploadMaptile(scene, subMapTile, |
244 | scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), | 248 | scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), |
245 | scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), | 249 | scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), |
246 | scene.Name); | 250 | scene.Name); |
@@ -253,8 +257,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
253 | ///<summary> | 257 | ///<summary> |
254 | /// | 258 | /// |
255 | ///</summary> | 259 | ///</summary> |
256 | private void UploadMapTile(IScene scene) | 260 | public void UploadMapTile(IScene scene) |
257 | { | 261 | { |
262 | m_log.DebugFormat("{0}: upload maptile for {1}", LogHeader, scene.RegionInfo.RegionName); | ||
263 | |||
258 | // Create a JPG map tile and upload it to the AddMapTile API | 264 | // Create a JPG map tile and upload it to the AddMapTile API |
259 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); | 265 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); |
260 | if (tileGenerator == null) | 266 | if (tileGenerator == null) |
@@ -265,18 +271,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
265 | 271 | ||
266 | using (Bitmap mapTile = tileGenerator.CreateMapTile()) | 272 | using (Bitmap mapTile = tileGenerator.CreateMapTile()) |
267 | { | 273 | { |
268 | if (mapTile != null) | 274 | // XXX: The MapImageModule will return a null if the user has chosen not to create map tiles and there |
269 | { | 275 | // is no static map tile. |
270 | UploadMapTile(scene, mapTile); | 276 | if (mapTile == null) |
271 | } | 277 | return; |
272 | else | 278 | |
273 | { | 279 | UploadMapTile(scene, mapTile); |
274 | m_log.WarnFormat("{0} Tile image generation failed", LogHeader); | ||
275 | } | ||
276 | } | 280 | } |
277 | } | 281 | } |
278 | 282 | ||
279 | private void ConvertAndUploadMaptile(Image tileImage, uint locX, uint locY, string regionName) | 283 | private void ConvertAndUploadMaptile(IScene scene, Image tileImage, uint locX, uint locY, string regionName) |
280 | { | 284 | { |
281 | byte[] jpgData = Utils.EmptyBytes; | 285 | byte[] jpgData = Utils.EmptyBytes; |
282 | 286 | ||
@@ -288,7 +292,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
288 | if (jpgData != Utils.EmptyBytes) | 292 | if (jpgData != Utils.EmptyBytes) |
289 | { | 293 | { |
290 | string reason = string.Empty; | 294 | string reason = string.Empty; |
291 | if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, out reason)) | 295 | if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) |
292 | { | 296 | { |
293 | m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, | 297 | m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, |
294 | regionName, locX, locY, reason); | 298 | regionName, locX, locY, reason); |
@@ -300,4 +304,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
300 | } | 304 | } |
301 | } | 305 | } |
302 | } | 306 | } |
303 | } \ No newline at end of file | 307 | } |