diff options
Diffstat (limited to 'OpenSim')
5 files changed, 54 insertions, 8 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 | |||
192 | 192 | ||
193 | protected string RegionStats(OSHttpResponse httpResponse, Scene scene) | 193 | protected string RegionStats(OSHttpResponse httpResponse, Scene scene) |
194 | { | 194 | { |
195 | int users = scene.GetAvatars().Count; | 195 | int users = scene.GetRootAgentCount(); |
196 | int objects = scene.Entities.Count - users; | 196 | int objects = scene.Entities.Count - users; |
197 | 197 | ||
198 | RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); | 198 | 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 | |||
125 | rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); | 125 | rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString()); |
126 | rxw.WriteEndAttribute(); | 126 | rxw.WriteEndAttribute(); |
127 | 127 | ||
128 | int users = s.GetAvatars().Count; | 128 | int users = s.GetRootAgentCount(); |
129 | rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); | 129 | rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty); |
130 | rxw.WriteValue(users); | 130 | rxw.WriteValue(users); |
131 | rxw.WriteEndAttribute(); | 131 | rxw.WriteEndAttribute(); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fec8aa7..55f4550 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1523,7 +1523,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1523 | public void SaveTerrain() | 1523 | public void SaveTerrain() |
1524 | { | 1524 | { |
1525 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1525 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | public void StoreWindlightProfile(RegionMeta7WindlightData wl) | 1528 | public void StoreWindlightProfile(RegionMeta7WindlightData wl) |
1529 | { | 1529 | { |
@@ -4363,6 +4363,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4363 | } | 4363 | } |
4364 | 4364 | ||
4365 | /// <summary> | 4365 | /// <summary> |
4366 | /// Cheaply return the number of avatars in a region (without fetching a list object) | ||
4367 | /// </summary> | ||
4368 | public int GetRootAgentCount() | ||
4369 | { | ||
4370 | return m_sceneGraph.GetRootAgentCount(); | ||
4371 | } | ||
4372 | |||
4373 | /// <summary> | ||
4366 | /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. | 4374 | /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. |
4367 | /// This list is a new object, so it can be iterated over without locking. | 4375 | /// This list is a new object, so it can be iterated over without locking. |
4368 | /// </summary> | 4376 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0785f7f..0277ed8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | /// since the group's last persistent backup | 104 | /// since the group's last persistent backup |
105 | /// </summary> | 105 | /// </summary> |
106 | private bool m_hasGroupChanged = false; | 106 | private bool m_hasGroupChanged = false; |
107 | private long timeFirstChanged; | 107 | private long timeFirstChanged = 0; |
108 | private long timeLastChanged; | 108 | private long timeLastChanged = 0; |
109 | long m_maxPersistTime = 0; | ||
110 | long m_minPersistTime = 0; | ||
111 | Random m_rand; | ||
112 | |||
109 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | 113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); |
110 | 114 | ||
111 | public void lockPartsForRead(bool locked) | 115 | public void lockPartsForRead(bool locked) |
@@ -182,6 +186,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | timeLastChanged = DateTime.Now.Ticks; | 186 | timeLastChanged = DateTime.Now.Ticks; |
183 | if (!m_hasGroupChanged) | 187 | if (!m_hasGroupChanged) |
184 | timeFirstChanged = DateTime.Now.Ticks; | 188 | timeFirstChanged = DateTime.Now.Ticks; |
189 | if (m_rand == null) | ||
190 | { | ||
191 | byte[] val = new byte[16]; | ||
192 | m_rootPart.UUID.ToBytes(val, 0); | ||
193 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
194 | } | ||
195 | if (Scene.GetRootAgentCount() == 0) | ||
196 | { | ||
197 | //If the region is empty, this change has been made by an automated process | ||
198 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
199 | |||
200 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
201 | m_maxPersistTime = (long)((float)Scene.m_persistAfter * factor); | ||
202 | m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * factor); | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
207 | //but add a random factor so we stagger the object persistance a little | ||
208 | m_maxPersistTime = (long)((float)Scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
209 | m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
210 | } | ||
185 | } | 211 | } |
186 | m_hasGroupChanged = value; | 212 | m_hasGroupChanged = value; |
187 | } | 213 | } |
@@ -197,8 +223,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | return false; | 223 | return false; |
198 | if (m_scene.ShuttingDown) | 224 | if (m_scene.ShuttingDown) |
199 | return true; | 225 | return true; |
226 | |||
227 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
228 | { | ||
229 | m_maxPersistTime = m_scene.m_persistAfter; | ||
230 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
231 | } | ||
232 | |||
200 | long currentTime = DateTime.Now.Ticks; | 233 | long currentTime = DateTime.Now.Ticks; |
201 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 234 | |
235 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
236 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
237 | |||
238 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
202 | return true; | 239 | return true; |
203 | return false; | 240 | return false; |
204 | } | 241 | } |
@@ -529,6 +566,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
529 | /// </summary> | 566 | /// </summary> |
530 | public SceneObjectGroup() | 567 | public SceneObjectGroup() |
531 | { | 568 | { |
569 | |||
532 | } | 570 | } |
533 | 571 | ||
534 | /// <summary> | 572 | /// <summary> |
@@ -545,7 +583,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
545 | /// Constructor. This object is added to the scene later via AttachToScene() | 583 | /// Constructor. This object is added to the scene later via AttachToScene() |
546 | /// </summary> | 584 | /// </summary> |
547 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 585 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
548 | { | 586 | { |
549 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 587 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
550 | } | 588 | } |
551 | 589 | ||
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 | |||
5266 | public LSL_Integer llGetRegionAgentCount() | 5266 | public LSL_Integer llGetRegionAgentCount() |
5267 | { | 5267 | { |
5268 | m_host.AddScriptLPS(1); | 5268 | m_host.AddScriptLPS(1); |
5269 | return new LSL_Integer(World.GetAvatars().Count); | 5269 | return new LSL_Integer(World.GetRootAgentCount()); |
5270 | } | 5270 | } |
5271 | 5271 | ||
5272 | public LSL_Vector llGetRegionCorner() | 5272 | public LSL_Vector llGetRegionCorner() |