/// <summary>
        ///     Server side
        /// </summary>
        /// <param name="FunctionName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "EstateUpdated")
            {
                EstateSettings            es = (EstateSettings)parameters;
                IEstateConnector          estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
                ISyncMessagePosterService asyncPoster     = m_registry.RequestModuleInterface <ISyncMessagePosterService> ();
                IGridService gridService = m_registry.RequestModuleInterface <IGridService> ();

                if (estateConnector != null && gridService != null && asyncPoster != null)
                {
                    List <UUID> regions = estateConnector.GetRegions((int)es.EstateID);
                    if (regions != null)
                    {
                        foreach (UUID region in regions)
                        {
                            //Send the message to update all regions that are in this estate, as a setting changed
                            GridRegion r = gridService.GetRegionByUUID(null, region);
                            if (r != null)
                            {
                                asyncPoster.Post(r.ServerURI, SyncMessageHelper.UpdateEstateInfo(es.EstateID, region));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Example #2
0
 /// <summary>
 /// Region side
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 protected OSDMap OnMessageReceived(OSDMap message)
 {
     //We need to check and see if this is an AgentStatusChange
     if (message.ContainsKey("Method") && message["Method"] == "EstateUpdated")
     {
         OSDMap innerMessage = (OSDMap)message["Message"];
         //We got a message, deal with it
         uint         estateID = innerMessage["EstateID"].AsUInteger();
         UUID         regionID = innerMessage["RegionID"].AsUUID();
         SceneManager manager  = m_registry.RequestModuleInterface <SceneManager>();
         if (manager != null)
         {
             Scene s = null;
             if (manager.TryGetScene(regionID, out s))
             {
                 if (s.RegionInfo.EstateSettings.EstateID == estateID)
                 {
                     IEstateConnector estateConnector = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>();
                     if (estateConnector != null)
                     {
                         EstateSettings es = null;
                         if (estateConnector.LoadEstateSettings(regionID, out es))
                         {
                             s.RegionInfo.EstateSettings = es;
                             m_log.Debug("[EstateProcessor]: Updated estate information.");
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
Example #3
0
        protected void ChangeEstate(IScene scene, string[] cmd)
        {
            IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                string removeFromEstate =
                    MainConsole.Instance.Prompt(
                        "Are you sure you want to leave the estate for region " + scene.RegionInfo.RegionName + "?",
                        "yes");
                if (removeFromEstate == "yes")
                {
                    if (!EstateConnector.DelinkRegion(scene.RegionInfo.RegionID))
                    {
                        MainConsole.Instance.Warn("Unable to remove this region from the estate.");
                        return;
                    }
                    scene.RegionInfo.EstateSettings = CreateEstateInfo(scene);
                }
                else
                {
                    MainConsole.Instance.Warn("No action has been taken.");
                }
            }
        }
        public string GetCurrentEstate(UUID regionID)
        {
            object remoteValue = InternalDoRemote(regionID);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return((string)remoteValue);
            }

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

            if (conn != null)
            {
                EstateSettings es = conn.GetEstateSettings(regionID);
                if (es == null || es.EstateID == 0)
                {
                    return("");
                }
                else
                {
                    return(es.EstateName);
                }
            }
            return("");
        }
        public string GetEstateOwnerName(UUID regionID)
        {
            object remoteValue = InternalDoRemote(regionID);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return((string)remoteValue);
            }

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

            if (conn != null)
            {
                EstateSettings es = conn.GetEstateSettings(regionID);
                if (es == null || es.EstateID == 0)
                {
                    return("");
                }
                else
                {
                    return(m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, es.EstateOwner).Name);
                }
            }
            return("");
        }
        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.Count == 0)
            {
                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);
            }
        }
        public bool CreateNewEstate(UUID regionID, string estateName, string ownerName)
        {
            object remoteValue = InternalDoRemote(regionID, estateName, ownerName);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return(remoteValue == null ? false : (bool)remoteValue);
            }

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

            if (conn != null)
            {
                var account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, ownerName);
                if (account != null)
                {
                    UUID userID = account.PrincipalID;
                    conn.DelinkRegion(regionID);

                    return(conn.CreateNewEstate(new EstateSettings()
                    {
                        EstateName = estateName, EstateOwner = userID
                    }, regionID) != 0);
                }
            }
            return(false);
        }
Example #8
0
        /// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="ES">EstateSettings</param>
        private void  UpdateSystemEstates(IEstateConnector estateConnector, EstateSettings ES)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = ES.EstateID;
            int  newEstateID = Constants.SystemEstateID;

            // 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 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);
            }
        }
        public List <string> GetEstatesForUser(string name)
        {
            object remoteValue = InternalDoRemote(name);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return((List <string>)remoteValue);
            }

            List <string>    estateItems = new List <string>();
            IEstateConnector conn        = Aurora.DataManager.DataManager.RequestPlugin <IEstateConnector>();

            if (conn != null)
            {
                UserAccount account = m_registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, name);
                if (account != null)
                {
                    List <EstateSettings> estates = conn.GetEstates(account.PrincipalID);
                    foreach (var es in estates)
                    {
                        estateItems.Add(es.EstateName);
                    }
                }
            }
            return(estateItems);
        }
        public uint Count(uint estateID, RegionFlags flags)
        {
            IEstateConnector estates = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (estates == null)
            {
                return(0);
            }

            EstateSettings es = estates.GetEstateSettings((int)estateID);

            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters ["Flags"] = (uint)flags;

            List <GridRegion> query = ParseQuery(null, GD.Query(new string [] { "*" }, m_realm, filter, null, null, null));

            uint count = 0;

            query.ForEach(delegate(GridRegion region) {
                if (region.EstateOwner == es.EstateOwner &&
                    estates.GetEstateID(region.RegionID) == es.EstateID)
                {
                    ++count;
                }
            });

            return(count);
        }
        /// <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);
        }
        /// <summary>
        ///     Region side
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //We need to check and see if this is an AgentStatusChange
            if (message.ContainsKey("Method") && message ["Method"] == "EstateUpdated")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                //We got a message, deal with it
                uint             estateID        = innerMessage ["EstateID"].AsUInteger();
                UUID             regionID        = innerMessage ["RegionID"].AsUUID();
                ISceneManager    manager         = m_registry.RequestModuleInterface <ISceneManager> ();
                IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

                if (manager != null && estateConnector != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.RegionInfo.EstateSettings.EstateID == estateID)
                        {
                            EstateSettings es = null;
                            if ((es = estateConnector.GetRegionEstateSettings(regionID)) != null && es.EstateID != 0)
                            {
                                scene.RegionInfo.EstateSettings = es;
                                MainConsole.Instance.Debug("[EstateProcessor]: Updated estate information.");
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public void FinishStartup(IScene scene, IConfigSource source, ISimulationBase openSimBase)
        {
            if (scene.RegionInfo.EstateSettings != null)
            {
                return;
            }

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

            if (EstateConnector != null)
            {
                EstateSettings ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID);
                if (ES == null)
                {
                    //It could not find the estate service, wait until it can find it
                    MainConsole.Instance.Warn("We could not find the estate service for this sim. Please make sure that your URLs are correct in grid mode.");
                    while (true)
                    {
                        MainConsole.Instance.Prompt("Press enter to try again.");
                        if ((ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null || ES.EstateID == 0)
                        {
                            ES = CreateEstateInfo(scene);
                            break;
                        }
                        if (ES != null)
                        {
                            break;
                        }
                    }
                }
                else if (ES.EstateID == 0)
                {
                    //It found the estate service, but found no estates for this region, make a new one
                    MainConsole.Instance.Warn("Your region " + scene.RegionInfo.RegionName + " is not part of an estate.");

                    bool noGui = false;

                    IConfig startupconfig = source.Configs["Startup"];
                    if (startupconfig != null)
                    {
                        noGui = startupconfig.GetBoolean("NoGUI", false);
                    }

                    if (noGui)
                    {
                        ES = CreateEstateInfo(scene);
                    }
                    else
                    {
                        Aurora.Management.RegionManager.StartSynchronously(true,
                                                                           Management.RegionManagerPage.EstateSetup, source,
                                                                           openSimBase.ApplicationRegistry.RequestModuleInterface <IRegionManagement>());
                        FinishStartup(scene, source, openSimBase);
                        return;
                    }
                }
                scene.RegionInfo.EstateSettings = ES;
            }
        }
        /// <summary>
        /// Deletes an estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void DeleteEstateCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            string estateName = "";

            // check for passed estate name
            estateName = (cmd.Length < 3)
                ? MainConsole.Instance.Prompt("Estate name", estateName)
                : Util.CombineParams(cmd, 2);
            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 bogies...
            if (Utilities.IsSystemUser(ES.EstateOwner))
            {
                MainConsole.Instance.Info("[EstateService]: Tsk, tsk.  System estates should not be deleted!");
                return;
            }

            // check for linked regions
            var regions = estateConnector.GetRegions((int)ES.EstateID);

            if (regions.Count > 0)
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' has {1} associated regions. These must be unlinked before deletion!",
                                                estateName, regions.Count);
                return;
            }

            var okDelete = MainConsole.Instance.Prompt("Delete estate '" + estateName + "'. Are you sure? (yes/no)", "no").ToLower() == "yes";

            if (okDelete)
            {
                estateConnector.DeleteEstate((int)ES.EstateID);
                MainConsole.Instance.Warn(estateName + " has been deleted");
            }
            else
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' has not been deleted.", estateName);
            }
        }
        public void FinishedStartup()
        {
            m_accountService  = m_registry.RequestModuleInterface <IUserAccountService> ();
            m_estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            // only valid if we are local
            if (m_accountService.IsLocalConnector)
            {
                AddCommands();
            }
        }
