From f34cc6b46949033803c79235b9d82da9bf9634dd Mon Sep 17 00:00:00 2001
From: Thomas Grimshaw
Date: Mon, 5 Apr 2010 22:08:34 +0200
Subject: Add a much cheaper agent count retrieval method. This is obsoleted
by 0.7 so it can be reverted then.
---
OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs | 2 +-
.../ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs | 2 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 10 +++++++++-
.../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +-
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
index ed18207..dea166d 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs
@@ -192,7 +192,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
protected string RegionStats(OSHttpResponse httpResponse, Scene scene)
{
- int users = scene.GetAvatars().Count;
+ int users = scene.GetRootAgentCount();
int objects = scene.Entities.Count - users;
RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
index 5798286..82e9d9b 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
@@ -125,7 +125,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
rxw.WriteEndAttribute();
- int users = s.GetAvatars().Count;
+ int users = s.GetRootAgentCount();
rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
rxw.WriteValue(users);
rxw.WriteEndAttribute();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ab0d397..e5e6fc9 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1523,7 +1523,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SaveTerrain()
{
m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
- }
+ }
public void StoreWindlightProfile(RegionMeta7WindlightData wl)
{
@@ -4339,6 +4339,14 @@ namespace OpenSim.Region.Framework.Scenes
}
///
+ /// Cheaply return the number of avatars in a region (without fetching a list object)
+ ///
+ public int GetRootAgentCount()
+ {
+ return m_sceneGraph.GetRootAgentCount();
+ }
+
+ ///
/// Return a list of all ScenePresences in this region. This returns child agents as well as root agents.
/// This list is a new object, so it can be iterated over without locking.
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 10ebf67..a76f386 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5266,7 +5266,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGetRegionAgentCount()
{
m_host.AddScriptLPS(1);
- return new LSL_Integer(World.GetAvatars().Count);
+ return new LSL_Integer(World.GetRootAgentCount());
}
public LSL_Vector llGetRegionCorner()
--
cgit v1.1