Allow creation of link regions if there is an existing region within a 4096 range.

Also add GetHyperlinks() to the grid service.
This commit is contained in:
Marck
2010-08-06 07:46:19 +02:00
committed by Diva Canto
parent 8d520f4525
commit 7e47ab746e
8 changed files with 146 additions and 4 deletions

View File

@@ -426,6 +426,22 @@ namespace OpenSim.Services.GridService
return ret;
}
public List<GridRegion> GetHyperlinks(UUID scopeID)
{
List<GridRegion> ret = new List<GridRegion>();
List<RegionData> 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);

View File

@@ -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
/// <returns></returns>
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<GridRegion> 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<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID);
IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
if (availableRegions.Count() == 0)
{
return false;
}
}
return true;
}