diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d0013ba199..06e8a545c7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -360,6 +360,7 @@ namespace OpenSim.Region.Environment.Scenes StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; + StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; StatsReporter.SetObjectCapacity(objectCapacity); diff --git a/OpenSim/Region/Environment/Scenes/SceneGraph.cs b/OpenSim/Region/Environment/Scenes/SceneGraph.cs index 3ffa5c332e..8476344ac9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Environment/Scenes/SceneGraph.cs @@ -694,6 +694,24 @@ namespace OpenSim.Region.Environment.Scenes } } + public void RecalculateStats() + { + List SPList = GetScenePresences(); + int rootcount = 0; + int childcount = 0; + + foreach (ScenePresence user in SPList) + { + if (user.IsChildAgent) + childcount++; + else + rootcount++; + } + m_numRootAgents = rootcount; + m_numChildAgents = childcount; + + } + public int GetChildAgentCount() { // some network situations come in where child agents get closed twice. @@ -1748,5 +1766,7 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + + } } diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index e2afa5a852..efda1405d0 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -39,10 +39,16 @@ namespace OpenSim.Region.Environment.Scenes { public delegate void SendStatResult(SimStats stats); + public delegate void YourStatsAreWrong(); + public event SendStatResult OnSendStatsResult; + public event YourStatsAreWrong OnStatsIncorrect; + private SendStatResult handlerSendStatResult = null; + private YourStatsAreWrong handlerStatsIncorrect = null; + private enum Stats : uint { TimeDilation = 0, @@ -306,15 +312,30 @@ namespace OpenSim.Region.Environment.Scenes public void SetRootAgents(int rootAgents) { m_rootAgents = rootAgents; + CheckStatSanity(); + + } + + internal void CheckStatSanity() + { + if (m_rootAgents < 0 || m_childAgents < 0) + { + handlerStatsIncorrect = OnStatsIncorrect; + if (handlerStatsIncorrect != null) + { + handlerStatsIncorrect(); + } + } + if (m_rootAgents == 0 && m_childAgents == 0) + { + m_unAckedBytes = 0; + } } public void SetChildAgents(int childAgents) { - m_childAgents = (childAgents > 0) ? childAgents : 0; - if (childAgents < 0) - { - //List avs= m_scene.GetScenePresences(); - } + m_childAgents = childAgents; + CheckStatSanity(); } public void SetObjects(int objects)