mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
a few changes to getregion(s)byName()
This commit is contained in:
@@ -300,33 +300,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
rinfo = m_LocalGridService.GetRegionByName(scopeID, name);
|
||||
var ruri = new RegionURI(name, m_ThisGridInfo);
|
||||
return GetRegionByURI(scopeID, ruri);
|
||||
}
|
||||
|
||||
public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri)
|
||||
{
|
||||
GridRegion rinfo = m_LocalGridService.GetRegionByURI(scopeID, uri);
|
||||
if (rinfo != null)
|
||||
{
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
if(m_RemoteGridService == null)
|
||||
return null;
|
||||
if (m_RemoteGridService == null || !uri.IsLocalGrid)
|
||||
return rinfo;
|
||||
|
||||
// HG urls should not get here, strip them
|
||||
// side effect is that local regions with same name as HG may also be found
|
||||
// this mb good or bad
|
||||
string regionName = name;
|
||||
if(name.Contains("."))
|
||||
{
|
||||
if(!m_ThisGridInfo.HasHGConfig)
|
||||
return rinfo; // no HG
|
||||
|
||||
string regionURI = "";
|
||||
if (!Util.buildHGRegionURI(name, out regionURI, out regionName))
|
||||
return rinfo; // invalid
|
||||
if (m_ThisGridInfo.IsLocalGrid(regionURI) != 1)
|
||||
return rinfo; // not local grid
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(regionName))
|
||||
if (uri.HasRegionName)
|
||||
rinfo = m_RemoteGridService.GetRegionByName(scopeID, uri.RegionName);
|
||||
else
|
||||
{
|
||||
rinfo = m_RemoteGridService.GetDefaultRegions(UUID.Zero)[0];
|
||||
if (rinfo == null)
|
||||
@@ -334,8 +326,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
||||
else
|
||||
m_log.WarnFormat("[REMOTE GRID CONNECTOR] returned default region {0}", rinfo.RegionName);
|
||||
}
|
||||
else
|
||||
rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
|
||||
|
||||
m_RegionInfoCache.Cache(scopeID, rinfo);
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
@@ -369,6 +369,11 @@ namespace OpenSim.Services.Connectors
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
|
||||
@@ -529,18 +529,63 @@ namespace OpenSim.Services.GridService
|
||||
|
||||
public GridRegion GetRegionByName(UUID scopeID, string name)
|
||||
{
|
||||
RegionData rdata = m_Database.GetSpecific(name, scopeID);
|
||||
if (rdata != null)
|
||||
return RegionData2RegionInfo(rdata);
|
||||
var nameURI = new RegionURI(name);
|
||||
if (!nameURI.IsValid)
|
||||
return null;
|
||||
return GetRegionByURI(scopeID, nameURI);
|
||||
}
|
||||
|
||||
if (m_AllowHypergridMapSearch)
|
||||
public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri)
|
||||
{
|
||||
if (!uri.IsValid)
|
||||
return null;
|
||||
|
||||
bool localGrid = true;
|
||||
if (uri.HasHost)
|
||||
{
|
||||
GridRegion r = GetHypergridRegionByName(scopeID, name);
|
||||
if (r != null)
|
||||
return r;
|
||||
if (!uri.ResolveDNS())
|
||||
return null;
|
||||
localGrid = m_HypergridLinker.IsLocalGrid(uri.HostUrl);
|
||||
uri.IsLocalGrid = localGrid;
|
||||
}
|
||||
|
||||
return null;
|
||||
if (localGrid)
|
||||
{
|
||||
if(uri.HasRegionName)
|
||||
{
|
||||
RegionData rdata = m_Database.GetSpecific(uri.RegionName, scopeID);
|
||||
if (rdata != null)
|
||||
return RegionData2RegionInfo(rdata);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<GridRegion> defregs = GetDefaultRegions(scopeID);
|
||||
if (defregs != null)
|
||||
return defregs[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!m_AllowHypergridMapSearch)
|
||||
return null;
|
||||
|
||||
string mapname = uri.RegionHostPortSpaceName;
|
||||
List<RegionData> rdatas = m_Database.Get("%" + Util.EscapeForLike(mapname), scopeID);
|
||||
if (rdatas != null && rdatas.Count > 0)
|
||||
{
|
||||
foreach (RegionData rdata in rdatas)
|
||||
{
|
||||
int indx = rdata.RegionName.IndexOf("://");
|
||||
if (indx < 0)
|
||||
continue;
|
||||
string rname = rdata.RegionName.Substring(indx + 3);
|
||||
if (mapname.Equals(rname, StringComparison.InvariantCultureIgnoreCase))
|
||||
return RegionData2RegionInfo(rdata);
|
||||
}
|
||||
}
|
||||
|
||||
GridRegion r = m_HypergridLinker.LinkRegion(scopeID, uri);
|
||||
return r;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
|
||||
@@ -551,17 +596,6 @@ namespace OpenSim.Services.GridService
|
||||
if (!nameURI.IsValid)
|
||||
return new List<GridRegion>();
|
||||
|
||||
bool localGrid = true;
|
||||
if (nameURI.HasHost)
|
||||
{
|
||||
if (!nameURI.ResolveDNS())
|
||||
return new List<GridRegion>();
|
||||
localGrid = m_HypergridLinker.IsLocalGrid(nameURI.HostUrl);
|
||||
nameURI.IsLocalGrid = localGrid;
|
||||
if (!nameURI.IsValid)
|
||||
return new List<GridRegion>();
|
||||
}
|
||||
|
||||
return GetRegionsByURI(scopeID, nameURI, maxNumber);
|
||||
}
|
||||
|
||||
@@ -571,52 +605,31 @@ namespace OpenSim.Services.GridService
|
||||
if (!nameURI.IsValid)
|
||||
return new List<GridRegion>();
|
||||
|
||||
bool localGrid;
|
||||
if (nameURI.HasHost)
|
||||
{
|
||||
if (!nameURI.ResolveDNS())
|
||||
return new List<GridRegion>();
|
||||
localGrid = m_HypergridLinker.IsLocalGrid(nameURI.HostUrl);
|
||||
nameURI.IsLocalGrid = localGrid;
|
||||
if (!nameURI.IsValid)
|
||||
return new List<GridRegion>();
|
||||
}
|
||||
else
|
||||
localGrid = true;
|
||||
|
||||
int count = 0;
|
||||
|
||||
string mapname = nameURI.RegionHostPortSpaceName;
|
||||
List<RegionData> rdatas = m_Database.Get("%" + Util.EscapeForLike(mapname) + "%", scopeID);
|
||||
List<GridRegion> rinfos = new List<GridRegion>();
|
||||
|
||||
if (m_AllowHypergridMapSearch && nameURI.HasHost)
|
||||
{
|
||||
if (rdatas != null && (rdatas.Count > 0))
|
||||
{
|
||||
bool haveMatch = false;
|
||||
// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
|
||||
foreach (RegionData rdata in rdatas)
|
||||
{
|
||||
int indx = rdata.RegionName.IndexOf("://");
|
||||
if(indx < 0)
|
||||
continue;
|
||||
string rname = rdata.RegionName.Substring(indx + 3);
|
||||
if (mapname.Equals(rname, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
haveMatch = true;
|
||||
rinfos.Insert(0, RegionData2RegionInfo(rdata));
|
||||
if (count == maxNumber)
|
||||
rinfos.RemoveAt(count - 1);
|
||||
}
|
||||
else if (count++ < maxNumber)
|
||||
rinfos.Add(RegionData2RegionInfo(rdata));
|
||||
}
|
||||
if (haveMatch)
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
GridRegion r = m_HypergridLinker.LinkRegion(scopeID, nameURI);
|
||||
if (r != null)
|
||||
{
|
||||
if (count == maxNumber)
|
||||
rinfos.RemoveAt(count - 1);
|
||||
rinfos.Add(r);
|
||||
}
|
||||
}
|
||||
else
|
||||
if(localGrid)
|
||||
{
|
||||
if (!nameURI.HasRegionName)
|
||||
{
|
||||
List<GridRegion> dinfos = GetDefaultRegions(scopeID);
|
||||
if(dinfos != null && dinfos.Count >0)
|
||||
if (dinfos != null && dinfos.Count > 0)
|
||||
rinfos.Add(dinfos[0]);
|
||||
}
|
||||
else
|
||||
@@ -638,52 +651,45 @@ namespace OpenSim.Services.GridService
|
||||
}
|
||||
}
|
||||
}
|
||||
return rinfos;
|
||||
}
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a hypergrid region.
|
||||
/// </summary>
|
||||
/// <param name="scopeID"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns>null if no hypergrid region could be found.</returns>
|
||||
protected GridRegion GetHypergridRegionByName(UUID scopeID, string name)
|
||||
{
|
||||
if (name.Contains("."))
|
||||
if (!m_AllowHypergridMapSearch)
|
||||
return rinfos;
|
||||
|
||||
if (rdatas != null && (rdatas.Count > 0))
|
||||
{
|
||||
string regionURI = "";
|
||||
string regionName = "";
|
||||
if (!Util.buildHGRegionURI(name, out regionURI, out regionName))
|
||||
return null;
|
||||
|
||||
string mapname;
|
||||
bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
|
||||
if (localGrid)
|
||||
bool haveMatch = false;
|
||||
// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
|
||||
foreach (RegionData rdata in rdatas)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(regionName))
|
||||
int indx = rdata.RegionName.IndexOf("://");
|
||||
if(indx < 0)
|
||||
continue;
|
||||
string rname = rdata.RegionName.Substring(indx + 3);
|
||||
if (mapname.Equals(rname, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
List< GridRegion> defregs = GetDefaultRegions(scopeID);
|
||||
if(defregs == null)
|
||||
return null;
|
||||
return defregs[0];
|
||||
haveMatch = true;
|
||||
rinfos.Insert(0, RegionData2RegionInfo(rdata));
|
||||
if (count == maxNumber)
|
||||
rinfos.RemoveAt(count - 1);
|
||||
}
|
||||
mapname = regionName;
|
||||
}
|
||||
else
|
||||
mapname = regionURI + regionName;
|
||||
|
||||
List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID);
|
||||
if ((rdatas != null) && (rdatas.Count > 0))
|
||||
return RegionData2RegionInfo(rdatas[0]); // get the first
|
||||
|
||||
if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
|
||||
{
|
||||
string HGname = regionURI +" "+ regionName;
|
||||
return m_HypergridLinker.LinkRegion(scopeID, HGname);
|
||||
else if (count++ < maxNumber)
|
||||
rinfos.Add(RegionData2RegionInfo(rdata));
|
||||
}
|
||||
if (haveMatch)
|
||||
return rinfos;
|
||||
}
|
||||
return null;
|
||||
|
||||
GridRegion r = m_HypergridLinker.LinkRegion(scopeID, nameURI);
|
||||
if (r != null)
|
||||
{
|
||||
if (count == maxNumber)
|
||||
rinfos.RemoveAt(count - 1);
|
||||
rinfos.Add(r);
|
||||
}
|
||||
|
||||
return rinfos;
|
||||
}
|
||||
|
||||
public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace OpenSim.Services.Interfaces
|
||||
/// <param name="regionName"></param>
|
||||
/// <returns>Returns the region information if the name matched. Null otherwise.</returns>
|
||||
GridRegion GetRegionByName(UUID scopeID, string regionName);
|
||||
GridRegion GetRegionByURI(UUID scopeID, RegionURI uri);
|
||||
|
||||
/// <summary>
|
||||
/// Get information about regions starting with the provided name.
|
||||
|
||||
Reference in New Issue
Block a user