From b98613091cd6dc2f914fb5ab38ca33cdff21fc24 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 00:42:21 -0700 Subject: Added new ForEachRootScenePresence to Scene since almost every delegate passed to ForEachScenePresence checks for !IsChildAgent first. It consolidates child and root handling for coming refactors. --- OpenSim/Region/Framework/Scenes/Scene.cs | 60 +++++++++++++------------ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 16 ++++++- OpenSim/Region/Framework/Scenes/SceneManager.cs | 9 ++-- 3 files changed, 50 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e43185d..302103a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -893,22 +893,17 @@ namespace OpenSim.Region.Framework.Scenes try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - - List old = new List(); - old.Add(otherRegion.RegionHandle); - agent.DropOldNeighbours(old); - if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, otherRegion); - } - } - ); + ForEachRootScenePresence(delegate(ScenePresence agent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + + List old = new List(); + old.Add(otherRegion.RegionHandle); + agent.DropOldNeighbours(old); + if (m_teleportModule != null) + m_teleportModule.EnableChildAgent(agent, otherRegion); + }); } catch (NullReferenceException) { @@ -1043,16 +1038,11 @@ namespace OpenSim.Region.Framework.Scenes GridRegion r = new GridRegion(region); try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - if (m_teleportModule != null) - m_teleportModule.EnableChildAgent(agent, r); - } - } - ); + ForEachRootScenePresence(delegate(ScenePresence agent) + { + if (m_teleportModule != null) + m_teleportModule.EnableChildAgent(agent, r); + }); } catch (NullReferenceException) { @@ -1456,11 +1446,10 @@ namespace OpenSim.Region.Framework.Scenes /// Stats on the Simulator's performance private void SendSimStatsPackets(SimStats stats) { - ForEachScenePresence( + ForEachRootScenePresence( delegate(ScenePresence agent) { - if (!agent.IsChildAgent) - agent.ControllingClient.SendSimStats(stats); + agent.ControllingClient.SendSimStats(stats); } ); } @@ -4290,6 +4279,19 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// Performs action on all ROOT (not child) scene presences. + /// This is just a shortcut function since frequently actions only appy to root SPs + /// + /// + public void ForEachRootScenePresence(Action action) + { + if(m_sceneGraph != null) + { + m_sceneGraph.ForEachRootScenePresence(action); + } + } + + /// /// Performs action on all scene presences. /// /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index caec704..542bd51 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1190,7 +1190,21 @@ namespace OpenSim.Region.Framework.Scenes } } } - + + /// + /// Performs action on all ROOT (not child) scene presences. + /// This is just a shortcut function since frequently actions only appy to root SPs + /// + /// + public void ForEachRootScenePresence(Action action) + { + ForEachScenePresence(delegate(ScenePresence sp) + { + if (!sp.IsChildAgent) + action(sp); + }); + } + /// /// Performs action on all scene presences. This can ultimately run the actions in parallel but /// any delegates passed in will need to implement their own locking on data they reference and diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index a58b87d..3bfd866 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -458,9 +458,9 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { - if (!scenePresence.IsChildAgent && (name == null || scenePresence.Name == name)) + if (name == null || scenePresence.Name == name) { m_log.DebugFormat("Packet debug for {0} {1} set to {2}", scenePresence.Firstname, @@ -481,10 +481,9 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { - if (!scenePresence.IsChildAgent) - avatars.Add(scenePresence); + avatars.Add(scenePresence); }); } ); -- cgit v1.1