From 16d68749a457acf079a6737f4ca9a9adb9e53e2f Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Fri, 3 Oct 2008 23:00:42 +0000 Subject: Add the missing bits for the new region-search: - Added lookup in the data-layer - MySQL works - SQLite doesn't have a grid-db, so it won't work there - I added MSSQL-code to the best of my knowledge; but I don't know MSSQL :-) - Added the plumbing up to OGS1GridServices. This speaks with the grid-server via XMLRPC. - Modified MapSearchModule to use the new data. It's backward compatible; if used with an old grid-server, it just returns one found region instead of a list. - Refactored a bit. Note: This updates data, grid-server and region code. No new files. --- .../Modules/World/WorldMap/MapSearchModule.cs | 57 +++++++++++++--------- .../Scenes/SceneCommunicationService.cs | 6 ++- 2 files changed, 38 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs index 1a15585..8cc707c 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs @@ -78,35 +78,44 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap private void OnMapNameRequest(IClientAPI remoteClient, string mapName) { - m_log.DebugFormat("[MAPSEARCH]: looking for region {0}", mapName); - - // TODO currently, this only returns one region per name. LL servers will return all starting with the provided name. - RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); - // fetch the mapblock of the named sim. We need this anyway (we have the map open, and just jumped to the sim), - // so there shouldn't be any penalty for that. - if (info == null) - { - m_log.Warn("[MAPSEARCHMODULE]: Got Null Region Question!"); - return; + if (mapName.Length < 3) + { + remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); + return; + } + + // try to fetch from GridServer + List regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20); + if (regionInfos == null) + { + m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?"); + // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region + regionInfos = new List(); + RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName); + if (info != null) regionInfos.Add(info); } - List mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)info.RegionLocX, - (int)info.RegionLocY, - (int)info.RegionLocX, - (int)info.RegionLocY); List blocks = new List(); - MapBlockData data = new MapBlockData(); - data.Agents = 3; // TODO set to number of agents in region - data.Access = 21; // TODO what's this? - data.MapImageId = mapBlocks.Count == 0 ? UUID.Zero : mapBlocks[0].MapImageId; - data.Name = info.RegionName; - data.RegionFlags = 0; // TODO fix this - data.WaterHeight = 0; // not used - data.X = (ushort)info.RegionLocX; - data.Y = (ushort)info.RegionLocY; - blocks.Add(data); + MapBlockData data; + if (regionInfos.Count > 0) + { + foreach (RegionInfo info in regionInfos) + { + data = new MapBlockData(); + data.Agents = 0; + data.Access = 21; // TODO what's this? + data.MapImageId = info.RegionSettings.TerrainImageID; + data.Name = info.RegionName; + data.RegionFlags = 0; // TODO not used? + data.WaterHeight = 0; // not used + data.X = (ushort)info.RegionLocX; + data.Y = (ushort)info.RegionLocY; + blocks.Add(data); + } + } + // final block, closing the search result data = new MapBlockData(); data.Agents = 0; data.Access = 255; diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index c33c777..08793d9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -806,6 +806,10 @@ namespace OpenSim.Region.Environment.Scenes { return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); } - + + public List RequestNamedRegions(string name, int maxNumber) + { + return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); + } } } -- cgit v1.1