Example #16
0
        public void FinishStartup(Scene scene, IConfigSource source, ISimulationBase openSimBase)
        {
            IEstateConnector EstateConnector = DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                EstateSettings ES;
                if (EstateConnector.LoadEstateSettings(scene.RegionInfo.RegionID, out ES) && ES == null)
                {
                    //It found the estate service, but found no estates for this region, make a new one
                    m_log.Warn("Your region " + scene.RegionInfo.RegionName + " is not part of an estate.");
                    ES = CreateEstateInfo(scene);
                }
                else if (ES != null)
                {
                    //It found the estate service and it found an estate for this region
                }
                else
                {
                    //It could not find the estate service, wait until it can find it
                    m_log.Warn("We could not find the estate service for this sim. Please make sure that your URLs are correct in grid mode.");
                    while (true)
                    {
                        MainConsole.Instance.CmdPrompt("Press enter to try again.");
                        if (EstateConnector.LoadEstateSettings(scene.RegionInfo.RegionID, out ES) && ES == null)
                        {
                            ES = CreateEstateInfo(scene);
                            break;
                        }
                        else if (ES != null)
                        {
                            break;
                        }
                    }
                }
                //Get the password from the database now that we have either created a new estate and saved it, joined a new estate, or just reloaded
                IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                EstatePassword     s = null;
                if (g != null)
                {
                    s = g.GetGeneric <EstatePassword>(scene.RegionInfo.RegionID, "EstatePassword", ES.EstateID.ToString(), new EstatePassword());
                }
                if (s != null)
                {
                    ES.EstatePass = s.Password;
                }

                scene.RegionInfo.EstateSettings = ES;
            }
        }
        public void FinishedStartup()
        {
            m_accountService = m_registry.RequestModuleInterface<IUserAccountService> ();
            m_estateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector> ();

            // these are only valid if we are local
            if (m_accountService.IsLocalConnector)
            {
                // check and/or create default system estates
                CheckSystemEstateInfo (Constants.SystemEstateID, systemEstateName, (UUID) Constants.RealEstateOwnerUUID);
                CheckSystemEstateInfo (Constants.MainlandEstateID, mainlandEstateName, (UUID) Constants.GovernorUUID);

                AddCommands ();
            }
        }
