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.

0.7.2-post-fixes
Dan Lake 2011-10-27 00:42:21 -07:00 committed by Justin Clark-Casey (justincc)
parent a16c9206b4
commit b36ff0fd24
14 changed files with 78 additions and 87 deletions

View File

@ -279,12 +279,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
HashSet<UUID> receiverIDs = new HashSet<UUID>(); HashSet<UUID> receiverIDs = new HashSet<UUID>();
((Scene)c.Scene).ForEachScenePresence( ((Scene)c.Scene).ForEachRootScenePresence(
delegate(ScenePresence presence) delegate(ScenePresence presence)
{ {
// ignore chat from child agents
if (presence.IsChildAgent) return;
IClientAPI client = presence.ControllingClient; IClientAPI client = presence.ControllingClient;
// don't forward SayOwner chat from objects to // don't forward SayOwner chat from objects to

View File

@ -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 // This is a bit crude. It seems the client will be null before it actually stops the thread
// The thread will kill itself eventually :/ // The thread will kill itself eventually :/
// Is there another way to make sure *all* clients get this 'inter region' message? // Is there another way to make sure *all* clients get this 'inter region' message?
m_scene.ForEachScenePresence( m_scene.ForEachRootScenePresence(
delegate(ScenePresence p) 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 // Possibly this should really be p.Close() though that method doesn't send a close
// to the client // to the client

View File

@ -658,17 +658,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
return; return;
Scene.ForEachScenePresence(delegate(ScenePresence sp) Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (sp.UUID != senderID) if (sp.UUID != senderID)
{ {
ScenePresence p = Scene.GetScenePresence(sp.UUID);
// make sure they are still there, we could be working down a long list // make sure they are still there, we could be working down a long list
// Also make sure they are actually in the region // 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); Scene.TeleportClientHome(p.UUID, p.ControllingClient);
}
} }
}); });
} }
@ -929,10 +927,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
public void sendRegionInfoPacketToAll() public void sendRegionInfoPacketToAll()
{ {
Scene.ForEachScenePresence(delegate(ScenePresence sp) Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (!sp.IsChildAgent) HandleRegionInfoRequest(sp.ControllingClient);
HandleRegionInfoRequest(sp.ControllingClient);
}); });
} }

View File

@ -476,11 +476,8 @@ namespace OpenSim.Region.CoreModules.World.Land
public void SendLandUpdateToAvatarsOverMe(bool snap_selection) 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; ILandObject over = null;
try try
{ {

View File

@ -70,11 +70,8 @@ namespace OpenSim.Region.CoreModules.World.Sound
SceneObjectGroup grp = part.ParentGroup; 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); double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
if (dis > 100.0) // Max audio distance if (dis > 100.0) // Max audio distance
return; 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); double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
if (dis > 100.0) // Max audio distance if (dis > 100.0) // Max audio distance
return; return;

View File

@ -488,12 +488,9 @@ namespace OpenSim.Region.CoreModules
private void SunUpdateToAllClients() private void SunUpdateToAllClients()
{ {
m_scene.ForEachScenePresence(delegate(ScenePresence sp) m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (!sp.IsChildAgent)
{
SunToClient(sp.ControllingClient); SunToClient(sp.ControllingClient);
}
}); });
} }

View File

@ -435,10 +435,9 @@ namespace OpenSim.Region.CoreModules
m_frameLastUpdateClientArray = m_frame; 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);
}); });
} }
} }

View File

