From 5f5fdc36248788b97c1283f65e2188fa1d60a361 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 22 Jan 2010 16:22:23 +0000 Subject: [PATCH] Allow oar loading to work even if an estate module is not present Write bare bones unit test for region setting loads --- .../World/Archiver/ArchiveReadRequest.cs | 6 +- .../World/Archiver/Tests/ArchiverTests.cs | 70 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 52add238c6..8ed1913c30 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -423,9 +423,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; - + IEstateModule estateModule = m_scene.RequestModuleInterface(); - estateModule.sendRegionHandshakeToAll(); + + if (estateModule != null) + estateModule.sendRegionHandshakeToAll(); return true; } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index edac4a4e8b..4f7a1372ac 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -36,6 +36,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Serialization; +using OpenSim.Framework.Serialization.External; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Scenes; @@ -269,6 +270,75 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); } + /// + /// Test loading the region settings of a V0.2 OpenSim Region Archive. + /// + [Test] + public void TestLoadOarV0_2RegionSettings() + { + TestHelper.InMethod(); + //log4net.Config.XmlConfigurator.Configure(); + + SerialiserModule serialiserModule = new SerialiserModule(); + ArchiverModule archiverModule = new ArchiverModule(); + Scene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + + MemoryStream archiveWriteStream = new MemoryStream(); + TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); + + tar.WriteDir(ArchiveConstants.TERRAINS_PATH); + tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); + + RegionSettings rs = new RegionSettings(); + rs.AgentLimit = 17; + rs.AllowDamage = true; + rs.AllowLandJoinDivide = true; + rs.AllowLandResell = true; + rs.BlockFly = true; + rs.BlockShowInSearch = true; + rs.BlockTerraform = true; + rs.DisableCollisions = true; + rs.DisablePhysics = true; + rs.DisableScripts = true; + rs.Elevation1NW = 15.9; + rs.Elevation1NE = 45.3; + rs.Elevation1SE = 49; + rs.Elevation1SW = 1.9; + rs.Elevation2NW = 4.5; + rs.Elevation2NE = 19.2; + rs.Elevation2SE = 9.2; + rs.Elevation2SW = 2.1; + rs.FixedSun = true; + rs.ObjectBonus = 1.4; + rs.RestrictPushing = true; + rs.TerrainLowerLimit = 0.4; + rs.TerrainRaiseLimit = 17.9; + rs.TerrainTexture1 = UUID.Parse("00000000-0000-0000-0000-000000000020"); + rs.TerrainTexture2 = UUID.Parse("00000000-0000-0000-0000-000000000040"); + rs.TerrainTexture3 = UUID.Parse("00000000-0000-0000-0000-000000000060"); + rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); + rs.UseEstateSun = true; + rs.WaterHeight = 23; + + tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs)); + + tar.Close(); + + MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + + lock (this) + { + scene.EventManager.OnOarFileLoaded += LoadCompleted; + archiverModule.DearchiveRegion(archiveReadStream); + } + + Assert.That(m_lastErrorMessage, Is.Null); + RegionSettings loadedRs = scene.RegionInfo.RegionSettings; + + Assert.That(loadedRs.AgentLimit, Is.EqualTo(17)); + } + /// /// Test merging a V0.2 OpenSim Region Archive into an existing scene ///