From d22d46ee96f7ba0e15e4bc96581ffd316f4797d5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Aug 2015 13:41:45 +0100 Subject: update MapSearchModule --- .../CoreModules/World/WorldMap/MapSearchModule.cs | 54 +++++++++++++++------- .../CoreModules/World/WorldMap/WorldMapModule.cs | 2 +- .../Region/Framework/Interfaces/IWorldMapModule.cs | 5 ++ 3 files changed, 44 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 14deeb6..1e5af1b 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -49,6 +49,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List m_scenes = new List(); List m_Clients; + IWorldMapModule m_WorldMap; + IWorldMapModule WorldMap + { + get + { + if (m_WorldMap == null) + m_WorldMap = m_scene.RequestModuleInterface(); + return m_WorldMap; + } + + } + #region ISharedRegionModule Members public void Initialise(IConfigSource source) { @@ -130,9 +142,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { Util.FireAndForget(x => { - if (mapName.Length < 2) + List blocks = new List(); + if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) { - remoteClient.SendAlertMessage("Use a search string with at least 2 characters"); + // final block, closing the search result + AddFinalBlock(blocks); + + // flags are agent flags sent from the viewer. + // they have different values depending on different viewers, apparently + remoteClient.SendMapBlock(blocks, flags); + remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); return; } @@ -160,8 +179,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // remoteClient.SendAlertMessage("Hyperlink could not be established."); //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); - List blocks = new List(); - + MapBlockData data; if (regionInfos.Count > 0) { @@ -171,9 +189,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap data.Agents = 0; data.Access = info.Access; if (flags == 2) // V2 sends this - data.MapImageId = UUID.Zero; + { + List datas = WorldMap.Map2BlockFromGridRegion(info, flags); + // ugh! V2-3 is very sensitive about the result being + // exactly the same as the requested name + + if (regionInfos.Count == 1 && (mapName != mapNameOrig)) + datas.ForEach(d => d.Name = mapNameOrig); + + blocks.AddRange(datas); + } else - data.MapImageId = info.TerrainImage; + { + MapBlockData block = new MapBlockData(); + WorldMap.MapBlockFromGridRegion(block,info, flags); + blocks.Add(block); + } // ugh! V2-3 is very sensitive about the result being // exactly the same as the requested name if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) @@ -189,16 +220,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } // final block, closing the search result - data = new MapBlockData(); - data.Agents = 0; - data.Access = 255; - data.MapImageId = UUID.Zero; - data.Name = mapName; - data.RegionFlags = 0; - data.WaterHeight = 0; // not used - data.X = 0; - data.Y = 0; - blocks.Add(data); + AddFinalBlock(blocks); // flags are agent flags sent from the viewer. // they have different values depending on different viewers, apparently diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 59529d8..31b1c35 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1143,7 +1143,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return allBlocks; } - protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) + public void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) { block.Access = r.Access; switch (flag & 0xffff) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index 65c57a6..e9cf4ad 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs @@ -24,6 +24,9 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.Framework.Interfaces { @@ -33,5 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces /// Generate a map tile for the scene. a terrain texture for this scene /// void GenerateMaptile(); + List Map2BlockFromGridRegion(GridRegion r, uint flag); + void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag); } } -- cgit v1.1