From 870bbcfc6c264c515ac660837d16ccad4e59ac64 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 13 Dec 2010 09:42:27 -0800 Subject: [PATCH 1/7] This may have been the biggest, baddest bug in OpenSim ever... confusion between bytes per second and bytes per millisecond. --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index bdbd2848c6..4d9ca0959b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -119,6 +119,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Properties + // To help debugging + private static int idCount = 0; + private int id; + /// /// Default constructor /// @@ -134,6 +138,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP MaxBurst = maxBurst; DripRate = dripRate; lastDrip = Environment.TickCount & Int32.MaxValue; + id = idCount++; } /// @@ -191,6 +196,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (tokensPerMS == 0) { content = maxBurst; + //Console.WriteLine("XXX (" + id + ") content = maxBurst and maxBurst = " + maxBurst); return true; } else @@ -205,11 +211,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } - int dripAmount = deltaMS * tokensPerMS; - + // dripAmpount here is in bytes per millisecond + int dripAmount = deltaMS * tokensPerMS; + // but content is in bytes per second, so let's multiply by 1000 + dripAmount = dripAmount * 1000; content = Math.Min(content + dripAmount, maxBurst); lastDrip = now; + //Console.WriteLine("XXX (" + id + ") deltaMS=" + deltaMS + "; tokensPerMS=" + tokensPerMS + "; content=" + content + "; dripAmount=" + dripAmount); return true; } } From 6b8d01d8c4b4c4f05e0bc51724984dab22e4ee51 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 13 Dec 2010 11:45:17 -0800 Subject: [PATCH 2/7] It turns out that the 1/2 sec burst for prims download is not a bug, but a feature of the client. The client sets the throttles in such a way that makes the server behave like that. The same happens in the Linden Grid. Revert "This may have been the biggest, baddest bug in OpenSim ever... confusion between bytes per second and bytes per millisecond." This reverts commit 870bbcfc6c264c515ac660837d16ccad4e59ac64. --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 4d9ca0959b..bdbd2848c6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -119,10 +119,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Properties - // To help debugging - private static int idCount = 0; - private int id; - /// /// Default constructor /// @@ -138,7 +134,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP MaxBurst = maxBurst; DripRate = dripRate; lastDrip = Environment.TickCount & Int32.MaxValue; - id = idCount++; } /// @@ -196,7 +191,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (tokensPerMS == 0) { content = maxBurst; - //Console.WriteLine("XXX (" + id + ") content = maxBurst and maxBurst = " + maxBurst); return true; } else @@ -211,14 +205,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP return false; } - // dripAmpount here is in bytes per millisecond - int dripAmount = deltaMS * tokensPerMS; - // but content is in bytes per second, so let's multiply by 1000 - dripAmount = dripAmount * 1000; + int dripAmount = deltaMS * tokensPerMS; + content = Math.Min(content + dripAmount, maxBurst); lastDrip = now; - //Console.WriteLine("XXX (" + id + ") deltaMS=" + deltaMS + "; tokensPerMS=" + tokensPerMS + "; content=" + content + "; dripAmount=" + dripAmount); return true; } } From 9a24c0b41c786f49766c212c656f8162e4c263ef Mon Sep 17 00:00:00 2001 From: Marck Date: Mon, 13 Dec 2010 21:19:33 +0100 Subject: [PATCH 3/7] Show map tile for hyperlinks. Perform Check4096 before adding a hyperlink. Configuration option AssetService in section [GridService] must be set to enable this functionality. Map tiles do currently not show for hyperlinks set in simulators that are connected to grids, see Mantis #5270. --- .../Hypergrid/GatekeeperServiceConnector.cs | 29 +++---- .../Services/GridService/HypergridLinker.cs | 76 ++++++++++--------- .../HypergridService/GatekeeperService.cs | 29 ++++--- bin/Robust.HG.ini.example | 6 ++ bin/config-include/GridCommon.ini.example | 3 + bin/config-include/GridHypergrid.ini | 9 ++- .../StandaloneCommon.ini.example | 3 + bin/config-include/StandaloneHypergrid.ini | 11 ++- 8 files changed, 95 insertions(+), 71 deletions(-) diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 85c13804a6..d4fd1b8950 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Net; using System.Reflection; using OpenSim.Framework; @@ -48,7 +49,7 @@ namespace OpenSim.Services.Connectors.Hypergrid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -// private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); + private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); private IAssetService m_AssetService; @@ -143,24 +144,25 @@ namespace OpenSim.Services.Connectors.Hypergrid return true; } - UUID m_MissingTexture = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); - - public UUID GetMapImage(UUID regionID, string imageURL) + public UUID GetMapImage(UUID regionID, string imageURL, string storagePath) { if (m_AssetService == null) - return m_MissingTexture; + return m_HGMapImage; + UUID mapTile = m_HGMapImage; + string filename = string.Empty; + Bitmap bitmap = null; try { - WebClient c = new WebClient(); //m_log.Debug("JPEG: " + imageURL); - string filename = regionID.ToString(); - c.DownloadFile(imageURL, filename + ".jpg"); - Bitmap m = new Bitmap(filename + ".jpg"); + string name = regionID.ToString(); + filename = Path.Combine(storagePath, name + ".jpg"); + c.DownloadFile(imageURL, filename); + bitmap = new Bitmap(filename); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); - byte[] imageData = OpenJPEG.EncodeFromImage(m, true); - AssetBase ass = new AssetBase(UUID.Random(), "region " + filename, (sbyte)AssetType.Texture, regionID.ToString()); + byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); + AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); // !!! for now //info.RegionSettings.TerrainImageID = ass.FullID; @@ -172,14 +174,13 @@ namespace OpenSim.Services.Connectors.Hypergrid m_AssetService.Store(ass); // finally - return ass.FullID; - + mapTile = ass.FullID; } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); } - return UUID.Zero; + return mapTile; } public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 9863ba0e6b..643d0fc114 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net; using System.Reflection; @@ -52,8 +53,6 @@ namespace OpenSim.Services.GridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private static UUID m_HGMapImage = new UUID("00000000-0000-1111-9999-000000000013"); - private static uint m_autoMappingX = 0; private static uint m_autoMappingY = 0; private static bool m_enableAutoMapping = false; @@ -65,6 +64,7 @@ namespace OpenSim.Services.GridService protected UUID m_ScopeID = UUID.Zero; protected bool m_Check4096 = true; + protected string m_MapTileDirectory = string.Empty; // Hyperlink regions are hyperlinks on the map public readonly Dictionary m_HyperlinkRegions = new Dictionary(); @@ -121,9 +121,24 @@ namespace OpenSim.Services.GridService m_Check4096 = gridConfig.GetBoolean("Check4096", true); + m_MapTileDirectory = gridConfig.GetString("MapTileDirectory", string.Empty); + m_GatekeeperConnector = new GatekeeperServiceConnector(m_AssetService); - m_log.DebugFormat("[HYPERGRID LINKER]: Loaded all services..."); + m_log.Debug("[HYPERGRID LINKER]: Loaded all services..."); + } + + if (!string.IsNullOrEmpty(m_MapTileDirectory)) + { + try + { + Directory.CreateDirectory(m_MapTileDirectory); + } + catch (Exception e) + { + m_log.WarnFormat("[HYPERGRID LINKER]: Could not create map tile storage directory {0}: {1}", m_MapTileDirectory, e); + m_MapTileDirectory = string.Empty; + } } if (MainConsole.Instance != null) @@ -271,42 +286,22 @@ namespace OpenSim.Services.GridService if (!m_GatekeeperConnector.LinkRegion(regInfo, out regionID, out handle, out externalName, out imageURL, out reason)) return false; - if (regionID != UUID.Zero) - { - region = m_GridService.GetRegionByUUID(scopeID, regionID); - if (region != null) - { - m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", - region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); - regInfo = region; - return true; - } - - regInfo.RegionID = regionID; - - if ( externalName == string.Empty ) - regInfo.RegionName = regInfo.ServerURI; - else - regInfo.RegionName = externalName; - - m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName); - - // Try get the map image - //regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL); - // I need a texture that works for this... the one I tried doesn't seem to be working - regInfo.TerrainImage = m_HGMapImage; - - AddHyperlinkRegion(regInfo, handle); - m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); - - } - else + if (regionID == UUID.Zero) { m_log.Warn("[HYPERGRID LINKER]: Unable to link region"); reason = "Remote region could not be found"; return false; } + region = m_GridService.GetRegionByUUID(scopeID, regionID); + if (region != null) + { + m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", + region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); + regInfo = region; + return true; + } + uint x, y; if (m_Check4096 && !Check4096(handle, out x, out y)) { @@ -316,7 +311,20 @@ namespace OpenSim.Services.GridService return false; } - m_log.Debug("[HYPERGRID LINKER]: link region succeeded"); + regInfo.RegionID = regionID; + + if ( externalName == string.Empty ) + regInfo.RegionName = regInfo.ServerURI; + else + regInfo.RegionName = externalName; + + m_log.Debug("[HYPERGRID LINKER]: naming linked region " + regInfo.RegionName); + + // Get the map image + regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory); + + AddHyperlinkRegion(regInfo, handle); + m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); return true; } diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 05be7b8307..4419201a50 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -123,42 +123,39 @@ namespace OpenSim.Services.HypergridService externalName = m_ExternalName + ((regionName != string.Empty) ? " " + regionName : ""); imageURL = string.Empty; reason = string.Empty; - + GridRegion region = null; m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName); if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty) { List defs = m_GridService.GetDefaultRegions(m_ScopeID); if (defs != null && defs.Count > 0) - m_DefaultGatewayRegion = defs[0]; - - try { - regionID = m_DefaultGatewayRegion.RegionID; - regionHandle = m_DefaultGatewayRegion.RegionHandle; + region = defs[0]; + m_DefaultGatewayRegion = region; } - catch + else { reason = "Grid setup problem. Try specifying a particular region here."; m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to send information. Please specify a default region for this grid!"); return false; } - - return true; } - - GridRegion region = m_GridService.GetRegionByName(m_ScopeID, regionName); - if (region == null) + else { - reason = "Region not found"; - return false; + region = m_GridService.GetRegionByName(m_ScopeID, regionName); + if (region == null) + { + reason = "Region not found"; + return false; + } } regionID = region.RegionID; regionHandle = region.RegionHandle; - string regionimage = "regionImage" + region.RegionID.ToString(); - regionimage = regionimage.Replace("-", ""); + string regionimage = "regionImage" + regionID.ToString(); + regionimage = regionimage.Replace("-", ""); imageURL = region.ServerURI + "index.php?method=" + regionimage; return true; diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index c690e06f82..9adf1ac5ff 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -68,6 +68,12 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 ;; Perform distance check for the creation of a linked region ; Check4096 = "True" + ;; Needed to display non-default map tile images for linked regions + AssetService = "OpenSim.Services.AssetService.dll:AssetService" + + ;; Directory for map tile images of linked regions + ; MapTileDirectory = "./" + ;; Next, we can specify properties of regions, including default and fallback regions ;; The syntax is: Region_ = "" ;; or: Region_ = "" diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 1122cbd186..761e5eb1dd 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -42,6 +42,9 @@ GridServerURI = "http://mygridserver.com:8003" ;AllowHypergridMapSearch = true + ;; Directory for map tile images of linked regions + ; MapTileDirectory = "./" + [AvatarService] ; ; change this to your grid-wide grid server diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index 409b2a9760..e983755787 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -44,12 +44,15 @@ LocalGridInventoryService = "OpenSim.Region.CoreModules.dll:RemoteXInventoryServicesConnector" [GridService] - ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, - ; which in turn uses this + ; RemoteGridServicesConnector instantiates a LocalGridServicesConnector, + ; which in turn uses this LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" StorageProvider = "OpenSim.Data.Null.dll:NullRegionData" - AllowHypergridMapSearch = true + ; Needed to display non-default map tile images for linked regions + AssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" + + AllowHypergridMapSearch = true [LibraryService] LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService" diff --git a/bin/config-include/StandaloneCommon.ini.example b/bin/config-include/StandaloneCommon.ini.example index 58059f52a1..4956bc34fa 100644 --- a/bin/config-include/StandaloneCommon.ini.example +++ b/bin/config-include/StandaloneCommon.ini.example @@ -65,6 +65,9 @@ ;; With hypergrid, perform distance check for the creation of a linked region ; Check4096 = true + ;; Directory for map tile images of remote regions + ; MapTileDirectory = "./" + ;; Next, we can specify properties of regions, including default and fallback regions ;; The syntax is: Region_ = "" ;; where can be DefaultRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 68aa7397fc..486f22e698 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -65,12 +65,15 @@ LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" [GridService] - ; LocalGridServicesConnector needs this - LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" - Realm = "regions" + ; LocalGridServicesConnector needs this + LocalServiceModule = "OpenSim.Services.GridService.dll:GridService" + Realm = "regions" StorageProvider = "OpenSim.Data.Null.dll" - AllowHypergridMapSearch = true + ; Needed to display non-default map tile images for remote regions + AssetService = "OpenSim.Services.AssetService.dll:AssetService" + + AllowHypergridMapSearch = true [PresenceService] LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" From a4588befb7b75d0b48664a3ff1998464aac5eed5 Mon Sep 17 00:00:00 2001 From: Marck Date: Mon, 13 Dec 2010 22:00:34 +0100 Subject: [PATCH 4/7] Changed logging level for message about failure to retrieve a map image from a linked region. --- .../Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index d4fd1b8950..1ac8478220 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -178,7 +178,7 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { - m_log.Warn("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); + m_log.Info("[GATEKEEPER SERVICE CONNECTOR]: Failed getting/storing map image, because it is probably already in the cache"); } return mapTile; } From d6803e6448535aac738d7193760d9d28b7146bd5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 13 Dec 2010 20:28:14 +0000 Subject: [PATCH 5/7] Change some lookups in he Land Management module to make group permissions work better. Add a generic group permissions hoot to the scene permissions system. --- .../Framework/Scenes/Scene.Permissions.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d67638ad1f..ab0eed8449 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -68,6 +68,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool IsGodHandler(UUID user, Scene requestFromScene); public delegate bool IsAdministratorHandler(UUID user); public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); + public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); @@ -131,6 +132,7 @@ namespace OpenSim.Region.Framework.Scenes public event IsGodHandler OnIsGod; public event IsAdministratorHandler OnIsAdministrator; public event EditParcelHandler OnEditParcel; + public event EditParcelPropertiesHandler OnEditParcelProperties; public event SellParcelHandler OnSellParcel; public event AbandonParcelHandler OnAbandonParcel; public event ReclaimParcelHandler OnReclaimParcel; @@ -734,6 +736,21 @@ namespace OpenSim.Region.Framework.Scenes } return true; } + + public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p) + { + EditParcelPropertiesHandler handler = OnEditParcelProperties; + if (handler != null) + { + Delegate[] list = handler.GetInvocationList(); + foreach (EditParcelPropertiesHandler h in list) + { + if (h(user, parcel, p, m_scene) == false) + return false; + } + } + return true; + } #endregion #region SELL PARCEL @@ -1043,4 +1060,4 @@ namespace OpenSim.Region.Framework.Scenes return true; } } -} \ No newline at end of file +} From 9bd7f3b03a315d713d53451a36fd64c419ce5f35 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 13 Dec 2010 20:35:56 +0000 Subject: [PATCH 6/7] Revamp the viewer -> banlist packet processing so fix a number of bugs. Remove the too coarse CanEditParcel method in favor of a CanEditParcelProperties method that takes a GroupPowers argument to specify what action is to be taken. Also, make the method to set parcel data much more granular. Permissions in a deeded setting should now work. --- OpenSim/Framework/IClientAPI.cs | 7 +- .../ClientStack/LindenUDP/LLClientView.cs | 10 +- .../World/Land/LandManagementModule.cs | 34 ++- .../CoreModules/World/Land/LandObject.cs | 204 +++++++++++++----- .../World/Permissions/PermissionsModule.cs | 56 +---- .../Framework/Interfaces/ILandObject.cs | 2 +- .../Framework/Scenes/Scene.Permissions.cs | 14 -- .../RegionCombinerModule.cs | 2 +- .../RegionCombinerPermissionModule.cs | 4 +- .../Shared/Api/Implementation/LSL_Api.cs | 88 +++++--- .../Shared/Api/Implementation/OSSL_Api.cs | 2 +- 11 files changed, 243 insertions(+), 180 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 027f9c54b1..b9c932339e 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -174,9 +174,10 @@ namespace OpenSim.Framework public delegate void ParcelAccessListRequest( UUID agentID, UUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client); - public delegate void ParcelAccessListUpdateRequest( - UUID agentID, UUID sessionID, uint flags, int landLocalID, List entries, - IClientAPI remote_client); + public delegate void ParcelAccessListUpdateRequest(UUID agentID, uint flags, + int landLocalID, UUID transactionID, int sequenceID, + int sections, List entries, + IClientAPI remote_client); public delegate void ParcelPropertiesRequest( int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f125822604..c934b9ef76 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -8239,7 +8239,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = block.ID; entry.Flags = (AccessList)block.Flags; - entry.Time = new DateTime(); + entry.Time = Util.ToDateTime(block.Time); entries.Add(entry); } @@ -8247,8 +8247,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (handlerParcelAccessListUpdateRequest != null) { handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, - updatePacket.AgentData.SessionID, updatePacket.Data.Flags, - updatePacket.Data.LocalID, entries, this); + updatePacket.Data.Flags, + updatePacket.Data.LocalID, + updatePacket.Data.TransactionID, + updatePacket.Data.SequenceID, + updatePacket.Data.Sections, + entries, this); } return true; } diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 695202f741..ac4705c222 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Land client.OnParcelSelectObjects += ClientOnParcelSelectObjects; client.OnParcelObjectOwnerRequest += ClientOnParcelObjectOwnerRequest; client.OnParcelAccessListRequest += ClientOnParcelAccessListRequest; - client.OnParcelAccessListUpdateRequest += ClientOnParcelAccessUpdateListRequest; + client.OnParcelAccessListUpdateRequest += ClientOnParcelAccessListUpdateRequest; client.OnParcelAbandonRequest += ClientOnParcelAbandonRequest; client.OnParcelGodForceOwner += ClientOnParcelGodForceOwner; client.OnParcelReclaim += ClientOnParcelReclaim; @@ -508,14 +508,22 @@ namespace OpenSim.Region.CoreModules.World.Land if (land != null) { - m_landList[landLocalID].SendAccessList(agentID, sessionID, flags, sequenceID, remote_client); + land.SendAccessList(agentID, sessionID, flags, sequenceID, remote_client); } } - public void ClientOnParcelAccessUpdateListRequest(UUID agentID, UUID sessionID, uint flags, int landLocalID, - List entries, - IClientAPI remote_client) + public void ClientOnParcelAccessListUpdateRequest(UUID agentID, + uint flags, int landLocalID, UUID transactionID, int sequenceID, + int sections, List entries, + IClientAPI remote_client) { + // Flags is the list to update, it can mean either the ban or + // the access list (WTH is a pass list? Mentioned in ParcelFlags) + // + // There may be multiple packets, because these can get LONG. + // Use transactionID to determine a new chain of packets since + // packets may have come in out of sequence and that would be + // a big mess if using the sequenceID ILandObject land; lock (m_landList) { @@ -524,9 +532,15 @@ namespace OpenSim.Region.CoreModules.World.Land if (land != null) { - if (agentID == land.LandData.OwnerID) + GroupPowers requiredPowers = GroupPowers.LandManageAllowed; + if (flags == (uint)AccessList.Ban) + requiredPowers = GroupPowers.LandManageBanned; + + if (m_scene.Permissions.CanEditParcelProperties(agentID, + land, requiredPowers)) { - land.UpdateAccessList(flags, entries, remote_client); + land.UpdateAccessList(flags, transactionID, sequenceID, + sections, entries, remote_client); } } else @@ -854,7 +868,7 @@ namespace OpenSim.Region.CoreModules.World.Land //If we are still here, then they are subdividing within one piece of land //Check owner - if (!m_scene.Permissions.CanEditParcel(attempting_user_id, startLandObject)) + if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, startLandObject, GroupPowers.LandDivideJoin)) { return; } @@ -922,7 +936,7 @@ namespace OpenSim.Region.CoreModules.World.Land { return; } - if (!m_scene.Permissions.CanEditParcel(attempting_user_id, masterLandObject)) + if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, masterLandObject, GroupPowers.LandDivideJoin)) { return; } @@ -1570,7 +1584,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (land == null) return; - if (!m_scene.Permissions.CanEditParcel(remoteClient.AgentId, land)) + if (!m_scene.Permissions.CanEditParcelProperties(remoteClient.AgentId, land, GroupPowers.LandOptions)) return; land.LandData.OtherCleanTime = otherCleanTime; diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index d87352f849..801d3a4ece 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -54,6 +54,7 @@ namespace OpenSim.Region.CoreModules.World.Land protected LandData m_landData = new LandData(); protected Scene m_scene; protected List primsOverMe = new List(); + protected Dictionary m_listTransactions = new Dictionary(); public bool[,] LandBitmap { @@ -199,36 +200,81 @@ namespace OpenSim.Region.CoreModules.World.Land public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) { - if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) - { - //Needs later group support - bool snap_selection = false; - LandData newData = LandData.Copy(); + //Needs later group support + bool snap_selection = false; + LandData newData = LandData.Copy(); - if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) + uint allowedDelta = 0; + + // These two are always blocked as no client can set them anyway + // ParcelFlags.ForSaleObjects + // ParcelFlags.LindenHome + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) + { + allowedDelta |= (uint)(ParcelFlags.AllowLandmark | + ParcelFlags.AllowTerraform | + ParcelFlags.AllowDamage | + ParcelFlags.CreateObjects | + ParcelFlags.RestrictPushObject | + ParcelFlags.AllowGroupScripts | + ParcelFlags.CreateGroupObjects | + ParcelFlags.AllowAPrimitiveEntry | + ParcelFlags.AllowGroupObjectEntry); + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale)) + { + if (args.AuthBuyerID != newData.AuthBuyerID || + args.SalePrice != newData.SalePrice) { - if (m_scene.Permissions.CanSellParcel(remote_client.AgentId, this)) - { - newData.AuthBuyerID = args.AuthBuyerID; - newData.SalePrice = args.SalePrice; - snap_selection = true; - } + snap_selection = true; } + + newData.AuthBuyerID = args.AuthBuyerID; + newData.SalePrice = args.SalePrice; + + if (!LandData.IsGroupOwned) + { + newData.GroupID = args.GroupID; + + allowedDelta |= (uint)(ParcelFlags.AllowDeedToGroup | + ParcelFlags.ContributeWithDeed | + ParcelFlags.SellParcelObjects); + } + + allowedDelta |= (uint)ParcelFlags.ForSale; + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.FindPlaces)) + { newData.Category = args.Category; + + allowedDelta |= (uint)(ParcelFlags.ShowDirectory | + ParcelFlags.AllowPublish | + ParcelFlags.MaturePublish); + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) + { newData.Description = args.Desc; - newData.GroupID = args.GroupID; + newData.Name = args.Name; + newData.SnapshotID = args.SnapshotID; + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.SetLandingPoint)) + { newData.LandingType = args.LandingType; + newData.UserLocation = args.UserLocation; + newData.UserLookAt = args.UserLookAt; + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.ChangeMedia)) + { newData.MediaAutoScale = args.MediaAutoScale; newData.MediaID = args.MediaID; newData.MediaURL = args.MediaURL; newData.MusicURL = args.MusicURL; - newData.Name = args.Name; - newData.Flags = args.ParcelFlags; - newData.PassHours = args.PassHours; - newData.PassPrice = args.PassPrice; - newData.SnapshotID = args.SnapshotID; - newData.UserLocation = args.UserLocation; - newData.UserLookAt = args.UserLookAt; newData.MediaType = args.MediaType; newData.MediaDescription = args.MediaDescription; newData.MediaWidth = args.MediaWidth; @@ -237,10 +283,40 @@ namespace OpenSim.Region.CoreModules.World.Land newData.ObscureMusic = args.ObscureMusic; newData.ObscureMedia = args.ObscureMedia; - m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - - SendLandUpdateToAvatarsOverMe(snap_selection); + allowedDelta |= (uint)(ParcelFlags.SoundLocal | + ParcelFlags.UrlWebPage | + ParcelFlags.UrlRawHtml | + ParcelFlags.AllowVoiceChat | + ParcelFlags.UseEstateVoiceChan); } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandManagePasses)) + { + newData.PassHours = args.PassHours; + newData.PassPrice = args.PassPrice; + + allowedDelta |= (uint)ParcelFlags.UsePassList; + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageAllowed)) + { + allowedDelta |= (uint)(ParcelFlags.UseAccessGroup | + ParcelFlags.UseAccessList); + } + + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageBanned)) + { + allowedDelta |= (uint)(ParcelFlags.UseBanList | + ParcelFlags.DenyAnonymous | + ParcelFlags.DenyAgeUnverified); + } + + uint preserve = LandData.Flags & ~allowedDelta; + newData.Flags = preserve | (args.ParcelFlags & allowedDelta); + + m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); + + SendLandUpdateToAvatarsOverMe(snap_selection); } public void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) @@ -295,14 +371,14 @@ namespace OpenSim.Region.CoreModules.World.Land if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = avatar; - entry.Flags = AccessList.Ban; - entry.Time = new DateTime(); - //See if they are on the list, but make sure the owner isn't banned - if (LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) + if (LandData.ParcelAccessList.FindIndex( + delegate(ParcelManager.ParcelAccessEntry e) + { + if (e.AgentID == avatar && e.Flags == AccessList.Ban) + return true; + return false; + }) != -1 && LandData.OwnerID != avatar) { - //They are banned, so lets send them a notice about this parcel return true; } } @@ -316,15 +392,14 @@ namespace OpenSim.Region.CoreModules.World.Land if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = avatar; - entry.Flags = AccessList.Access; - entry.Time = new DateTime(); - - //If they are not on the access list and are not the owner - if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) + if (LandData.ParcelAccessList.FindIndex( + delegate(ParcelManager.ParcelAccessEntry e) + { + if (e.AgentID == avatar && e.Flags == AccessList.Access) + return true; + return false; + }) == -1 && LandData.OwnerID != avatar) { - //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel return true; } } @@ -421,39 +496,50 @@ namespace OpenSim.Region.CoreModules.World.Land } } - public void UpdateAccessList(uint flags, List entries, IClientAPI remote_client) + public void UpdateAccessList(uint flags, UUID transactionID, + int sequenceID, int sections, + List entries, + IClientAPI remote_client) { LandData newData = LandData.Copy(); - if (entries.Count == 1 && entries[0].AgentID == UUID.Zero) + if ((!m_listTransactions.ContainsKey(flags)) || + m_listTransactions[flags] != transactionID) { - entries.Clear(); - } + m_listTransactions[flags] = transactionID; - List toRemove = new List(); - foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList) - { - if (entry.Flags == (AccessList)flags) + List toRemove = + new List(); + + foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList) { - toRemove.Add(entry); + if (entry.Flags == (AccessList)flags) + toRemove.Add(entry); + } + + foreach (ParcelManager.ParcelAccessEntry entry in toRemove) + { + newData.ParcelAccessList.Remove(entry); + } + + // Checked here because this will always be the first + // and only packet in a transaction + if (entries.Count == 1 && entries[0].AgentID == UUID.Zero) + { + return; } } - foreach (ParcelManager.ParcelAccessEntry entry in toRemove) - { - newData.ParcelAccessList.Remove(entry); - } foreach (ParcelManager.ParcelAccessEntry entry in entries) { - ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); + ParcelManager.ParcelAccessEntry temp = + new ParcelManager.ParcelAccessEntry(); + temp.AgentID = entry.AgentID; - temp.Time = new DateTime(); //Pointless? Yes. + temp.Time = entry.Time; temp.Flags = (AccessList)flags; - if (!newData.ParcelAccessList.Contains(temp)) - { - newData.ParcelAccessList.Add(temp); - } + newData.ParcelAccessList.Add(temp); } m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); @@ -711,7 +797,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client) { - if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this)) + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) { List resultLocalIDs = new List(); try @@ -761,7 +847,7 @@ namespace OpenSim.Region.CoreModules.World.Land /// public void SendLandObjectOwners(IClientAPI remote_client) { - if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this)) + if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) { Dictionary primCount = new Dictionary(); List groups = new List(); diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index f5f383964e..364dd6cb28 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -37,56 +37,6 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -// Temporary fix of wrong GroupPowers constants in OpenMetaverse library -enum GroupPowers : long - { - None = 0, - LandEjectAndFreeze = 1, - Invite = 2, - ReturnGroupSet = 2, - Eject = 4, - ReturnNonGroup = 4, - ChangeOptions = 8, - LandGardening = 8, - CreateRole = 16, - DeedObject = 16, - ModerateChat = 32, - DeleteRole = 32, - RoleProperties = 64, - ObjectManipulate = 64, - ObjectSetForSale = 128, - AssignMemberLimited = 128, - AssignMember = 256, - Accountable = 256, - RemoveMember = 512, - SendNotices = 1024, - ChangeActions = 1024, - ChangeIdentity = 2048, - ReceiveNotices = 2048, - StartProposal = 4096, - LandDeed = 4096, - VoteOnProposal = 8192, - LandRelease = 8192, - LandSetSale = 16384, - LandDivideJoin = 32768, - ReturnGroupOwned = 65536, - JoinChat = 65536, - FindPlaces = 131072, - LandChangeIdentity = 262144, - SetLandingPoint = 524288, - ChangeMedia = 1048576, - LandEdit = 2097152, - LandOptions = 4194304, - AllowEditLand = 8388608, - AllowFly = 16777216, - AllowRez = 33554432, - AllowLandmark = 67108864, - AllowVoiceChat = 134217728, - AllowSetHome = 268435456, - LandManageAllowed = 536870912, - LandManageBanned = 1073741824 - } - namespace OpenSim.Region.CoreModules.World.Permissions { public class PermissionsModule : IRegionModule @@ -214,7 +164,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED - m_scene.Permissions.OnEditParcel += CanEditParcel; //MAYBE FULLY IMPLEMENTED + m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED m_scene.Permissions.OnInstantMessage += CanInstantMessage; m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; //NOT YET IMPLEMENTED m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED @@ -1005,12 +955,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions return GenericObjectPermission(editorID, objectID, false); } - private bool CanEditParcel(UUID user, ILandObject parcel, Scene scene) + private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; - return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDivideJoin); + return GenericParcelOwnerPermission(user, parcel, (ulong)p); } /// diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs index 084184ffb4..585eb004fa 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.Framework.Interfaces void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); List CreateAccessListArrayByFlag(AccessList flag); void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); - void UpdateAccessList(uint flags, List entries, IClientAPI remote_client); + void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List entries, IClientAPI remote_client); void UpdateLandBitmapByteArray(); void SetLandBitmapFromByteArray(); bool[,] GetLandBitmap(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index ab0eed8449..1295e580eb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -722,20 +722,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region EDIT PARCEL - public bool CanEditParcel(UUID user, ILandObject parcel) - { - EditParcelHandler handler = OnEditParcel; - if (handler != null) - { - Delegate[] list = handler.GetInvocationList(); - foreach (EditParcelHandler h in list) - { - if (h(user, parcel, m_scene) == false) - return false; - } - } - return true; - } public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p) { diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index ff0e743113..4a24c7d223 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -1001,7 +1001,7 @@ namespace OpenSim.Region.RegionCombinerModule VirtualRegion.Permissions.OnDuplicateObject += BigRegion.PermissionModule.CanDuplicateObject; VirtualRegion.Permissions.OnDeleteObject += BigRegion.PermissionModule.CanDeleteObject; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnEditObject += BigRegion.PermissionModule.CanEditObject; //MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnEditParcel += BigRegion.PermissionModule.CanEditParcel; //MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnEditParcelProperties += BigRegion.PermissionModule.CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED VirtualRegion.Permissions.OnInstantMessage += BigRegion.PermissionModule.CanInstantMessage; VirtualRegion.Permissions.OnInventoryTransfer += BigRegion.PermissionModule.CanInventoryTransfer; //NOT YET IMPLEMENTED VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs index 393322d2d1..7c662c9b3a 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs @@ -105,9 +105,9 @@ namespace OpenSim.Region.RegionCombinerModule return m_rootScene.Permissions.CanEditObject(objectid, editorid); } - public bool CanEditParcel(UUID user, ILandObject parcel, Scene scene) + public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers g, Scene scene) { - return m_rootScene.Permissions.CanEditParcel(user, parcel); + return m_rootScene.Permissions.CanEditParcelProperties(user, parcel, g); } public bool CanInstantMessage(UUID user, UUID target, Scene startscene) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3c5f2d03c8..30fb252cbd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6287,16 +6287,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); UUID key; - LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; - if (land.OwnerID == m_host.OwnerID) + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); if (UUID.TryParse(avatar, out key)) { - entry.AgentID = key; - entry.Flags = AccessList.Access; - entry.Time = DateTime.Now.AddHours(hours); - land.ParcelAccessList.Add(entry); + if (land.LandData.ParcelAccessList.FindIndex( + delegate(ParcelManager.ParcelAccessEntry e) + { + if (e.AgentID == key && e.Flags == AccessList.Access) + return true; + return false; + }) == -1) + { + entry.AgentID = key; + entry.Flags = AccessList.Access; + entry.Time = DateTime.Now.AddHours(hours); + land.LandData.ParcelAccessList.Add(entry); + } } } ScriptSleep(100); @@ -9023,7 +9032,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // according to the docs, this command only works if script owner and land owner are the same // lets add estate owners and gods, too, and use the generic permission check. ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); - if (!World.Permissions.CanEditParcel(m_host.OwnerID, landObject)) return; + if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return; bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)? byte loop = 0; @@ -9466,16 +9475,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); UUID key; - LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; - if (land.OwnerID == m_host.OwnerID) + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); if (UUID.TryParse(avatar, out key)) { - entry.AgentID = key; - entry.Flags = AccessList.Ban; - entry.Time = DateTime.Now.AddHours(hours); - land.ParcelAccessList.Add(entry); + if (land.LandData.ParcelAccessList.FindIndex( + delegate(ParcelManager.ParcelAccessEntry e) + { + if (e.AgentID == key && e.Flags == AccessList.Ban) + return true; + return false; + }) == -1) + { + entry.AgentID = key; + entry.Flags = AccessList.Ban; + entry.Time = DateTime.Now.AddHours(hours); + land.LandData.ParcelAccessList.Add(entry); + } } } ScriptSleep(100); @@ -9485,19 +9503,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); UUID key; - LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; - if (land.OwnerID == m_host.OwnerID) + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) { if (UUID.TryParse(avatar, out key)) { - foreach (ParcelManager.ParcelAccessEntry entry in land.ParcelAccessList) - { - if (entry.AgentID == key && entry.Flags == AccessList.Access) - { - land.ParcelAccessList.Remove(entry); - break; - } - } + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(ParcelManager.ParcelAccessEntry e) + { + if (e.AgentID == key && e.Flags == AccessList.Access) + return true; + return false; + }); + + if (idx != -1) + land.LandData.ParcelAccessList.RemoveAt(idx); } } ScriptSleep(100); @@ -9507,19 +9527,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); UUID key; - LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; - if (land.OwnerID == m_host.OwnerID) + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) { if (UUID.TryParse(avatar, out key)) { - foreach (ParcelManager.ParcelAccessEntry entry in land.ParcelAccessList) - { - if (entry.AgentID == key && entry.Flags == AccessList.Ban) - { - land.ParcelAccessList.Remove(entry); - break; - } - } + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(ParcelManager.ParcelAccessEntry e) + { + if (e.AgentID == key && e.Flags == AccessList.Ban) + return true; + return false; + }); + + if (idx != -1) + land.LandData.ParcelAccessList.RemoveAt(idx); } } ScriptSleep(100); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3b13d06384..5a796b8787 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1335,7 +1335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - if (! World.Permissions.CanEditParcel(m_host.OwnerID, startLandObject)) + if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions)) { OSSLShoutError("You do not have permission to modify the parcel"); return; From 2a9f0950710a84412e6276e5cc73c6245f838a36 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 13 Dec 2010 22:26:44 +0100 Subject: [PATCH 7/7] Fix a small bug in ban list handling --- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 801d3a4ece..3e41c55dcd 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -526,6 +526,8 @@ namespace OpenSim.Region.CoreModules.World.Land // and only packet in a transaction if (entries.Count == 1 && entries[0].AgentID == UUID.Zero) { + m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); + return; } }