/// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates(IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID)
            {
                estateConnector.DeleteEstate((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate(eS);
                MainConsole.Instance.Info("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions)
            {
                estateConnector.LinkRegion(regID, newEstateID);
            }
            if (regions.Count > 0)
            {
                MainConsole.Instance.InfoFormat("Relinked {0} regions", regions.Count);
            }
        }
        protected void HandleResetMainlandEstate(IScene scene, string [] cmd)
        {
            CheckSystemEstateInfo(Constants.MainlandEstateID, mainlandEstateName, (UUID)Constants.GovernorUUID);

            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            var regions = gridService.GetRegionsByName(null, "", null, null);

            if (regions == null || regions.Count < 1)
            {
                return;
            }

            int updated = 0;

            foreach (var region in regions)
            {
                string regType = region.RegionType.ToLower();
                if (regType.StartsWith("m", StringComparison.Ordinal))
                {
                    estateConnector.LinkRegion(region.RegionID, Constants.MainlandEstateID);
                    updated++;
                }
            }

            if (updated > 0)
            {
                MainConsole.Instance.InfoFormat("Relinked {0} mainland regions", updated);
            }
        }
Exemple #3
0
        /// <summary>
        /// Links a region to a system estate.
        /// </summary>
        /// <returns>The system estate.</returns>
        /// <param name="regionID">Region ID.</param>
        /// <param name="estateID">Estate ID.</param>
        EstateSettings LinkSystemEstate(UUID regionID, int estateID)
        {
            // link region to a system estate > Mainland / Governor  or System / RealEstateOwner
            IEstateConnector     estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            ISystemEstateService sysEstates      = m_registry.RequestModuleInterface <ISystemEstateService> ();
            EstateSettings       ES;
            string estateName = sysEstates.GetSystemEstateName(estateID);

            // try & link region
            if (estateConnector.LinkRegion(regionID, estateID))
            {
                ES = estateConnector.GetRegionEstateSettings(regionID);      // refresh to check linking
                if ((ES == null) || (ES.EstateID == 0))
                {
                    MainConsole.Instance.Warn("An error was encountered linking the region to '" + estateName + "'!\n" +
                                              "Possibly a problem with the server connection, please link this region later.");
                    return(null);
                }
                MainConsole.Instance.Warn("Successfully joined '" + estateName + "'!");
                return(ES);
            }

            MainConsole.Instance.Warn("Joining '" + estateName + "' failed. Please link this region later.");
            return(null);
        }
        public void ChangeEstate(string ownerName, string estateToJoin, UUID regionID)
        {
            InternalDoRemote(ownerName, estateToJoin, regionID);
            if (m_doRemoteOnly)
            {
                return;
            }

            IEstateConnector conn = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>();

            if (conn != null)
            {
                conn.DelinkRegion(regionID);
                UserAccount account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, ownerName);
                conn.LinkRegion(regionID, conn.GetEstate(account.PrincipalID, estateToJoin));
            }
        }
        /// <summary>
        /// Links the region to the mainland estate.
        /// </summary>
        /// <returns>The mainland estate.</returns>
        /// <param name="regionID">Region I.</param>
        private EstateSettings LinkMainlandEstate(UUID regionID)
        {
            // link region to the Mainland... assign to RealEstateOwner & System Estate
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
            EstateSettings   ES;

            // link region to the 'Mainland'
            if (estateConnector.LinkRegion(regionID, Constants.SystemEstateID))
            {
                ES = estateConnector.GetEstateSettings(regionID);      // refresh to check linking
                if ((ES == null) || (ES.EstateID == 0))
                {
                    MainConsole.Instance.Warn("An error was encountered linking the region to the 'Mainland'!\nPossibly a problem with the server connection, please link this region later.");
                    return(null);
                }
                MainConsole.Instance.Warn("Successfully joined the 'Mainland'!");
                return(ES);
            }

            MainConsole.Instance.Warn("Joining the 'Mainland' failed. Please link this region later.");
            return(null);
        }
Exemple #6
0
        /// <summary>
        /// Links a region to an estate.
        /// </summary>
        /// <returns>The region estate.</returns>
        /// <param name="regionID">Region identifier.</param>
        /// <param name="estateID">Estate name.</param>
        EstateSettings LinkRegionEstate(UUID regionID, int estateID)
        {
            EstateSettings   ES = null;
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            // link up the region
            ES = estateConnector.GetRegionEstateSettings(regionID);

            if (!estateConnector.LinkRegion(regionID, estateID))
            {
                MainConsole.Instance.WarnFormat("[Estate]: Joining the {0} estate failed. Please try again.", ES.EstateName);
                return(ES);
            }

            // make sure that the region is fully set up
            if ((ES = estateConnector.GetRegionEstateSettings(regionID)) == null || ES.EstateID == 0)
            {
                MainConsole.Instance.Warn("[Estate]: Unable to verify region update (possible server connection error), please try again.");
                return(null);
            }

            MainConsole.Instance.InfoFormat("[Estate]: Successfully joined the {0} estate!", ES.EstateName);
            return(ES);
        }
Exemple #7
0
        private EstateSettings CreateEstateInfo(Scene scene)
        {
            EstateSettings ES = new EstateSettings();

            while (true)
            {
                IEstateConnector EstateConnector = DataManager.RequestPlugin <IEstateConnector>();

                string      name    = MainConsole.Instance.CmdPrompt("Estate owner name", LastEstateOwner);
                UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, name);

                if (account == null)
                {
                    string createNewUser = MainConsole.Instance.CmdPrompt("Could not find user " + name + ". Would you like to create this user?", "yes");

                    if (createNewUser == "yes")
                    {
                        // Create a new account
                        string password = MainConsole.Instance.PasswdPrompt(name + "'s password");
                        string email    = MainConsole.Instance.CmdPrompt(name + "'s email", "");

                        scene.UserAccountService.CreateUser(name, Util.Md5Hash(password), email);
                        account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, name);

                        if (account == null)
                        {
                            m_log.ErrorFormat("[EstateService]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first.");
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                LastEstateOwner = account.Name;

                string response = "no";
                List <EstateSettings> ownerEstates = EstateConnector.GetEstates(account.PrincipalID);
                if (ownerEstates != null)
                {
                    m_log.WarnFormat("Found user. {0} has {1} estates currently. {2}", account.Name, ownerEstates.Count,
                                     "These estates are the following:");
                    for (int i = 0; i < ownerEstates.Count; i++)
                    {
                        m_log.Warn(ownerEstates[i].EstateName);
                    }
                    response = MainConsole.Instance.CmdPrompt("Do you wish to join one of these existing estates? (Options are {yes, no})", LastEstateChoise, new List <string>()
                    {
                        "yes", "no"
                    });
                }
                else
                {
                    m_log.WarnFormat("Found user. {0} has no estates currently. Creating a new estate.", account.Name);
                }
                LastEstateChoise = response;
                if (response == "no")
                {
                    // Create a new estate
                    ES.EstateName = MainConsole.Instance.CmdPrompt("New estate name", scene.RegionInfo.EstateSettings.EstateName);

                    //Set to auto connect to this region next
                    LastEstateName   = ES.EstateName;
                    LastEstateChoise = "yes";

                    string Password = Util.Md5Hash(Util.Md5Hash(MainConsole.Instance.CmdPrompt("New estate password (to keep others from joining your estate, blank to have no pass)", ES.EstatePass)));
                    ES.EstatePass  = Password;
                    ES.EstateOwner = account.PrincipalID;

                    ES = EstateConnector.CreateEstate(ES, scene.RegionInfo.RegionID);
                    if (ES == null)
                    {
                        m_log.Warn("The connection to the server was broken, please try again soon.");
                        continue;
                    }
                    else if (ES.EstateID == 0)
                    {
                        m_log.Warn("There was an error in creating this estate: " + ES.EstateName); //EstateName holds the error. See LocalEstateConnector for more info.
                        continue;
                    }
                    //We set this back if there wasn't an error because the EstateService will NOT send it back
                    IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                    EstatePassword     s = new EstatePassword()
                    {
                        Password = Password
                    };
                    if (g != null) //Save the pass to the database
                    {
                        g.AddGeneric(scene.RegionInfo.RegionID, "EstatePassword", ES.EstateID.ToString(), s.ToOSD());
                    }
                    break;
                }
                else if (response == "yes")
                {
                    if (ownerEstates.Count != 1)
                    {
                        response = MainConsole.Instance.CmdPrompt("Estate name to join", LastEstateName);
                        if (response == "None")
                        {
                            continue;
                        }
                        LastEstateName = response;
                    }
                    else
                    {
                        LastEstateName = ownerEstates[0].EstateName;
                    }

                    List <int> estateIDs = EstateConnector.GetEstates(LastEstateName);
                    if (estateIDs == null)
                    {
                        m_log.Warn("The connection to the server was broken, please try again soon.");
                        continue;
                    }
                    if (estateIDs.Count < 1)
                    {
                        m_log.Warn("The name you have entered matches no known estate. Please try again");
                        continue;
                    }

                    int estateID = estateIDs[0];

                    string Password = Util.Md5Hash(Util.Md5Hash(MainConsole.Instance.CmdPrompt("Password for the estate", "")));
                    //We save the Password because we have to reset it after we tell the EstateService about it, as it clears it for security reasons
                    if (EstateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID, Password))
                    {
                        if (EstateConnector.LoadEstateSettings(scene.RegionInfo.RegionID, out ES)) //We could do by EstateID now, but we need to completely make sure that it fully is set up
                        {
                            if (ES == null)
                            {
                                m_log.Warn("The connection to the server was broken, please try again soon.");
                                continue;
                            }
                            //Reset the pass and save it to the database
                            IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                            EstatePassword     s = new EstatePassword()
                            {
                                Password = Password
                            };
                            if (g != null) //Save the pass to the database
                            {
                                g.AddGeneric(scene.RegionInfo.RegionID, "EstatePassword", ES.EstateID.ToString(), s.ToOSD());
                            }
                        }
                        else
                        {
                            m_log.Warn("The connection to the server was broken, please try again soon.");
                            continue;
                        }
                        m_log.Warn("Successfully joined the estate!");
                        break;
                    }

                    m_log.Warn("Joining the estate failed. Please try again.");
                    continue;
                }
            }
            return(ES);
        }
        /// <summary>
        /// Un-link a region from an estate region.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void EstateUnLinkRegionCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();

            string estateName = "";
            string regionName = "";

            // check for passed estate name
            estateName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Estate name", estateName)
                : cmd [3];
            if (estateName == "")
            {
                return;
            }

            // verify that the estate does exist
            EstateSettings ES = estateConnector.GetEstateSettings(estateName);

            if (ES == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName);
                return;
            }

            // check for passed  region to link to
            if (scene != null)
            {
                regionName = scene.RegionInfo.RegionName;
            }

            regionName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Region to remove", regionName)
                : cmd [4];
            if (regionName == "")
            {
                return;
            }

            // verify that the region does exist
            var region = gridService.GetRegionByName(null, regionName);

            if (region == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' does not exist!", regionName);
                return;
            }
            regionName = region.RegionName;

            // verify that the region is actually part of the estate
            if (!estateConnector.EstateRegionExists((int)ES.EstateID, region.RegionID))
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' is not part of the '{1}' estate!",
                                                 regionName, ES.EstateName);
                return;
            }

            // have all details.. do it...
            if (!estateConnector.DelinkRegion(region.RegionID))
            {
                MainConsole.Instance.Warn("Unlinking the region failed. Please try again.");
                return;
            }

            // unlink was successful..
            MainConsole.Instance.InfoFormat("Region '{0}' has been removed from estate '{1}'",
                                            regionName, estateName);

            //We really need to attach it to another estate though...
            ISystemEstateService sysEstateInfo = m_registry.RequestModuleInterface <ISystemEstateService> ();

            ES = estateConnector.GetEstateSettings(sysEstateInfo.SystemEstateName);
            if (ES != null)
            {
                if (estateConnector.LinkRegion(region.RegionID, (int)ES.EstateID))
                {
                    MainConsole.Instance.WarnFormat("'{0}' has been placed in the '{1}' estate until re-assigned",
                                                    regionName, sysEstateInfo.SystemEstateName);
                    UpdateConsoleRegionEstate(regionName, ES);
                }
            }
        }
        /// <summary>
        /// Link a region to an estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void EstateLinkRegionCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();

            string estateName = "";
            string regionName = "";

            // check for passed estate name
            estateName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Estate name", estateName)
                : cmd [3];
            if (estateName == "")
            {
                return;
            }

            // verify that the estate does exist
            EstateSettings ES = estateConnector.GetEstateSettings(estateName);

            if (ES == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName);
                return;
            }

            // check for passed  region to link to
            if (scene != null)
            {
                regionName = scene.RegionInfo.RegionName;
            }

            regionName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Region to add to " + estateName, regionName)
                : cmd [4];
            if (regionName == "")
            {
                return;
            }

            // verify that the region does exist
            var region = gridService.GetRegionByName(null, regionName);

            if (region == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The requested region '{0}' does not exist!", regionName);
                return;
            }

            // have all details.. do it...
            regionName = region.RegionName;
            if (estateConnector.LinkRegion(region.RegionID, (int)ES.EstateID))
            {
                // check for update..
                var es = estateConnector.GetRegionEstateSettings(region.RegionID);
                if ((es == null) || (es.EstateID == 0))
                {
                    MainConsole.Instance.Warn("The region link failed, please try again soon.");
                }
                else
                {
                    MainConsole.Instance.InfoFormat("Region '{0}' is now attached to estate '{1}'", regionName, estateName);
                    UpdateConsoleRegionEstate(regionName, es);
                }
            }
            else
            {
                MainConsole.Instance.Warn("Joining the estate failed. Please try again.");
            }
        }
        /// <summary>
        /// Creates the estate info for a region.
        /// </summary>
        /// <returns>The estate info.</returns>
        /// <param name="scene">Scene.</param>
        private EstateSettings CreateEstateInfo(IScene scene)
        {
            // check for regionType to determine if this is 'Mainland' or an 'Estate'
            string regType = scene.RegionInfo.RegionType.ToLower();

            if (regType.StartsWith("m"))
            {
                return(LinkMainlandEstate(scene.RegionInfo.RegionID));
            }

            // we are linking to a user estate
            IEstateConnector     estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
            ISystemEstateService sysEstateInfo   = m_registry.RequestModuleInterface <ISystemEstateService>();

            string sysEstateOwnerName;
            var    sysAccount = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, (UUID)Constants.RealEstateOwnerUUID);

            if (sysAccount == null)
            {
                sysEstateOwnerName = sysEstateInfo.SystemEstateOwnerName;
            }
            else
            {
                sysEstateOwnerName = sysAccount.Name;
            }


            // This is an 'Estate' so get some details....
            LastEstateOwner = sysEstateOwnerName;
            while (true)
            {
                UserAccount account;
                string      estateOwner;

                estateOwner = MainConsole.Instance.Prompt("Estate owner name (" + sysEstateOwnerName + "/User Name)", LastEstateOwner);

                // we have a prospective estate owner...
                List <EstateSettings> ownerEstates = null;
                account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, estateOwner);
                if (account != null)
                {
                    // we have a user account...
                    LastEstateOwner = account.Name;

                    ownerEstates = estateConnector.GetEstates(account.PrincipalID);
                }

                if (account == null || ownerEstates == null || ownerEstates.Count == 0)
                {
                    if (account == null)
                    {
                        MainConsole.Instance.Warn("[Estate]: Unable to locate the user " + estateOwner);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[Estate]: The user, {0}, has no estates currently.", account.Name);
                    }

                    string joinMainland = MainConsole.Instance.Prompt(
                        "Do you want to 'park' the region with the system owner/estate? (yes/no)", "yes");
                    if (joinMainland.ToLower().StartsWith("y"))                      // joining 'mainland'
                    {
                        return(LinkMainlandEstate(scene.RegionInfo.RegionID));
                    }

                    continue;
                }

                if (ownerEstates.Count > 1)
                {
                    MainConsole.Instance.InfoFormat("[Estate]: User {0} has {1} estates currently. {2}",
                                                    account.Name, ownerEstates.Count, "These estates are the following:");
                    foreach (EstateSettings t in ownerEstates)
                    {
                        MainConsole.Instance.CleanInfo("         " + t.EstateName);
                    }

                    LastEstateName = ownerEstates[0].EstateName;

                    List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList();
                    responses.Add("Cancel");

                    do
                    {
                        //TODO: This could be a problem if we have a lot of estates
                        string response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses);
                        if (response == "None" || response == "Cancel")
                        {
                            LastEstateName = "";
                            break;
                        }
                        LastEstateName = response;
                    } while (LastEstateName == "");
                    if (LastEstateName == "")
                    {
                        continue;
                    }
                }
                else
                {
                    LastEstateName = ownerEstates[0].EstateName;
                }


                // we should have a user account and estate name by now
                int estateID = estateConnector.GetEstate(account.PrincipalID, LastEstateName);
                if (estateID == 0)
                {
                    MainConsole.Instance.Warn("[Estate]: The name you have entered matches no known estate. Please try again");
                    continue;
                }

                // link up the region
                EstateSettings ES;
                if (estateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID))
                {
                    if ((ES = estateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null ||
                        ES.EstateID == 0)
                    //We could do by EstateID now, but we need to completely make sure that it fully is set up
                    {
                        MainConsole.Instance.Warn("[Estate]: The connection to the server was broken, please try again.");
                        continue;
                    }
                }
                else
                {
                    MainConsole.Instance.WarnFormat("[Estate]: Joining the {0} estate failed. Please try again.", LastEstateName);
                    continue;
                }

                MainConsole.Instance.InfoFormat("[Estate]: Successfully joined the {0} estate!", LastEstateName);
                return(ES);
            }
        }
