From 07c487a28f6ce6d85cf32fba0c2ded724f7b5af7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 21:36:45 +0100 Subject: Make ban, eject, freeze and the scripted versions of those work. --- .../CoreModules/World/Land/LandManagementModule.cs | 6 +- .../Region/CoreModules/World/Land/LandObject.cs | 78 +++++++++++++++------- 2 files changed, 57 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 5db56b0..0f83d82 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -508,7 +508,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void ClientOnParcelAccessListUpdateRequest(UUID agentID, uint flags, int landLocalID, UUID transactionID, int sequenceID, - int sections, List entries, + int sections, List entries, IClientAPI remote_client) { // Flags is the list to update, it can mean either the ban or @@ -1777,10 +1777,10 @@ namespace OpenSim.Region.CoreModules.World.Land if ((flags & 1) != 0) // Ban TODO: Remove magic number { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry entry = new LandAccessEntry(); entry.AgentID = targetAvatar.UUID; entry.Flags = AccessList.Ban; - entry.Time = new DateTime(); + entry.Expires = 0; // Perm land.LandData.ParcelAccessList.Add(entry); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 07b28c7..debf6d2 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -467,21 +467,26 @@ namespace OpenSim.Region.CoreModules.World.Land public bool IsBannedFromLand(UUID avatar) { + ExpireAccessList(); + if (m_scene.Permissions.IsAdministrator(avatar)) return false; if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) return false; + if (avatar == LandData.OwnerID) + return false; + if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) { if (LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + delegate(LandAccessEntry e) { if (e.AgentID == avatar && e.Flags == AccessList.Ban) return true; return false; - }) != -1 && LandData.OwnerID != avatar) + }) != -1) { return true; } @@ -491,21 +496,26 @@ namespace OpenSim.Region.CoreModules.World.Land public bool IsRestrictedFromLand(UUID avatar) { + ExpireAccessList(); + if (m_scene.Permissions.IsAdministrator(avatar)) return false; if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) return false; + if (avatar == LandData.OwnerID) + return false; + if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) { if (LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + delegate(LandAccessEntry e) { if (e.AgentID == avatar && e.Flags == AccessList.Access) return true; return false; - }) == -1 && LandData.OwnerID != avatar) + }) == -1) { if (!HasGroupAccess(avatar)) { @@ -570,19 +580,24 @@ namespace OpenSim.Region.CoreModules.World.Land #region AccessList Functions - public List CreateAccessListArrayByFlag(AccessList flag) + public List CreateAccessListArrayByFlag(AccessList flag) { - List list = new List(); - foreach (ParcelManager.ParcelAccessEntry entry in LandData.ParcelAccessList) + ExpireAccessList(); + + List list = new List(); + foreach (LandAccessEntry entry in LandData.ParcelAccessList) { if (entry.Flags == flag) - { - list.Add(entry.AgentID); - } + list.Add(entry); } if (list.Count == 0) { - list.Add(UUID.Zero); + LandAccessEntry e = new LandAccessEntry(); + e.AgentID = UUID.Zero; + e.Flags = 0; + e.Expires = 0; + + list.Add(e); } return list; @@ -594,20 +609,20 @@ namespace OpenSim.Region.CoreModules.World.Land if (flags == (uint) AccessList.Access || flags == (uint) AccessList.Both) { - List avatars = CreateAccessListArrayByFlag(AccessList.Access); - remote_client.SendLandAccessListData(avatars,(uint) AccessList.Access,LandData.LocalID); + List accessEntries = CreateAccessListArrayByFlag(AccessList.Access); + remote_client.SendLandAccessListData(accessEntries,(uint) AccessList.Access,LandData.LocalID); } if (flags == (uint) AccessList.Ban || flags == (uint) AccessList.Both) { - List avatars = CreateAccessListArrayByFlag(AccessList.Ban); - remote_client.SendLandAccessListData(avatars, (uint)AccessList.Ban, LandData.LocalID); + List accessEntries = CreateAccessListArrayByFlag(AccessList.Ban); + remote_client.SendLandAccessListData(accessEntries, (uint)AccessList.Ban, LandData.LocalID); } } public void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, - List entries, + List entries, IClientAPI remote_client) { LandData newData = LandData.Copy(); @@ -617,16 +632,16 @@ namespace OpenSim.Region.CoreModules.World.Land { m_listTransactions[flags] = transactionID; - List toRemove = - new List(); + List toRemove = + new List(); - foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList) + foreach (LandAccessEntry entry in newData.ParcelAccessList) { if (entry.Flags == (AccessList)flags) toRemove.Add(entry); } - foreach (ParcelManager.ParcelAccessEntry entry in toRemove) + foreach (LandAccessEntry entry in toRemove) { newData.ParcelAccessList.Remove(entry); } @@ -641,13 +656,13 @@ namespace OpenSim.Region.CoreModules.World.Land } } - foreach (ParcelManager.ParcelAccessEntry entry in entries) + foreach (LandAccessEntry entry in entries) { - ParcelManager.ParcelAccessEntry temp = - new ParcelManager.ParcelAccessEntry(); + LandAccessEntry temp = + new LandAccessEntry(); temp.AgentID = entry.AgentID; - temp.Time = entry.Time; + temp.Expires = entry.Expires; temp.Flags = (AccessList)flags; newData.ParcelAccessList.Add(temp); @@ -1164,5 +1179,20 @@ namespace OpenSim.Region.CoreModules.World.Land } #endregion + + private void ExpireAccessList() + { + List delete = new List(); + + foreach (LandAccessEntry entry in LandData.ParcelAccessList) + { + if (entry.Expires != 0 && entry.Expires < Util.UnixTimeSinceEpoch()) + delete.Add(entry); + } + foreach (LandAccessEntry entry in delete) + LandData.ParcelAccessList.Remove(entry); + + m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); + } } } -- cgit v1.1