From 7e47ab746ef588648b8edbbc7cfb48c4d90c5e34 Mon Sep 17 00:00:00 2001 From: Marck Date: Fri, 6 Aug 2010 07:46:19 +0200 Subject: Allow creation of link regions if there is an existing region within a 4096 range. Also add GetHyperlinks() to the grid service. --- OpenSim/Services/GridService/GridService.cs | 16 ++++++++++++ OpenSim/Services/GridService/HypergridLinker.cs | 34 ++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/GridService') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ebaed42..79a45fe 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -426,6 +426,22 @@ namespace OpenSim.Services.GridService return ret; } + public List GetHyperlinks(UUID scopeID) + { + List ret = new List(); + + List regions = m_Database.GetHyperlinks(scopeID); + + foreach (RegionData r in regions) + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } + + m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); + return ret; + } + public int GetRegionFlags(UUID scopeID, UUID regionID) { RegionData region = m_Database.Get(regionID, scopeID); diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 1f53007..017df41 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net; using System.Reflection; using System.Xml; @@ -332,18 +333,43 @@ namespace OpenSim.Services.GridService /// public bool Check4096(ulong realHandle, out uint x, out uint y) { - GridRegion defRegion = DefaultRegion; - uint ux = 0, uy = 0; Utils.LongToUInts(realHandle, out ux, out uy); x = ux / Constants.RegionSize; y = uy / Constants.RegionSize; - if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) || - (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize)) + const uint limit = (4096 - 1) * Constants.RegionSize; + uint xmin = ux - limit; + uint xmax = ux + limit; + uint ymin = uy - limit; + uint ymax = uy + limit; + // World map boundary checks + if (xmin < 0 || xmin > ux) + xmin = 0; + if (xmax > int.MaxValue || xmax < ux) + xmax = int.MaxValue; + if (ymin < 0 || ymin > uy) + ymin = 0; + if (ymax > int.MaxValue || ymax < uy) + ymax = int.MaxValue; + + // Check for any regions that are within the possible teleport range to the linked region + List regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); + if (regions.Count == 0) + { + return false; + } + else + { + // Check for regions which are not linked regions + List hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); + IEnumerable availableRegions = regions.Except(hyperlinks); + if (availableRegions.Count() == 0) { return false; } + } + return true; } -- cgit v1.1 From 009053479302e7581a85c7574a6cc8eaa23745d8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 6 Aug 2010 17:43:09 -0700 Subject: Added Check4096 config var under [GridService], at the request of many. Changed the iteration that Marck had on the Hyperlinker. ATTENTION! CONFIGURATION CHANGE AFFECTING Robust.HG.ini.example and StandaloneCommon.ini.example. --- OpenSim/Services/GridService/GridService.cs | 30 ++++++++++++------------- OpenSim/Services/GridService/HypergridLinker.cs | 23 +++++++++++++------ 2 files changed, 31 insertions(+), 22 deletions(-) (limited to 'OpenSim/Services/GridService') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 79a45fe..ce6f64b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -426,21 +426,21 @@ namespace OpenSim.Services.GridService return ret; } - public List GetHyperlinks(UUID scopeID) - { - List ret = new List(); - - List regions = m_Database.GetHyperlinks(scopeID); - - foreach (RegionData r in regions) - { - if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) - ret.Add(RegionData2RegionInfo(r)); - } - - m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); - return ret; - } + public List GetHyperlinks(UUID scopeID) + { + List ret = new List(); + + List regions = m_Database.GetHyperlinks(scopeID); + + foreach (RegionData r in regions) + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } + + m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); + return ret; + } public int GetRegionFlags(UUID scopeID, UUID regionID) { diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 017df41..b190f93 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -27,7 +27,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Reflection; using System.Xml; @@ -63,6 +62,7 @@ namespace OpenSim.Services.GridService protected GatekeeperServiceConnector m_GatekeeperConnector; protected UUID m_ScopeID = UUID.Zero; + protected bool m_Check4096 = true; // Hyperlink regions are hyperlinks on the map public readonly Dictionary m_HyperlinkRegions = new Dictionary(); @@ -117,6 +117,8 @@ namespace OpenSim.Services.GridService if (scope != string.Empty) UUID.TryParse(scope, out m_ScopeID); + m_Check4096 = gridConfig.GetBoolean("Check4096", true); + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); @@ -278,7 +280,7 @@ namespace OpenSim.Services.GridService } uint x, y; - if (!Check4096(handle, out x, out y)) + if (m_Check4096 && !Check4096(handle, out x, out y)) { RemoveHyperlinkRegion(regInfo.RegionID); reason = "Region is too far (" + x + ", " + y + ")"; @@ -363,11 +365,18 @@ namespace OpenSim.Services.GridService { // Check for regions which are not linked regions List hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); - IEnumerable availableRegions = regions.Except(hyperlinks); - if (availableRegions.Count() == 0) - { - return false; - } + // would like to use .Except, but doesn't seem to exist + //IEnumerable availableRegions = regions.Except(hyperlinks); + List availableRegions = regions.FindAll(delegate(GridRegion region) + { + // Ewww! n^2 + if (hyperlinks.Find(delegate(GridRegion r) { return r.RegionID == region.RegionID; }) == null) // not hyperlink. good. + return true; + + return false; + }); + if (availableRegions.Count == 0) + return false; } return true; -- cgit v1.1