From c7419a4d6165352c7faf15f027e34cdca9ba5ad2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Apr 2012 00:36:30 +0100 Subject: Adjust Snoopy's contribution for AVN --- .../Region/CoreModules/World/Land/LandObject.cs | 70 +++++----------------- 1 file changed, 14 insertions(+), 56 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index c21cf31..3b677e3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -56,11 +56,8 @@ namespace OpenSim.Region.CoreModules.World.Land protected List primsOverMe = new List(); protected Dictionary m_listTransactions = new Dictionary(); - protected IGroupsModule m_groupsModule; - protected const uint PARCEL_FLAG_USE_ACCESS_GROUP = 0x100; // parcel limits access to a group - protected Dictionary m_isGroupMemberCache = new Dictionary(); - protected Dictionary m_notGroupMemberCache = new Dictionary(); - protected const long m_groupMemberCacheTimeout = 30; // cache invalidation after 30 seconds + protected ExpiringCache m_groupMemberCache = new ExpiringCache(); + protected TimeSpan m_groupMemberCacheTimeout = TimeSpan.FromSeconds(30); // cache invalidation after 30 seconds public bool[,] LandBitmap { @@ -138,8 +135,6 @@ namespace OpenSim.Region.CoreModules.World.Land else LandData.GroupID = UUID.Zero; LandData.IsGroupOwned = is_group_owned; - - m_groupsModule = scene.RequestModuleInterface(); } #endregion @@ -450,19 +445,30 @@ namespace OpenSim.Region.CoreModules.World.Land ScenePresence sp; if (!m_scene.TryGetScenePresence(avatar, out sp)) { + bool isMember; + if (m_groupMemberCache.TryGetValue(avatar, out isMember)) + return isMember; + IGroupsModule groupsModule = m_scene.RequestModuleInterface(); if (groupsModule == null) return false; GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar); if (membership == null || membership.Length == 0) + { + m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); return false; + } foreach (GroupMembershipData d in membership) { if (d.GroupID == LandData.GroupID) + { + m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); return true; + } } + m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); return false; } @@ -520,55 +526,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (HasGroupAccess(avatar)) return false; - if (IsInLandAccessList(avatar)) - return false; - - UUID groupID = LandData.GroupID; - - if ((m_groupsModule != null) && (groupID != UUID.Zero) && ((LandData.Flags & PARCEL_FLAG_USE_ACCESS_GROUP) == PARCEL_FLAG_USE_ACCESS_GROUP)) - { - long now = Util.UnixTimeSinceEpoch(); - - if (m_isGroupMemberCache.ContainsKey(avatar)) - { - if (now - m_isGroupMemberCache[avatar] <= m_groupMemberCacheTimeout) // invalid? - { - m_isGroupMemberCache[avatar] = now; - return false; - } - else - m_isGroupMemberCache.Remove(avatar); - } - - if (m_notGroupMemberCache.ContainsKey(avatar)) - { - if (now - m_notGroupMemberCache[avatar] <= m_groupMemberCacheTimeout) // invalid? - { - // m_notGroupMemberCache[avatar] = now; - return true; - } - else - m_notGroupMemberCache.Remove(avatar); - } - - GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(avatar); - - if (GroupMembership != null) - { - for (int i = 0; i < GroupMembership.Length; i++) - { - if (groupID == GroupMembership[i].GroupID) - { - m_isGroupMemberCache[avatar] = now; - return false; - } - } - } - - m_notGroupMemberCache[avatar] = now; - } - - return true; + return (!IsInLandAccessList(avatar)); } public bool IsInLandAccessList(UUID avatar) -- cgit v1.1