diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/IRegionData.cs | 4 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 130 | ||||
-rw-r--r-- | OpenSim/Services/Interfaces/IGridService.cs | 4 |
3 files changed, 128 insertions, 10 deletions
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 50433ba..ca9b327 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs | |||
@@ -52,12 +52,12 @@ namespace OpenSim.Data | |||
52 | public int sizeY; | 52 | public int sizeY; |
53 | 53 | ||
54 | /// <summary> | 54 | /// <summary> |
55 | /// Return the x-coordinate of this region. | 55 | /// Return the x-coordinate of this region in region units. |
56 | /// </summary> | 56 | /// </summary> |
57 | public int coordX { get { return (int)Util.WorldToRegionLoc((uint)posX); } } | 57 | public int coordX { get { return (int)Util.WorldToRegionLoc((uint)posX); } } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Return the y-coordinate of this region. | 60 | /// Return the y-coordinate of this region in region units. |
61 | /// </summary> | 61 | /// </summary> |
62 | public int coordY { get { return (int)Util.WorldToRegionLoc((uint)posY); } } | 62 | public int coordY { get { return (int)Util.WorldToRegionLoc((uint)posY); } } |
63 | 63 | ||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 3c1e9f3..c368ffc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -47,6 +47,8 @@ namespace OpenSim.Services.GridService | |||
47 | LogManager.GetLogger( | 47 | LogManager.GetLogger( |
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | private string LogHeader = "[GRID SERVICE]"; | ||
51 | |||
50 | private bool m_DeleteOnUnregister = true; | 52 | private bool m_DeleteOnUnregister = true; |
51 | private static GridService m_RootInstance = null; | 53 | private static GridService m_RootInstance = null; |
52 | protected IConfigSource m_config; | 54 | protected IConfigSource m_config; |
@@ -56,6 +58,8 @@ namespace OpenSim.Services.GridService | |||
56 | protected bool m_AllowDuplicateNames = false; | 58 | protected bool m_AllowDuplicateNames = false; |
57 | protected bool m_AllowHypergridMapSearch = false; | 59 | protected bool m_AllowHypergridMapSearch = false; |
58 | 60 | ||
61 | protected bool m_SuppressVarregionOverlapCheckOnRegistration = false; | ||
62 | |||
59 | public GridService(IConfigSource config) | 63 | public GridService(IConfigSource config) |
60 | : base(config) | 64 | : base(config) |
61 | { | 65 | { |
@@ -75,7 +79,8 @@ namespace OpenSim.Services.GridService | |||
75 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); | 79 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); |
76 | } | 80 | } |
77 | m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); | 81 | m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); |
78 | m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); | 82 | m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); |
83 | m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration); | ||
79 | } | 84 | } |
80 | 85 | ||
81 | if (m_RootInstance == null) | 86 | if (m_RootInstance == null) |
@@ -144,12 +149,19 @@ namespace OpenSim.Services.GridService | |||
144 | if (regionInfos.RegionID == UUID.Zero) | 149 | if (regionInfos.RegionID == UUID.Zero) |
145 | return "Invalid RegionID - cannot be zero UUID"; | 150 | return "Invalid RegionID - cannot be zero UUID"; |
146 | 151 | ||
147 | RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | 152 | String reason = "Region overlaps another region"; |
148 | if ((region != null) && (region.RegionID != regionInfos.RegionID)) | 153 | RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); |
154 | // If there is a conflicting region, if it has the same ID and same coordinates | ||
155 | // then it is a region re-registering (permissions and ownership checked later). | ||
156 | if ((region != null) | ||
157 | && ( (region.coordX != regionInfos.RegionCoordX) | ||
158 | || (region.coordY != regionInfos.RegionCoordY) | ||
159 | || (region.RegionID != regionInfos.RegionID) ) | ||
160 | ) | ||
149 | { | 161 | { |
150 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | 162 | // If not same ID and same coordinates, this new region has conflicts and can't be registered. |
151 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | 163 | m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason); |
152 | return "Region overlaps another region"; | 164 | return reason; |
153 | } | 165 | } |
154 | 166 | ||
155 | if (region != null) | 167 | if (region != null) |
@@ -279,6 +291,112 @@ namespace OpenSim.Services.GridService | |||
279 | return String.Empty; | 291 | return String.Empty; |
280 | } | 292 | } |
281 | 293 | ||
294 | /// <summary> | ||
295 | /// Search the region map for regions conflicting with this region. | ||
296 | /// The region to be added is passed and we look for any existing regions that are | ||
297 | /// in the requested location, that are large varregions that overlap this region, or | ||
298 | /// are previously defined regions that would lie under this new region. | ||
299 | /// </summary> | ||
300 | /// <param name="regionInfos">Information on region requested to be added to the world map</param> | ||
301 | /// <param name="scopeID">Grid id for region</param> | ||
302 | /// <param name="reason">The reason the returned region conflicts with passed region</param> | ||
303 | /// <returns></returns> | ||
304 | private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason) | ||
305 | { | ||
306 | reason = "Reregistration"; | ||
307 | // First see if there is an existing region right where this region is trying to go | ||
308 | // (We keep this result so it can be returned if suppressing errors) | ||
309 | RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | ||
310 | RegionData region = noErrorRegion; | ||
311 | if (region != null | ||
312 | && region.RegionID == regionInfos.RegionID | ||
313 | && region.sizeX == regionInfos.RegionSizeX | ||
314 | && region.sizeY == regionInfos.RegionSizeY) | ||
315 | { | ||
316 | // If this seems to be exactly the same region, return this as it could be | ||
317 | // a re-registration (permissions checked by calling routine). | ||
318 | m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}", | ||
319 | LogHeader, RegionString(regionInfos)); | ||
320 | return region; | ||
321 | } | ||
322 | |||
323 | // No region exactly there or we're resizing an existing region. | ||
324 | // Fetch regions that could be varregions overlapping requested location. | ||
325 | int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10; | ||
326 | int xmax = regionInfos.RegionLocX; | ||
327 | int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10; | ||
328 | int ymax = regionInfos.RegionLocY; | ||
329 | List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | ||
330 | foreach (RegionData rdata in rdatas) | ||
331 | { | ||
332 | // m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) ); | ||
333 | if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX) | ||
334 | && (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) ) | ||
335 | { | ||
336 | region = rdata; | ||
337 | m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}", | ||
338 | LogHeader, RegionString(regionInfos), RegionString(region)); | ||
339 | reason = String.Format("Region location is overlapped by existing varregion {0}", | ||
340 | RegionString(region)); | ||
341 | |||
342 | if (m_SuppressVarregionOverlapCheckOnRegistration) | ||
343 | region = noErrorRegion; | ||
344 | return region; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | // There isn't a region that overlaps this potential region. | ||
349 | // See if this potential region overlaps an existing region. | ||
350 | // First, a shortcut of not looking for overlap if new region is legacy region sized | ||
351 | // and connot overlap anything. | ||
352 | if (regionInfos.RegionSizeX != Constants.RegionSize | ||
353 | || regionInfos.RegionSizeY != Constants.RegionSize) | ||
354 | { | ||
355 | // trim range looked for so we don't pick up neighbor regions just off the edges | ||
356 | xmin = regionInfos.RegionLocX; | ||
357 | xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10; | ||
358 | ymin = regionInfos.RegionLocY; | ||
359 | ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10; | ||
360 | rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | ||
361 | |||
362 | // If the region is being resized, the found region could be ourself. | ||
363 | foreach (RegionData rdata in rdatas) | ||
364 | { | ||
365 | // m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) ); | ||
366 | if (region == null || region.RegionID != regionInfos.RegionID) | ||
367 | { | ||
368 | region = rdata; | ||
369 | m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}", | ||
370 | LogHeader, RegionString(regionInfos), RegionString(region)); | ||
371 | reason = String.Format("Region {0} would overlap existing region {1}", | ||
372 | RegionString(regionInfos), RegionString(region)); | ||
373 | |||
374 | if (m_SuppressVarregionOverlapCheckOnRegistration) | ||
375 | region = noErrorRegion; | ||
376 | return region; | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | |||
381 | // If we get here, region is either null (nothing found here) or | ||
382 | // is the non-conflicting region found at the location being requested. | ||
383 | return region; | ||
384 | } | ||
385 | |||
386 | // String describing name and region location of passed region | ||
387 | private String RegionString(RegionData reg) | ||
388 | { | ||
389 | return String.Format("{0}/{1} at <{2},{3}>", | ||
390 | reg.RegionName, reg.RegionID, reg.coordX, reg.coordY); | ||
391 | } | ||
392 | |||
393 | // String describing name and region location of passed region | ||
394 | private String RegionString(GridRegion reg) | ||
395 | { | ||
396 | return String.Format("{0}/{1} at <{2},{3}>", | ||
397 | reg.RegionName, reg.RegionID, reg.RegionCoordX, reg.RegionCoordY); | ||
398 | } | ||
399 | |||
282 | public bool DeregisterRegion(UUID regionID) | 400 | public bool DeregisterRegion(UUID regionID) |
283 | { | 401 | { |
284 | RegionData region = m_Database.Get(regionID, UUID.Zero); | 402 | RegionData region = m_Database.Get(regionID, UUID.Zero); |
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index dec3d35..b7bcd6b 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -186,12 +186,12 @@ namespace OpenSim.Services.Interfaces | |||
186 | protected IPEndPoint m_internalEndPoint; | 186 | protected IPEndPoint m_internalEndPoint; |
187 | 187 | ||
188 | /// <summary> | 188 | /// <summary> |
189 | /// The co-ordinate of this region. | 189 | /// The co-ordinate of this region in region units. |
190 | /// </summary> | 190 | /// </summary> |
191 | public int RegionCoordX { get { return (int)Util.WorldToRegionLoc((uint)RegionLocX); } } | 191 | public int RegionCoordX { get { return (int)Util.WorldToRegionLoc((uint)RegionLocX); } } |
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
194 | /// The co-ordinate of this region | 194 | /// The co-ordinate of this region in region units |
195 | /// </summary> | 195 | /// </summary> |
196 | public int RegionCoordY { get { return (int)Util.WorldToRegionLoc((uint)RegionLocY); } } | 196 | public int RegionCoordY { get { return (int)Util.WorldToRegionLoc((uint)RegionLocY); } } |
197 | 197 | ||