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.
This commit is contained in:
Dan Lake
2011-11-03 17:06:08 -07:00
parent 69a4057135
commit 94dc7d07eb
23 changed files with 123 additions and 156 deletions

View File

@@ -228,7 +228,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
foreach (Scene s in m_scenes)
{
s.ForEachScenePresence(
// This should use ForEachClient, but clients don't have a position.
// If camera is moved into client, then camera position can be used
s.ForEachAvatar(
delegate(ScenePresence presence)
{
if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType))
@@ -279,11 +281,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
HashSet<UUID> receiverIDs = new HashSet<UUID>();
((Scene)c.Scene).ForEachRootScenePresence(
delegate(ScenePresence presence)
((Scene)c.Scene).ForEachRootClient(
delegate(IClientAPI client)
{
IClientAPI client = presence.ControllingClient;
// don't forward SayOwner chat from objects to
// non-owner agents
if ((c.Type == ChatTypeEnum.Owner) &&
@@ -292,8 +292,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
return;
client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
receiverIDs.Add(presence.UUID);
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
receiverIDs.Add(client.AgentId);
});
(c.Scene as Scene).EventManager.TriggerOnChatToClients(

View File

@@ -98,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendGeneralAlert(string message)
{
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
presence.ControllingClient.SendAlertMessage(message);
client.SendAlertMessage(message);
});
}
@@ -162,9 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message)
{
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
});
}

View File

@@ -140,14 +140,12 @@ 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.ForEachRootScenePresence(
delegate(ScenePresence p)
m_scene.ForEachRootClient(
delegate(IClientAPI client)
{
if (p.UUID != godID)
if (client.AgentId != godID)
{
// Possibly this should really be p.Close() though that method doesn't send a close
// to the client
p.ControllingClient.Close();
client.Close();
}
}
);