From 1afe38b319d8306b372b639ac2ad2c8e71c3e75d Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 28 Feb 2008 05:20:23 +0000 Subject: * 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. --- .../Environment/LandManagement/LandManager.cs | 2 + .../Region/Environment/Modules/FriendsModule.cs | 54 +++++++++++++++++++++- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 14 ++++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 2 +- 4 files changed, 70 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index 4f6015a..83ed3cf 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -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); } } diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index 4081a75..e1d3e2a 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs @@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Modules private List m_scene = new List(); + + Dictionary m_rootAgents = new Dictionary(); Dictionary m_pendingFriendRequests = new Dictionary(); 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, diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 5389ec4..62011ea 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -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); + } + + } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 9f3c924..ef23432 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -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); } -- cgit v1.1