diff options
Diffstat (limited to 'OpenSim/Services/GridService/GridService.cs')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 175 |
1 files changed, 159 insertions, 16 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 3dc87bc..aab403a 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -85,13 +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 | "show region", | 88 | "deregister region id", |
89 | "show region <Region name>", | 89 | "deregister region id <Region UUID>", |
90 | "Deregister a region manually.", | ||
91 | String.Empty, | ||
92 | HandleDeregisterRegion); | ||
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 | |||
106 | MainConsole.Instance.Commands.AddCommand("Regions", true, | ||
107 | "show region name", | ||
108 | "show region name <Region name>", | ||
90 | "Show details on a region", | 109 | "Show details on a region", |
91 | String.Empty, | 110 | String.Empty, |
92 | HandleShowRegion); | 111 | HandleShowRegion); |
93 | 112 | ||
94 | 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, | ||
95 | "set region flags", | 121 | "set region flags", |
96 | "set region flags <Region name> <flags>", | 122 | "set region flags <Region name> <flags>", |
97 | "Set database flags for region", | 123 | "Set database flags for region", |
@@ -495,34 +521,151 @@ namespace OpenSim.Services.GridService | |||
495 | return -1; | 521 | return -1; |
496 | } | 522 | } |
497 | 523 | ||
524 | private void HandleDeregisterRegion(string module, string[] cmd) | ||
525 | { | ||
526 | if (cmd.Length != 4) | ||
527 | { | ||
528 | MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>"); | ||
529 | return; | ||
530 | } | ||
531 | |||
532 | string rawRegionUuid = cmd[3]; | ||
533 | UUID regionUuid; | ||
534 | |||
535 | if (!UUID.TryParse(rawRegionUuid, out regionUuid)) | ||
536 | { | ||
537 | MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid); | ||
538 | return; | ||
539 | } | ||
540 | |||
541 | GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid); | ||
542 | |||
543 | if (region == null) | ||
544 | { | ||
545 | MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid); | ||
546 | return; | ||
547 | } | ||
548 | |||
549 | if (DeregisterRegion(regionUuid)) | ||
550 | { | ||
551 | MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid); | ||
552 | } | ||
553 | else | ||
554 | { | ||
555 | // I don't think this can ever occur if we know that the region exists. | ||
556 | MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid); | ||
557 | } | ||
558 | |||
559 | return; | ||
560 | } | ||
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 | |||
498 | private void HandleShowRegion(string module, string[] cmd) | 576 | private void HandleShowRegion(string module, string[] cmd) |
499 | { | 577 | { |
500 | if (cmd.Length != 3) | 578 | if (cmd.Length != 4) |
501 | { | 579 | { |
502 | MainConsole.Instance.Output("Syntax: show region <region name>"); | 580 | MainConsole.Instance.Output("Syntax: show region name <region name>"); |
503 | return; | 581 | return; |
504 | } | 582 | } |
505 | 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); | ||
506 | if (regions == null || regions.Count < 1) | 587 | if (regions == null || regions.Count < 1) |
507 | { | 588 | { |
508 | MainConsole.Instance.Output("Region not found"); | 589 | MainConsole.Instance.Output("No region with name {0} found", regionName); |
590 | return; | ||
591 | } | ||
592 | |||
593 | OutputRegionsToConsole(regions); | ||
594 | } | ||
595 | |||
596 | private void HandleShowRegionAt(string module, string[] cmd) | ||
597 | { | ||
598 | if (cmd.Length != 5) | ||
599 | { | ||
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"); | ||
509 | return; | 608 | return; |
510 | } | 609 | } |
511 | 610 | ||
512 | MainConsole.Instance.Output("Region Name Region UUID"); | 611 | if (!int.TryParse(cmd[4], out y)) |
513 | MainConsole.Instance.Output("Location URI"); | 612 | { |
514 | MainConsole.Instance.Output("Owner ID Flags"); | 613 | MainConsole.Instance.Output("y-coord must be an integer"); |
515 | MainConsole.Instance.Output("-------------------------------------------------------------------------------"); | 614 | return; |
615 | } | ||
616 | |||
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; | ||
622 | } | ||
623 | |||
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 | |||
516 | foreach (RegionData r in regions) | 657 | foreach (RegionData r in regions) |
517 | { | 658 | { |
518 | OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); | 659 | OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); |
519 | MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", | 660 | dispTable.AddRow( |
520 | r.RegionName, r.RegionID, | 661 | r.RegionName, |
521 | String.Format("{0},{1}", r.posX / Constants.RegionSize, r.posY / Constants.RegionSize), | 662 | r.RegionID.ToString(), |
522 | r.Data["serverURI"], | 663 | string.Format("{0},{1}", r.coordX, r.coordY), |
523 | r.Data["owner_uuid"], flags)); | 664 | r.Data["owner_uuid"].ToString(), |
665 | flags.ToString()); | ||
524 | } | 666 | } |
525 | return; | 667 | |
668 | MainConsole.Instance.Output(dispTable.ToString()); | ||
526 | } | 669 | } |
527 | 670 | ||
528 | private int ParseFlags(int prev, string flags) | 671 | private int ParseFlags(int prev, string flags) |