From 0d1b8675004a37c1a5590a6825b5204b08e285e6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 6 Jan 2009 00:07:24 +0000 Subject: * Added a way for the sim stats reporter to say to the scene that the stats are illogical. --- OpenSim/Region/Environment/Scenes/Scene.cs | 1 + OpenSim/Region/Environment/Scenes/SceneGraph.cs | 20 +++++++++++++++ .../Region/Environment/Scenes/SimStatsReporter.cs | 29 +++++++++++++++++++--- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d0013ba..06e8a54 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 3ffa5c3..8476344 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 e2afa5a..efda140 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(); + } - public void SetChildAgents(int childAgents) + internal void CheckStatSanity() { - m_childAgents = (childAgents > 0) ? childAgents : 0; - if (childAgents < 0) + if (m_rootAgents < 0 || m_childAgents < 0) { - //List avs= m_scene.GetScenePresences(); + handlerStatsIncorrect = OnStatsIncorrect; + if (handlerStatsIncorrect != null) + { + handlerStatsIncorrect(); + } } + if (m_rootAgents == 0 && m_childAgents == 0) + { + m_unAckedBytes = 0; + } + } + + public void SetChildAgents(int childAgents) + { + m_childAgents = childAgents; + CheckStatSanity(); } public void SetObjects(int objects) -- cgit v1.1