diff options
Show map tile for hyperlinks. Perform Check4096 before adding a hyperlink.
Configuration option AssetService in section [GridService] must be set to enable this functionality.
Map tiles do currently not show for hyperlinks set in simulators that are connected to grids, see Mantis #5270.
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 85c1380..d4fd1b8 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.IO; | ||
32 | using System.Net; | 33 | using System.Net; |
33 | using System.Reflection; | 34 | using System.Reflection; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -48,7 +49,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
48 | { | 49 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 51 | ||
51 | // private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); | 52 | private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); |
52 | 53 | ||
53 | private IAssetService m_AssetService; | 54 | private IAssetService m_AssetService; |
54 | 55 | ||
@@ -143,24 +144,25 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
143 | return true; | 144 | return true; |
144 | } | 145 | } |
145 | 146 | ||
146 | UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); | 147 | public UUID GetMapImage(UUID regionID, string imageURL, string storagePath) |
147 | |||
148 | public UUID GetMapImage(UUID regionID, string imageURL) | ||
149 | { | 148 | { |
150 | if (m_AssetService == null) | 149 | if (m_AssetService == null) |
151 | return m_MissingTexture; | 150 | return m_HGMapImage; |
152 | 151 | ||
152 | UUID mapTile = m_HGMapImage; | ||
153 | string filename = string.Empty; | ||
154 | Bitmap bitmap = null; | ||
153 | try | 155 | try |
154 | { | 156 | { |
155 | |||
156 | WebClient c = new WebClient(); | 157 | WebClient c = new WebClient(); |
157 | //m_log.Debug("JPEG: " + imageURL); | 158 | //m_log.Debug("JPEG: " + imageURL); |
158 | string filename = regionID.ToString(); | 159 | string name = regionID.ToString(); |
159 | c.DownloadFile(imageURL, filename + ".jpg"); | 160 | filename = Path.Combine(storagePath, name + ".jpg"); |
160 | Bitmap m = new Bitmap(filename + ".jpg"); | 161 | c.DownloadFile(imageURL, filename); |
162 | bitmap = new Bitmap(filename); | ||
161 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | 163 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); |
162 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | 164 | byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); |
163 | AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture, regionID.ToString()); | 165 | AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); |
164 | 166 | ||
165 | // !!! for now | 167 | // !!! for now |
166 | //info.RegionSettings.TerrainImageID = ass.FullID; | 168 | //info.RegionSettings.TerrainImageID = ass.FullID; |
@@ -172,14 +174,13 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
172 | m_AssetService.Store(ass); | 174 | m_AssetService.Store(ass); |
173 | 175 | ||
174 | // finally | 176 | // finally |
175 | return ass.FullID; | 177 | mapTile = ass.FullID; |
176 | |||
177 | } | 178 | } |
178 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | 179 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke |
179 | { | 180 | { |
180 | m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); | 181 | m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); |
181 | } | 182 | } |
182 | return UUID.Zero; | 183 | return mapTile; |
183 | } | 184 | } |
184 | 185 | ||
185 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) | 186 | public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) |