예제 #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
                }
            }
        }