mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
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:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -145,57 +145,38 @@ namespace OpenSim.Region.CoreModules.World.LightShare
|
||||
param.Add(mBlock);
|
||||
return param;
|
||||
}
|
||||
public void SendProfileToClient(ScenePresence presence)
|
||||
|
||||
public void SendProfileToClient(IClientAPI client)
|
||||
{
|
||||
SendProfileToClient(client, m_scene.RegionInfo.WindlightSettings);
|
||||
}
|
||||
|
||||
public void SendProfileToClient(IClientAPI client, RegionLightShareData wl)
|
||||
{
|
||||
IClientAPI client = presence.ControllingClient;
|
||||
if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
|
||||
{
|
||||
if (presence.IsChildAgent == false)
|
||||
{
|
||||
List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings);
|
||||
client.SendGenericMessage("Windlight", param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//We probably don't want to spam chat with this.. probably
|
||||
//m_log.Debug("[WINDLIGHT]: Module disabled");
|
||||
}
|
||||
}
|
||||
public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl)
|
||||
{
|
||||
IClientAPI client = presence.ControllingClient;
|
||||
if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
|
||||
{
|
||||
if (presence.IsChildAgent == false)
|
||||
{
|
||||
List<byte[]> param = compileWindlightSettings(wl);
|
||||
client.SendGenericMessage("Windlight", param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//We probably don't want to spam chat with this.. probably
|
||||
//m_log.Debug("[WINDLIGHT]: Module disabled");
|
||||
List<byte[]> param = compileWindlightSettings(wl);
|
||||
client.SendGenericMessage("Windlight", param);
|
||||
}
|
||||
}
|
||||
|
||||
private void EventManager_OnMakeRootAgent(ScenePresence presence)
|
||||
{
|
||||
m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
|
||||
SendProfileToClient(presence);
|
||||
SendProfileToClient(presence.ControllingClient);
|
||||
}
|
||||
|
||||
private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID)
|
||||
{
|
||||
ScenePresence Sc;
|
||||
if (m_scene.TryGetScenePresence(pUUID,out Sc))
|
||||
{
|
||||
SendProfileToClient(Sc,wl);
|
||||
}
|
||||
IClientAPI client;
|
||||
m_scene.TryGetClient(pUUID, out client);
|
||||
SendProfileToClient(client, wl);
|
||||
}
|
||||
|
||||
private void EventManager_OnSaveNewWindlightProfile()
|
||||
{
|
||||
if (m_scene.RegionInfo.WindlightSettings.valid)
|
||||
m_scene.ForEachScenePresence(SendProfileToClient);
|
||||
m_scene.ForEachRootClient(SendProfileToClient);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
||||
@@ -658,14 +658,14 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||
if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
|
||||
return;
|
||||
|
||||
Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
Scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
{
|
||||
if (sp.UUID != senderID)
|
||||
if (client.AgentId != senderID)
|
||||
{
|
||||
// make sure they are still there, we could be working down a long list
|
||||
// Also make sure they are actually in the region
|
||||
ScenePresence p;
|
||||
if(Scene.TryGetScenePresence(sp.UUID, out p))
|
||||
if(Scene.TryGetScenePresence(client.AgentId, out p))
|
||||
Scene.TeleportClientHome(p.UUID, p.ControllingClient);
|
||||
}
|
||||
});
|
||||
@@ -927,9 +927,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||
|
||||
public void sendRegionInfoPacketToAll()
|
||||
{
|
||||
Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
Scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
{
|
||||
HandleRegionInfoRequest(sp.ControllingClient);
|
||||
HandleRegionInfoRequest(client);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
|
||||
public void SendLandUpdateToAvatarsOverMe(bool snap_selection)
|
||||
{
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar)
|
||||
m_scene.ForEachAvatar(delegate(ScenePresence avatar)
|
||||
{
|
||||
ILandObject over = null;
|
||||
try
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
|
||||
SceneObjectGroup grp = part.ParentGroup;
|
||||
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
m_scene.ForEachAvatar(delegate(ScenePresence sp)
|
||||
{
|
||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
|
||||
if (dis > 100.0) // Max audio distance
|
||||
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
}
|
||||
}
|
||||
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
m_scene.ForEachAvatar(delegate(ScenePresence sp)
|
||||
{
|
||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
|
||||
if (dis > 100.0) // Max audio distance
|
||||
|
||||
@@ -488,9 +488,9 @@ namespace OpenSim.Region.CoreModules
|
||||
|
||||
private void SunUpdateToAllClients()
|
||||
{
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
{
|
||||
SunToClient(sp.ControllingClient);
|
||||
SunToClient(client);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules
|
||||
m_frameLastUpdateClientArray = m_frame;
|
||||
}
|
||||
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
{
|
||||
sp.ControllingClient.SendWindData(windSpeeds);
|
||||
client.SendWindData(windSpeeds);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
m_scene.ForEachAvatar(delegate(ScenePresence sp)
|
||||
{
|
||||
// Don't send a green dot for yourself
|
||||
if (sp.UUID != remoteClient.AgentId)
|
||||
@@ -1180,7 +1180,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
else
|
||||
{
|
||||
OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount());
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
m_scene.ForEachAvatar(delegate(ScenePresence sp)
|
||||
{
|
||||
OSDMap responsemapdata = new OSDMap();
|
||||
responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
|
||||
|
||||
Reference in New Issue
Block a user