aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/OpenSimBase.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs122
1 files changed, 84 insertions, 38 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index e950613..ea9edf6 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -793,66 +793,112 @@ namespace OpenSim
793 } 793 }
794 794
795 /// <summary> 795 /// <summary>
796 /// Load the estate information for the provided RegionInfo object. 796 /// Create an estate with an initial region.
797 /// </summary> 797 /// </summary>
798 /// <remarks>
799 /// This method doesn't allow an estate to be created with the same name as existing estates.
800 /// </remarks>
798 /// <param name="regInfo"></param> 801 /// <param name="regInfo"></param>
799 public void PopulateRegionEstateInfo(RegionInfo regInfo) 802 /// <param name="existingName">A list of estate names that already exist.</param>
803 /// <returns>true if the estate was created, false otherwise</returns>
804 public bool CreateEstate(RegionInfo regInfo, List<string> existingNames)
800 { 805 {
801 IEstateDataService estateDataService = EstateDataService; 806 // Create a new estate
807 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
808 string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
802 809
803 if (estateDataService != null) 810 if (existingNames.Contains(newName))
804 { 811 {
805 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, false); 812 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName);
813 return false;
806 } 814 }
815
816 regInfo.EstateSettings.EstateName = newName;
817
818 // FIXME: Later on, the scene constructor will reload the estate settings no matter what.
819 // Therefore, we need to do an initial save here otherwise the new estate name will be reset
820 // back to the default. The reloading of estate settings by scene could be eliminated if it
821 // knows that the passed in settings in RegionInfo are already valid. Also, it might be
822 // possible to eliminate some additional later saves made by callers of this method.
823 regInfo.EstateSettings.Save();
824
825 return true;
826 }
827
828 /// <summary>
829 /// Load the estate information for the provided RegionInfo object.
830 /// </summary>
831 /// <param name="regInfo"></param>
832 public void PopulateRegionEstateInfo(RegionInfo regInfo)
833 {
834 if (EstateDataService != null)
835 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false);
807 836
808 if (regInfo.EstateSettings.EstateID == 0) // No record at all 837 if (regInfo.EstateSettings.EstateID == 0) // No record at all
809 { 838 {
810 MainConsole.Instance.Output("Your region is not part of an estate."); 839 MainConsole.Instance.OutputFormat("Region {0} is not part of an estate.", regInfo.RegionName);
840
841 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll();
842 List<string> estateNames = new List<string>();
843 foreach (EstateSettings estate in estates)
844 estateNames.Add(estate.EstateName);
845
811 while (true) 846 while (true)
812 { 847 {
813 string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() { "yes", "no" }); 848 if (estates.Count == 0)
814 if (response == "no") 849 {
815 { 850 MainConsole.Instance.Output("No existing estates found. You must create a new one.");
816 // Create a new estate
817 regInfo.EstateSettings = estateDataService.LoadEstateSettings(regInfo.RegionID, true);
818
819 regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
820 851
821 // FIXME: Later on, the scene constructor will reload the estate settings no matter what. 852 if (CreateEstate(regInfo, estateNames))
822 // Therefore, we need to do an initial save here otherwise the new estate name will be reset 853 break;
823 // back to the default. The reloading of estate settings by scene could be eliminated if it 854 else
824 // knows that the passed in settings in RegionInfo are already valid. Also, it might be 855 continue;
825 // possible to eliminate some additional later saves made by callers of this method.
826 regInfo.EstateSettings.Save();
827 break;
828 } 856 }
829 else 857 else
830 { 858 {
831 response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); 859 string response
832 if (response == "None") 860 = MainConsole.Instance.CmdPrompt(
833 continue; 861 string.Format(
834 862 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName),
835 List<int> estateIDs = estateDataService.GetEstates(response); 863 "yes",
836 if (estateIDs.Count < 1) 864 new List<string>() { "yes", "no" });
865
866 if (response == "no")
837 { 867 {
838 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); 868 if (CreateEstate(regInfo, estateNames))
839 continue; 869 break;
870 else
871 continue;
872 }
873 else
874 {
875 response
876 = MainConsole.Instance.CmdPrompt(
877 string.Format(
878 "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())),
879 estateNames[0]);
880
881 List<int> estateIDs = EstateDataService.GetEstates(response);
882 if (estateIDs.Count < 1)
883 {
884 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
885 continue;
886 }
887
888 int estateID = estateIDs[0];
889
890 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
891
892 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
893 break;
894
895 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
840 } 896 }
841
842 int estateID = estateIDs[0];
843
844 regInfo.EstateSettings = estateDataService.LoadEstateSettings(estateID);
845
846 if (estateDataService.LinkRegion(regInfo.RegionID, estateID))
847 break;
848
849 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
850 } 897 }
851 } 898 }
852 } 899 }
853 } 900 }
854 } 901 }
855
856 902
857 public class OpenSimConfigSource 903 public class OpenSimConfigSource
858 { 904 {