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.cs140
1 files changed, 118 insertions, 22 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 11897f8..aab403a 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -85,20 +85,39 @@ namespace OpenSim.Services.GridService
85 if (MainConsole.Instance != null) 85 if (MainConsole.Instance != null)
86 { 86 {
87 MainConsole.Instance.Commands.AddCommand("Regions", true, 87 MainConsole.Instance.Commands.AddCommand("Regions", true,
88 "deregister region", 88 "deregister region id",
89 "deregister region <Region UUID>", 89 "deregister region id <Region UUID>",
90 "Deregister a region manually.", 90 "Deregister a region manually.",
91 String.Empty, 91 String.Empty,
92 HandleDeregisterRegion); 92 HandleDeregisterRegion);
93 93
94 // A messy way of stopping this command being added if we are in standalone (since the simulator
95 // has an identically named command
96 //
97 // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined.
98 if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0)
99 MainConsole.Instance.Commands.AddCommand("Regions", true,
100 "show regions",
101 "show regions",
102 "Show details on all regions",
103 String.Empty,
104 HandleShowRegions);
105
94 MainConsole.Instance.Commands.AddCommand("Regions", true, 106 MainConsole.Instance.Commands.AddCommand("Regions", true,
95 "show region", 107 "show region name",
96 "show region <Region name>", 108 "show region name <Region name>",
97 "Show details on a region", 109 "Show details on a region",
98 String.Empty, 110 String.Empty,
99 HandleShowRegion); 111 HandleShowRegion);
100 112
101 MainConsole.Instance.Commands.AddCommand("Regions", true, 113 MainConsole.Instance.Commands.AddCommand("Regions", true,
114 "show region at",
115 "show region at <x-coord> <y-coord>",
116 "Show details on a region at the given co-ordinate.",
117 "For example, show region at 1000 1000",
118 HandleShowRegionAt);
119
120 MainConsole.Instance.Commands.AddCommand("Regions", true,
102 "set region flags", 121 "set region flags",
103 "set region flags <Region name> <flags>", 122 "set region flags <Region name> <flags>",
104 "Set database flags for region", 123 "Set database flags for region",
@@ -504,13 +523,13 @@ namespace OpenSim.Services.GridService
504 523
505 private void HandleDeregisterRegion(string module, string[] cmd) 524 private void HandleDeregisterRegion(string module, string[] cmd)
506 { 525 {
507 if (cmd.Length != 3) 526 if (cmd.Length != 4)
508 { 527 {
509 MainConsole.Instance.Output("Syntax: degregister region <Region UUID>"); 528 MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>");
510 return; 529 return;
511 } 530 }
512 531
513 string rawRegionUuid = cmd[2]; 532 string rawRegionUuid = cmd[3];
514 UUID regionUuid; 533 UUID regionUuid;
515 534
516 if (!UUID.TryParse(rawRegionUuid, out regionUuid)) 535 if (!UUID.TryParse(rawRegionUuid, out regionUuid))
@@ -540,36 +559,113 @@ namespace OpenSim.Services.GridService
540 return; 559 return;
541 } 560 }
542 561
562 private void HandleShowRegions(string module, string[] cmd)
563 {
564 if (cmd.Length != 2)
565 {
566 MainConsole.Instance.Output("Syntax: show regions");
567 return;
568 }
569
570 List<RegionData> regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero);
571
572 OutputRegionsToConsoleSummary(regions);
573 }
574
575
543 private void HandleShowRegion(string module, string[] cmd) 576 private void HandleShowRegion(string module, string[] cmd)
544 { 577 {
545 if (cmd.Length != 3) 578 if (cmd.Length != 4)
546 { 579 {
547 MainConsole.Instance.Output("Syntax: show region <region name>"); 580 MainConsole.Instance.Output("Syntax: show region name <region name>");
548 return; 581 return;
549 } 582 }
550 List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero); 583
584 string regionName = cmd[3];
585
586 List<RegionData> regions = m_Database.Get(regionName, UUID.Zero);
551 if (regions == null || regions.Count < 1) 587 if (regions == null || regions.Count < 1)
552 { 588 {
553 MainConsole.Instance.Output("Region not found"); 589 MainConsole.Instance.Output("No region with name {0} found", regionName);
554 return; 590 return;
555 } 591 }
556 592
557 foreach (RegionData r in regions) 593 OutputRegionsToConsole(regions);
594 }
595
596 private void HandleShowRegionAt(string module, string[] cmd)
597 {
598 if (cmd.Length != 5)
558 { 599 {
559 OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); 600 MainConsole.Instance.Output("Syntax: show region at <x-coord> <y-coord>");
601 return;
602 }
603
604 int x, y;
605 if (!int.TryParse(cmd[3], out x))
606 {
607 MainConsole.Instance.Output("x-coord must be an integer");
608 return;
609 }
560 610
561 ConsoleDisplayList dispList = new ConsoleDisplayList(); 611 if (!int.TryParse(cmd[4], out y))
562 dispList.AddRow("Region Name", r.RegionName); 612 {
563 dispList.AddRow("Region ID", r.RegionID); 613 MainConsole.Instance.Output("y-coord must be an integer");
564 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); 614 return;
565 dispList.AddRow("URI", r.Data["serverURI"]); 615 }
566 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
567 dispList.AddRow("Flags", flags);
568 616
569 MainConsole.Instance.Output(dispList.ToString()); 617 RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero);
618 if (region == null)
619 {
620 MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
621 return;
570 } 622 }
571 623
572 return; 624 OutputRegionToConsole(region);
625 }
626
627 private void OutputRegionToConsole(RegionData r)
628 {
629 OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
630
631 ConsoleDisplayList dispList = new ConsoleDisplayList();
632 dispList.AddRow("Region Name", r.RegionName);
633 dispList.AddRow("Region ID", r.RegionID);
634 dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
635 dispList.AddRow("URI", r.Data["serverURI"]);
636 dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
637 dispList.AddRow("Flags", flags);
638
639 MainConsole.Instance.Output(dispList.ToString());
640 }
641
642 private void OutputRegionsToConsole(List<RegionData> regions)
643 {
644 foreach (RegionData r in regions)
645 OutputRegionToConsole(r);
646 }
647
648 private void OutputRegionsToConsoleSummary(List<RegionData> regions)
649 {
650 ConsoleDisplayTable dispTable = new ConsoleDisplayTable();
651 dispTable.AddColumn("Name", 16);
652 dispTable.AddColumn("ID", 36);
653 dispTable.AddColumn("Position", 11);
654 dispTable.AddColumn("Owner ID", 36);
655 dispTable.AddColumn("Flags", 60);
656
657 foreach (RegionData r in regions)
658 {
659 OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
660 dispTable.AddRow(
661 r.RegionName,
662 r.RegionID.ToString(),
663 string.Format("{0},{1}", r.coordX, r.coordY),
664 r.Data["owner_uuid"].ToString(),
665 flags.ToString());
666 }
667
668 MainConsole.Instance.Output(dispTable.ToString());
573 } 669 }
574 670
575 private int ParseFlags(int prev, string flags) 671 private int ParseFlags(int prev, string flags)