From 94dc7d07ebc22ce0e0d9b77e91538ddc90799bee Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 3 Nov 2011 17:06:08 -0700 Subject: Renamed ForEachRootScenePresence to ForEachAvatar. Cleaned up calls to the 3 iteration functions so more of them are using the correct iteration for the action they are performing. The 3 iterators that seem to fit all actions within OpenSim at this time are: ForEachAvatar: Perform an action on all avatars (root presences) ForEachClient: Perform an action on all clients (root or child clients) ForEachRootClient: Perform an action on all clients that have an avatar There are still a dozen places or so calling the old ForEachScenePresence that will take a little more refactoring to eliminate. --- OpenSim/Region/Framework/Scenes/Scene.cs | 76 ++++++++++------------ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneManager.cs | 12 ++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 +++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- 6 files changed, 55 insertions(+), 63 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dff43fd..b996e86 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -872,7 +872,7 @@ namespace OpenSim.Region.Framework.Scenes try { - ForEachRootScenePresence(delegate(ScenePresence agent) + ForEachAvatar(delegate(ScenePresence agent) { //agent.ControllingClient.new //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); @@ -1017,7 +1017,7 @@ namespace OpenSim.Region.Framework.Scenes GridRegion r = new GridRegion(region); try { - ForEachRootScenePresence(delegate(ScenePresence agent) + ForEachAvatar(delegate(ScenePresence agent) { if (m_teleportModule != null) m_teleportModule.EnableChildAgent(agent, r); @@ -1423,12 +1423,10 @@ namespace OpenSim.Region.Framework.Scenes /// Stats on the Simulator's performance private void SendSimStatsPackets(SimStats stats) { - ForEachRootScenePresence( - delegate(ScenePresence agent) - { - agent.ControllingClient.SendSimStats(stats); - } - ); + ForEachRootClient(delegate(IClientAPI client) + { + client.SendSimStats(stats); + }); } /// @@ -4214,35 +4212,32 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.GetScenePresence(localID); } + /// + /// Returns true if scene presence is a child (no avatar in this scene) + /// + /// + /// public override bool PresenceChildStatus(UUID avatarID) { - ScenePresence cp = GetScenePresence(avatarID); - - // FIXME: This is really crap - some logout code is relying on a NullReferenceException to halt its processing - // This needs to be fixed properly by cleaning up the logout code. - //if (cp != null) - // return cp.IsChildAgent; - - //return false; - - return cp.IsChildAgent; + ScenePresence sp; + return TryGetScenePresence(avatarID, out sp) && sp.IsChildAgent; } /// - /// Performs action on all ROOT (not child) scene presences. - /// This is just a shortcut function since frequently actions only appy to root SPs + /// Performs action on all avatars in the scene (root scene presences) + /// Avatars may be an NPC or a 'real' client. /// /// - public void ForEachRootScenePresence(Action action) + public void ForEachAvatar(Action action) { if(m_sceneGraph != null) { - m_sceneGraph.ForEachRootScenePresence(action); + m_sceneGraph.ForEachAvatar(action); } } /// - /// Performs action on all scene presences. + /// Performs action on all scene presences (root and child) /// /// public void ForEachScenePresence(Action action) @@ -4254,25 +4249,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Perform the given action for each object - /// - /// - // public void ForEachObject(Action action) - // { - // List presenceList; - // - // lock (m_sceneObjects) - // { - // presenceList = new List(m_sceneObjects.Values); - // } - // - // foreach (SceneObjectGroup presence in presenceList) - // { - // action(presence); - // } - // } - - /// /// Get a group via its UUID /// /// @@ -4344,6 +4320,22 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.TryGetAvatarByName(avatarName, out avatar); } + /// + /// Perform an action on all clients with an avatar in this scene (root only) + /// + /// + public void ForEachRootClient(Action action) + { + ForEachAvatar(delegate(ScenePresence presence) + { + action(presence.ControllingClient); + }); + } + + /// + /// Perform an action on all clients connected to the region (root and child) + /// + /// public void ForEachClient(Action action) { m_clientManager.ForEachSync(action); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 82ded28..a137bca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1190,7 +1190,7 @@ namespace OpenSim.Region.Framework.Scenes /// This is just a shortcut function since frequently actions only appy to root SPs /// /// - public void ForEachRootScenePresence(Action action) + public void ForEachAvatar(Action action) { ForEachScenePresence(delegate(ScenePresence sp) { diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 3bfd866..9b72bee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -458,16 +458,16 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootClient(delegate(IClientAPI client) { - if (name == null || scenePresence.Name == name) + if (name == null || client.Name == name) { m_log.DebugFormat("Packet debug for {0} {1} set to {2}", - scenePresence.Firstname, - scenePresence.Lastname, + client.FirstName, + client.LastName, newDebug); - scenePresence.ControllingClient.DebugPacketLevel = newDebug; + client.DebugPacketLevel = newDebug; } }); } @@ -481,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachAvatar(delegate(ScenePresence scenePresence) { avatars.Add(scenePresence); }); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a0a7344..3c80eb5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1150,7 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = parts[i]; - Scene.ForEachScenePresence(delegate(ScenePresence avatar) + Scene.ForEachAvatar(delegate(ScenePresence avatar) { if (avatar.ParentID == LocalId) avatar.StandUp(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 44f822c..1a709e9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -992,7 +992,7 @@ namespace OpenSim.Region.Framework.Scenes public PrimitiveBaseShape Shape { get { return m_shape; } - set { m_shape = value; } + set { m_shape = value;} } /// @@ -1336,12 +1336,12 @@ namespace OpenSim.Region.Framework.Scenes /// private void SendRootPartPropertiesToClient(UUID AgentID) { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + m_parentGroup.Scene.ForEachClient(delegate(IClientAPI client) { // Ugly reference :( - if (avatar.UUID == AgentID) + if (client.AgentId == AgentID) { - m_parentGroup.SendPropertiesToClient(avatar.ControllingClient); + m_parentGroup.SendPropertiesToClient(client); } }); } @@ -1461,9 +1461,9 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootClient(delegate(IClientAPI client) { - sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); + client.SendAttachedSoundGainChange(UUID, (float)volume); }); } @@ -2216,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2347,7 +2347,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2470,7 +2470,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2696,7 +2696,7 @@ namespace OpenSim.Region.Framework.Scenes } } - m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence sp) { if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1d77b06..5fc597c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -956,7 +956,7 @@ namespace OpenSim.Region.Framework.Scenes } // send the animations of the other presences to me - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_scene.ForEachAvatar(delegate(ScenePresence presence) { if (presence != this) presence.Animator.SendAnimPackToClient(ControllingClient); @@ -2596,7 +2596,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarDataToMe() { int count = 0; - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + m_scene.ForEachAvatar(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) @@ -2660,7 +2660,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID); int count = 0; - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + m_scene.ForEachAvatar(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) -- cgit v1.1