Exemple #11
0
        /// <summary>
        ///     The god has requested that we update something in the region configuration
        /// </summary>
        /// <param name="client"></param>
        /// <param name="BillableFactor"></param>
        /// <param name="PricePerMeter"></param>
        /// <param name="EstateID"></param>
        /// <param name="RegionFlags"></param>
        /// <param name="SimName"></param>
        /// <param name="RedirectX"></param>
        /// <param name="RedirectY"></param>
        public void GodUpdateRegionInfoUpdate(IClientAPI client, float BillableFactor, int PricePerMeter, ulong EstateID,
                                              ulong RegionFlags, byte [] SimName, int RedirectX, int RedirectY)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            //Check god perms
            if (!client.Scene.Permissions.IsGod(client.AgentId))
            {
                return;
            }

            string oldRegionName = client.Scene.RegionInfo.RegionName;

            //Update their current region with new information
            if (Utils.BytesToString(SimName) != oldRegionName)
            {
                client.Scene.RegionInfo.RegionName = Utils.BytesToString(SimName);
                MainConsole.Instance.InfoFormat("[God] Region {0} has been renamed to {1}", oldRegionName, Utils.BytesToString(SimName));
                client.SendAgentAlertMessage("Region has been renamed to " + Utils.BytesToString(SimName), true);
            }

            // Save the old region locations
            int oldRegionLocX = client.Scene.RegionInfo.RegionLocX;
            int oldRegionLocY = client.Scene.RegionInfo.RegionLocY;
            int newRegionLocX = oldRegionLocX;
            int newRegionLocY = oldRegionLocY;

            //Set the region loc X and Y
            if (RedirectX != 0)
            {
                client.Scene.RegionInfo.RegionLocX = RedirectX * Constants.RegionSize;
                newRegionLocX = RedirectX;
            }
            if (RedirectY != 0)
            {
                client.Scene.RegionInfo.RegionLocY = RedirectY * Constants.RegionSize;
                newRegionLocY = RedirectY;
            }

            // Check if there's changes to display the new coords on the console and inworld
            if (newRegionLocX != oldRegionLocX || newRegionLocY != oldRegionLocY)
            {
                var oldMapLocX = oldRegionLocX / Constants.RegionSize;
                var oldMapLocY = oldRegionLocY / Constants.RegionSize;
                var newMapLocX = newRegionLocX / Constants.RegionSize;
                var newMapLocY = newRegionLocY / Constants.RegionSize;

                MainConsole.Instance.InfoFormat("[God] Region {0} has been moved from {1},{2} to {3},{4}",
                                                client.Scene.RegionInfo.RegionName,
                                                oldMapLocX, oldMapLocY,
                                                newMapLocX, newMapLocY);
                client.SendAgentAlertMessage("Region has been moved from " + oldMapLocX + "," + oldMapLocY
                                             + " to " + newMapLocX + "," + newMapLocY, true);
            }

            //Update the estate ID
            if (client.Scene.RegionInfo.EstateSettings.EstateID != EstateID)
            {
                bool changed = estateConnector.LinkRegion(client.Scene.RegionInfo.RegionID, (int)EstateID);
                if (!changed)
                {
                    client.SendAgentAlertMessage("Unable to connect to the given estate.", false);
                }
                else
                {
                    client.Scene.RegionInfo.EstateSettings.EstateID = (uint)EstateID;
                    estateConnector.SaveEstateSettings(client.Scene.RegionInfo.EstateSettings);
                }
            }

            //Set/Reset Estate settings
            client.Scene.RegionInfo.EstateSettings.BillableFactor = BillableFactor;
            client.Scene.RegionInfo.EstateSettings.PricePerMeter  = PricePerMeter;
            client.Scene.RegionInfo.EstateSettings.SetFromFlags(RegionFlags);

            // Set/Reset Region flags
            client.Scene.RegionInfo.RegionSettings.AllowDamage =
                ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.AllowDamage) == (ulong)OpenMetaverse.RegionFlags.AllowDamage);
            client.Scene.RegionInfo.RegionSettings.FixedSun = ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.SunFixed) ==
                                                               (ulong)OpenMetaverse.RegionFlags.SunFixed);
            client.Scene.RegionInfo.RegionSettings.BlockTerraform =
                ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.BlockTerraform) == (ulong)OpenMetaverse.RegionFlags.BlockTerraform);
            client.Scene.RegionInfo.RegionSettings.Sandbox =
                ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.Sandbox) == (ulong)OpenMetaverse.RegionFlags.Sandbox);

            //Update skipping scripts/physics/collisions
            IEstateModule mod = client.Scene.RequestModuleInterface <IEstateModule> ();

            if (mod != null)
            {
                mod.SetSceneCoreDebug(
                    ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.SkipScripts) == (ulong)OpenMetaverse.RegionFlags.SkipScripts),
                    ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.SkipCollisions) == (ulong)OpenMetaverse.RegionFlags.SkipCollisions),
                    ((RegionFlags & (ulong)OpenMetaverse.RegionFlags.SkipPhysics) == (ulong)OpenMetaverse.RegionFlags.SkipPhysics));
            }

            //Save the changes
            estateConnector.SaveEstateSettings(client.Scene.RegionInfo.EstateSettings);

            //Tell the clients to update all references to the new settings
            foreach (IScenePresence sp in client.Scene.GetScenePresences())
            {
                HandleRegionInfoRequest(sp.ControllingClient, client.Scene);
            }

            //Update the grid server as well
            IGridRegisterModule gridRegisterModule = client.Scene.RequestModuleInterface <IGridRegisterModule> ();

            if (gridRegisterModule != null)
            {
                gridRegisterModule.UpdateGridRegion(client.Scene);
            }
        }
