diff options
Diffstat (limited to 'OpenSim/Services/GridService')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 23 | ||||
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 61 |
2 files changed, 51 insertions, 33 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e72b7f9..8198592 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -313,8 +313,10 @@ namespace OpenSim.Services.GridService | |||
313 | if (region != null) | 313 | if (region != null) |
314 | { | 314 | { |
315 | // Not really? Maybe? | 315 | // Not really? Maybe? |
316 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, | 316 | // The adjacent regions are presumed to be the same size as the current region |
317 | region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); | 317 | List<RegionData> rdatas = m_Database.Get( |
318 | region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, | ||
319 | region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); | ||
318 | 320 | ||
319 | foreach (RegionData rdata in rdatas) | 321 | foreach (RegionData rdata in rdatas) |
320 | { | 322 | { |
@@ -347,6 +349,11 @@ namespace OpenSim.Services.GridService | |||
347 | return null; | 349 | return null; |
348 | } | 350 | } |
349 | 351 | ||
352 | // Get a region given its base coordinates. | ||
353 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
354 | // be the base coordinate of the region. | ||
355 | // The snapping is technically unnecessary but is harmless because regions are always | ||
356 | // multiples of the legacy region size (256). | ||
350 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 357 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
351 | { | 358 | { |
352 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; | 359 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; |
@@ -441,6 +448,8 @@ namespace OpenSim.Services.GridService | |||
441 | RegionData rdata = new RegionData(); | 448 | RegionData rdata = new RegionData(); |
442 | rdata.posX = (int)rinfo.RegionLocX; | 449 | rdata.posX = (int)rinfo.RegionLocX; |
443 | rdata.posY = (int)rinfo.RegionLocY; | 450 | rdata.posY = (int)rinfo.RegionLocY; |
451 | rdata.sizeX = rinfo.RegionSizeX; | ||
452 | rdata.sizeY = rinfo.RegionSizeY; | ||
444 | rdata.RegionID = rinfo.RegionID; | 453 | rdata.RegionID = rinfo.RegionID; |
445 | rdata.RegionName = rinfo.RegionName; | 454 | rdata.RegionName = rinfo.RegionName; |
446 | rdata.Data = rinfo.ToKeyValuePairs(); | 455 | rdata.Data = rinfo.ToKeyValuePairs(); |
@@ -454,6 +463,8 @@ namespace OpenSim.Services.GridService | |||
454 | GridRegion rinfo = new GridRegion(rdata.Data); | 463 | GridRegion rinfo = new GridRegion(rdata.Data); |
455 | rinfo.RegionLocX = rdata.posX; | 464 | rinfo.RegionLocX = rdata.posX; |
456 | rinfo.RegionLocY = rdata.posY; | 465 | rinfo.RegionLocY = rdata.posY; |
466 | rinfo.RegionSizeX = rdata.sizeX; | ||
467 | rinfo.RegionSizeY = rdata.sizeY; | ||
457 | rinfo.RegionID = rdata.RegionID; | 468 | rinfo.RegionID = rdata.RegionID; |
458 | rinfo.RegionName = rdata.RegionName; | 469 | rinfo.RegionName = rdata.RegionName; |
459 | rinfo.ScopeID = rdata.ScopeID; | 470 | rinfo.ScopeID = rdata.ScopeID; |
@@ -633,20 +644,20 @@ namespace OpenSim.Services.GridService | |||
633 | return; | 644 | return; |
634 | } | 645 | } |
635 | 646 | ||
636 | int x, y; | 647 | uint x, y; |
637 | if (!int.TryParse(cmd[3], out x)) | 648 | if (!uint.TryParse(cmd[3], out x)) |
638 | { | 649 | { |
639 | MainConsole.Instance.Output("x-coord must be an integer"); | 650 | MainConsole.Instance.Output("x-coord must be an integer"); |
640 | return; | 651 | return; |
641 | } | 652 | } |
642 | 653 | ||
643 | if (!int.TryParse(cmd[4], out y)) | 654 | if (!uint.TryParse(cmd[4], out y)) |
644 | { | 655 | { |
645 | MainConsole.Instance.Output("y-coord must be an integer"); | 656 | MainConsole.Instance.Output("y-coord must be an integer"); |
646 | return; | 657 | return; |
647 | } | 658 | } |
648 | 659 | ||
649 | RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero); | 660 | RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); |
650 | if (region == null) | 661 | if (region == null) |
651 | { | 662 | { |
652 | MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); | 663 | MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 4024295..4ebfd5c 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -183,8 +183,8 @@ namespace OpenSim.Services.GridService | |||
183 | public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) | 183 | public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) |
184 | { | 184 | { |
185 | string reason = string.Empty; | 185 | string reason = string.Empty; |
186 | int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; | 186 | uint xloc = Util.RegionToWorldLoc((uint)random.Next(0, Int16.MaxValue)); |
187 | return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason); | 187 | return TryLinkRegionToCoords(scopeID, regionDescriptor, (int)xloc, 0, out reason); |
188 | } | 188 | } |
189 | 189 | ||
190 | private static Random random = new Random(); | 190 | private static Random random = new Random(); |
@@ -260,7 +260,7 @@ namespace OpenSim.Services.GridService | |||
260 | { | 260 | { |
261 | m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", | 261 | m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", |
262 | ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), | 262 | ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), |
263 | remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize); | 263 | remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc)); |
264 | 264 | ||
265 | reason = string.Empty; | 265 | reason = string.Empty; |
266 | Uri uri = null; | 266 | Uri uri = null; |
@@ -311,7 +311,7 @@ namespace OpenSim.Services.GridService | |||
311 | if (region != null) | 311 | if (region != null) |
312 | { | 312 | { |
313 | m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", | 313 | m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", |
314 | regInfo.RegionLocX / Constants.RegionSize, regInfo.RegionLocY / Constants.RegionSize, | 314 | Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY), |
315 | region.RegionName, region.RegionID); | 315 | region.RegionName, region.RegionID); |
316 | reason = "Coordinates are already in use"; | 316 | reason = "Coordinates are already in use"; |
317 | return false; | 317 | return false; |
@@ -347,7 +347,7 @@ namespace OpenSim.Services.GridService | |||
347 | if (region != null) | 347 | if (region != null) |
348 | { | 348 | { |
349 | m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", | 349 | m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", |
350 | region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); | 350 | Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY)); |
351 | regInfo = region; | 351 | regInfo = region; |
352 | return true; | 352 | return true; |
353 | } | 353 | } |
@@ -424,10 +424,10 @@ namespace OpenSim.Services.GridService | |||
424 | // { | 424 | // { |
425 | // uint ux = 0, uy = 0; | 425 | // uint ux = 0, uy = 0; |
426 | // Utils.LongToUInts(realHandle, out ux, out uy); | 426 | // Utils.LongToUInts(realHandle, out ux, out uy); |
427 | // x = ux / Constants.RegionSize; | 427 | // x = Util.WorldToRegionLoc(ux); |
428 | // y = uy / Constants.RegionSize; | 428 | // y = Util.WorldToRegionLoc(uy); |
429 | // | 429 | // |
430 | // const uint limit = (4096 - 1) * Constants.RegionSize; | 430 | // const uint limit = Util.RegionToWorldLoc(4096 - 1); |
431 | // uint xmin = ux - limit; | 431 | // uint xmin = ux - limit; |
432 | // uint xmax = ux + limit; | 432 | // uint xmax = ux + limit; |
433 | // uint ymin = uy - limit; | 433 | // uint ymin = uy - limit; |
@@ -502,9 +502,14 @@ namespace OpenSim.Services.GridService | |||
502 | MainConsole.Instance.Output(new string('-', 72)); | 502 | MainConsole.Instance.Output(new string('-', 72)); |
503 | foreach (RegionData r in regions) | 503 | foreach (RegionData r in regions) |
504 | { | 504 | { |
505 | MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n", | 505 | MainConsole.Instance.Output( |
506 | r.RegionName, r.RegionID, String.Format("{0},{1} ({2},{3})", r.posX, r.posY, | 506 | String.Format("{0}\n{2,-32} {1}\n", |
507 | r.posX / Constants.RegionSize, r.posY / Constants.RegionSize))); | 507 | r.RegionName, r.RegionID, |
508 | String.Format("{0},{1} ({2},{3})", r.posX, r.posY, | ||
509 | Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY) | ||
510 | ) | ||
511 | ) | ||
512 | ); | ||
508 | } | 513 | } |
509 | return; | 514 | return; |
510 | } | 515 | } |
@@ -529,8 +534,8 @@ namespace OpenSim.Services.GridService | |||
529 | int xloc, yloc; | 534 | int xloc, yloc; |
530 | string serverURI; | 535 | string serverURI; |
531 | string remoteName = null; | 536 | string remoteName = null; |
532 | xloc = Convert.ToInt32(cmdparams[0]) * (int)Constants.RegionSize; | 537 | xloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[0])); |
533 | yloc = Convert.ToInt32(cmdparams[1]) * (int)Constants.RegionSize; | 538 | yloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[1])); |
534 | serverURI = cmdparams[2]; | 539 | serverURI = cmdparams[2]; |
535 | if (cmdparams.Length > 3) | 540 | if (cmdparams.Length > 3) |
536 | remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3); | 541 | remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3); |
@@ -601,13 +606,13 @@ namespace OpenSim.Services.GridService | |||
601 | { | 606 | { |
602 | // old format | 607 | // old format |
603 | GridRegion regInfo; | 608 | GridRegion regInfo; |
604 | int xloc, yloc; | 609 | uint xloc, yloc; |
605 | uint externalPort; | 610 | uint externalPort; |
606 | string externalHostName; | 611 | string externalHostName; |
607 | try | 612 | try |
608 | { | 613 | { |
609 | xloc = Convert.ToInt32(cmdparams[0]); | 614 | xloc = Convert.ToUInt32(cmdparams[0]); |
610 | yloc = Convert.ToInt32(cmdparams[1]); | 615 | yloc = Convert.ToUInt32(cmdparams[1]); |
611 | externalPort = Convert.ToUInt32(cmdparams[3]); | 616 | externalPort = Convert.ToUInt32(cmdparams[3]); |
612 | externalHostName = cmdparams[2]; | 617 | externalHostName = cmdparams[2]; |
613 | //internalPort = Convert.ToUInt32(cmdparams[4]); | 618 | //internalPort = Convert.ToUInt32(cmdparams[4]); |
@@ -621,10 +626,11 @@ namespace OpenSim.Services.GridService | |||
621 | } | 626 | } |
622 | 627 | ||
623 | // Convert cell coordinates given by the user to meters | 628 | // Convert cell coordinates given by the user to meters |
624 | xloc = xloc * (int)Constants.RegionSize; | 629 | xloc = Util.RegionToWorldLoc(xloc); |
625 | yloc = yloc * (int)Constants.RegionSize; | 630 | yloc = Util.RegionToWorldLoc(yloc); |
626 | string reason = string.Empty; | 631 | string reason = string.Empty; |
627 | if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | 632 | if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc, |
633 | string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | ||
628 | { | 634 | { |
629 | // What is this? The GridRegion instance will be discarded anyway, | 635 | // What is this? The GridRegion instance will be discarded anyway, |
630 | // which effectively ignores any local name given with the command. | 636 | // which effectively ignores any local name given with the command. |
@@ -704,13 +710,13 @@ namespace OpenSim.Services.GridService | |||
704 | private void ReadLinkFromConfig(IConfig config) | 710 | private void ReadLinkFromConfig(IConfig config) |
705 | { | 711 | { |
706 | GridRegion regInfo; | 712 | GridRegion regInfo; |
707 | int xloc, yloc; | 713 | uint xloc, yloc; |
708 | uint externalPort; | 714 | uint externalPort; |
709 | string externalHostName; | 715 | string externalHostName; |
710 | uint realXLoc, realYLoc; | 716 | uint realXLoc, realYLoc; |
711 | 717 | ||
712 | xloc = Convert.ToInt32(config.GetString("xloc", "0")); | 718 | xloc = Convert.ToUInt32(config.GetString("xloc", "0")); |
713 | yloc = Convert.ToInt32(config.GetString("yloc", "0")); | 719 | yloc = Convert.ToUInt32(config.GetString("yloc", "0")); |
714 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); | 720 | externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); |
715 | externalHostName = config.GetString("externalHostName", ""); | 721 | externalHostName = config.GetString("externalHostName", ""); |
716 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); | 722 | realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); |
@@ -718,18 +724,19 @@ namespace OpenSim.Services.GridService | |||
718 | 724 | ||
719 | if (m_enableAutoMapping) | 725 | if (m_enableAutoMapping) |
720 | { | 726 | { |
721 | xloc = (int)((xloc % 100) + m_autoMappingX); | 727 | xloc = (xloc % 100) + m_autoMappingX; |
722 | yloc = (int)((yloc % 100) + m_autoMappingY); | 728 | yloc = (yloc % 100) + m_autoMappingY; |
723 | } | 729 | } |
724 | 730 | ||
725 | if (((realXLoc == 0) && (realYLoc == 0)) || | 731 | if (((realXLoc == 0) && (realYLoc == 0)) || |
726 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && | 732 | (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && |
727 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) | 733 | ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) |
728 | { | 734 | { |
729 | xloc = xloc * (int)Constants.RegionSize; | 735 | xloc = Util.RegionToWorldLoc(xloc); |
730 | yloc = yloc * (int)Constants.RegionSize; | 736 | yloc = Util.RegionToWorldLoc(yloc); |
731 | string reason = string.Empty; | 737 | string reason = string.Empty; |
732 | if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | 738 | if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc, |
739 | string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) | ||
733 | { | 740 | { |
734 | regInfo.RegionName = config.GetString("localName", ""); | 741 | regInfo.RegionName = config.GetString("localName", ""); |
735 | } | 742 | } |