refactor: Instead of performing a ScenePresence lookup twice over LocateClientObject() and GetClientScene(), do the lookup just once in LocateClientObject()

0.7.4.1
Justin Clark-Casey (justincc) 2012-05-07 18:27:33 +01:00
parent cdf97ab3a6
commit 5053506d88
1 changed files with 2 additions and 18 deletions

View File

@ -448,30 +448,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
/// Find the client for a ID
/// </summary>
public IClientAPI LocateClientObject(UUID agentID)
{
Scene scene = GetClientScene(agentID);
if (scene != null)
{
ScenePresence presence = scene.GetScenePresence(agentID);
if (presence != null)
return presence.ControllingClient;
}
return null;
}
/// <summary>
/// Find the scene for an agent
/// </summary>
private Scene GetClientScene(UUID agentId)
{
lock (m_Scenes)
{
foreach (Scene scene in m_Scenes)
{
ScenePresence presence = scene.GetScenePresence(agentId);
ScenePresence presence = scene.GetScenePresence(agentID);
if (presence != null && !presence.IsChildAgent)
return scene;
return presence.ControllingClient;
}
}