* Added a way for the friends module to definitively know if an avatar's root agent is on the instance and if so, which region the avatar's root agent is in.

This commit is contained in:
Teravus Ovares
2008-02-28 05:20:23 +00:00
parent 41c369de82
commit 1afe38b319
4 changed files with 70 additions and 2 deletions

View File

@@ -775,6 +775,8 @@ namespace OpenSim.Region.Environment.LandManagement
if (!avatar.IsChildAgent)
{
over.sendLandUpdateToClient(avatar.ControllingClient);
m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID,
m_scene.RegionInfo.RegionID);
}
}

View File

@@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Modules
private List<Scene> m_scene = new List<Scene>();
Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
public void Initialise(Scene scene, IConfigSource config)
@@ -62,6 +64,9 @@ namespace OpenSim.Region.Environment.Modules
scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnGridInstantMessageToFriendsModule += OnGridInstantMessage;
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnClientClosed += ClientLoggedOut;
}
@@ -86,13 +91,60 @@ namespace OpenSim.Region.Environment.Modules
client.OnTerminateFriendship += OnTerminateFriendship;
}
private void ClientLoggedOut(LLUUID AgentId)
{
lock (m_rootAgents)
{
if (m_rootAgents.ContainsKey(AgentId))
{
m_rootAgents.Remove(AgentId);
m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out.");
}
}
}
private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
{
int i = 0;
lock (m_rootAgents)
{
if (m_rootAgents.ContainsKey(avatar.UUID))
{
if (avatar.RegionHandle != m_rootAgents[avatar.UUID])
{
m_rootAgents[avatar.UUID] = avatar.RegionHandle;
m_log.Info("[FRIEND]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
// Claim User! my user! Mine mine mine!
}
}
else
{
m_rootAgents.Add(avatar.UUID, avatar.RegionHandle);
m_log.Info("[FRIEND]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
}
}
//m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
}
private void MakeChildAgent(ScenePresence avatar)
{
lock (m_rootAgents)
{
if (m_rootAgents.ContainsKey(avatar.UUID))
{
if (m_rootAgents[avatar.UUID] == avatar.RegionHandle)
{
m_rootAgents.Remove(avatar.UUID);
m_log.Info("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
}
}
}
}
private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID,

View File

@@ -133,6 +133,9 @@ namespace OpenSim.Region.Environment.Scenes
public event ScriptChangedEvent OnScriptChangedEvent;
public event OnNewPresenceDelegate OnMakeChildAgent;
public class MoneyTransferArgs : System.EventArgs
{
public LLUUID sender;
@@ -185,6 +188,7 @@ namespace OpenSim.Region.Environment.Scenes
private NewGridInstantMessage handler023 = null; //OnGridInstantMessageToIMModule;
private NewGridInstantMessage handler024 = null; //OnGridInstantMessageToFriendsModule;
private ClientClosed handler025 = null; //OnClientClosed;
private OnNewPresenceDelegate handler026 = null; //OnMakeChildAgent;
public void TriggerOnScriptChangedEvent(uint localID, uint change)
{
@@ -405,6 +409,16 @@ namespace OpenSim.Region.Environment.Scenes
handler025(ClientID);
}
}
public void TriggerOnMakeChildAgent(ScenePresence presence)
{
handler026 = OnMakeChildAgent;
if (handler026 != null)
{
handler026(presence);
}
}
}
}

View File

@@ -547,7 +547,7 @@ namespace OpenSim.Region.Environment.Scenes
m_isChildAgent = true;
m_scene.SwapRootAgentCount(true);
RemoveFromPhysicalScene();
m_scene.EventManager.TriggerOnMakeChildAgent(this);
//this.Pos = new LLVector3(128, 128, 70);
}