diff options
author | Marck | 2010-08-06 07:46:19 +0200 |
---|---|---|
committer | Diva Canto | 2010-08-06 17:02:03 -0700 |
commit | 7e47ab746ef588648b8edbbc7cfb48c4d90c5e34 (patch) | |
tree | 0ba450dffb35724504634f88cc21b9c59a983130 /OpenSim/Services/GridService | |
parent | Remove old test classes that don't actually test anything not done elsewhere (diff) | |
download | opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.zip opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.tar.gz opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.tar.bz2 opensim-SC-7e47ab746ef588648b8edbbc7cfb48c4d90c5e34.tar.xz |
Allow creation of link regions if there is an existing region within a 4096 range.
Also add GetHyperlinks() to the grid service.
Diffstat (limited to 'OpenSim/Services/GridService')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 16 | ||||
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 34 |
2 files changed, 46 insertions, 4 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ebaed42..79a45fe 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -426,6 +426,22 @@ namespace OpenSim.Services.GridService | |||
426 | return ret; | 426 | return ret; |
427 | } | 427 | } |
428 | 428 | ||
429 | public List<GridRegion> GetHyperlinks(UUID scopeID) | ||
430 | { | ||
431 | List<GridRegion> ret = new List<GridRegion>(); | ||
432 | |||
433 | List<RegionData> regions = m_Database.GetHyperlinks(scopeID); | ||
434 | |||
435 | foreach (RegionData r in regions) | ||
436 | { | ||
437 | if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) | ||
438 | ret.Add(RegionData2RegionInfo(r)); | ||
439 | } | ||
440 | |||
441 | m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); | ||
442 | return ret; | ||
443 | } | ||
444 | |||
429 | public int GetRegionFlags(UUID scopeID, UUID regionID) | 445 | public int GetRegionFlags(UUID scopeID, UUID regionID) |
430 | { | 446 | { |
431 | RegionData region = m_Database.Get(regionID, scopeID); | 447 | RegionData region = m_Database.Get(regionID, scopeID); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 1f53007..017df41 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
30 | using System.Net; | 31 | using System.Net; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Xml; | 33 | using System.Xml; |
@@ -332,18 +333,43 @@ namespace OpenSim.Services.GridService | |||
332 | /// <returns></returns> | 333 | /// <returns></returns> |
333 | public bool Check4096(ulong realHandle, out uint x, out uint y) | 334 | public bool Check4096(ulong realHandle, out uint x, out uint y) |
334 | { | 335 | { |
335 | GridRegion defRegion = DefaultRegion; | ||
336 | |||
337 | uint ux = 0, uy = 0; | 336 | uint ux = 0, uy = 0; |
338 | Utils.LongToUInts(realHandle, out ux, out uy); | 337 | Utils.LongToUInts(realHandle, out ux, out uy); |
339 | x = ux / Constants.RegionSize; | 338 | x = ux / Constants.RegionSize; |
340 | y = uy / Constants.RegionSize; | 339 | y = uy / Constants.RegionSize; |
341 | 340 | ||
342 | if ((Math.Abs((int)defRegion.RegionLocX - ux) >= 4096 * Constants.RegionSize) || | 341 | const uint limit = (4096 - 1) * Constants.RegionSize; |
343 | (Math.Abs((int)defRegion.RegionLocY - uy) >= 4096 * Constants.RegionSize)) | 342 | uint xmin = ux - limit; |
343 | uint xmax = ux + limit; | ||
344 | uint ymin = uy - limit; | ||
345 | uint ymax = uy + limit; | ||
346 | // World map boundary checks | ||
347 | if (xmin < 0 || xmin > ux) | ||
348 | xmin = 0; | ||
349 | if (xmax > int.MaxValue || xmax < ux) | ||
350 | xmax = int.MaxValue; | ||
351 | if (ymin < 0 || ymin > uy) | ||
352 | ymin = 0; | ||
353 | if (ymax > int.MaxValue || ymax < uy) | ||
354 | ymax = int.MaxValue; | ||
355 | |||
356 | // Check for any regions that are within the possible teleport range to the linked region | ||
357 | List<GridRegion> regions = m_GridService.GetRegionRange(m_ScopeID, (int)xmin, (int)xmax, (int)ymin, (int)ymax); | ||
358 | if (regions.Count == 0) | ||
359 | { | ||
360 | return false; | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | // Check for regions which are not linked regions | ||
365 | List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(m_ScopeID); | ||
366 | IEnumerable<GridRegion> availableRegions = regions.Except(hyperlinks); | ||
367 | if (availableRegions.Count() == 0) | ||
344 | { | 368 | { |
345 | return false; | 369 | return false; |
346 | } | 370 | } |
371 | } | ||
372 | |||
347 | return true; | 373 | return true; |
348 | } | 374 | } |
349 | 375 | ||