fix region overlaps on registration
parent
cfb98050f7
commit
8299941517
|
@ -202,10 +202,24 @@ namespace OpenSim.Services.GridService
|
||||||
if (regionInfos.RegionID == UUID.Zero)
|
if (regionInfos.RegionID == UUID.Zero)
|
||||||
return "Invalid RegionID - cannot be zero UUID";
|
return "Invalid RegionID - cannot be zero UUID";
|
||||||
|
|
||||||
String reason = "Region overlaps another region";
|
String reason = "Region overlaps another region";
|
||||||
// we should not need to check for overlaps
|
|
||||||
|
List<RegionData> rdatas = m_Database.Get(
|
||||||
|
regionInfos.RegionLocX,
|
||||||
|
regionInfos.RegionLocY,
|
||||||
|
regionInfos.RegionLocX + regionInfos.RegionSizeX,
|
||||||
|
regionInfos.RegionLocY + regionInfos.RegionSizeY,
|
||||||
|
scopeID);
|
||||||
|
|
||||||
|
RegionData region = null;
|
||||||
|
if(rdatas.Count > 1)
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("{0} Register region overlaps with {1} regions", LogHeader, scopeID, rdatas.Count);
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
else if(rdatas.Count == 1)
|
||||||
|
region = rdatas[0];
|
||||||
|
|
||||||
RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
|
|
||||||
if ((region != null) && (region.RegionID != regionInfos.RegionID))
|
if ((region != null) && (region.RegionID != regionInfos.RegionID))
|
||||||
{
|
{
|
||||||
// If not same ID and same coordinates, this new region has conflicts and can't be registered.
|
// If not same ID and same coordinates, this new region has conflicts and can't be registered.
|
||||||
|
@ -341,99 +355,7 @@ namespace OpenSim.Services.GridService
|
||||||
|
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
/// <summary>
|
|
||||||
/// Search the region map for regions conflicting with this region.
|
|
||||||
/// The region to be added is passed and we look for any existing regions that are
|
|
||||||
/// in the requested location, that are large varregions that overlap this region, or
|
|
||||||
/// are previously defined regions that would lie under this new region.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="regionInfos">Information on region requested to be added to the world map</param>
|
|
||||||
/// <param name="scopeID">Grid id for region</param>
|
|
||||||
/// <param name="reason">The reason the returned region conflicts with passed region</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason)
|
|
||||||
{
|
|
||||||
reason = "Reregistration";
|
|
||||||
// First see if there is an existing region right where this region is trying to go
|
|
||||||
// (We keep this result so it can be returned if suppressing errors)
|
|
||||||
RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
|
|
||||||
RegionData region = noErrorRegion;
|
|
||||||
if (region != null
|
|
||||||
&& region.RegionID == regionInfos.RegionID
|
|
||||||
&& region.sizeX == regionInfos.RegionSizeX
|
|
||||||
&& region.sizeY == regionInfos.RegionSizeY)
|
|
||||||
{
|
|
||||||
// If this seems to be exactly the same region, return this as it could be
|
|
||||||
// a re-registration (permissions checked by calling routine).
|
|
||||||
m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}",
|
|
||||||
LogHeader, RegionString(regionInfos));
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No region exactly there or we're resizing an existing region.
|
|
||||||
// Fetch regions that could be varregions overlapping requested location.
|
|
||||||
int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10;
|
|
||||||
int xmax = regionInfos.RegionLocX;
|
|
||||||
int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10;
|
|
||||||
int ymax = regionInfos.RegionLocY;
|
|
||||||
List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
|
|
||||||
foreach (RegionData rdata in rdatas)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) );
|
|
||||||
if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX)
|
|
||||||
&& (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) )
|
|
||||||
{
|
|
||||||
region = rdata;
|
|
||||||
m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}",
|
|
||||||
LogHeader, RegionString(regionInfos), RegionString(region));
|
|
||||||
reason = String.Format("Region location is overlapped by existing varregion {0}",
|
|
||||||
RegionString(region));
|
|
||||||
|
|
||||||
if (m_SuppressVarregionOverlapCheckOnRegistration)
|
|
||||||
region = noErrorRegion;
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// There isn't a region that overlaps this potential region.
|
|
||||||
// See if this potential region overlaps an existing region.
|
|
||||||
// First, a shortcut of not looking for overlap if new region is legacy region sized
|
|
||||||
// and connot overlap anything.
|
|
||||||
if (regionInfos.RegionSizeX != Constants.RegionSize
|
|
||||||
|| regionInfos.RegionSizeY != Constants.RegionSize)
|
|
||||||
{
|
|
||||||
// trim range looked for so we don't pick up neighbor regions just off the edges
|
|
||||||
xmin = regionInfos.RegionLocX;
|
|
||||||
xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10;
|
|
||||||
ymin = regionInfos.RegionLocY;
|
|
||||||
ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10;
|
|
||||||
rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID);
|
|
||||||
|
|
||||||
// If the region is being resized, the found region could be ourself.
|
|
||||||
foreach (RegionData rdata in rdatas)
|
|
||||||
{
|
|
||||||
// m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) );
|
|
||||||
if (region == null || region.RegionID != regionInfos.RegionID)
|
|
||||||
{
|
|
||||||
region = rdata;
|
|
||||||
m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}",
|
|
||||||
LogHeader, RegionString(regionInfos), RegionString(region));
|
|
||||||
reason = String.Format("Region {0} would overlap existing region {1}",
|
|
||||||
RegionString(regionInfos), RegionString(region));
|
|
||||||
|
|
||||||
if (m_SuppressVarregionOverlapCheckOnRegistration)
|
|
||||||
region = noErrorRegion;
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, region is either null (nothing found here) or
|
|
||||||
// is the non-conflicting region found at the location being requested.
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// String describing name and region location of passed region
|
// String describing name and region location of passed region
|
||||||
private String RegionString(RegionData reg)
|
private String RegionString(RegionData reg)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue