public void TestLoadOarUnorderedParts() { TestHelpers.InMethod(); UUID ownerId = TestHelpers.ParseTail(0xaaaa); MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11); SceneObjectPart sop2 = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId); SceneObjectPart sop3 = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId); // Add the parts so they will be written out in reverse order to the oar sog1.AddPart(sop3); sop3.LinkNum = 3; sog1.AddPart(sop2); sop2.LinkNum = 2; tar.WriteFile( ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition), SceneObjectSerializer.ToXml2Format(sog1)); tar.Close(); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(archiveReadStream); } Assert.That(m_lastErrorMessage, Is.Null); SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2"); Assert.That(part2.LinkNum, Is.EqualTo(2)); SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3"); Assert.That(part3.LinkNum, Is.EqualTo(3)); }
public void TestLoadMultiRegionOar() { TestHelpers.InMethod(); // Create an ArchiveScenesGroup with the regions in the OAR. This is needed to generate the control file. int WIDTH = 2; int HEIGHT = 2; for (uint y = 0; y < HEIGHT; y++) { for (uint x = 0; x < WIDTH; x++) { Scene scene; if (x == 0 && y == 0) { scene = m_scene; // this scene was already created in SetUp() } else { scene = m_sceneHelpers.SetupScene(string.Format("Unit test region {0}", (y * WIDTH) + x + 1), UUID.Random(), 1000 + x, 1000 + y); SceneHelpers.SetupSceneModules(scene, new ArchiverModule(), m_serialiserModule, new TerrainModule()); } } } ArchiveScenesGroup scenesGroup = new ArchiveScenesGroup(); m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene) { scenesGroup.AddScene(scene); }); scenesGroup.CalcSceneLocations(); // Generate the OAR file MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); ArchiveWriteRequest writeRequest = new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty); writeRequest.MultiRegionFormat = true; tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, writeRequest.CreateControlFile(scenesGroup)); SceneObjectPart part1 = CreateSceneObjectPart1(); part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f); part1.SitTargetPosition = new Vector3(1, 2, 3); SceneObjectGroup object1 = new SceneObjectGroup(part1); // Let's put some inventory items into our object string soundItemName = "sound-item1"; UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); Type type = GetType(); Assembly assembly = type.Assembly; string soundDataResourceName = null; string[] names = assembly.GetManifestResourceNames(); foreach (string name in names) { if (name.EndsWith(".Resources.test-sound.wav")) { soundDataResourceName = name; } } Assert.That(soundDataResourceName, Is.Not.Null); byte[] soundData; UUID soundUuid; CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid); TaskInventoryItem item1 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; part1.Inventory.AddInventoryItem(item1, true); m_scene.AddNewSceneObject(object1, false); string object1FileName = string.Format( "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", part1.Name, Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), part1.UUID); string path = "regions/1_1_Unit_test_region/" + ArchiveConstants.OBJECTS_PATH + object1FileName; tar.WriteFile(path, SceneObjectSerializer.ToXml2Format(object1)); tar.Close(); // Delete the current objects, to test that they're loaded from the OAR and didn't // just remain in the scene. m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene) { scene.DeleteAllSceneObjects(); }); // Create a "hole", to test that that the corresponding region isn't loaded from the OAR m_sceneHelpers.SceneManager.CloseScene(SceneManager.Instance.Scenes[1]); // Check thay the OAR file contains the expected data MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(archiveReadStream); } Assert.That(m_lastErrorMessage, Is.Null); Assert.AreEqual(3, m_sceneHelpers.SceneManager.Scenes.Count); TestLoadedRegion(part1, soundItemName, soundData); }
public void TestLoadOarRegionSettings() { TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); tar.WriteDir(ArchiveConstants.TERRAINS_PATH); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); 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.SunPosition = 12.0; 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; rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111"); rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33")); tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs)); tar.Close(); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(archiveReadStream); } Assert.That(m_lastErrorMessage, Is.Null); RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings; Assert.That(loadedRs.AgentLimit, Is.EqualTo(17)); Assert.That(loadedRs.AllowDamage, Is.True); Assert.That(loadedRs.AllowLandJoinDivide, Is.True); Assert.That(loadedRs.AllowLandResell, Is.True); Assert.That(loadedRs.BlockFly, Is.True); Assert.That(loadedRs.BlockShowInSearch, Is.True); Assert.That(loadedRs.BlockTerraform, Is.True); Assert.That(loadedRs.DisableCollisions, Is.True); Assert.That(loadedRs.DisablePhysics, Is.True); Assert.That(loadedRs.DisableScripts, Is.True); Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9)); Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3)); Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49)); Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9)); Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5)); Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2)); Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2)); Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1)); Assert.That(loadedRs.FixedSun, Is.True); Assert.AreEqual(12.0, loadedRs.SunPosition); Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4)); Assert.That(loadedRs.RestrictPushing, Is.True); Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4)); Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9)); Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020"))); Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040"))); Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060"))); Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080"))); Assert.That(loadedRs.UseEstateSun, Is.True); Assert.That(loadedRs.WaterHeight, Is.EqualTo(23)); Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject); // because no object was found with the original UUID Assert.AreEqual(0, loadedRs.SpawnPoints().Count); }
public void TestLoadOarDeededLand() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID landID = TestHelpers.ParseTail(0x10); MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector(); IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Groups"); config.Set("Enabled", true); config.Set("Module", "GroupsModule"); config.Set("DebugEnabled", true); SceneHelpers.SetupSceneModules( m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() }); // Create group in scene for loading // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests. UUID groupID = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero); // Construct OAR MemoryStream oarStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(oarStream); tar.WriteDir(ArchiveConstants.LANDDATA_PATH); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); LandObject lo = new LandObject(groupID, true, m_scene); lo.SetLandBitmap(lo.BasicFullRegionLandBitmap()); LandData ld = lo.LandData; ld.GlobalID = landID; string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null)); tar.Close(); oarStream = new MemoryStream(oarStream.ToArray()); // Load OAR lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(oarStream); } ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); LandData rLd = rLo.LandData; Assert.That(rLd.GlobalID, Is.EqualTo(landID)); Assert.That(rLd.OwnerID, Is.EqualTo(groupID)); Assert.That(rLd.GroupID, Is.EqualTo(groupID)); Assert.That(rLd.IsGroupOwned, Is.EqualTo(true)); }
public void TestLoadOar() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); // Put in a random blank directory to check that this doesn't upset the load process tar.WriteDir("ignoreme"); // Also check that direct entries which will also have a file entry containing that directory doesn't // upset load tar.WriteDir(ArchiveConstants.TERRAINS_PATH); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); SceneObjectPart part1 = CreateSceneObjectPart1(); part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f); part1.SitTargetPosition = new Vector3(1, 2, 3); SceneObjectGroup object1 = new SceneObjectGroup(part1); // Let's put some inventory items into our object string soundItemName = "sound-item1"; UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); Type type = GetType(); Assembly assembly = type.Assembly; string soundDataResourceName = null; string[] names = assembly.GetManifestResourceNames(); foreach (string name in names) { if (name.EndsWith(".Resources.test-sound.wav")) { soundDataResourceName = name; } } Assert.That(soundDataResourceName, Is.Not.Null); byte[] soundData; UUID soundUuid; CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid); TaskInventoryItem item1 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; part1.Inventory.AddInventoryItem(item1, true); m_scene.AddNewSceneObject(object1, false); string object1FileName = string.Format( "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", part1.Name, Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), part1.UUID); tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1)); tar.Close(); MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); lock (this) { m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_archiverModule.DearchiveRegion(archiveReadStream); } Assert.That(m_lastErrorMessage, Is.Null); TestLoadedRegion(part1, soundItemName, soundData); }