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/CoreModules/Avatar/Chat/ChatModule.cs | 7 ++----- OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | 4 ++-- .../CoreModules/World/Estate/EstateManagementModule.cs | 13 +++++-------- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 5 +---- OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 10 ++-------- OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 5 +---- OpenSim/Region/CoreModules/World/Wind/WindModule.cs | 5 ++--- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 4 ++-- 8 files changed, 17 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 4359c01..2cd71c4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -279,12 +279,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat HashSet receiverIDs = new HashSet(); - ((Scene)c.Scene).ForEachScenePresence( + ((Scene)c.Scene).ForEachRootScenePresence( delegate(ScenePresence presence) - { - // ignore chat from child agents - if (presence.IsChildAgent) return; - + { IClientAPI client = presence.ControllingClient; // don't forward SayOwner chat from objects to diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 5ec64d5..562c3b1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -140,10 +140,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods // This is a bit crude. It seems the client will be null before it actually stops the thread // The thread will kill itself eventually :/ // Is there another way to make sure *all* clients get this 'inter region' message? - m_scene.ForEachScenePresence( + m_scene.ForEachRootScenePresence( delegate(ScenePresence p) { - if (p.UUID != godID && !p.IsChildAgent) + if (p.UUID != godID) { // Possibly this should really be p.Close() though that method doesn't send a close // to the client diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index c199a77..5427b68 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -658,17 +658,15 @@ namespace OpenSim.Region.CoreModules.World.Estate if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) return; - Scene.ForEachScenePresence(delegate(ScenePresence sp) + Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.UUID != senderID) { - ScenePresence p = Scene.GetScenePresence(sp.UUID); // make sure they are still there, we could be working down a long list // Also make sure they are actually in the region - if (p != null && !p.IsChildAgent) - { + ScenePresence p; + if(Scene.TryGetScenePresence(sp.UUID, out p)) Scene.TeleportClientHome(p.UUID, p.ControllingClient); - } } }); } @@ -929,10 +927,9 @@ namespace OpenSim.Region.CoreModules.World.Estate public void sendRegionInfoPacketToAll() { - Scene.ForEachScenePresence(delegate(ScenePresence sp) + Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - HandleRegionInfoRequest(sp.ControllingClient); + HandleRegionInfoRequest(sp.ControllingClient); }); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 8c40171..0da0de3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -476,11 +476,8 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdateToAvatarsOverMe(bool snap_selection) { - m_scene.ForEachScenePresence(delegate(ScenePresence avatar) + m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar) { - if (avatar.IsChildAgent) - return; - ILandObject over = null; try { diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 22ffcd6..93b1005 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -70,11 +70,8 @@ namespace OpenSim.Region.CoreModules.World.Sound SceneObjectGroup grp = part.ParentGroup; - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; - double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance return; @@ -122,11 +119,8 @@ namespace OpenSim.Region.CoreModules.World.Sound } } - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (sp.IsChildAgent) - return; - double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance return; diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 4e14c73..d2c1289 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -488,12 +488,9 @@ namespace OpenSim.Region.CoreModules private void SunUpdateToAllClients() { - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - { SunToClient(sp.ControllingClient); - } }); } diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 6bac555..bea5db1 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -435,10 +435,9 @@ namespace OpenSim.Region.CoreModules m_frameLastUpdateClientArray = m_frame; } - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { - if (!sp.IsChildAgent) - sp.ControllingClient.SendWindData(windSpeeds); + sp.ControllingClient.SendWindData(windSpeeds); }); } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 857079c..509c0d8 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -401,10 +401,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } else { - m_scene.ForEachScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { // Don't send a green dot for yourself - if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId) + if (sp.UUID != remoteClient.AgentId) { mapitem = new mapItemReply(); mapitem.x = (uint)(xstart + sp.AbsolutePosition.X); -- cgit v1.1 From 06577d7299f38c342c9b241c691e647e5329837e Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 01:25:12 -0700 Subject: Continuation of previous checkin. Found more places where ForEachScenePresence can be changed to ForEachRootScenePresence. --- OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index d2a0860..3ce446b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -98,10 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendGeneralAlert(string message) { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent) - presence.ControllingClient.SendAlertMessage(message); + presence.ControllingClient.SendAlertMessage(message); }); } @@ -163,10 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendNotificationToUsersInRegion( UUID fromAvatarID, string fromAvatarName, string message) { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (!presence.IsChildAgent) - presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); + presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); }); } -- cgit v1.1 From 272bf712796ad8e98e79aee50311a84deaf23d79 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 27 Oct 2011 02:26:37 -0700 Subject: Removed use of 'is' operator and casting to find the root ScenePresence in MessageTransfer modules and Groups module. --- .../InstantMessage/HGMessageTransferModule.cs | 57 +++++++++------------- .../Avatar/InstantMessage/MessageTransferModule.cs | 52 ++++++++------------ 2 files changed, 41 insertions(+), 68 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index 72b448b..321a705 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -143,24 +143,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Try root avatar only first foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) - { -// m_log.DebugFormat( -// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", -// toAgentID.ToString(), scene.RegionInfo.RegionName); - - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - if (!user.IsChildAgent) - { - // Local message -// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); +// m_log.DebugFormat( +// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", +// toAgentID.ToString(), scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null && !sp.IsChildAgent) + { + // Local message +// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); - // Message sent - result(true); - return; - } + // Message sent + result(true); + return; } } @@ -168,16 +163,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage foreach (Scene scene in m_Scenes) { // m_log.DebugFormat( -// "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); - - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) - { +// "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", +// toAgentID, scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null) + { // Local message - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); + sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); @@ -231,17 +224,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage bool successful = false; foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(toAgentID); + if(!sp.IsChildAgent) { - ScenePresence user = - (ScenePresence)scene.Entities[toAgentID]; - - if (!user.IsChildAgent) - { - scene.EventManager.TriggerIncomingInstantMessage(gim); - successful = true; - } + scene.EventManager.TriggerIncomingInstantMessage(gim); + successful = true; } } if (!successful) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 45b84f4..0dad3c4 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -136,24 +136,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Try root avatar only first foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) +// m_log.DebugFormat( +// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", +// toAgentID.ToString(), scene.RegionInfo.RegionName); + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null && !sp.IsChildAgent) { -// m_log.DebugFormat( -// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", -// toAgentID.ToString(), scene.RegionInfo.RegionName); - - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - if (!user.IsChildAgent) - { - // Local message -// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); - - // Message sent - result(true); - return; - } + // Local message +// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); + sp.ControllingClient.SendInstantMessage(im); + + // Message sent + result(true); + return; } } @@ -162,15 +157,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { // m_log.DebugFormat( // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); - - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null) { // Local message - ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; - // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); - user.ControllingClient.SendInstantMessage(im); + sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); @@ -389,17 +381,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // Trigger the Instant message in the scene. foreach (Scene scene in m_Scenes) { - if (scene.Entities.ContainsKey(toAgentID) && - scene.Entities[toAgentID] is ScenePresence) + ScenePresence sp = scene.GetScenePresence(toAgentID); + if (sp != null && !sp.IsChildAgent) { - ScenePresence user = - (ScenePresence)scene.Entities[toAgentID]; - - if (!user.IsChildAgent) - { - scene.EventManager.TriggerIncomingInstantMessage(gim); - successful = true; - } + scene.EventManager.TriggerIncomingInstantMessage(gim); + successful = true; } } if (!successful) -- cgit v1.1