Exemple #12
0
        /// <summary>
        /// Creates the estate info for a region.
        /// </summary>
        /// <returns>The estate info.</returns>
        /// <param name="scene">Scene.</param>
        EstateSettings CreateEstateInfo(IScene scene)
        {
            // check for regionType to determine if this is 'Mainland' or an 'Estate'
            string regType = scene.RegionInfo.RegionType.ToLower();

            if (regType.StartsWith("m", System.StringComparison.Ordinal))
            {
                return(LinkSystemEstate(scene.RegionInfo.RegionID, Constants.MainlandEstateID));
            }

            // we are linking to a user estate
            IEstateConnector      estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            ISystemAccountService sysAccounts     = m_registry.RequestModuleInterface <ISystemAccountService> ();

            string sysEstateOwnerName;
            var    sysAccount = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, sysAccounts.SystemEstateOwnerUUID);

            if (!sysAccount.Valid)
            {
                sysEstateOwnerName = sysAccounts.SystemEstateOwnerName;
            }
            else
            {
                sysEstateOwnerName = sysAccount.Name;
            }


            // This is an 'Estate' so get some details....
            var    LastEstateOwner = sysEstateOwnerName;
            string LastEstateName;

            while (true)
            {
                UserAccount ownerAcct;
                string      estateOwner;

                estateOwner = MainConsole.Instance.Prompt("Estate owner name (" + sysEstateOwnerName + "/User Name)", LastEstateOwner);

                // we have a prospective estate owner...
                List <EstateSettings> ownerEstates = null;
                ownerAcct = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, estateOwner);
                if (ownerAcct.Valid)
                {
                    // we have a user account...
                    LastEstateOwner = ownerAcct.Name;
                    ownerEstates    = estateConnector.GetEstates(ownerAcct.PrincipalID);
                }

                if (!ownerAcct.Valid || ownerEstates == null || ownerEstates.Count == 0)
                {
                    if (!ownerAcct.Valid)
                    {
                        MainConsole.Instance.Warn("[Estate]: Unable to locate the user " + estateOwner);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[Estate]: The user, {0}, has no estates currently.", ownerAcct.Name);
                    }

                    string joinSystemland = MainConsole.Instance.Prompt(
                        "Do you want to 'park' the region with the system owner/estate? (yes/no)", "yes");
                    if (joinSystemland.ToLower().StartsWith("y", System.StringComparison.Ordinal))                        // joining 'Systemland'
                    {
                        return(LinkSystemEstate(scene.RegionInfo.RegionID, Constants.SystemEstateID));
                    }

                    continue;
                }

                if (ownerEstates.Count > 1)
                {
                    MainConsole.Instance.InfoFormat("[Estate]: User {0} has {1} estates currently. {2}",
                                                    ownerAcct.Name, ownerEstates.Count, "These estates are the following:");
                    foreach (EstateSettings t in ownerEstates)
                    {
                        MainConsole.Instance.CleanInfo("         " + t.EstateName);
                    }

                    LastEstateName = ownerEstates [0].EstateName;

                    List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList();
                    responses.Add("Cancel");

                    do
                    {
                        //TODO: This could be a problem if we have a lot of estates
                        string response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses);
                        if (response == "None" || response == "Cancel")
                        {
                            LastEstateName = "";
                            break;
                        }
                        LastEstateName = response;
                    } while (LastEstateName == "");
                    if (LastEstateName == "")
                    {
                        continue;
                    }
                }
                else
                {
                    LastEstateName = ownerEstates [0].EstateName;
                }


                // we should have a user account and estate name by now
                int estateID = estateConnector.GetEstate(ownerAcct.PrincipalID, LastEstateName);
                if (estateID == 0)
                {
                    MainConsole.Instance.Warn("[Estate]: The name you have entered matches no known estate. Please try again");
                    continue;
                }

                // link up the region
                EstateSettings ES;
                UUID           oldOwnerID = UUID.Zero;
                if (scene.RegionInfo.EstateSettings != null)
                {
                    oldOwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
                }

                if (!estateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID))
                {
                    MainConsole.Instance.WarnFormat("[Estate]: Joining the {0} estate failed. Please try again.", LastEstateName);
                    continue;
                }

                // make sure that the region is fully set up
                if ((ES = estateConnector.GetRegionEstateSettings(scene.RegionInfo.RegionID)) == null || ES.EstateID == 0)
                {
                    MainConsole.Instance.Warn("[Estate]: Unable to verify region update (possible server connection error), please try again.");
                    continue;
                }

                // Linking was successful, change any previously owned parcels to the new owner
                if (oldOwnerID != UUID.Zero)
                {
                    IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule> ();
                    if (parcelManagement != null)
                    {
                        parcelManagement.ReclaimParcels(oldOwnerID, ES.EstateOwner);
                    }
                }

                MainConsole.Instance.InfoFormat("[Estate]: Successfully joined the {0} estate!", LastEstateName);
                return(ES);
            }
        }