Example #18
0
        public void FinishedStartup()
        {
            m_accountService  = m_registry.RequestModuleInterface <IUserAccountService> ();
            m_estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            // these are only valid if we are local
            if (m_accountService.IsLocalConnector)
            {
                // check and/or create default system estates
                CheckSystemEstateInfo(Constants.SystemEstateID, systemEstateName, (UUID)Constants.RealEstateOwnerUUID);
                CheckSystemEstateInfo(Constants.MainlandEstateID, mainlandEstateName, (UUID)Constants.GovernorUUID);

                AddCommands();
            }
        }
        public void FinishedStartup()
        {
            m_accountService  = m_registry.RequestModuleInterface <IUserAccountService>();
            m_estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            // these are only valid if we are local
            if (!m_accountService.RemoteCalls())
            {
                // check and/or create default RealEstate user
                CheckSystemUserInfo();
                CheckSystemEstateInfo();

                AddCommands();
            }
        }
        /// <summary>
        /// Shows details of all estates.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void ShowEstatesCommand(IScene scene, string [] cmd)
        {
            IEstateConnector    estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IUserAccountService accountService  = m_registry.RequestModuleInterface <IUserAccountService> ();

            string estateInfo;
            var    estates = estateConnector.GetEstateNames();

            // headings
            estateInfo  = string.Format("{0, -20}", "Estate");
            estateInfo += string.Format("{0, -20}", "Owner");
            estateInfo += string.Format("{0, -10}", "Regions");
            estateInfo += string.Format("{0, -10}", "Voice");
            estateInfo += string.Format("{0, -10}", "Price/M");
            estateInfo += string.Format("{0, -10}", "Public");
            estateInfo += string.Format("{0, -10}", "Tax Free");
            estateInfo += string.Format("{0, -10}", "Direct Tp");

            MainConsole.Instance.CleanInfo(estateInfo);
            MainConsole.Instance.CleanInfo("--------------------------------------------------------------------------------------------------");

            foreach (string estate in estates)
            {
                var            estateID = estateConnector.GetEstateID(estate);
                EstateSettings ES       = estateConnector.GetEstateIDSettings(estateID);

                if (ES != null)
                {
                    //var regInfo = scene.RegionInfo;
                    UserAccount EstateOwner = accountService.GetUserAccount(null, ES.EstateOwner);
                    var         regions     = estateConnector.GetRegions(estateID);

                    // todo ... change hardcoded field sizes to public constants
                    estateInfo  = string.Format("{0, -20}", ES.EstateName);
                    estateInfo += string.Format("{0, -20}", EstateOwner.Name);
                    estateInfo += string.Format("{0, -10}", regions.Count);
                    estateInfo += string.Format("{0, -10}", (ES.AllowVoice) ? "Yes" : "No");
                    estateInfo += string.Format("{0, -10}", ES.PricePerMeter);
                    estateInfo += string.Format("{0, -10}", (ES.PublicAccess) ? "Yes" : "No");
                    estateInfo += string.Format("{0, -10}", (ES.TaxFree) ? "Yes" : "No");
                    estateInfo += string.Format("{0, -10}", (ES.AllowDirectTeleport) ? "Yes" : "No");

                    MainConsole.Instance.CleanInfo(estateInfo);
                }
            }
            MainConsole.Instance.CleanInfo("\n");
        }
        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));
            }
        }
Example #22
0
        public void FinishStartup(IScene scene, IConfigSource source, ISimulationBase openSimBase)
        {
            if (scene.RegionInfo.EstateSettings != null)
            {
                return;
            }

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

            if (EstateConnector != null)
            {
                EstateSettings ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID);
                if (ES == null)
                {
                    //It could not find the estate service, wait until it can find it
                    MainConsole.Instance.Warn(
                        "We could not find the estate service for this sim. Please make sure that your URLs are correct in grid mode.");
                    while (true)
                    {
                        MainConsole.Instance.Prompt("Press enter to try again.");
                        if ((ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null ||
                            ES.EstateID == 0)
                        {
                            ES = CreateEstateInfo(scene);
                            break;
                        }
                        if (ES != null)
                        {
                            break;
                        }
                    }
                }
                else if (ES.EstateID == 0)
                {
                    //It found the estate service, but found no estates for this region, make a new one
                    MainConsole.Instance.Warn("[EstateInitializer]: Your region " + scene.RegionInfo.RegionName +
                                              " is not part of an estate.");

                    ES = CreateEstateInfo(scene);
                }
                scene.RegionInfo.EstateSettings = ES;
            }
        }
        public List <GridRegion> Get(uint start, uint count, uint estateID, RegionFlags flags,
                                     Dictionary <string, bool> sort)
        {
            List <GridRegion> resp    = new List <GridRegion>();
            IEstateConnector  estates = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (count == 0 || estates == null)
            {
                return(resp);
            }

            EstateSettings es = estates.GetEstateSettings((int)estateID);

            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters["Flags"] = (uint)flags;

            while (resp.Count < count)
            {
                uint limit = count - (uint)resp.Count;
                List <GridRegion> query = ParseQuery(null,
                                                     GD.Query(new string[] { "*" }, m_realm, filter, sort, start, count));

                if (query.Count == 0)
                {
                    break;
                }

                query.ForEach(delegate(GridRegion region)
                {
                    if (region.EstateOwner == es.EstateOwner &&
                        estates.GetEstateID(region.RegionID) == es.EstateID)
                    {
                        resp.Add(region);
                    }
                });

                start += limit;
            }

            return(resp);
        }
        public bool Store(GridRegion region)
        {
            if (region.EstateOwner == UUID.Zero)
            {
                IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
                EstateSettings   ES = null;
                if (EstateConnector != null)
                {
                    ES = EstateConnector.GetRegionEstateSettings(region.RegionID);
                    if ((ES != null) && (ES.EstateID != 0))
                    {
                        region.EstateOwner = ES.EstateOwner;
                    }
                }
                if (region.EstateOwner == UUID.Zero && ES != null && ES.EstateID != 0)
                {
                    MainConsole.Instance.Error(
                        "[LocalGridConnector] Attempt to store region with owner of UUID.Zero detected:" +
                        (new System.Diagnostics.StackTrace()).GetFrame(1));
                }
            }

            Dictionary <string, object> row = new Dictionary <string, object> (14);

            row ["ScopeID"]    = region.ScopeID;
            row ["RegionUUID"] = region.RegionID;
            row ["RegionName"] = region.RegionName;
            row ["LocX"]       = region.RegionLocX;
            row ["LocY"]       = region.RegionLocY;
            row ["LocZ"]       = region.RegionLocZ;
            row ["OwnerUUID"]  = region.EstateOwner;
            row ["Access"]     = region.Access;
            row ["SizeX"]      = region.RegionSizeX;
            row ["SizeY"]      = region.RegionSizeY;
            row ["SizeZ"]      = region.RegionSizeZ;
            row ["Flags"]      = region.Flags;
            row ["SessionID"]  = region.SessionID;
            row ["Info"]       = OSDParser.SerializeJsonString(region.ToOSD());

            return(m_GD.Replace(m_realm, row));
        }
        /// <summary>
        /// Sets(renames) an existing estate name.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void SetEstateNameCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            string estateName    = "";
            string estateNewName = "";

            // check for passed estate name
            estateName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("Estate name to be changed", 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  estate new name
            estateNewName = (cmd.Length < 4)
                ? MainConsole.Instance.Prompt("New name for the Estate", estateNewName)
                : cmd [4];
            if (estateNewName == "")
            {
                return;
            }

            // We have a valid Estate and user, send it off for processing.
            ES.EstateName = estateNewName;
            estateConnector.SaveEstateSettings(ES);

            MainConsole.Instance.InfoFormat("[EstateService]: Estate '{0}' changed to '{1}'", estateName, estateNewName);
        }
        /// <summary>
        /// Changes the region estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void ChangeEstate(IScene scene, string[] cmd)
        {
            IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                // a bit of info re 'Mainland'
                string regType = scene.RegionInfo.RegionType.ToLower();
                if (regType.StartsWith("m") && (scene.RegionInfo.EstateSettings.EstateID == Constants.SystemEstateID))
                {
                    MainConsole.Instance.Info("[Estate]: This region is already part of the Mainland system estate");
                    return;
                }

                string removeFromEstate =
                    MainConsole.Instance.Prompt(
                        "Are you sure you want to change the estate for region '" + scene.RegionInfo.RegionName + "'? (yes/no)",
                        "yes");

                if (removeFromEstate == "yes")
                {
                    if (regType.StartsWith("m"))
                    {
                        MainConsole.Instance.Info("[Estate]: Mainland type regions can only be part of the Mainland system estate");
                    }

                    if (!EstateConnector.DelinkRegion(scene.RegionInfo.RegionID))
                    {
                        MainConsole.Instance.Warn("[Estate]: Unable to remove this region from the estate.");
                        return;
                    }
                    scene.RegionInfo.EstateSettings = CreateEstateInfo(scene);
                }
                else
                {
                    MainConsole.Instance.Warn("[Estate]: No action has been taken.");
                }
            }
        }
        /// <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);
        }
Example #28
0
        protected void ChangeEstate(string module, string[] cmd)
        {
            IEstateConnector EstateConnector = DataManager.RequestPlugin <IEstateConnector>();

            if (EstateConnector != null)
            {
                if (MainConsole.Instance.ConsoleScene == null)
                {
                    m_log.Warn("Select a region before using this command.");
                    return;
                }
                Scene  scene            = (Scene)MainConsole.Instance.ConsoleScene;
                string removeFromEstate = MainConsole.Instance.CmdPrompt("Are you sure you want to leave the estate for region " + scene.RegionInfo.RegionName + "?", "yes");
                if (removeFromEstate == "yes")
                {
                    if (!EstateConnector.DelinkRegion(scene.RegionInfo.RegionID, scene.RegionInfo.EstateSettings.EstatePass))
                    {
                        m_log.Warn("Unable to remove this region from the estate.");
                        return;
                    }
                    scene.RegionInfo.EstateSettings = CreateEstateInfo(scene);
                    IGenericsConnector g = DataManager.RequestPlugin <IGenericsConnector>();
                    EstatePassword     s = null;
                    if (g != null)
                    {
                        s = g.GetGeneric <EstatePassword>(scene.RegionInfo.RegionID, "EstatePassword", scene.RegionInfo.EstateSettings.EstateID.ToString(), new EstatePassword());
                    }
                    if (s != null)
                    {
                        scene.RegionInfo.EstateSettings.EstatePass = s.Password;
                    }
                }
                else
                {
                    m_log.Warn("No action has been taken.");
                }
            }
        }
Example #29
0
        public void FinishStartup(IScene scene, IConfigSource source, ISimulationBase simBase)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (estateConnector != null)
            {
                EstateSettings ES = estateConnector.GetRegionEstateSettings(scene.RegionInfo.RegionID);
                if (ES == null)
                {
                    //Could not locate the estate service, wait until it can find it
                    MainConsole.Instance.Warn(
                        "We could not find the estate service for this region. Please make sure that your URLs are correct in grid mode.");
                    while (true)
                    {
                        MainConsole.Instance.Prompt("Press enter to try again.");
                        if ((ES = estateConnector.GetRegionEstateSettings(scene.RegionInfo.RegionID)) == null ||
                            ES.EstateID == 0)
                        {
                            ES = CreateEstateInfo(scene);
                            break;
                        }
                        if (ES != null)
                        {
                            break;
                        }
                    }
                }
                else if (ES.EstateID == 0)
                {
                    //This region does not belong to an estate, make a new one or join and existing one
                    MainConsole.Instance.Warn("[EstateInitializer]: Your region '" + scene.RegionInfo.RegionName +
                                              "' is not part of an estate.");

                    ES = CreateEstateInfo(scene);
                }
                scene.RegionInfo.EstateSettings = ES;
            }
        }
Example #30
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);
        }
        public void FinishedStartup()
        {
            m_accountService = m_registry.RequestModuleInterface<IUserAccountService>();
            m_estateConnector  = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector>();

            // these are only valid if we are local
            if (!m_accountService.RemoteCalls())
            {
                // check and/or create default RealEstate user
                CheckSystemUserInfo ();
                CheckSystemEstateInfo ();

                AddCommands ();
            }
        }
        /// <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);
        }
