Removed use of 'is' operator and casting to find the root ScenePresence in MessageTransfer modules and Groups module.

remove-scene-viewer
Dan Lake 2011-10-27 02:26:37 -07:00
parent 06577d7299
commit 272bf71279
4 changed files with 52 additions and 81 deletions

View File

@ -143,41 +143,34 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// Try root avatar only first // Try root avatar only first
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
if (scene.Entities.ContainsKey(toAgentID) &&
scene.Entities[toAgentID] is ScenePresence)
{
// m_log.DebugFormat( // m_log.DebugFormat(
// "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}",
// toAgentID.ToString(), scene.RegionInfo.RegionName); // toAgentID.ToString(), scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID);
ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; if (sp != null && !sp.IsChildAgent)
if (!user.IsChildAgent)
{ {
// Local message // Local message
// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID);
user.ControllingClient.SendInstantMessage(im); sp.ControllingClient.SendInstantMessage(im);
// Message sent // Message sent
result(true); result(true);
return; return;
} }
} }
}
// try child avatar second // try child avatar second
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); // "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}",
// toAgentID, scene.RegionInfo.RegionName);
if (scene.Entities.ContainsKey(toAgentID) && ScenePresence sp = scene.GetScenePresence(toAgentID);
scene.Entities[toAgentID] is ScenePresence) if (sp != null)
{ {
// Local message // Local message
ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
// m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, 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 // Message sent
result(true); result(true);
@ -231,19 +224,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
bool successful = false; bool successful = false;
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
if (scene.Entities.ContainsKey(toAgentID) && ScenePresence sp = scene.GetScenePresence(toAgentID);
scene.Entities[toAgentID] is ScenePresence) if(!sp.IsChildAgent)
{
ScenePresence user =
(ScenePresence)scene.Entities[toAgentID];
if (!user.IsChildAgent)
{ {
scene.EventManager.TriggerIncomingInstantMessage(gim); scene.EventManager.TriggerIncomingInstantMessage(gim);
successful = true; successful = true;
} }
} }
}
if (!successful) if (!successful)
{ {
// If the message can't be delivered to an agent, it // If the message can't be delivered to an agent, it

View File

@ -136,41 +136,33 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// Try root avatar only first // Try root avatar only first
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
if (scene.Entities.ContainsKey(toAgentID) &&
scene.Entities[toAgentID] is ScenePresence)
{
// m_log.DebugFormat( // m_log.DebugFormat(
// "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", // "[INSTANT MESSAGE]: Looking for root agent {0} in {1}",
// toAgentID.ToString(), scene.RegionInfo.RegionName); // toAgentID.ToString(), scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID);
ScenePresence user = (ScenePresence) scene.Entities[toAgentID]; if (sp != null && !sp.IsChildAgent)
if (!user.IsChildAgent)
{ {
// Local message // Local message
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID);
user.ControllingClient.SendInstantMessage(im); sp.ControllingClient.SendInstantMessage(im);
// Message sent // Message sent
result(true); result(true);
return; return;
} }
} }
}
// try child avatar second // try child avatar second
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName);
ScenePresence sp = scene.GetScenePresence(toAgentID);
if (scene.Entities.ContainsKey(toAgentID) && if (sp != null)
scene.Entities[toAgentID] is ScenePresence)
{ {
// Local message // Local message
ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
// m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, 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 // Message sent
result(true); result(true);
@ -389,19 +381,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// Trigger the Instant message in the scene. // Trigger the Instant message in the scene.
foreach (Scene scene in m_Scenes) foreach (Scene scene in m_Scenes)
{ {
if (scene.Entities.ContainsKey(toAgentID) && ScenePresence sp = scene.GetScenePresence(toAgentID);
scene.Entities[toAgentID] is ScenePresence) if (sp != null && !sp.IsChildAgent)
{
ScenePresence user =
(ScenePresence)scene.Entities[toAgentID];
if (!user.IsChildAgent)
{ {
scene.EventManager.TriggerIncomingInstantMessage(gim); scene.EventManager.TriggerIncomingInstantMessage(gim);
successful = true; successful = true;
} }
} }
}
if (!successful) if (!successful)
{ {
// If the message can't be delivered to an agent, it // If the message can't be delivered to an agent, it

View File

@ -504,19 +504,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Try root avatar first // Try root avatar first
foreach (Scene scene in m_sceneList) foreach (Scene scene in m_sceneList)
{ {
if (scene.Entities.ContainsKey(agentID) && ScenePresence sp = scene.GetScenePresence(agentID);
scene.Entities[agentID] is ScenePresence) if (sp != null)
{ {
ScenePresence user = (ScenePresence)scene.Entities[agentID]; if (!sp.IsChildAgent)
if (!user.IsChildAgent)
{ {
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name);
return user.ControllingClient; return sp.ControllingClient;
} }
else else
{ {
if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name);
child = user.ControllingClient; child = sp.ControllingClient;
} }
} }
} }

View File

@ -1076,17 +1076,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
// Try root avatar first // Try root avatar first
foreach (Scene scene in m_sceneList) foreach (Scene scene in m_sceneList)
{ {
if (scene.Entities.ContainsKey(agentID) && ScenePresence sp = scene.GetScenePresence(agentID);
scene.Entities[agentID] is ScenePresence) if (sp != null)
{ {
ScenePresence user = (ScenePresence)scene.Entities[agentID]; if (!sp.IsChildAgent)
if (!user.IsChildAgent)
{ {
return user.ControllingClient; return sp.ControllingClient;
} }
else else
{ {
child = user.ControllingClient; child = sp.ControllingClient;
} }
} }
} }