aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/GridService/GridService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/GridService/GridService.cs')
-rw-r--r--OpenSim/Services/GridService/GridService.cs99
1 files changed, 69 insertions, 30 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 7f71835..76415ce 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Services.GridService
86 { 86 {
87 MainConsole.Instance.Commands.AddCommand("Regions", true, 87 MainConsole.Instance.Commands.AddCommand("Regions", true,
88 "deregister region id", 88 "deregister region id",
89 "deregister region id <Region UUID>", 89 "deregister region id <region-id>+",
90 "Deregister a region manually.", 90 "Deregister a region manually.",
91 String.Empty, 91 String.Empty,
92 HandleDeregisterRegion); 92 HandleDeregisterRegion);
@@ -265,8 +265,9 @@ namespace OpenSim.Services.GridService
265 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); 265 m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
266 } 266 }
267 267
268 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", 268 m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3} with flags {4}",
269 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY); 269 regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY,
270 (OpenSim.Framework.RegionFlags)flags);
270 271
271 return String.Empty; 272 return String.Empty;
272 } 273 }
@@ -311,8 +312,9 @@ namespace OpenSim.Services.GridService
311 if (region != null) 312 if (region != null)
312 { 313 {
313 // Not really? Maybe? 314 // Not really? Maybe?
314 List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, 315 List<RegionData> rdatas = m_Database.Get(
315 region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); 316 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1,
317 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
316 318
317 foreach (RegionData rdata in rdatas) 319 foreach (RegionData rdata in rdatas)
318 { 320 {
@@ -345,6 +347,11 @@ namespace OpenSim.Services.GridService
345 return null; 347 return null;
346 } 348 }
347 349
350 // Get a region given its base coordinates.
351 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
352 // be the base coordinate of the region.
353 // The snapping is technically unnecessary but is harmless because regions are always
354 // multiples of the legacy region size (256).
348 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 355 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
349 { 356 {
350 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; 357 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -439,6 +446,8 @@ namespace OpenSim.Services.GridService
439 RegionData rdata = new RegionData(); 446 RegionData rdata = new RegionData();
440 rdata.posX = (int)rinfo.RegionLocX; 447 rdata.posX = (int)rinfo.RegionLocX;
441 rdata.posY = (int)rinfo.RegionLocY; 448 rdata.posY = (int)rinfo.RegionLocY;
449 rdata.sizeX = rinfo.RegionSizeX;
450 rdata.sizeY = rinfo.RegionSizeY;
442 rdata.RegionID = rinfo.RegionID; 451 rdata.RegionID = rinfo.RegionID;
443 rdata.RegionName = rinfo.RegionName; 452 rdata.RegionName = rinfo.RegionName;
444 rdata.Data = rinfo.ToKeyValuePairs(); 453 rdata.Data = rinfo.ToKeyValuePairs();
@@ -452,6 +461,8 @@ namespace OpenSim.Services.GridService
452 GridRegion rinfo = new GridRegion(rdata.Data); 461 GridRegion rinfo = new GridRegion(rdata.Data);
453 rinfo.RegionLocX = rdata.posX; 462 rinfo.RegionLocX = rdata.posX;
454 rinfo.RegionLocY = rdata.posY; 463 rinfo.RegionLocY = rdata.posY;
464 rinfo.RegionSizeX = rdata.sizeX;
465 rinfo.RegionSizeY = rdata.sizeY;
455 rinfo.RegionID = rdata.RegionID; 466 rinfo.RegionID = rdata.RegionID;
456 rinfo.RegionName = rdata.RegionName; 467 rinfo.RegionName = rdata.RegionName;
457 rinfo.ScopeID = rdata.ScopeID; 468 rinfo.ScopeID = rdata.ScopeID;
@@ -477,6 +488,33 @@ namespace OpenSim.Services.GridService
477 return ret; 488 return ret;
478 } 489 }
479 490
491 public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
492 {
493 List<GridRegion> ret = new List<GridRegion>();
494
495 List<RegionData> regions = m_Database.GetDefaultHypergridRegions(scopeID);
496
497 foreach (RegionData r in regions)
498 {
499 if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0)
500 ret.Add(RegionData2RegionInfo(r));
501 }
502
503 int hgDefaultRegionsFoundOnline = regions.Count;
504
505 // For now, hypergrid default regions will always be given precedence but we will also return simple default
506 // regions in case no specific hypergrid regions are specified.
507 ret.AddRange(GetDefaultRegions(scopeID));
508
509 int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline;
510
511 m_log.DebugFormat(
512 "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions",
513 hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline);
514
515 return ret;
516 }
517
480 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) 518 public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
481 { 519 {
482 List<GridRegion> ret = new List<GridRegion>(); 520 List<GridRegion> ret = new List<GridRegion>();
@@ -525,40 +563,41 @@ namespace OpenSim.Services.GridService
525 563
526 private void HandleDeregisterRegion(string module, string[] cmd) 564 private void HandleDeregisterRegion(string module, string[] cmd)
527 { 565 {
528 if (cmd.Length != 4) 566 if (cmd.Length < 4)
529 { 567 {
530 MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>"); 568 MainConsole.Instance.Output("Usage: degregister region id <region-id>+");
531 return; 569 return;
532 } 570 }
533 571
534 string rawRegionUuid = cmd[3]; 572 for (int i = 3; i < cmd.Length; i++)
535 UUID regionUuid;
536
537 if (!UUID.TryParse(rawRegionUuid, out regionUuid))
538 { 573 {
539 MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid); 574 string rawRegionUuid = cmd[i];
540 return; 575 UUID regionUuid;
541 }
542 576
543 GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid); 577 if (!UUID.TryParse(rawRegionUuid, out regionUuid))
578 {
579 MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid);
580 return;
581 }
544 582
545 if (region == null) 583 GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid);
546 {
547 MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid);
548 return;
549 }
550 584
551 if (DeregisterRegion(regionUuid)) 585 if (region == null)
552 { 586 {
553 MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid); 587 MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid);
554 } 588 return;
555 else 589 }
556 {
557 // I don't think this can ever occur if we know that the region exists.
558 MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid);
559 }
560 590
561 return; 591 if (DeregisterRegion(regionUuid))
592 {
593 MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid);
594 }
595 else
596 {
597 // I don't think this can ever occur if we know that the region exists.
598 MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid);
599 }
600 }
562 } 601 }
563 602
564 private void HandleShowRegions(string module, string[] cmd) 603 private void HandleShowRegions(string module, string[] cmd)