diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandObject.cs | 70 |
1 files changed, 14 insertions, 56 deletions
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 | |||
56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | 56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); |
57 | protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); | 57 | protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); |
58 | 58 | ||
59 | protected IGroupsModule m_groupsModule; | 59 | protected ExpiringCache<UUID, bool> m_groupMemberCache = new ExpiringCache<UUID, bool>(); |
60 | protected const uint PARCEL_FLAG_USE_ACCESS_GROUP = 0x100; // parcel limits access to a group | 60 | protected TimeSpan m_groupMemberCacheTimeout = TimeSpan.FromSeconds(30); // cache invalidation after 30 seconds |
61 | protected Dictionary<UUID, long> m_isGroupMemberCache = new Dictionary<UUID, long>(); | ||
62 | protected Dictionary<UUID, long> m_notGroupMemberCache = new Dictionary<UUID, long>(); | ||
63 | protected const long m_groupMemberCacheTimeout = 30; // cache invalidation after 30 seconds | ||
64 | 61 | ||
65 | public bool[,] LandBitmap | 62 | public bool[,] LandBitmap |
66 | { | 63 | { |
@@ -138,8 +135,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
138 | else | 135 | else |
139 | LandData.GroupID = UUID.Zero; | 136 | LandData.GroupID = UUID.Zero; |
140 | LandData.IsGroupOwned = is_group_owned; | 137 | LandData.IsGroupOwned = is_group_owned; |
141 | |||
142 | m_groupsModule = scene.RequestModuleInterface<IGroupsModule>(); | ||
143 | } | 138 | } |
144 | 139 | ||
145 | #endregion | 140 | #endregion |
@@ -450,19 +445,30 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
450 | ScenePresence sp; | 445 | ScenePresence sp; |
451 | if (!m_scene.TryGetScenePresence(avatar, out sp)) | 446 | if (!m_scene.TryGetScenePresence(avatar, out sp)) |
452 | { | 447 | { |
448 | bool isMember; | ||
449 | if (m_groupMemberCache.TryGetValue(avatar, out isMember)) | ||
450 | return isMember; | ||
451 | |||
453 | IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | 452 | IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); |
454 | if (groupsModule == null) | 453 | if (groupsModule == null) |
455 | return false; | 454 | return false; |
456 | 455 | ||
457 | GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar); | 456 | GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar); |
458 | if (membership == null || membership.Length == 0) | 457 | if (membership == null || membership.Length == 0) |
458 | { | ||
459 | m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); | ||
459 | return false; | 460 | return false; |
461 | } | ||
460 | 462 | ||
461 | foreach (GroupMembershipData d in membership) | 463 | foreach (GroupMembershipData d in membership) |
462 | { | 464 | { |
463 | if (d.GroupID == LandData.GroupID) | 465 | if (d.GroupID == LandData.GroupID) |
466 | { | ||
467 | m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); | ||
464 | return true; | 468 | return true; |
469 | } | ||
465 | } | 470 | } |
471 | m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout); | ||
466 | return false; | 472 | return false; |
467 | } | 473 | } |
468 | 474 | ||
@@ -520,55 +526,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
520 | if (HasGroupAccess(avatar)) | 526 | if (HasGroupAccess(avatar)) |
521 | return false; | 527 | return false; |
522 | 528 | ||
523 | if (IsInLandAccessList(avatar)) | 529 | return (!IsInLandAccessList(avatar)); |
524 | return false; | ||
525 | |||
526 | UUID groupID = LandData.GroupID; | ||
527 | |||
528 | if ((m_groupsModule != null) && (groupID != UUID.Zero) && ((LandData.Flags & PARCEL_FLAG_USE_ACCESS_GROUP) == PARCEL_FLAG_USE_ACCESS_GROUP)) | ||
529 | { | ||
530 | long now = Util.UnixTimeSinceEpoch(); | ||
531 | |||
532 | if (m_isGroupMemberCache.ContainsKey(avatar)) | ||
533 | { | ||
534 | if (now - m_isGroupMemberCache[avatar] <= m_groupMemberCacheTimeout) // invalid? | ||
535 | { | ||
536 | m_isGroupMemberCache[avatar] = now; | ||
537 | return false; | ||
538 | } | ||
539 | else | ||
540 | m_isGroupMemberCache.Remove(avatar); | ||
541 | } | ||
542 | |||
543 | if (m_notGroupMemberCache.ContainsKey(avatar)) | ||
544 | { | ||
545 | if (now - m_notGroupMemberCache[avatar] <= m_groupMemberCacheTimeout) // invalid? | ||
546 | { | ||
547 | // m_notGroupMemberCache[avatar] = now; | ||
548 | return true; | ||
549 | } | ||
550 | else | ||
551 | m_notGroupMemberCache.Remove(avatar); | ||
552 | } | ||
553 | |||
554 | GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(avatar); | ||
555 | |||
556 | if (GroupMembership != null) | ||
557 | { | ||
558 | for (int i = 0; i < GroupMembership.Length; i++) | ||
559 | { | ||
560 | if (groupID == GroupMembership[i].GroupID) | ||
561 | { | ||
562 | m_isGroupMemberCache[avatar] = now; | ||
563 | return false; | ||
564 | } | ||
565 | } | ||
566 | } | ||
567 | |||
568 | m_notGroupMemberCache[avatar] = now; | ||
569 | } | ||
570 | |||
571 | return true; | ||
572 | } | 530 | } |
573 | 531 | ||
574 | public bool IsInLandAccessList(UUID avatar) | 532 | public bool IsInLandAccessList(UUID avatar) |