|
@@ -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,7 +596,16 @@ namespace OpenSim.Services.GridService
|
|
|
if (!nameURI.IsValid)
|
|
|
return new List<GridRegion>();
|
|
|
|
|
|
- bool localGrid = true;
|
|
|
+ return GetRegionsByURI(scopeID, nameURI, maxNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<GridRegion> GetRegionsByURI(UUID scopeID, RegionURI nameURI, int maxNumber)
|
|
|
+ {
|
|
|
+ // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name);
|
|
|
+ if (!nameURI.IsValid)
|
|
|
+ return new List<GridRegion>();
|
|
|
+
|
|
|
+ bool localGrid;
|
|
|
if (nameURI.HasHost)
|
|
|
{
|
|
|
if (!nameURI.ResolveDNS())
|
|
@@ -561,15 +615,8 @@ namespace OpenSim.Services.GridService
|
|
|
if (!nameURI.IsValid)
|
|
|
return new List<GridRegion>();
|
|
|
}
|
|
|
-
|
|
|
- return GetRegionsByURI(scopeID, nameURI, maxNumber);
|
|
|
- }
|
|
|
-
|
|
|
- public List<GridRegion> GetRegionsByURI(UUID scopeID, RegionURI nameURI, int maxNumber)
|
|
|
- {
|
|
|
- // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name);
|
|
|
- if (!nameURI.IsValid)
|
|
|
- return new List<GridRegion>();
|
|
|
+ else
|
|
|
+ localGrid = true;
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
@@ -577,46 +624,12 @@ namespace OpenSim.Services.GridService
|
|
|
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("."))
|
|
|
- {
|
|
|
- string regionURI = "";
|
|
|
- string regionName = "";
|
|
|
- if (!Util.buildHGRegionURI(name, out regionURI, out regionName))
|
|
|
- return null;
|
|
|
+ if (!m_AllowHypergridMapSearch)
|
|
|
+ return rinfos;
|
|
|
|
|
|
- string mapname;
|
|
|
- bool localGrid = m_HypergridLinker.IsLocalGrid(regionURI);
|
|
|
- if (localGrid)
|
|
|
+ if (rdatas != null && (rdatas.Count > 0))
|
|
|
+ {
|
|
|
+ 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 if (count++ < maxNumber)
|
|
|
+ rinfos.Add(RegionData2RegionInfo(rdata));
|
|
|
}
|
|
|
- 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 (haveMatch)
|
|
|
+ return rinfos;
|
|
|
+ }
|
|
|
|
|
|
- if(!localGrid && !string.IsNullOrWhiteSpace(regionURI))
|
|
|
- {
|
|
|
- string HGname = regionURI +" "+ regionName;
|
|
|
- return m_HypergridLinker.LinkRegion(scopeID, HGname);
|
|
|
- }
|
|
|
+ GridRegion r = m_HypergridLinker.LinkRegion(scopeID, nameURI);
|
|
|
+ if (r != null)
|
|
|
+ {
|
|
|
+ if (count == maxNumber)
|
|
|
+ rinfos.RemoveAt(count - 1);
|
|
|
+ rinfos.Add(r);
|
|
|
}
|
|
|
- return null;
|
|
|
+
|
|
|
+ return rinfos;
|
|
|
}
|
|
|
|
|
|
public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
|