@ -401,10 +401,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
} }
else else
{ {
m_scene.ForEachScenePresence(delegate(ScenePresence sp) m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
// Don't send a green dot for yourself // Don't send a green dot for yourself
if (!sp.IsChildAgent && sp.UUID != remoteClient.AgentId) if (sp.UUID != remoteClient.AgentId)
{ {
mapitem = new mapItemReply(); mapitem = new mapItemReply();
mapitem.x = (uint)(xstart + sp.AbsolutePosition.X); mapitem.x = (uint)(xstart + sp.AbsolutePosition.X);

View File

@ -893,22 +893,17 @@ namespace OpenSim.Region.Framework.Scenes
try try
{ {
ForEachScenePresence(delegate(ScenePresence agent) ForEachRootScenePresence(delegate(ScenePresence agent)
{ {
// If agent is a root agent. //agent.ControllingClient.new
if (!agent.IsChildAgent) //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
{
//agent.ControllingClient.new
//this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
List<ulong> old = new List<ulong>(); List<ulong> old = new List<ulong>();
old.Add(otherRegion.RegionHandle); old.Add(otherRegion.RegionHandle);
agent.DropOldNeighbours(old); agent.DropOldNeighbours(old);
if (m_teleportModule != null) if (m_teleportModule != null)
m_teleportModule.EnableChildAgent(agent, otherRegion); m_teleportModule.EnableChildAgent(agent, otherRegion);
} });
}
);
} }
catch (NullReferenceException) catch (NullReferenceException)
{ {
@ -1003,16 +998,11 @@ namespace OpenSim.Region.Framework.Scenes
GridRegion r = new GridRegion(region); GridRegion r = new GridRegion(region);
try try
{ {
ForEachScenePresence(delegate(ScenePresence agent) ForEachRootScenePresence(delegate(ScenePresence agent)
{ {
// If agent is a root agent. if (m_teleportModule != null)
if (!agent.IsChildAgent) m_teleportModule.EnableChildAgent(agent, r);
{ });
if (m_teleportModule != null)
m_teleportModule.EnableChildAgent(agent, r);
}
}
);
} }
catch (NullReferenceException) catch (NullReferenceException)
{ {
@ -1417,11 +1407,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="stats">Stats on the Simulator's performance</param> /// <param name="stats">Stats on the Simulator's performance</param>
private void SendSimStatsPackets(SimStats stats) private void SendSimStatsPackets(SimStats stats)
{ {
ForEachScenePresence( ForEachRootScenePresence(
delegate(ScenePresence agent) delegate(ScenePresence agent)
{ {
if (!agent.IsChildAgent) agent.ControllingClient.SendSimStats(stats);
agent.ControllingClient.SendSimStats(stats);
} }
); );
} }
@ -4256,6 +4245,19 @@ namespace OpenSim.Region.Framework.Scenes
return cp.IsChildAgent; return cp.IsChildAgent;
} }
/// <summary>
/// Performs action on all ROOT (not child) scene presences.
/// This is just a shortcut function since frequently actions only appy to root SPs
/// </summary>
/// <param name="action"></param>
public void ForEachRootScenePresence(Action<ScenePresence> action)
{
if(m_sceneGraph != null)
{
m_sceneGraph.ForEachRootScenePresence(action);
}
}
/// <summary> /// <summary>
/// Performs action on all scene presences. /// Performs action on all scene presences.
/// </summary> /// </summary>

View File

@ -1191,6 +1191,20 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Performs action on all ROOT (not child) scene presences.
/// This is just a shortcut function since frequently actions only appy to root SPs
/// </summary>
/// <param name="action"></param>
public void ForEachRootScenePresence(Action<ScenePresence> action)
{
ForEachScenePresence(delegate(ScenePresence sp)
{
if (!sp.IsChildAgent)
action(sp);
});
}
/// <summary> /// <summary>
/// Performs action on all scene presences. This can ultimately run the actions in parallel but /// 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 /// any delegates passed in will need to implement their own locking on data they reference and

View File

@ -458,9 +458,9 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene( ForEachCurrentScene(
delegate(Scene scene) 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}", m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
scenePresence.Firstname, scenePresence.Firstname,
@ -481,10 +481,9 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene( ForEachCurrentScene(
delegate(Scene scene) delegate(Scene scene)
{ {
scene.ForEachScenePresence(delegate(ScenePresence scenePresence) scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
{ {
if (!scenePresence.IsChildAgent) avatars.Add(scenePresence);
avatars.Add(scenePresence);
}); });
} }
); );

View File

@ -373,13 +373,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
scene.GetRootAgentCount(), scene.RegionInfo.RegionName, scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
scene.RegionInfo.RegionID, scene.RegionInfo.RegionID,
DateTime.UtcNow.ToString("s"))); DateTime.UtcNow.ToString("s")));
scene.ForEachScenePresence(delegate(ScenePresence sp) scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (!sp.IsChildAgent)
{
list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
list.Append("</avatars>"); list.Append("</avatars>");
}
}); });
string payload = list.ToString(); string payload = list.ToString();

View File

@ -711,10 +711,8 @@ namespace OpenSim.Region.RegionCombinerModule
List<Vector3> CoarseLocations = new List<Vector3>(); List<Vector3> CoarseLocations = new List<Vector3>();
List<UUID> AvatarUUIDs = new List<UUID>(); List<UUID> AvatarUUIDs = new List<UUID>();
connectiondata.RegionScene.ForEachScenePresence(delegate(ScenePresence sp) connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (sp.IsChildAgent)
return;
if (sp.UUID != presence.UUID) if (sp.UUID != presence.UUID)
{ {
if (sp.ParentID != 0) if (sp.ParentID != 0)

View File

@ -3719,9 +3719,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
List<UUID> keytable = new List<UUID>(); List<UUID> keytable = new List<UUID>();
// parse for sitting avatare-uuids // parse for sitting avatare-uuids
World.ForEachScenePresence(delegate(ScenePresence presence) World.ForEachRootScenePresence(delegate(ScenePresence presence)
{ {
if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
keytable.Add(presence.UUID); keytable.Add(presence.UUID);
}); });
@ -3781,9 +3781,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
// parse for sitting avatare-names // parse for sitting avatare-names
List<String> nametable = new List<String>(); List<String> nametable = new List<String>();
World.ForEachScenePresence(delegate(ScenePresence presence) World.ForEachRootScenePresence(delegate(ScenePresence presence)
{ {
if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
nametable.Add(presence.ControllingClient.Name); nametable.Add(presence.ControllingClient.Name);
}); });
@ -7547,9 +7547,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
int avatarCount = 0; int avatarCount = 0;
World.ForEachScenePresence(delegate(ScenePresence presence) World.ForEachRootScenePresence(delegate(ScenePresence presence)
{ {
if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
avatarCount++; avatarCount++;
}); });
@ -9315,9 +9315,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
landObject.SetMediaUrl(url); landObject.SetMediaUrl(url);
// now send to all (non-child) agents in the parcel // now send to all (non-child) agents in the parcel
World.ForEachScenePresence(delegate(ScenePresence sp) World.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (!sp.IsChildAgent && (sp.currentParcelUUID == landData.GlobalID)) if (sp.currentParcelUUID == landData.GlobalID)
{ {
sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL, sp.ControllingClient.SendParcelMediaUpdate(landData.MediaURL,
landData.MediaID, landData.MediaID,
@ -9348,9 +9348,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (presence == null) if (presence == null)
{ {
// send to all (non-child) agents in the parcel // send to all (non-child) agents in the parcel
World.ForEachScenePresence(delegate(ScenePresence sp) World.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
if (!sp.IsChildAgent && (sp.currentParcelUUID == landData.GlobalID)) if (sp.currentParcelUUID == landData.GlobalID)
{ {
sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this? sp.ControllingClient.SendParcelMediaCommand(0x4, // TODO what is this?
(ParcelMediaCommandEnum)commandToSend, (ParcelMediaCommandEnum)commandToSend,