Merge branch 'master' into careminster-presence-refactor

This commit is contained in:
Melanie
2010-08-07 05:41:41 +01:00
23 changed files with 27795 additions and 27780 deletions

View File

@@ -556,6 +556,56 @@ namespace OpenSim.Services.Connectors
return rinfos;
}
public List<GridRegion> GetHyperlinks(UUID scopeID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString();
sendData["METHOD"] = "get_hyperlinks";
List<GridRegion> rinfos = new List<GridRegion>();
string reply = string.Empty;
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
ServerUtils.BuildQueryString(sendData));
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
return rinfos;
}
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData != null)
{
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
foreach (object r in rinfosList)
{
if (r is Dictionary<string, object>)
{
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo);
}
}
}
else
m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks {0} received null response",
scopeID);
}
else
m_log.DebugFormat("[GRID CONNECTOR]: GetHyperlinks received null reply");
return rinfos;
}
public virtual int GetRegionFlags(UUID scopeID, UUID regionID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();

View File

@@ -359,6 +359,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
return new List<GridRegion>(0);
}
public List<GridRegion> GetHyperlinks(UUID scopeID)
{
// Hypergrid/linked regions are not supported
return new List<GridRegion>();
}
public int GetRegionFlags(UUID scopeID, UUID regionID)
{
const int REGION_ONLINE = 4;

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

@@ -62,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<UUID, GridRegion> m_HyperlinkRegions = new Dictionary<UUID, GridRegion>();
@@ -116,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...");
@@ -277,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 + ")";
@@ -332,18 +335,50 @@ 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);
// would like to use .Except, but doesn't seem to exist
//IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks);
List<GridRegion> 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;
}

View File

@@ -92,6 +92,7 @@ namespace OpenSim.Services.Interfaces
List<GridRegion> GetDefaultRegions(UUID scopeID);
List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
List<GridRegion> GetHyperlinks(UUID scopeID);
int GetRegionFlags(UUID scopeID, UUID regionID);
}