diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index f1cb0f770f..3408d350eb 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -389,16 +389,10 @@ namespace OpenSim.Framework // Appearance public AvatarAppearance Appearance; -// DEBUG ON - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); -// DEBUG OFF - // Scripted public ControllerData[] Controllers; - public string CallbackURI; // to remove + public string CallbackURI; public string NewCallbackURI; // These two must have the same Count @@ -407,6 +401,10 @@ namespace OpenSim.Framework public Dictionary MovementAnimationOverRides = new Dictionary(); + public List CachedFriendsOnline; + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public void SetLookAt(Vector3 value) { if (value.X == 0 && value.Y == 0) @@ -424,7 +422,7 @@ namespace OpenSim.Framework public virtual OSDMap Pack(EntityTransferContext ctx) { -// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); + //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); @@ -575,6 +573,16 @@ namespace OpenSim.Framework args["parent_part"] = OSD.FromUUID(ParentPart); args["sit_offset"] = OSD.FromString(SitOffset.ToString()); + if(CachedFriendsOnline != null && CachedFriendsOnline.Count > 0) + { + OSDArray cfonl = new OSDArray(CachedFriendsOnline.Count); + { + foreach(UUID id in CachedFriendsOnline) + cfonl.Add(id); + } + args["cfonline"] = cfonl; + } + return args; } @@ -871,6 +879,14 @@ namespace OpenSim.Framework ParentPart = tmp.AsUUID(); if (args.TryGetValue("sit_offset", out tmp) && tmp != null) Vector3.TryParse(tmp.AsString(), out SitOffset); + + if (args.TryGetValue("cfonline", out tmp) && tmp != null) + { + OSDArray cfonl = (OSDArray)tmp; + CachedFriendsOnline = new List(cfonl.Count); + foreach(OSD o in cfonl) + CachedFriendsOnline.Add(o.AsUUID()); + } } public AgentData() diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 6d08b7bcf6..559ad9c52a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - public void CacheFriendOnline(UUID userID, UUID friendID, bool online) + public virtual void CacheFriendOnline(UUID userID, UUID friendID, bool online) { if (!m_OnlineFriendsCache.TryGetValue(userID, out HashSet friends)) { @@ -292,6 +292,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends else friends.Remove(friendID); } + public virtual List GetCachedFriendsOnline(UUID userID) + { + if (m_OnlineFriendsCache.TryGetValue(userID, out HashSet friends)) + { + List friendslst = new List(friends.Count); + foreach(UUID id in friends) + friendslst.Add(id); + return friendslst; + } + else + return null; + } private void OnMakeRootAgent(ScenePresence sp) { diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 3bd7fbfbf2..5d14119f0f 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs @@ -99,5 +99,6 @@ namespace OpenSim.Region.Framework.Interfaces bool IsFriendOnline(UUID userID, UUID friendID); void CacheFriendsOnline(UUID userID, List friendsOnline, bool online); void CacheFriendOnline(UUID userID, UUID friendOnline, bool online); + List GetCachedFriendsOnline(UUID userID); } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fd87dfdb89..bc06a47c90 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4947,6 +4947,12 @@ namespace OpenSim.Region.Framework.Scenes else cAgent.ActiveGroupTitle = Grouptitle; } + + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + if (friendsModule != null) + { + cAgent.CachedFriendsOnline = friendsModule.GetCachedFriendsOnline(UUID); + } } private void CopyFrom(AgentData cAgent) @@ -5107,6 +5113,13 @@ namespace OpenSim.Region.Framework.Scenes lock (m_originRegionIDAccessLock) m_originRegionID = cAgent.RegionID; + + if (cAgent.CachedFriendsOnline != null) + { + IFriendsModule friendsModule = m_scene.RequestModuleInterface(); + friendsModule?.CacheFriendsOnline(UUID, cAgent.CachedFriendsOnline, true); + } + } public bool CopyAgent(out IAgentData agent)