Marck's patch on 4096 checks with conflicts resolved.
parent
db629af6d3
commit
a0fa6dc967
|
@ -233,6 +233,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||||
return m_GridService.GetFallbackRegions(scopeID, x, y);
|
return m_GridService.GetFallbackRegions(scopeID, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GridRegion> GetHyperlinks(UUID scopeID)
|
||||||
|
{
|
||||||
|
return m_GridService.GetHyperlinks(scopeID);
|
||||||
|
}
|
||||||
|
|
||||||
public int GetRegionFlags(UUID scopeID, UUID regionID)
|
public int GetRegionFlags(UUID scopeID, UUID regionID)
|
||||||
{
|
{
|
||||||
return m_GridService.GetRegionFlags(scopeID, regionID);
|
return m_GridService.GetRegionFlags(scopeID, regionID);
|
||||||
|
|
|
@ -136,6 +136,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
|
||||||
900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
|
900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize);
|
||||||
Assert.IsNotNull(results, "Retrieved GetRegionRange list is null");
|
Assert.IsNotNull(results, "Retrieved GetRegionRange list is null");
|
||||||
Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
|
Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected");
|
||||||
|
|
||||||
|
results = m_LocalConnector.GetHyperlinks(UUID.Zero);
|
||||||
|
Assert.IsNotNull(results, "Retrieved GetHyperlinks list is null");
|
||||||
|
Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,9 @@ namespace OpenSim.Server.Handlers.Grid
|
||||||
case "get_fallback_regions":
|
case "get_fallback_regions":
|
||||||
return GetFallbackRegions(request);
|
return GetFallbackRegions(request);
|
||||||
|
|
||||||
|
case "get_hyperlinks":
|
||||||
|
return GetHyperlinks(request);
|
||||||
|
|
||||||
case "get_region_flags":
|
case "get_region_flags":
|
||||||
return GetRegionFlags(request);
|
return GetRegionFlags(request);
|
||||||
}
|
}
|
||||||
|
@ -483,6 +486,36 @@ namespace OpenSim.Server.Handlers.Grid
|
||||||
return encoding.GetBytes(xmlString);
|
return encoding.GetBytes(xmlString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] GetHyperlinks(Dictionary<string, object> request)
|
||||||
|
{
|
||||||
|
//m_log.DebugFormat("[GRID HANDLER]: GetHyperlinks");
|
||||||
|
UUID scopeID = UUID.Zero;
|
||||||
|
if (request.ContainsKey("SCOPEID"))
|
||||||
|
UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
|
||||||
|
else
|
||||||
|
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get linked regions");
|
||||||
|
|
||||||
|
List<GridRegion> rinfos = m_GridService.GetHyperlinks(scopeID);
|
||||||
|
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
|
||||||
|
result["result"] = "null";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
foreach (GridRegion rinfo in rinfos)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
|
||||||
|
result["region" + i] = rinfoDict;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||||
|
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
|
||||||
|
UTF8Encoding encoding = new UTF8Encoding();
|
||||||
|
return encoding.GetBytes(xmlString);
|
||||||
|
}
|
||||||
|
|
||||||
byte[] GetRegionFlags(Dictionary<string, object> request)
|
byte[] GetRegionFlags(Dictionary<string, object> request)
|
||||||
{
|
{
|
||||||
UUID scopeID = UUID.Zero;
|
UUID scopeID = UUID.Zero;
|
||||||
|
|
|
@ -556,6 +556,56 @@ namespace OpenSim.Services.Connectors
|
||||||
return rinfos;
|
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)
|
public virtual int GetRegionFlags(UUID scopeID, UUID regionID)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||||
|
|
|
@ -357,6 +357,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
return new List<GridRegion>(0);
|
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)
|
public int GetRegionFlags(UUID scopeID, UUID regionID)
|
||||||
{
|
{
|
||||||
const int REGION_ONLINE = 4;
|
const int REGION_ONLINE = 4;
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace OpenSim.Services.GridService
|
||||||
{
|
{
|
||||||
// Regions reserved for the null key cannot be taken.
|
// Regions reserved for the null key cannot be taken.
|
||||||
if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString())
|
if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString())
|
||||||
return "Region location us reserved";
|
return "Region location is reserved";
|
||||||
|
|
||||||
// Treat it as an auth request
|
// Treat it as an auth request
|
||||||
//
|
//
|
||||||
|
@ -210,6 +210,7 @@ namespace OpenSim.Services.GridService
|
||||||
{
|
{
|
||||||
int newFlags = 0;
|
int newFlags = 0;
|
||||||
string regionName = rdata.RegionName.Trim().Replace(' ', '_');
|
string regionName = rdata.RegionName.Trim().Replace(' ', '_');
|
||||||
|
newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty));
|
||||||
newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty));
|
newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty));
|
||||||
newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty));
|
newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty));
|
||||||
rdata.Data["flags"] = newFlags.ToString();
|
rdata.Data["flags"] = newFlags.ToString();
|
||||||
|
@ -425,6 +426,22 @@ namespace OpenSim.Services.GridService
|
||||||
return ret;
|
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)
|
public int GetRegionFlags(UUID scopeID, UUID regionID)
|
||||||
{
|
{
|
||||||
RegionData region = m_Database.Get(regionID, scopeID);
|
RegionData region = m_Database.Get(regionID, scopeID);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
@ -332,18 +333,43 @@ namespace OpenSim.Services.GridService
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Check4096(ulong realHandle, out uint x, out uint y)
|
public bool Check4096(ulong realHandle, out uint x, out uint y)
|
||||||
{
|
{
|
||||||
GridRegion defRegion = DefaultRegion;
|
|
||||||
|
|
||||||
uint ux = 0, uy = 0;
|
uint ux = 0, uy = 0;
|
||||||
Utils.LongToUInts(realHandle, out ux, out uy);
|
Utils.LongToUInts(realHandle, out ux, out uy);
|
||||||
x = ux / Constants.RegionSize;
|
x = ux / Constants.RegionSize;
|
||||||
y = uy / Constants.RegionSize;
|
y = uy / Constants.RegionSize;
|
||||||
|
|
||||||
if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) ||
|
const uint limit = (4096 - 1) * Constants.RegionSize;
|
||||||
(Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * 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;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
|
|
||||||
List<GridRegion> GetDefaultRegions(UUID scopeID);
|
List<GridRegion> GetDefaultRegions(UUID scopeID);
|
||||||
List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
|
List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
|
||||||
|
List<GridRegion> GetHyperlinks(UUID scopeID);
|
||||||
|
|
||||||
int GetRegionFlags(UUID scopeID, UUID regionID);
|
int GetRegionFlags(UUID scopeID, UUID regionID);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue