コード例 #1
0
        /// <summary>
        /// Checks for a valid system estate. Adds or corrects if required
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        private void CheckSystemEstateInfo()
        {
            // these should have already been checked but just make sure...
            if (m_estateConnector == null)
            {
                return;
            }

            if (m_estateConnector.RemoteCalls())
            {
                return;
            }

            EstateSettings ES;

            //            ES = estateConnector.GetEstateSettings (Constants.SystemEstateName);
            //ES = m_estateConnector.GetEstateSettings (SystemEstateName);
            ES = m_estateConnector.GetEstateSettings(Constants.SystemEstateID);
            if (ES != null)
            {
                // ensure correct ID
                if (ES.EstateID != Constants.SystemEstateID)
                {
                    UpdateSystemEstates(m_estateConnector, ES);
                }

                // in case of configuration changes
                if (ES.EstateName != SystemEstateName)
                {
                    ES.EstateName = SystemEstateName;
                    m_estateConnector.SaveEstateSettings(ES);
                    MainConsole.Instance.Info("[EstateService]: The system Estate name has been updated to " + SystemEstateName);
                }

                return;
            }

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

            ES.EstateID = (uint)m_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.",
                                                SystemEstateName, SystemEstateOwnerName);
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <summary>
        /// Sets the estate owner.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void SetEstateOwnerCommand(IScene scene, string [] cmd)
        {
            IEstateConnector    estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IUserAccountService accountService  = m_registry.RequestModuleInterface <IUserAccountService> ();

            string      estateName = "";
            string      estateOwner;
            UserAccount ownerAccount;

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

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

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

            // owner?
            if (cmd.Length < 5)
            {
                var  newOwner      = "Unknown";
                UUID estateOwnerID = ES.EstateOwner;
                ownerAccount = accountService.GetUserAccount(null, estateOwnerID);
                if (ownerAccount != null)
                {
                    newOwner = ownerAccount.Name;
                }
                estateOwner = MainConsole.Instance.Prompt("New owner for this estate", newOwner);
            }
            else
            {
                estateOwner = Util.CombineParams(cmd, 5);  // in case of spaces in the name e.g. Allan Allard
            }
            if (estateOwner == "")
            {
                return;
            }

            // check to make sure the user exists
            ownerAccount = accountService.GetUserAccount(null, estateOwner);
            if (ownerAccount == null)
            {
                MainConsole.Instance.WarnFormat("[User Account Service]: The user, '{0}' was not found!", estateOwner);
                return;
            }

            // check for bogies...
            if (Utilities.IsSystemUser(ownerAccount.PrincipalID))
            {
                MainConsole.Instance.Info("[EstateService]: Tsk, tsk.  System users should not be used as estate managers!");
                return;
            }

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

            MainConsole.Instance.InfoFormat("[EstateService]: Estate owner for '{0}' changed to '{1}'", estateName, estateOwner);
        }
コード例 #4
0
        protected void HandleResetSystemEstate(IScene scene, string [] cmd)
        {
            // delete and recreate the system estate
            IEstateConnector      estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            ISystemAccountService sysAccounts     = m_registry.RequestModuleInterface <ISystemAccountService> ();

            bool update = false;

            // verify that the estate does exist
            EstateSettings ES;

            ES = estateConnector.GetEstateSettings(Constants.SystemEstateName);
            if (ES == null)
            {
                ES = estateConnector.GetEstateSettings(SystemEstateName);
                if (ES == null)
                {
                    MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist yet!", SystemEstateName);
                    MainConsole.Instance.Warn("[EstateService]: It will be created when you link a region to the estate");
                }
            }

            // A system Estate exists?
            if (ES != null)
            {
                if (ES.EstateName != SystemEstateName)
                {
                    ES.EstateName = SystemEstateName;
                    update        = true;
                }

                if (ES.EstateOwner != sysAccounts.SystemEstateOwnerUUID)
                {
                    ES.EstateOwner = sysAccounts.SystemEstateOwnerUUID;
                    update         = true;
                }

                // save any updates
                if (update)
                {
                    estateConnector.SaveEstateSettings(ES);
                    MainConsole.Instance.Warn("[EstateService]: Estate details have been updated");
                }
            }

            // check the System estate owner details
            UserAccount uinfo;

            uinfo = m_accountService.GetUserAccount(null, UUID.Parse(Constants.RealEstateOwnerUUID));
            if (uinfo == null)
            {
                MainConsole.Instance.Warn("[EstateService]: The system estate user does not exist yet!");
                MainConsole.Instance.Warn("[EstateService]: This account will be created automatically");
            }

            if ((uinfo != null) && (uinfo.Name != sysAccounts.SystemEstateOwnerName))
            {
                //string[] name = uinfo.Name.Split (' ');
                //uinfo.FirstName = name [0];
                //uinfo.LastName = name [1];
                uinfo.Name = sysAccounts.SystemEstateOwnerName;
                m_accountService.StoreUserAccount(uinfo);
                update = true;
            }

            if (update)
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The system Estate details have been reset");
            }
            else
            {
                MainConsole.Instance.InfoFormat("[EstateService]: Estate details are correct as configured");
            }
        }
コード例 #5
0
        /// <summary>
        /// Checks for a valid system estate. Adds or corrects if required
        /// </summary>
        /// <param name="estateID">Estate I.</param>
        /// <param name="estateName">Estate name.</param>
        /// <param name="ownerUUID">Owner UUI.</param>
        void CheckSystemEstateInfo(int estateID, string estateName, UUID ownerUUID)
        {
            // these should have already been checked but just make sure...
            if (m_estateConnector == null)
            {
                return;
            }

            if (m_estateConnector.RemoteCalls())
            {
                return;
            }

            ISystemAccountService sysAccounts = m_registry.RequestModuleInterface <ISystemAccountService> ();
            EstateSettings        ES;

            // check for existing estate name in case of estate ID change
            ES = m_estateConnector.GetEstateSettings(estateName);
            if (ES != null)
            {
                // ensure correct ID
                if (ES.EstateID != estateID)
                {
                    UpdateSystemEstates(m_estateConnector, ES, estateID);
                }
            }

            ES = m_estateConnector.GetEstateIDSettings(estateID);
            if ((ES != null) && (ES.EstateID != 0))
            {
                // ensure correct owner
                if (ES.EstateOwner != ownerUUID)
                {
                    ES.EstateOwner = ownerUUID;
                    m_estateConnector.SaveEstateSettings(ES);
                    MainConsole.Instance.Info("[EstateService]: The system Estate owner has been updated to " +
                                              sysAccounts.GetSystemEstateOwnerName(estateID));
                }


                // in case of configuration changes
                if (ES.EstateName != estateName)
                {
                    ES.EstateName = estateName;
                    m_estateConnector.SaveEstateSettings(ES);
                    MainConsole.Instance.Info("[EstateService]: The system Estate name has been updated to " + estateName);
                }

                return;
            }

            // Create a new estate

            ES             = new EstateSettings();
            ES.EstateName  = estateName;
            ES.EstateOwner = ownerUUID;

            ES.EstateID = (uint)m_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.",
                                                ES.EstateName, sysAccounts.GetSystemEstateOwnerName(estateID));
            }
        }
コード例 #6
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);
            }
        }