From 6fbfb47b92cf01b839208d0cc7898749306e19f4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 19 Jan 2014 11:03:08 -0800 Subject: [PATCH] varregion: add --noterrain and --noparcel to 'load oar'. --noterrain suppresses the loading of the terrain from the oar. --noparcels suppresses the loading of parcel information from the oar. --- .../RemoteController/RemoteAdminPlugin.cs | 6 ++-- OpenSim/Region/Application/OpenSim.cs | 6 ++-- .../World/Archiver/ArchiveReadRequest.cs | 32 +++++++++++++------ .../World/Archiver/ArchiverModule.cs | 29 ++++++++++++----- .../World/Archiver/Tests/ArchiverTests.cs | 17 ++++++---- .../Interfaces/IRegionArchiverModule.cs | 26 +++++---------- 6 files changed, 70 insertions(+), 46 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3cd6b3b51a..7067a627df 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1484,9 +1484,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController } IRegionArchiverModule archiver = scene.RequestModuleInterface(); - Vector3 displacement = new Vector3(0f, 0f, 0f); + Dictionary archiveOptions = new Dictionary(); + if (mergeOar) archiveOptions.Add("merge", null); + if (skipAssets) archiveOptions.Add("skipAssets", null); if (archiver != null) - archiver.DearchiveRegion(filename, mergeOar, skipAssets, displacement, Guid.Empty); + archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions); else throw new Exception("Archiver module not present for scene"); diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index a3361788a1..30e2b1bcd4 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -266,11 +266,13 @@ namespace OpenSim SavePrimsXml2); m_console.Commands.AddCommand("Archiving", false, "load oar", - "load oar [--merge] [--skip-assets] [--displacement \"\"] []", + "load oar [--merge] [--skip-assets] [--noterrain] [--displacement \"\"] []", "Load a region's data from an OAR archive.", "--merge will merge the OAR with the existing scene." + Environment.NewLine + "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine - + "--displacement will add this value to the position of every object loaded" + Environment.NewLine + + "--displacement will add this value to the position of every object loaded" + Environment.NewLine + + "--noterrain suppresses the loading of terrain from the oar" + Environment.NewLine + + "--noparcels suppresses the loading of parcels from the oar" + Environment.NewLine + "The path can be either a filesystem location or a URI." + " If this is not given then the command looks for an OAR named region.oar in the current directory.", LoadOar); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index d249129c17..637c4a3ad0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -99,6 +99,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// protected bool m_merge; + /// + /// If true, suppresses the loading of terrain from the oar file + /// + protected bool m_noTerrain; + + /// + /// If true, suppresses the loading of parcels from the oar file + /// + protected bool m_noParcels; + /// /// Should we ignore any assets when reloading the archive? /// @@ -107,7 +117,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// Displacement added to each object as it is added to the world /// - protected Vector3 m_displacement = new Vector3(0f, 0f, 0f); + protected Vector3 m_displacement = Vector3.Zero; /// /// Used to cache lookups for valid uuids. @@ -137,7 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver private IAssetService m_assetService = null; - public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) + public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionaryoptions) { m_rootScene = scene; @@ -155,10 +165,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver } m_errorMessage = String.Empty; - m_merge = merge; - m_skipAssets = skipAssets; + m_merge = options.ContainsKey("merge"); + m_noTerrain = options.ContainsKey("noTerrain"); + m_noParcels = options.ContainsKey("noParcels"); + m_skipAssets = options.ContainsKey("skipAssets"); m_requestId = requestId; - m_displacement = displacement; + m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero; // Zero can never be a valid user id m_validUserUuids[UUID.Zero] = false; @@ -167,13 +179,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_assetService = m_rootScene.AssetService; } - public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) + public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionaryoptions) { m_rootScene = scene; m_loadPath = null; m_loadStream = loadStream; - m_merge = merge; - m_skipAssets = skipAssets; + m_skipAssets = options.ContainsKey("skipAssets"); + m_merge = options.ContainsKey("merge"); m_requestId = requestId; // Zero can never be a valid user id @@ -249,7 +261,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); } - else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) + else if (!m_noTerrain && !m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) { LoadTerrain(scene, filePath, data); } @@ -257,7 +269,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { LoadRegionSettings(scene, filePath, data, dearchivedScenes); } - else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) + else if (!m_noParcels && !m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) { sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index fb694de022..df5b4436c6 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -104,11 +104,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver { bool mergeOar = false; bool skipAssets = false; + bool noTerrain = false; + bool noParcels = false; Vector3 displacement = new Vector3(0f, 0f, 0f); OptionSet options = new OptionSet(); options.Add("m|merge", delegate (string v) { mergeOar = (v != null); }); options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); }); + options.Add("noterrain", delegate (string v) { noTerrain = (v != null); }); + options.Add("noparcels", delegate (string v) { noParcels = (v != null); }); options.Add("displacement=", delegate (string v) { try { @@ -138,13 +142,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver // foreach (string param in mainParams) // m_log.DebugFormat("GOT PARAM [{0}]", param); + Dictionary archiveOptions = new Dictionary(); + if (mergeOar) archiveOptions.Add("merge", null); + if (skipAssets) archiveOptions.Add("skipAssets", null); + if (noTerrain) archiveOptions.Add("noTerrain", null); + if (noParcels) archiveOptions.Add("noParcels", null); + if (displacement != Vector3.Zero) archiveOptions.Add("displacement", displacement); + if (mainParams.Count > 2) { - DearchiveRegion(mainParams[2], mergeOar, skipAssets, displacement, Guid.Empty); + DearchiveRegion(mainParams[2], Guid.Empty, archiveOptions); } else { - DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, displacement, Guid.Empty); + DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, Guid.Empty, archiveOptions); } } @@ -214,25 +225,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver public void DearchiveRegion(string loadPath) { - DearchiveRegion(loadPath, false, false, new Vector3(0f, 0f, 0f), Guid.Empty); + Dictionary archiveOptions = new Dictionary(); + DearchiveRegion(loadPath, Guid.Empty, archiveOptions); } - public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) + public void DearchiveRegion(string loadPath, Guid requestId, Dictionary options) { m_log.InfoFormat( "[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath); - new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, displacement, requestId).DearchiveRegion(); + new ArchiveReadRequest(Scene, loadPath, requestId, options).DearchiveRegion(); } public void DearchiveRegion(Stream loadStream) { - DearchiveRegion(loadStream, false, false, new Vector3(0f, 0f, 0f), Guid.Empty); + Dictionary archiveOptions = new Dictionary(); + DearchiveRegion(loadStream, Guid.Empty, archiveOptions); } - public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId) + public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary options) { - new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion(); + new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion(); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index c412acb96d..53f41f986e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -224,8 +224,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests byte[] data = tar.ReadEntry(out filePath, out tarEntryType); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); - - ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); + + Dictionary archiveOptions = new Dictionary(); + ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); Assert.That(arr.ControlFileLoaded, Is.True); @@ -308,8 +309,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests byte[] data = tar.ReadEntry(out filePath, out tarEntryType); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); - - ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); + + Dictionary archiveOptions = new Dictionary(); + ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); Assert.That(arr.ControlFileLoaded, Is.True); @@ -752,7 +754,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); - m_archiverModule.DearchiveRegion(archiveReadStream, true, false, new Vector3(0f, 0f, 0f), Guid.Empty); + Dictionary archiveOptions = new Dictionary(); + archiveOptions.Add("merge", null); + m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions); SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); @@ -860,7 +864,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests byte[] data = tar.ReadEntry(out filePath, out tarEntryType); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); - ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty); + Dictionary archiveOptions = new Dictionary(); + ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); Assert.That(arr.ControlFileLoaded, Is.True); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 1c00b6c8b2..99bc87ddb5 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs @@ -102,16 +102,11 @@ namespace OpenSim.Region.Framework.Interfaces /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. /// /// - /// - /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region - /// settings in the archive will be ignored. - /// - /// - /// If true, the archive is loaded without loading any assets contained within it. This is useful if the - /// assets are already known to be present in the grid's asset service. - /// /// If supplied, this request Id is later returned in the saved event - void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId); + /// + /// Dictionary of options. + /// + void DearchiveRegion(string loadPath, Guid requestId, Dictionary options); /// /// Dearchive a region from a stream. This replaces the existing scene. @@ -129,15 +124,10 @@ namespace OpenSim.Region.Framework.Interfaces /// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event. /// /// - /// - /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region - /// settings in the archive will be ignored. - /// - /// - /// If true, the archive is loaded without loading any assets contained within it. This is useful if the - /// assets are already known to be present in the grid's asset service. - /// If supplied, this request Id is later returned in the saved event - void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId); + /// + /// Dictionary of options. + /// + void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary options); } }