diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1985e72900..c9998c0d86 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7285,23 +7285,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetNumberOfPrims() { m_host.AddScriptLPS(1); - ScenePresence[] presences = World.GetScenePresences(); - if (presences.Length == 0) - return 0; - int avatarCount = 0; - for (int i = 0; i < presences.Length; i++) + World.ForEachScenePresence(delegate(ScenePresence presence) { - ScenePresence presence = presences[i]; - - if (!presence.IsChildAgent && presence.ParentID != 0) - { - if (m_host.ParentGroup.HasChildPrim(presence.ParentID)) - { + if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) avatarCount++; - } - } - } + }); return m_host.ParentGroup.PrimCount + avatarCount; }