diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs index e4ed9fa..f8f66d6 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | |||
@@ -755,17 +755,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
755 | // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets. | 755 | // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets. |
756 | // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago... | 756 | // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago... |
757 | List<UUID> friendIDsToSendTo = new List<UUID>(); | 757 | List<UUID> friendIDsToSendTo = new List<UUID>(); |
758 | List<UUID> friendIDsToReceiveFromOffline = new List<UUID>(); | 758 | List<UUID> candidateFriendIDsToReceive = new List<UUID>(); |
759 | List<UUID> friendIDsToReceiveFromOnline = new List<UUID>(); | 759 | |
760 | foreach (FriendListItem item in friendList) | 760 | foreach (FriendListItem item in friendList) |
761 | { | 761 | { |
762 | if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0) | 762 | if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0) |
763 | { | 763 | { |
764 | // friend is allowed to see my presence => add | 764 | // friend is allowed to see my presence => add |
765 | if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) friendIDsToSendTo.Add(item.Friend); | 765 | if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) |
766 | friendIDsToSendTo.Add(item.Friend); | ||
766 | 767 | ||
767 | // I'm allowed to see friend's presence => add as offline, we might reconsider in a momnet... | 768 | if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) |
768 | if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) friendIDsToReceiveFromOffline.Add(item.Friend); | 769 | candidateFriendIDsToReceive.Add(item.Friend); |
769 | } | 770 | } |
770 | } | 771 | } |
771 | 772 | ||
@@ -780,19 +781,21 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
780 | { | 781 | { |
781 | // build a list of friends to look up region-information and on-/offline-state for | 782 | // build a list of friends to look up region-information and on-/offline-state for |
782 | List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo); | 783 | List<UUID> friendIDsToLookup = new List<UUID>(friendIDsToSendTo); |
783 | foreach (UUID uuid in friendIDsToReceiveFromOffline) | 784 | foreach (UUID uuid in candidateFriendIDsToReceive) |
784 | { | 785 | { |
785 | if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid); | 786 | if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid); |
786 | } | 787 | } |
787 | 788 | ||
788 | m_log.DebugFormat("[FRIEND]: {0} to lookup, {1} to send to, {2} to receive from for agent {3}", | 789 | m_log.DebugFormat( |
789 | friendIDsToLookup.Count, friendIDsToSendTo.Count, friendIDsToReceiveFromOffline.Count, client.Name); | 790 | "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}", |
791 | friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name); | ||
790 | 792 | ||
791 | // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't | 793 | // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't |
792 | // necessarily contain the correct online state... | 794 | // necessarily contain the correct online state... |
793 | Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup); | 795 | Dictionary<UUID, FriendRegionInfo> friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup); |
794 | m_log.DebugFormat("[FRIEND]: Found {0} regionInfos for {1} friends of {2}", | 796 | m_log.DebugFormat( |
795 | friendRegions.Count, friendIDsToLookup.Count, client.Name); | 797 | "[FRIEND]: Found {0} regionInfos for {1} friends of {2}", |
798 | friendRegions.Count, friendIDsToLookup.Count, client.Name); | ||
796 | 799 | ||
797 | // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. | 800 | // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. |
798 | UUID[] agentArr = new UUID[] { client.AgentId }; | 801 | UUID[] agentArr = new UUID[] { client.AgentId }; |
@@ -800,26 +803,26 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
800 | // first, send to friend presence state to me, if I'm online... | 803 | // first, send to friend presence state to me, if I'm online... |
801 | if (iAmOnline) | 804 | if (iAmOnline) |
802 | { | 805 | { |
803 | for (int i = friendIDsToReceiveFromOffline.Count - 1; i >= 0; --i) | 806 | List<UUID> friendIDsToReceive = new List<UUID>(); |
807 | |||
808 | for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i) | ||
804 | { | 809 | { |
805 | UUID uuid = friendIDsToReceiveFromOffline[i]; | 810 | UUID uuid = candidateFriendIDsToReceive[i]; |
806 | FriendRegionInfo info; | 811 | FriendRegionInfo info; |
807 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) | 812 | if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) |
808 | { | 813 | { |
809 | friendIDsToReceiveFromOffline.RemoveAt(i); | 814 | friendIDsToReceive.Add(uuid); |
810 | friendIDsToReceiveFromOnline.Add(uuid); | ||
811 | } | 815 | } |
812 | } | 816 | } |
813 | 817 | ||
814 | m_log.DebugFormat("[FRIEND]: Sending {0} offline and {1} online friends to {2}", | 818 | m_log.DebugFormat( |
815 | friendIDsToReceiveFromOffline.Count, friendIDsToReceiveFromOnline.Count, client.Name); | 819 | "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name); |
816 | 820 | ||
817 | if (friendIDsToReceiveFromOffline.Count > 0) client.SendAgentOffline(friendIDsToReceiveFromOffline.ToArray()); | 821 | if (friendIDsToReceive.Count > 0) |
818 | if (friendIDsToReceiveFromOnline.Count > 0) client.SendAgentOnline(friendIDsToReceiveFromOnline.ToArray()); | 822 | client.SendAgentOnline(friendIDsToReceive.ToArray()); |
819 | 823 | ||
820 | // clear them for a possible second iteration; we don't have to repeat this | 824 | // clear them for a possible second iteration; we don't have to repeat this |
821 | friendIDsToReceiveFromOffline.Clear(); | 825 | candidateFriendIDsToReceive.Clear(); |
822 | friendIDsToReceiveFromOnline.Clear(); | ||
823 | } | 826 | } |
824 | 827 | ||
825 | // now, send my presence state to my friends | 828 | // now, send my presence state to my friends |