diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b86fd4d7ea..515d62040e 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -54,6 +54,7 @@ namespace OpenSim.Services.GridService protected IAuthenticationService m_AuthenticationService = null; protected bool m_AllowDuplicateNames = false; + protected bool m_AllowHypergridMapSearch = false; public GridService(IConfigSource config) : base(config) @@ -74,6 +75,7 @@ namespace OpenSim.Services.GridService m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); } m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); + m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); } if (m_RootInstance == null) @@ -327,6 +329,13 @@ namespace OpenSim.Services.GridService } } + if (m_AllowHypergridMapSearch && rdatas.Count == 0 && name.Contains(".")) + { + GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); + if (r != null) + rinfos.Add(r); + } + return rinfos; } @@ -410,9 +419,14 @@ namespace OpenSim.Services.GridService { RegionData region = m_Database.Get(regionID, scopeID); - int flags = Convert.ToInt32(region.Data["flags"]); - //m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags); - return flags; + if (region != null) + { + int flags = Convert.ToInt32(region.Data["flags"]); + //m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags); + return flags; + } + else + return -1; } private void HandleShowRegion(string module, string[] cmd) diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index b0cf723e3c..1289cf6974 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -130,26 +130,17 @@ namespace OpenSim.Services.GridService #region Link Region - public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) + public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) { - regionID = UUID.Zero; - imageURL = string.Empty; - regionHandle = 0; - reason = string.Empty; + string reason = string.Empty; int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; - GridRegion region = TryLinkRegionToCoords(regionDescriptor, xloc, 0, out reason); - if (region == null) - return false; - - regionID = region.RegionID; - regionHandle = region.RegionHandle; - return true; + return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason); } private static Random random = new Random(); // From the command line link-region - public GridRegion TryLinkRegionToCoords(string mapName, int xloc, int yloc, out string reason) + public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, out string reason) { reason = string.Empty; string host = "127.0.0.1"; @@ -183,7 +174,7 @@ namespace OpenSim.Services.GridService catch { } GridRegion regInfo; - bool success = TryCreateLink(xloc, yloc, regionName, port, host, out regInfo, out reason); + bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, out regInfo, out reason); if (success) { regInfo.RegionName = mapName; @@ -195,7 +186,7 @@ namespace OpenSim.Services.GridService // From the command line and the 2 above - public bool TryCreateLink(int xloc, int yloc, + public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo, out string reason) { m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); @@ -207,6 +198,7 @@ namespace OpenSim.Services.GridService regInfo.ExternalHostName = externalHostName; regInfo.RegionLocX = xloc; regInfo.RegionLocY = yloc; + regInfo.ScopeID = scopeID; try { @@ -228,7 +220,16 @@ namespace OpenSim.Services.GridService if (regionID != UUID.Zero) { + GridRegion r = m_GridService.GetRegionByUUID(scopeID, regionID); + if (r != null) + { + m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); + regInfo = r; + return true; + } + regInfo.RegionID = regionID; + regInfo.RegionName = regInfo.ExternalHostName + ":" + regInfo.HttpPort + ":" + regInfo.RegionName; // Try get the map image regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); // I need a texture that works for this... the one I tried doesn't seem to be working @@ -451,9 +452,9 @@ namespace OpenSim.Services.GridService xloc = xloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize; string reason = string.Empty; - if (TryLinkRegionToCoords(mapName, xloc, yloc, out reason) == null) + if (TryLinkRegionToCoords(UUID.Zero, mapName, xloc, yloc, out reason) == null) MainConsole.Instance.Output("Failed to link region: " + reason); - MainConsole.Instance.Output("Hyperlink estalished"); + MainConsole.Instance.Output("Hyperlink established"); } else { @@ -482,7 +483,7 @@ namespace OpenSim.Services.GridService xloc = xloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize; string reason = string.Empty; - if (TryCreateLink(xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) + if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) { if (cmdparams.Length >= 5) { @@ -584,7 +585,7 @@ namespace OpenSim.Services.GridService xloc = xloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize; string reason = string.Empty; - if (TryCreateLink(xloc, yloc, "", externalPort, + if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, out regInfo, out reason)) { regInfo.RegionName = config.GetString("localName", ""); diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index af502db188..0be7bab457 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -70,6 +70,8 @@ LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" Realm = "regions" + AllowHypergridMapSearch = true + [HypergridService] GridService = "OpenSim.Services.GridService.dll:GridService" AssetService = "OpenSim.Services.AssetService.dll:AssetService"