Exemplo n.º 1
0
        private void OnCheck(object sender, ElapsedEventArgs e)
        {
            if (m_statsReporter.LastReportedSimFPS < BaseRateFramesPerSecond * (PercentToBeginShutDownOfServices / 100) && m_statsReporter.LastReportedSimFPS != 0 && AllowDisableScripts)
            {
                //Less than the percent to start shutting things down... Lets kill some stuff
                IScriptModule scriptEngine = m_scene.RequestModuleInterface <IScriptModule>();
                if (scriptEngine != null)
                {
                    scriptEngine.StopAllScripts();
                }
            }

            if (m_statsReporter.LastReportedSimFPS == 0 && KillSimOnZeroFPS)
            {
                if (SimZeroFPSStartTime == DateTime.MinValue)
                {
                    SimZeroFPSStartTime = DateTime.Now;
                }
                if (SimZeroFPSStartTime.AddMinutes(MinutesBeforeZeroFPSKills) > SimZeroFPSStartTime)
                {
                    MainConsole.Instance.RunCommand("shutdown");
                }
            }
            else if (SimZeroFPSStartTime != DateTime.MinValue)
            {
                SimZeroFPSStartTime = DateTime.MinValue;
            }

            IEstateModule mod = m_scene.RequestModuleInterface <IEstateModule>();

            float[] stats = m_scene.RequestModuleInterface <IMonitorModule>().GetRegionStats(m_scene.RegionInfo.RegionID.ToString());
            if (stats[2] /*PhysicsFPS*/ < BaseRateFramesPerSecond * (PercentToBeginShutDownOfServices / 100) &&
                stats[2] != 0 &&
                AllowDisablePhysics &&
                !m_scene.RegionInfo.RegionSettings.DisablePhysics) //Don't redisable physics again, physics will be frozen at the last FPS
            {
                DisabledPhysicsStartTime = DateTime.Now;
                if (mod != null)
                {
                    mod.SetSceneCoreDebug(m_scene.RegionInfo.RegionSettings.DisableScripts, m_scene.RegionInfo.RegionSettings.DisableCollisions, false); //These are opposite of what you want the value to be... go figure
                }
            }

            if (m_scene.RegionInfo.RegionSettings.DisablePhysics &&
                AllowDisablePhysics &&
                DisabledPhysicsStartTime != DateTime.MinValue && //This makes sure we don't screw up the setting if the user disabled physics manually
                DisabledPhysicsStartTime.AddSeconds(TimeAfterToReenablePhysics) > DateTime.Now)
            {
                DisabledPhysicsStartTime = DateTime.MinValue;
                if (mod != null)
                {
                    mod.SetSceneCoreDebug(m_scene.RegionInfo.RegionSettings.DisableScripts, m_scene.RegionInfo.RegionSettings.DisableCollisions, true);//These are opposite of what you want the value to be... go figure
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The god has requested that we update something in the region configs
        /// </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)
        {
            //Check god perms
            if (!((Scene)client.Scene).Permissions.IsGod(client.AgentId))
            {
                return;
            }

            //Update their current region with new information
            string oldRegionName = client.Scene.RegionInfo.RegionName;

            client.Scene.RegionInfo.RegionName = Utils.BytesToString(SimName);

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

            //Update the estate ID
            if (client.Scene.RegionInfo.EstateSettings.EstateID != EstateID)
            {
                //If they are changing estates, we have to ask them for the password to the estate, so send them an llTextBox
                string        Password = "";
                IWorldComm    comm     = client.Scene.RequestModuleInterface <IWorldComm>();
                IDialogModule dialog   = client.Scene.RequestModuleInterface <IDialogModule>();
                //If the comms module is not null, we send the user a text box on a random channel so that they cannot be tapped into
                if (comm != null && dialog != null)
                {
                    int Channel = new Random().Next(1000, 100000);
                    //Block the channel so NOONE can access it until the question is answered
                    comm.AddBlockedChannel(Channel);
                    ChannelDirectory.Add(client.AgentId, new EstateChange()
                    {
                        Channel = Channel, EstateID = (uint)EstateID, OldEstateID = ((Scene)client.Scene).RegionInfo.EstateSettings.EstateID
                    });
                    //Set the ID temperarily, if it doesn't work, we will revert it later
                    ((Scene)client.Scene).RegionInfo.EstateSettings.EstateID = (uint)EstateID;
                    client.OnChatFromClient += OnChatFromClient;
                    dialog.SendTextBoxToUser(client.AgentId, "Please type the password for the estate you wish to join. (Note: this channel is secured and will not be able to be listened in on)", Channel, "Server", UUID.Zero, UUID.Zero);
                }
                else
                {
                    bool changed = DataManager.DataManager.RequestPlugin <IEstateConnector>().LinkRegion(((Scene)client.Scene).RegionInfo.RegionID, (int)EstateID, Util.Md5Hash(Password));
                    if (!changed)
                    {
                        client.SendAgentAlertMessage("Unable to connect to the given estate.", false);
                    }
                    else
                    {
                        client.Scene.RegionInfo.EstateSettings.EstateID = (uint)EstateID;
                        client.Scene.RegionInfo.EstateSettings.Save();
                    }
                }
            }

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

            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
            client.Scene.RegionInfo.EstateSettings.Save();
            client.Scene.RegionInfo.RegionSettings.Save();

            //Save the changes
            IConfig config = m_config.Configs["RegionStartup"];

            if (config != null)
            {
                //TERRIBLE! Needs to be modular, but we can't access the module from a scene module!
                if (config.GetString("Default") == "RegionLoaderDataBaseSystem")
                {
                    SaveChangesDatabase(client.Scene.RegionInfo);
                }
                else
                {
                    SaveChangesFile(oldRegionName, client.Scene.RegionInfo);
                }
            }
            else
            {
                SaveChangesFile(oldRegionName, client.Scene.RegionInfo);
            }


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

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

            if (gridRegisterModule != null)
            {
                gridRegisterModule.UpdateGridRegion(client.Scene);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///   The god has requested that we update something in the region configs
        /// </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)
        {
            //Check god perms
            if (!client.Scene.Permissions.IsGod(client.AgentId))
            {
                return;
            }

            //Update their current region with new information
            string oldRegionName = client.Scene.RegionInfo.RegionName;

            client.Scene.RegionInfo.RegionName = Utils.BytesToString(SimName);

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

            //Update the estate ID
            if (client.Scene.RegionInfo.EstateSettings.EstateID != EstateID)
            {
                bool changed = DataManager.DataManager.RequestPlugin <IEstateConnector>().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;
                    client.Scene.RegionInfo.EstateSettings.Save();
                }
            }

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

            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
            client.Scene.RegionInfo.EstateSettings.Save();
            client.Scene.RegionInfo.RegionSettings.Save();

            //Save the changes
            IConfig config = m_config.Configs["RegionStartup"];

            if (config != null)
            {
                //TERRIBLE! Needs to be modular, but we can't access the module from a scene module!
                if (config.GetString("Default") == "RegionLoaderDataBaseSystem")
                {
                    SaveChangesDatabase(client.Scene.RegionInfo);
                }
                else
                {
                    SaveChangesFile(oldRegionName, client.Scene.RegionInfo);
                }
            }
            else
            {
                SaveChangesFile(oldRegionName, client.Scene.RegionInfo);
            }


            //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);
            }
        }