Example #33
0
        /// <summary>
        /// This method will produce a random city with the central region of the city being
        /// specified as a parameter. More parameters need to be made available for this method
        /// to produce a better quality city, note for now the minimum area for a city is a
        /// 3x3 grid of regions. This code is based on the original C++ version called pixel city.
        /// </summary>
        /// <param name="seed_value">Random integer seed value.</param>
        /// <returns>true / false indicator of success or failure.</returns>
        private bool doGenerate(int seed_value)
        {
            int rx, ry;
            //  Based on the initial seed value populate the regions that this shared module
            // is connected to, this means first get a list of the region, determine which
            // region is in the center of all the regions and set this as the hotzone, or
            // central part of the city (this is where the tallest/largest buildings will
            // be created) and will extend out to cover virtually all of the connected
            // regions if desired. No support for aging of the buildings or the city exists
            // yet it is a possible course for the future of this module.

            //  TODO
            //
            //      Validate the details in the configuration file against the settings in
            // the database, otherwise a new user/estate/parcel could be created which will
            // negate any of the security systems that Aurora has in place.

            //  First quick check to see if the module is enabled or not.
            if (!m_fEnabled)
            {
                m_log.Info("[CITY BUILDER]: Disabled, aborting auto generation.");
                return (false);
            }

            m_log.Info("[CITY BUILDER]: Auto generating the city.");

            //  Now we need to ask some basic values for the city generation, we already have
            // the base seed value as this is part of the 'city generate' command, now what
            // about a name, position, size, densities etc. Some of this can be generated
            // based on the seed value, but then, it would need to be confirmed by the user
            // or allow them to change it. TODO move all requested data into the configuration file.
            if (m_UserAccountService == null)
            {
                m_UserAccountService = simulationBase.ApplicationRegistry.RequestModuleInterface<IUserAccountService>();
            }

            //  Decide where the city is to be placed within the server instance.
            int r = CityModule.randomValue(10);

            string regionCount = MainConsole.Instance.CmdPrompt("Region Count ", r.ToString());
            r = Convert.ToInt32(regionCount);
            m_log.InfoFormat("[CITY BUILDER]: City area {0} x {1} regions ", r, r);

            //  Needs to be changed to use the 'defualt' properties and ask about the default
            // estate settings that are to be used, even if it is nothing more than just a
            // confirmation of the settings that are in the configuration file.
            cityName = MainConsole.Instance.CmdPrompt("City Name ", cityName);
            cityOwner = MainConsole.Instance.CmdPrompt("City Owner ", cityOwner);
            m_DefaultUserName = cityOwner;

            //  Make sure that the user and estate information specified in the configuration file
            // have been loaded and the information has either been found or has been created.
            m_DefaultUserAccount = m_UserAccountService.GetUserAccount(UUID.Zero, cityOwner);
            if (m_DefaultUserAccount == null)
            {
                m_log.InfoFormat("[CITY BUILDER]: Creating default account {0}", m_DefaultUserName);
                m_UserAccountService.CreateUser(m_DefaultUserName, Util.Md5Hash(m_DefaultUserPword), m_DefaultUserEmail);
                m_DefaultUserAccount = m_UserAccountService.GetUserAccount(UUID.Zero, m_DefaultUserName);
                cityOwner = m_DefaultUserName;
            }
            else
                m_log.InfoFormat("[CITY BUILDER]: Account found for {0}", m_DefaultUserName);

            // Obtain the scene manager that the server instance is using.
            sceneManager = simulationBase.ApplicationRegistry.RequestModuleInterface<SceneManager>();

            //  Construct the data instance for a city map to hold the total regions in the simulation.
            cityMap = new CityMap();
            citySeed = seed_value;
            cityMap.cityRegions = new Scene[r, r];
            cityMap.cityPlots = new List<BuildingPlot>();
            cityMap.cityBuildings = new List<CityBuilding>();

            //  Construct land and estate data and update to reflect the found user or the newly created one.
            cityLandData = new LandData();
            RegionInfo regionInfo = new RegionInfo();

            regionInfo.RegionID = UUID.Random();

            //  Determine if the default user account as specified in City Builder's configuration file
            // has any predefined estates, if so, just select the first one for now. Perhaps a search of
            // the estates to attempt to find a match to the details from the configuration file.
            EstateConnector = Aurora.DataManager.DataManager.RequestPlugin<IEstateConnector>();
            // Valid estate connection established.
            if (EstateConnector != null)
            {
                //  Valid estate connector, determine if the default user account has any estates.
                List<EstateSettings> estates = EstateConnector.GetEstates(m_DefaultUserAccount.PrincipalID);
                // No estates are found, so construct a new one based on the default estate settings
                // from the configuration file.
                if (estates == null)
                {
                    // No estates present so construct one.
                    m_DefaultEstate = new EstateSettings();

                    m_log.InfoFormat("[CITY BUILDER]: No estates found for user {0}, constructing default estate.", m_DefaultUserAccount.Name);

                    m_DefaultEstate.EstateOwner = m_DefaultUserAccount.PrincipalID;
                    m_DefaultEstate.EstateName = m_DefaultEstateName;
                    m_DefaultEstate.EstatePass = Util.Md5Hash(Util.Md5Hash(m_DefaultEstatePassword));
                    m_DefaultEstate.EstateID = (uint)CityModule.randomValue(1000);

                    regionInfo.EstateSettings = EstateConnector.CreateEstate(m_DefaultEstate, regionInfo.RegionID);
                }
                else
                {
                    //  Estates have been found, select the first estate in the list. No checking is done
                    // against the configuration file settings. TODO validate the estate against the
                    // configuration file.
                    m_DefaultEstate = estates[0];
                    regionInfo.EstateSettings = m_DefaultEstate;
                    m_log.InfoFormat("[CITY BUILDER]: {0} estates found for user {1}, selecting {2}",
                        estates.Count, m_DefaultUserAccount.Name, m_DefaultEstate.EstateName);
                }
            }
            else
            {
                m_log.Info("[CITY BUILDER]: No connection with server.");
                return (false);
            }

            //  Fill in land data for the estate/owner.
            cityLandData.OwnerID = m_DefaultUserAccount.PrincipalID;
            cityLandData.Name = m_DefaultEstateName;
            cityLandData.GlobalID = UUID.Random();
            cityLandData.GroupID = UUID.Zero;

            int regionPort = startPort;

            //  Construct the region.
            regionInfo.RegionSizeX = cityConfig.GetInt("DefaultRegionSize", 256);
            regionInfo.RegionSizeY = regionInfo.RegionSizeX;
            regionInfo.RegionType = "Mainland";
            regionInfo.ObjectCapacity = 100000;
            regionInfo.Startup = StartupType.Normal;
            regionInfo.ScopeID = UUID.Zero;

            IParcelServiceConnector parcelService = simulationBase.ApplicationRegistry.RequestModuleInterface<IParcelServiceConnector>();
            if (parcelService == null)
            {
                m_log.Info("[CITY BUILDER]: Unable to connect to servers parcel service.");
            }

            if (r == 1)
            {
                m_log.Info("[CITY BUILDER]: Single region city.");
                IPAddress address = IPAddress.Parse("0.0.0.0");
                regionInfo.ExternalHostName = Aurora.Framework.Utilities.GetExternalIp();
                regionInfo.FindExternalAutomatically = true;
                regionInfo.InternalEndPoint = new IPEndPoint(address, regionPort++);
                cityLandData.RegionID = regionInfo.RegionID;
                regionInfo.RegionName = "Region00";
                regionInfo.RegionLocX = (int)m_DefaultStartLocation.X;
                regionInfo.RegionLocY = (int)m_DefaultStartLocation.Y;
                if (parcelService != null)
                    parcelService.StoreLandObject(cityLandData);
                if (!createRegion(0, 0, regionInfo))
                {
                    m_log.Info("[CITY BUILDER]: Failed to construct region.");
                    return (false);
                }
            }
            else if (r > 1)
            {
                m_log.Info("[CITY BUILDER]: Multi-region city.");
                m_log.Info("[CITY BUILDER]: Finding external IP, please wait ... ");
                regionInfo.ExternalHostName = Aurora.Framework.Utilities.GetExternalIp();
                if (regionInfo.ExternalHostName.Length <= 0)
                {
                    regionInfo.FindExternalAutomatically = false;
                }
                else
                {
                    m_log.InfoFormat("[CITY BUILDER]: External IP address is {0}", regionInfo.ExternalHostName);
                    regionInfo.FindExternalAutomatically = true;
                }
                //  Construct the regions for the city.
                regionPort = startPort;
                INeighborService neighbours = simulationBase.ApplicationRegistry.RequestModuleInterface<INeighborService>();
                if (neighbours == null)
                {
                    m_log.Info("[CITY BUILDER]: No neighbours.");
                }
                else
                {
                    m_log.Info("[CITY BUILDER]: Neighbours service found.");
                }
                IPAddress address = IPAddress.Parse("0.0.0.0");

                for (rx = 0; rx < r; rx++)
                {
                    for (ry = 0; ry < r; ry++)
                    {
                        regionInfo.InternalEndPoint = new IPEndPoint(address, regionPort++);
                        cityLandData.RegionID = regionInfo.RegionID;
                        regionInfo.RegionName = "Region" + rx + ry;
                        regionInfo.RegionLocX = (int)(m_DefaultStartLocation.X + rx);
                        regionInfo.RegionLocY = (int)(m_DefaultStartLocation.Y + ry);
                        m_log.InfoFormat("[CITY BUILDER]: '{0}' @ {1},{2}, http://{3}/", regionInfo.RegionName,
                            regionInfo.RegionLocX, regionInfo.RegionLocY, regionInfo.InternalEndPoint);
                        if (parcelService != null)
                            parcelService.StoreLandObject(cityLandData);
                        if (!createRegion(rx, ry, regionInfo))
                        {
                            m_log.InfoFormat("[CITY BUILDER]: Failed to construct region at {0},{1}", rx, ry);
                            return (false);
                        }
                        if (neighbours != null)
                        {
                            m_log.Info("[CITY BUILDER]: Informing neighbours.");
                            neighbours.InformOurRegionsOfNewNeighbor(regionInfo);
                        }
                    }
                }
            }

            //  Either generate the terrain or loading from an existing file, DEM for example.
            m_log.Info("[CITY BUILDER]: [TERRAIN]");

            //  Construct the new terrain for each region and pass the height map to it.
            //  For the entire area covered by all of the regions construct a new terrain heightfield for it.
            // Also construct several maps that can be blended together in order to provide a suitablly natural
            // looking terrain which is not too flat or doesn't entirely consist of mountains.
            float[,] terrainMap;
            float[,] hMap1;
            float[,] hMap2;
            float[,] hMap3;
            float[,] hMap4;
            float[] bFactors = new float[4];
            int size = regionInfo.RegionSizeX;
            int y;
            int x;

            terrainMap = new float[ size * r, size * r ];
            hMap1 = new float[ size * r, size * r ];
            hMap2 = new float[ size * r, size * r ];
            hMap3 = new float[ size * r, size * r ];
            hMap4 = new float[ size * r, size * r ];
            //  Set blending factors.
            bFactors[0] = 0.75f;
            bFactors[1] = 0.55f;
            bFactors[2] = 0.35f;
            bFactors[3] = 0.05f;

            //  Generate four layers for the initial height map and then blend them together.
            for (x = 0; x < size; x++)
            {
                for (y = 0; y < size; y++)
                {
                    for (int i = 0; i < r; i++)
                    {
                        for (int j = 0; j < r; j++)
                        {
                            hMap1[i * x, i * y] = Perlin.noise2((float)x+i, (float)y+i);
                            hMap2[i * x, i * y] = Perlin.noise2((float)x, (float)y+i);
                            hMap3[i * x, i * y] = Perlin.noise2((float)x+i, (float)y);
                            hMap4[i * x, i * y] = Perlin.noise2((float)x+j, (float)y+i);
                            terrainMap[i*x, i*y] = (hMap1[i*x, i*y] * bFactors[0]) + (hMap2[i*x, i*y] * bFactors[1]) +
                                (hMap3[i*x, i*y] * bFactors[2]) + (hMap4[i*x, i*y] * bFactors[3]);
                        }
                    }
                }
            }

            //  DEBUG code that will save the resulting terrainMap as a jpeg image.
            m_log.Info("[CITY BUILDER]: Debug, save terrain map (full) as a jpeg image.");
            ManagedImage mImage = new ManagedImage(r * size, r * size, ManagedImage.ImageChannels.Bump);

            //   Find a way of copying the terrainMap array into the newly created image, then save
            // the image to disk.

            m_log.Info("[CITY BUILDER]: Terrain built and blended, tiling and region application.");

            //  Set the height map of each region based on the newly created terrainMap.
            ITerrain terrain = null;
            for (rx = 0; rx < r; rx++)
            {
                for (ry = 0; ry < r; ry++)
                {
                    Scene region = cityMap.cityRegions[rx, ry];
                    ITerrainChannel tChannel = new TerrainChannel(true, region);
                    region.TryRequestModuleInterface<ITerrain>(out terrain);

                    m_log.InfoFormat("[CITY BUILDER]: Region [ {0}, {1} ]", rx, ry);

                    float[,] tile = new float[ size, size ];
                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; i < size; j++)
                        {
                            tile[i, j] = terrainMap[(rx * size) + i, (ry * size) + j];
                        }
                    }

                    if (terrain != null & tile!=null)
                        terrain.SetHeights2D(tile);

                    // dispose of the tile now thats its not needed as a new tile is allocated next loop run.
                    tile = null;
                }
            }

            //  Rivers and other waterways. Randomly select a number of rivers for the entire area
            // and place them.
            int rCount = CityModule.randomValue(size / r);
            m_log.InfoFormat("[CITY BUILDER]: River count for entire area {0}", rCount);

            //  From the total number of regions pick a number of regions that will be 'centers'
            // for the entire city, record these in the centralRegions list.
            m_log.Info("[CITY BUILDER]: [CENTERS]");
            //  ( region count * region count ) / 3
            int aNum = CityModule.randomValue((cityMap.cityRegions.GetUpperBound(0) * cityMap.cityRegions.GetUpperBound(1))/3);
            if (aNum == 0)
            {
                aNum = 1;
            }
            m_log.InfoFormat("[CITY BUILDER]: Total regions {0}, selecting {1} regions for centers.", (r*r), aNum );
            int prevRegionX = 0;
            int prevRegionY = 0;
            while ( aNum > 0 )
            {
                int currRegionX = randomValue( cityMap.cityRegions.GetUpperBound(0) ) / 2;
                int currRegionY = randomValue( cityMap.cityRegions.GetUpperBound(1) ) / 2;

                // If the location selected is the same as the previous location try again.
                if (currRegionX == prevRegionX && currRegionY == prevRegionY)
                {
                    aNum--;
                    continue;
                }

                m_log.InfoFormat("[CITY BUILDER]: Region {0}, located {1},{2}", aNum, prevRegionX, prevRegionY);

                try
                {
                    Scene region = cityMap.centralRegions[(prevRegionX * cityMap.cityRegions.GetUpperBound(0)) + prevRegionY];
                    if (region!=null)
                    {
                        cityMap.centralRegions.Add(region);
                    }
                }
                catch
                {
                }
                aNum--;
                prevRegionX = currRegionX;
                prevRegionY = currRegionY;
            }

            m_log.Info("[CITY BUILDER]: [DENSITY]");
            float avgDensity = 0.0f;

            avgDensity += cityDensities[0];
            avgDensity += cityDensities[1];
            avgDensity += cityDensities[2];
            avgDensity += cityDensities[3];
            avgDensity /= 4;

            //  Before ANYTHING else is created construct the transport systems, priority is given
            // to the road network before the rail network, perhaps a configuration option to allow
            // for the prioritisation value of the transport system is possible.
            m_log.Info("[CITY BUILDER]: [FREEWAYS]");

            //  Construct a road system (high speed ~50-70 mph) between and around the city center regions.

            m_log.Info("[CITY BUILDER]: [HIGHWAYS]");

            m_log.Info("[CITY BUILDER]: [STREETS]");

            m_log.Info("[CITY BUILDER]: [RAILWAYS]");

            m_log.InfoFormat("[CITY BUILDER]: [RESIDENTIAL DENSITY] {0}%", cityDensities[0] * 100);
            m_log.InfoFormat("[CITY BUILDER]: [COMMERCIAL DENSITY] {0}%", cityDensities[1] * 100);
            m_log.InfoFormat("[CITY BUILDER]: [CORPORATE DENSITY] {0}%", cityDensities[2] * 100);
            m_log.InfoFormat("[CITY BUILDER]: [INDUSTRIAL DENISTY] {0}%", cityDensities[3] * 100);
            m_log.InfoFormat("[CITY BUILDER]: [AVERAGE DENSITY] {0}%", avgDensity);

            m_log.Info("[CITY BUILDER]: [BLOCKS]");
            m_log.Info("[CITY BUILDER]: [ALLOTMENT PLOTS]");
            m_log.Info("[CITY BUILDER]: [BUILDINGS]");

            return (true);
        }
 public EstateInfoHandler()
 {
     EstateConnector = DataManager.RequestPlugin<IEstateConnector>("IEstateConnectorLocal");
 }
        int GetUserEstateID(IScene scene, IEstateConnector estateConnector)
        {
            while (true)
            {
                UserAccount account;
                string estateOwner;

                estateOwner = MainConsole.Instance.Prompt ("Estate owner name");
                if (string.IsNullOrEmpty (estateOwner))
                    return 0;

                // 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...
                    ownerEstates = estateConnector.GetEstates (account.PrincipalID);
                }

                if (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);

                    continue;   // try again
                }

                string LastEstateName;
                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;
                }

                return estateID;
            }
        }
Example #36
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);
        }
Example #37
0
        private void CheckSystemEstateInfo(IEstateConnector estateConnector)
        {
            // these should have already been checked but just make sure...
            if (estateConnector == null)
                return;

            if (estateConnector.RemoteCalls ())
                return;

            if (estateConnector.EstateExists (Constants.SystemEstateName))
                return;

            // Create a new estate
            EstateSettings ES = new EstateSettings();
            ES.EstateName = Constants.SystemEstateName;
            ES.EstateOwner = (UUID) Constants.RealEstateOwnerUUID;

            ES.EstateID = (uint) estateConnector.CreateNewEstate(ES);
            if (ES.EstateID == 0)
            {
                MainConsole.Instance.Warn("There was an error in creating the system estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.

            } else {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.",
                    Constants.SystemEstateName, Constants.RealEstateOwnerName);
            }
        }