diff options
author | Justin Clark-Casey (justincc) | 2011-03-21 23:16:57 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-03-21 23:16:57 +0000 |
commit | 3382de4d8bcfce0c3f8e2e63ee63ed2428322461 (patch) | |
tree | 0248b577480812e6f371f223be82b5ca26cce460 /OpenSim/Region/Application/OpenSimBase.cs | |
parent | On initial opensim setup, don't ask the user whether they want to join an exi... (diff) | |
download | opensim-SC_OLD-3382de4d8bcfce0c3f8e2e63ee63ed2428322461.zip opensim-SC_OLD-3382de4d8bcfce0c3f8e2e63ee63ed2428322461.tar.gz opensim-SC_OLD-3382de4d8bcfce0c3f8e2e63ee63ed2428322461.tar.bz2 opensim-SC_OLD-3382de4d8bcfce0c3f8e2e63ee63ed2428322461.tar.xz |
In initial setup, stop a user being able to create a new estate with the same name as an existing estate.
Diffstat (limited to 'OpenSim/Region/Application/OpenSimBase.cs')
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 81a10e3..3f5e35e 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -795,20 +795,34 @@ namespace OpenSim | |||
795 | /// <summary> | 795 | /// <summary> |
796 | /// Create an estate with an initial region. | 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 CreateEstate(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 | // Create a new estate | 806 | // Create a new estate |
802 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); | 807 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); |
808 | string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); | ||
803 | 809 | ||
804 | regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); | 810 | if (existingNames.Contains(newName)) |
811 | { | ||
812 | MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); | ||
813 | return false; | ||
814 | } | ||
815 | |||
816 | regInfo.EstateSettings.EstateName = newName; | ||
805 | 817 | ||
806 | // FIXME: Later on, the scene constructor will reload the estate settings no matter what. | 818 | // FIXME: Later on, the scene constructor will reload the estate settings no matter what. |
807 | // Therefore, we need to do an initial save here otherwise the new estate name will be reset | 819 | // Therefore, we need to do an initial save here otherwise the new estate name will be reset |
808 | // back to the default. The reloading of estate settings by scene could be eliminated if it | 820 | // back to the default. The reloading of estate settings by scene could be eliminated if it |
809 | // knows that the passed in settings in RegionInfo are already valid. Also, it might be | 821 | // knows that the passed in settings in RegionInfo are already valid. Also, it might be |
810 | // possible to eliminate some additional later saves made by callers of this method. | 822 | // possible to eliminate some additional later saves made by callers of this method. |
811 | regInfo.EstateSettings.Save(); | 823 | regInfo.EstateSettings.Save(); |
824 | |||
825 | return true; | ||
812 | } | 826 | } |
813 | 827 | ||
814 | /// <summary> | 828 | /// <summary> |
@@ -825,16 +839,21 @@ namespace OpenSim | |||
825 | MainConsole.Instance.Output("Your region is not part of an estate."); | 839 | MainConsole.Instance.Output("Your region is not part of an estate."); |
826 | 840 | ||
827 | List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); | 841 | List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); |
842 | List<string> estateNames = new List<string>(); | ||
843 | foreach (EstateSettings estate in estates) | ||
844 | estateNames.Add(estate.EstateName); | ||
828 | 845 | ||
829 | while (true) | 846 | while (true) |
830 | { | 847 | { |
831 | if (estates.Count == 0) | 848 | if (estates.Count == 0) |
832 | { | 849 | { |
833 | MainConsole.Instance.Output( | 850 | MainConsole.Instance.Output( |
834 | "There aren't any existing estates. You will need to create a new one for this region."); | 851 | "No existing estates found. You must create a new one for this region."); |
835 | 852 | ||
836 | CreateEstate(regInfo); | 853 | if (CreateEstate(regInfo, estateNames)) |
837 | break; | 854 | break; |
855 | else | ||
856 | continue; | ||
838 | } | 857 | } |
839 | else | 858 | else |
840 | { | 859 | { |
@@ -844,15 +863,13 @@ namespace OpenSim | |||
844 | 863 | ||
845 | if (response == "no") | 864 | if (response == "no") |
846 | { | 865 | { |
847 | CreateEstate(regInfo); | 866 | if (CreateEstate(regInfo, estateNames)) |
848 | break; | 867 | break; |
868 | else | ||
869 | continue; | ||
849 | } | 870 | } |
850 | else | 871 | else |
851 | { | 872 | { |
852 | List<string> estateNames = new List<string>(); | ||
853 | foreach (EstateSettings estate in estates) | ||
854 | estateNames.Add(estate.EstateName); | ||
855 | |||
856 | response | 873 | response |
857 | = MainConsole.Instance.CmdPrompt( | 874 | = MainConsole.Instance.CmdPrompt( |
858 | string.Format( | 875 | string.Format( |
@@ -865,7 +882,7 @@ namespace OpenSim | |||
865 | List<int> estateIDs = EstateDataService.GetEstates(response); | 882 | List<int> estateIDs = EstateDataService.GetEstates(response); |
866 | if (estateIDs.Count < 1) | 883 | if (estateIDs.Count < 1) |
867 | { | 884 | { |
868 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); | 885 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again."); |
869 | continue; | 886 | continue; |
870 | } | 887 | } |
871 | 888 | ||