From 3382de4d8bcfce0c3f8e2e63ee63ed2428322461 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 21 Mar 2011 23:16:57 +0000 Subject: In initial setup, stop a user being able to create a new estate with the same name as an existing estate. --- OpenSim/Region/Application/OpenSimBase.cs | 45 +++++++++++++++++++++---------- 1 file 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 /// /// Create an estate with an initial region. /// + /// + /// This method doesn't allow an estate to be created with the same name as existing estates. + /// /// - public void CreateEstate(RegionInfo regInfo) + /// A list of estate names that already exist. + /// true if the estate was created, false otherwise + public bool CreateEstate(RegionInfo regInfo, List existingNames) { // Create a new estate regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); + string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); - regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); + if (existingNames.Contains(newName)) + { + MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); + return false; + } + + regInfo.EstateSettings.EstateName = newName; // FIXME: Later on, the scene constructor will reload the estate settings no matter what. // Therefore, we need to do an initial save here otherwise the new estate name will be reset // back to the default. The reloading of estate settings by scene could be eliminated if it // knows that the passed in settings in RegionInfo are already valid. Also, it might be // possible to eliminate some additional later saves made by callers of this method. - regInfo.EstateSettings.Save(); + regInfo.EstateSettings.Save(); + + return true; } /// @@ -825,16 +839,21 @@ namespace OpenSim MainConsole.Instance.Output("Your region is not part of an estate."); List estates = EstateDataService.LoadEstateSettingsAll(); + List estateNames = new List(); + foreach (EstateSettings estate in estates) + estateNames.Add(estate.EstateName); while (true) { if (estates.Count == 0) { MainConsole.Instance.Output( - "There aren't any existing estates. You will need to create a new one for this region."); + "No existing estates found. You must create a new one for this region."); - CreateEstate(regInfo); - break; + if (CreateEstate(regInfo, estateNames)) + break; + else + continue; } else { @@ -844,15 +863,13 @@ namespace OpenSim if (response == "no") { - CreateEstate(regInfo); - break; + if (CreateEstate(regInfo, estateNames)) + break; + else + continue; } else - { - List estateNames = new List(); - foreach (EstateSettings estate in estates) - estateNames.Add(estate.EstateName); - + { response = MainConsole.Instance.CmdPrompt( string.Format( @@ -865,7 +882,7 @@ namespace OpenSim List estateIDs = EstateDataService.GetEstates(response); if (estateIDs.Count < 1) { - MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); + MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again."); continue; } -- cgit v1.1