Reset() public méthode

public Reset ( ) : void
Résultat void
        /// <summary>
        /// Gets the name of the region.
        /// </summary>
        /// <returns><c>true</c>, if region name was gotten, <c>false</c> otherwise.</returns>
        /// <param name="regInfo">Reg info.</param>
        bool GetRegionName(ref RegionInfo regInfo)
        {
            var updated = false;

            Utilities.MarkovNameGenerator rNames = new Utilities.MarkovNameGenerator ();
            string regionName = rNames.FirstName (m_regionNameSeed == null ? Utilities.RegionNames : m_regionNameSeed, 3, 7);

            regionName = regInfo.RegionName;
            var oldName = regionName;

            do
            {
                regInfo.RegionName = MainConsole.Instance.Prompt ("Region Name (? for suggestion)", regionName);
                if (regInfo.RegionName == "" || regInfo.RegionName == "?")
                {
                    regionName = rNames.NextName;
                    regInfo.RegionName = "";
                    continue;
                }
            } while (regInfo.RegionName == "");
            rNames.Reset ();
            if (regInfo.RegionName != oldName)
                updated = true;

            return updated;
        }
        /// <summary>
        ///     Handle the create (add) user command from the console.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">string array with parameters: firstname, lastname, password, email</param>
        protected void HandleCreateUser(IScene scene, string[] cmd)
        {
            string userName = "";
            string password, email, uuid, scopeID;
            bool sysFlag = false;
            bool uuidFlag = false;
            List <string> userTypes = new List<string>(new [] {"Guest", "Resident", "Member", "Contractor", "Charter_Member"});

            List<string> cmdparams = new List<string>(cmd);
            foreach (string param in cmd)
            {
                if (param.StartsWith ("--system", StringComparison.Ordinal))
                {
                    sysFlag = true;
                    cmdparams.Remove(param);
                }
                if (param.StartsWith ("--uuid", StringComparison.Ordinal))
                {
                    uuidFlag = true;
                    cmdparams.Remove(param);
                }

            }

            // check for provided user name
            if (cmdparams.Count >= 4)
            {
                userName = cmdparams [2] + " " + cmdparams [3];
            } else
            {
                Utilities.MarkovNameGenerator ufNames = new Utilities.MarkovNameGenerator ();
                Utilities.MarkovNameGenerator ulNames = new Utilities.MarkovNameGenerator ();
                string[] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed;

                string firstName = ufNames.FirstName (nameSeed, 3, 4);
                string lastName = ulNames.FirstName (nameSeed, 5, 6);
                string enteredName = firstName + " " + lastName;
                if (userName != "")
                    enteredName = userName;

                do
                {
                    userName = MainConsole.Instance.Prompt ("User Name (? for suggestion)", enteredName);
                    if (userName == "" || userName == "?")
                    {
                        enteredName = ufNames.NextName + " " + ulNames.NextName;
                        userName = "";
                        continue;
                    }
                } while (userName == "");
                ufNames.Reset ();
                ulNames.Reset ();
            }

            // we have the name so check to make sure it is allowed
            UserAccount ua = GetUserAccount(null, userName);
            if (ua != null)
            {
                MainConsole.Instance.WarnFormat("[User account service]: This user, '{0}' already exists!", userName);
                return;
            }

            // password as well?
            password = cmdparams.Count < 5 ? MainConsole.Instance.PasswordPrompt("Password") : cmdparams[4];

            // maybe even an email?
            if (cmdparams.Count < 6 )
            { 
                email = MainConsole.Instance.Prompt ("Email for password recovery. ('none' if unknown)","none");
            }
            else
                email = cmdparams[5];

            if ((email.ToLower() != "none") && !Utilities.IsValidEmail(email))
            {
                MainConsole.Instance.Warn ("This does not look like a valid email address. ('none' if unknown)");
                email = MainConsole.Instance.Prompt ("Email", email);
            }

            // Get user type (for payments etc)
            var userType = MainConsole.Instance.Prompt("User type", "Resident", userTypes);

            // Get available user avatar archives
            var userAvatarArchive = "";
            var avatarArchives = GetAvatarArchivesFiles ();
            if (avatarArchives.Count > 0)
            {
                avatarArchives.Add("None");
                userAvatarArchive = MainConsole.Instance.Prompt("Avatar archive to use", "None", avatarArchives);
                if (userAvatarArchive == "None")
                    userAvatarArchive = "";
            }

            // Allow the modification the UUID if required - for matching user UUID with other Grids etc like SL
            uuid = UUID.Random().ToString();
            if (uuidFlag)
                while (true)
                {
                    uuid = MainConsole.Instance.Prompt("UUID (Required avatar UUID)", uuid);
                    UUID test;
                    if (UUID.TryParse(uuid, out test))
                        break;

                    MainConsole.Instance.Error("There was a problem verifying this UUID. Please retry.");
                }

            // this really should not be altered so hide it normally
            scopeID = UUID.Zero.ToString ();
            if (sysFlag)
            {
                scopeID = MainConsole.Instance.Prompt("Scope (Don't change unless you know what this is)", scopeID);
            }

            // we should be good to go
            CreateUser(UUID.Parse(uuid), UUID.Parse(scopeID), userName, Util.Md5Hash(password), email);
            // CreateUser will tell us success or problem
            //MainConsole.Instance.InfoFormat("[User account service]: User '{0}' created", name);

            // check for success
            UserAccount account = GetUserAccount(null, userName);
            if (account != null)
            {
                account.UserFlags = UserTypeToUserFlags (userType);
                StoreUserAccount(account);

                // update profile for the user as well
                if (m_profileConnector != null)
                {
                    IUserProfileInfo profile = m_profileConnector.GetUserProfile (account.PrincipalID);
                    if (profile == null)
                    {
                        m_profileConnector.CreateNewProfile (account.PrincipalID);          // create a profile for the user
                        profile = m_profileConnector.GetUserProfile (account.PrincipalID);
                    }

                    if (userAvatarArchive != "")
                        profile.AArchiveName = userAvatarArchive+".aa";
                    profile.MembershipGroup = UserFlagToType(account.UserFlags);
                    profile.IsNewUser = true;
                    m_profileConnector.UpdateUserProfile (profile);
                }
            } else
                MainConsole.Instance.WarnFormat("[User account service]: There was a problem creating the account for '{0}'", userName);

        }
        /// <summary>
        /// Creates/updates a region from console.
        /// </summary>
        /// <returns>The region from console.</returns>
        /// <param name="info">Info.</param>
        /// <param name="prompt">If set to <c>true</c> prompt.</param>
        /// <param name="currentInfo">Current info.</param>
        RegionInfo CreateRegionFromConsole(RegionInfo info, Boolean prompt, Dictionary<string, int> currentInfo)
        {
            if (info == null || info.NewRegion)
            {
                if (info == null)
                    info = new RegionInfo();

                info.RegionID = UUID.Random();

                if (currentInfo != null)
                {
                    info.RegionLocX = currentInfo ["minX"] > 0 ? currentInfo ["minX"] : 1000 * Constants.RegionSize;
                    info.RegionLocY = currentInfo ["minY"] > 0 ? currentInfo ["minY"] : 1000 * Constants.RegionSize;
                    info.RegionPort = currentInfo ["port"] > 0 ? currentInfo ["port"] + 1 : 9000;
                } else
                {
                    info.RegionLocX = 1000 * Constants.RegionSize;
                    info.RegionLocY = 1000 * Constants.RegionSize;
                    info.RegionPort = 9000;

                }
                prompt = true;
            }

            // prompt for user input
            if (prompt)
            {
                Utilities.MarkovNameGenerator rNames = new Utilities.MarkovNameGenerator();
                string regionName = rNames.FirstName (m_regionNameSeed == null ? Utilities.RegionNames: m_regionNameSeed, 3,7);
                if (info.RegionName != "")
                    regionName = info.RegionName;

                do
                {
                    info.RegionName = MainConsole.Instance.Prompt ("Region Name (? for suggestion)", regionName);
                    if (info.RegionName == "" || info.RegionName == "?")
                    {
                        regionName = rNames.NextName;
                        info.RegionName = "";
                        continue;
                    }
                }
                while (info.RegionName == "");
                rNames.Reset();

                info.RegionLocX =
                    int.Parse (MainConsole.Instance.Prompt ("Region Location X",
                    ((info.RegionLocX == 0
                            ? 1000
                            : info.RegionLocX / Constants.RegionSize)).ToString ())) * Constants.RegionSize;

                info.RegionLocY =
                    int.Parse (MainConsole.Instance.Prompt ("Region location Y",
                    ((info.RegionLocY == 0
                            ? 1000
                            : info.RegionLocY / Constants.RegionSize)).ToString ())) * Constants.RegionSize;

                var haveSize = true;
                var sizeCheck = "";
                do
                {
                    info.RegionSizeX = int.Parse (MainConsole.Instance.Prompt ("Region size X", info.RegionSizeX.ToString ()));
                    if (info.RegionSizeX > Constants.MaxRegionSize)
                    {
                        MainConsole.Instance.CleanInfo ("    The currently recommended maximum size is " + Constants.MaxRegionSize);
                        sizeCheck =  MainConsole.Instance.Prompt ("Continue with the X size of " + info.RegionSizeX + "? (yes/no)", "no");
                        haveSize = sizeCheck.ToLower().StartsWith("y");
                    }
                } while (! haveSize);

                // assume square regions
                info.RegionSizeY = info.RegionSizeX;

                do
                {
                    info.RegionSizeY = int.Parse (MainConsole.Instance.Prompt ("Region size Y", info.RegionSizeY.ToString ()));
                    if ( (info.RegionSizeY > info.RegionSizeX) && (info.RegionSizeY > Constants.MaxRegionSize) )
                    {
                        MainConsole.Instance.CleanInfo ("    The currently recommended maximum size is " + Constants.MaxRegionSize);
                        sizeCheck =  MainConsole.Instance.Prompt ("Continue with the Y size of " + info.RegionSizeY + "? (yes/no)", "no");
                        haveSize = sizeCheck.ToLower().StartsWith("y");
                    }
                } while (! haveSize);

                bool bigRegion = ((info.RegionSizeX > Constants.MaxRegionSize) || (info.RegionSizeY > Constants.MaxRegionSize));

                // * Mainland / Full Region (Private)
                // * Mainland / Homestead
                // * Mainland / Openspace
                //
                // * Estate / Full Region   (Private)
                info.RegionType = MainConsole.Instance.Prompt ("Region Type (Mainland/Estate)",
                    (info.RegionType == "" ? "Estate" : info.RegionType));

                // Region presets or advanced setup
                string setupMode;
                string terrainOpen = "Grassland";
                string terrainFull = "Grassland";
                var responses = new List<string>();
                if (info.RegionType.ToLower().StartsWith("m"))
                {
                    // Mainland regions
                    info.RegionType = "Mainland / ";
                    responses.Add("Full Region");
                    responses.Add("Homestead");
                    responses.Add ("Openspace");
                    responses.Add ("Universe");                            // TODO: remove?
                    responses.Add ("Custom");
                    setupMode = MainConsole.Instance.Prompt("Mainland region type?", "Full Region", responses).ToLower ();

                    // allow specifying terrain for Openspace
                    if (bigRegion)
                        terrainOpen = "flatland";
                    else if (setupMode.StartsWith("o"))
                        terrainOpen = MainConsole.Instance.Prompt("Openspace terrain ( Grassland, Swamp, Aquatic)?", terrainOpen).ToLower();

                } else
                {
                    // Estate regions
                    info.RegionType = "Estate / ";
                    responses.Add("Full Region");
                    responses.Add ("Universe");                            // TODO: Universe 'standard' setup, rename??
                    responses.Add ("Custom");
                    setupMode = MainConsole.Instance.Prompt("Estate region type?","Full Region", responses).ToLower();
                }

                // terrain can be specified for Full or custom regions
                if (bigRegion)
                    terrainFull = "Flatland";
                else if (setupMode.StartsWith ("f") || setupMode.StartsWith ("c"))
                {
                    var tresp = new List<string>();
                    tresp.Add ("Flatland");
                    tresp.Add ("Grassland");
                    tresp.Add ("Hills");
                    tresp.Add ("Mountainous");
                    tresp.Add ("Island");
                    tresp.Add ("Swamp");
                    tresp.Add ("Aquatic");
                    string tscape = MainConsole.Instance.Prompt ("Terrain Type?", terrainFull,tresp);
                    terrainFull = tscape;
                    // TODO: This would be where we allow selection of preset terrain files
                }

                if (setupMode.StartsWith("c"))
                {
                    info.RegionType = info.RegionType + "Custom";
                    info.RegionTerrain = terrainFull;

                    // allow port selection
                    info.RegionPort = int.Parse (MainConsole.Instance.Prompt ("Region Port", info.RegionPort.ToString ()));

                    // Startup mode
                    string scriptStart = MainConsole.Instance.Prompt (
                        "Region Startup - Normal or Delayed startup (normal/delay) : ","normal").ToLower();
                    info.Startup = scriptStart.StartsWith ("n") ? StartupType.Normal : StartupType.Medium;

                    info.SeeIntoThisSimFromNeighbor =  MainConsole.Instance.Prompt (
                        "See into this sim from neighbors (yes/no)",
                        info.SeeIntoThisSimFromNeighbor ? "yes" : "no").ToLower() == "yes";

                    info.InfiniteRegion = MainConsole.Instance.Prompt (
                        "Make an infinite region (yes/no)",
                        info.InfiniteRegion ? "yes" : "no").ToLower () == "yes";

                    info.ObjectCapacity =
                        int.Parse (MainConsole.Instance.Prompt ("Object capacity",
                        info.ObjectCapacity == 0
                                               ? "50000"
                                               : info.ObjectCapacity.ToString ()));
                }

                if (setupMode.StartsWith("w"))
                {
                    // 'standard' setup
                    info.RegionType = info.RegionType + "Universe";
                    //info.RegionPort;            // use auto assigned port
                    info.RegionTerrain = "Flatland";
                    info.Startup = StartupType.Normal;
                    info.SeeIntoThisSimFromNeighbor = true;
                    info.InfiniteRegion = false;
                    info.ObjectCapacity = 50000;

                }
                if (setupMode.StartsWith("o"))
                {
                    // 'Openspace' setup
                    info.RegionType = info.RegionType + "Openspace";
                    //info.RegionPort;            // use auto assigned port

                    if (terrainOpen.StartsWith("a"))
                        info.RegionTerrain = "Aquatic";
                    else if (terrainOpen.StartsWith("s"))
                        info.RegionTerrain = "Swamp";
                    else if (terrainOpen.StartsWith("g"))
                        info.RegionTerrain = "Grassland";
                    else
                        info.RegionTerrain = "Flatland";

                    info.Startup = StartupType.Medium;
                    info.SeeIntoThisSimFromNeighbor = true;
                    info.InfiniteRegion = false;
                    info.ObjectCapacity = 750;
                    info.RegionSettings.AgentLimit = 10;
                    info.RegionSettings.AllowLandJoinDivide = false;
                    info.RegionSettings.AllowLandResell = false;
                                   }
                if (setupMode.StartsWith("h"))
                {
                    // 'Homestead' setup
                    info.RegionType = info.RegionType + "Homestead";
                    //info.RegionPort;            // use auto assigned port
                    if (bigRegion)
                        info.RegionTerrain = "Flatland";
                    else
                        info.RegionTerrain = "Homestead";

                    info.Startup = StartupType.Medium;
                    info.SeeIntoThisSimFromNeighbor = true;
                    info.InfiniteRegion = false;
                    info.ObjectCapacity = 3750;
                    info.RegionSettings.AgentLimit = 20;
                    info.RegionSettings.AllowLandJoinDivide = false;
                    info.RegionSettings.AllowLandResell = false;
                }

                if (setupMode.StartsWith("f"))
                {
                    // 'Full Region' setup
                    info.RegionType = info.RegionType + "Full Region";
                    //info.RegionPort;            // use auto assigned port
                    info.RegionTerrain = terrainFull;
                    info.Startup = StartupType.Normal;
                    info.SeeIntoThisSimFromNeighbor = true;
                    info.InfiniteRegion = false;
                    info.ObjectCapacity = 15000;
                    info.RegionSettings.AgentLimit = 100;
                    if (info.RegionType.StartsWith ("M"))                           // defaults are 'true'
                    {
                        info.RegionSettings.AllowLandJoinDivide = false;
                        info.RegionSettings.AllowLandResell = false;
                    }
                }

            }

            // are we updating or adding?
            if (m_scene != null)
            {
                IGridRegisterModule gridRegister = m_scene.RequestModuleInterface<IGridRegisterModule>();
                //Re-register so that if the position has changed, we get the new neighbors
                gridRegister.RegisterRegionWithGrid(m_scene, true, false, null);

                // Tell clients about changes
                IEstateModule es = m_scene.RequestModuleInterface<IEstateModule> ();
                if (es != null)
                    es.sendRegionHandshakeToAll ();

                // in case we have changed the name
                if (m_scene.SimulationDataService.BackupFile != info.RegionName)
                {
                    string oldFile = BuildSaveFileName (m_scene.SimulationDataService.BackupFile);
                    if (File.Exists (oldFile))
                        File.Delete (oldFile);
                    m_scene.SimulationDataService.BackupFile = info.RegionName;
                }

                m_scene.SimulationDataService.ForceBackup();

                MainConsole.Instance.InfoFormat("[FileBasedSimulationData]: Save of {0} completed.",info.RegionName);
            }

            return info;
        }