From 8ddf787cfd090fc8f2715a6f2a5329348a12e28b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 16:00:28 -0800 Subject: Hypergrid map search back on, this time with a config var in the grid service. --- OpenSim/Services/GridService/GridService.cs | 20 +++++++++++-- OpenSim/Services/GridService/HypergridLinker.cs | 39 +++++++++++++------------ 2 files changed, 37 insertions(+), 22 deletions(-) (limited to 'OpenSim/Services/GridService') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b86fd4d..515d620 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 b0cf723..1289cf6 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", ""); -- cgit v1.1