Exemple #13
0
        private EstateSettings CreateEstateInfo(IScene scene)
        {
            EstateSettings ES = new EstateSettings();

            while (true)
            {
                IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

                string      name    = MainConsole.Instance.Prompt("Estate owner name", LastEstateOwner);
                UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, name);

                if (account == null)
                {
                    string createNewUser =
                        MainConsole.Instance.Prompt(
                            "Could not find user " + name + ". Would you like to create this user?", "yes");

                    if (createNewUser == "yes")
                    {
                        // Create a new account
                        string password = MainConsole.Instance.PasswordPrompt(name + "'s password");
                        string email    = MainConsole.Instance.Prompt(name + "'s email", "");

                        scene.UserAccountService.CreateUser(name, Util.Md5Hash(password), email);
                        account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, name);

                        if (account == null)
                        {
                            MainConsole.Instance.ErrorFormat(
                                "[EstateService]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level.");
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                LastEstateOwner = account.Name;

                List <EstateSettings> ownerEstates = EstateConnector.GetEstates(account.PrincipalID);
                string response = (ownerEstates != null && ownerEstates.Count > 0) ? "yes" : "no";
                if (ownerEstates != null && ownerEstates.Count > 0)
                {
                    MainConsole.Instance.WarnFormat("Found user. {0} has {1} estates currently. {2}", account.Name,
                                                    ownerEstates.Count,
                                                    "These estates are the following:");
                    foreach (EstateSettings t in ownerEstates)
                    {
                        MainConsole.Instance.Warn(t.EstateName);
                    }
                    response =
                        MainConsole.Instance.Prompt(
                            "Do you wish to join one of these existing estates? (Options are {yes, no, cancel})",
                            response, new List <string> {
                        "yes", "no", "cancel"
                    });
                }
                else
                {
                    MainConsole.Instance.WarnFormat("Found user. {0} has no estates currently. Creating a new estate.",
                                                    account.Name);
                }
                if (response == "no")
                {
                    // Create a new estate
                    // ES could be null
                    ES.EstateName = MainConsole.Instance.Prompt("New estate name (or cancel to go back)", "My Estate");
                    if (ES.EstateName == "cancel")
                    {
                        continue;
                    }
                    //Set to auto connect to this region next
                    LastEstateName = ES.EstateName;
                    ES.EstateOwner = account.PrincipalID;

                    ES.EstateID = (uint)EstateConnector.CreateNewEstate(ES, scene.RegionInfo.RegionID);
                    if (ES.EstateID == 0)
                    {
                        MainConsole.Instance.Warn("There was an error in creating this estate: " + ES.EstateName);
                        //EstateName holds the error. See LocalEstateConnector for more info.
                        continue;
                    }
                    break;
                }
                if (response == "yes")
                {
                    if (ownerEstates != null && ownerEstates.Count != 1)
                    {
                        if (LastEstateName == "")
                        {
                            LastEstateName = ownerEstates[0].EstateName;
                        }

                        List <string> responses = ownerEstates.Select(settings => settings.EstateName).ToList();

                        responses.Add("None");
                        responses.Add("Cancel");
                        response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses);
                        if (response == "None" || response == "Cancel")
                        {
                            continue;
                        }
                        LastEstateName = response;
                    }
                    else if (ownerEstates != null)
                    {
                        LastEstateName = ownerEstates[0].EstateName;
                    }

                    int estateID = EstateConnector.GetEstate(account.PrincipalID, LastEstateName);
                    if (estateID == 0)
                    {
                        MainConsole.Instance.Warn("The name you have entered matches no known estate. Please try again");
                        continue;
                    }

                    //We save the Password because we have to reset it after we tell the EstateService about it, as it clears it for security reasons
                    if (EstateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID))
                    {
                        if ((ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null ||
                            ES.EstateID == 0)
                        //We could do by EstateID now, but we need to completely make sure that it fully is set up
                        {
                            MainConsole.Instance.Warn("The connection to the server was broken, please try again soon.");
                            continue;
                        }
                        MainConsole.Instance.Warn("Successfully joined the estate!");
                        break;
                    }

                    MainConsole.Instance.Warn("Joining the estate failed. Please try again.");
                    continue;
                }
            }
            return(ES);
        }
        /// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates (IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions ((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID) {
                estateConnector.DeleteEstate ((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate (eS);
                MainConsole.Instance.Info ("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions) {
                estateConnector.LinkRegion (regID, newEstateID);
            }
            if (regions.Count > 0)
                MainConsole.Instance.InfoFormat ("Relinked {0} regions", regions.Count);
        }